First MachOViewer release 1.0a0

January 15, 2006

I’ve just relased the first MachOViewer alpha.

Features:

  1. Opens Frameworks, Bundles, Applications
  2. Displays used libraries, can open used library by double clicking it’s name
  3. Universal Binary aware (you can select the architecture you’re interested in in the top left corner)
  4. Displays imported exported symbols filter for library name or imported symbol name.

machoviewer_10a0

Advertisements

OSX: dumping LaunchServices database

January 15, 2006
How to dump & interpret the contents of the LaunchServices database
You shall use the lsregister command:/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister

Examples:
cd /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Versions/Current/Support/
lsregister local -dump

Related links
http://www.kernelthread.com/mac/apme/security/url.html
http://www.macosxhints.com/article.php?story=20031215144430486


operator::new[] overflow bug and Mac compilers

January 15, 2006

There’s a bug in the code generated operator new[] which causes potential overflow in VS C++ 2003 or previous versions. This seems to be fixed in VS C++ 2005. What about CodeWarrior and XCode (GCC 4.0):

Testcode:
struct Large {
public:
char data[256*256];
};

void testlargeallloc(long num)
{
try {
Large* large = new Large[num] ();
for (int i = 0; i rlwinm r0,r0,16,0,15
0x0000daac mr r3,r0
0x0000dab0 bl 0xde80

The effect is a bit different from pre 2005 VisualC++ where the code crashes in new. Here the program crashes when trying to access the elements.


PyObjC vs PyDev: debugging/running PyObjC apps.

January 15, 2006
PyObjC is a Cocoa wrapper for python. PyDev is a python development environemnt for Eclipse. You can get debugging/running of a PyObjC appilication from eclipse.
Configuring a py2app builder:
First you have to create an OSX application with py2app. For me it looks something like:
python setup.py py2app --alias --dist-dir=Debug

This will create you an OSX bundle using links to refer resources and python sources (–alias flag). This is usefull since this allows you running uptodate version of the app without reexecuting setup.py.I usually add this thing to the Builders of the project:

  1. Right click on the project, select Builders
  2. Press New and select Program
  3. Fill in Edit launch configuration properties:
    1. Location: /usr/bin/python
    2. Working Directory: ${project_loc}
    3. Arguments: ${build_project:setup.py} py2app –alias –dist-dir=${project_loc}/Debug
      pydev_builderssettings.png

To rerun setup.py, select Clean.. from Project menu.
Configuring a PyObjC application runner:

The next step is adding a pydev runner configuration to the project.

  1. From the Run menu select Run…
  2. Select Python Run and click New…
  3. In the main tab set the following:
    1. Project: click browse and select the project
    2. Main module: select the python file containing the main code for of the PyObjC app
  4. In the environment tab set the following:
    1. CFProcessPath: ${project_loc}/Debug/Foo.app/Contents/MacOS/Foo
      This is needed because the OS looks for nibs and other resources in the executable’s bundle. In this case the executable is the python interpreter /usr/bin/python – so  tell CoreFoundation to look for the resources in the Foo.app application package.
  5. Press apply to save the run configuration, then press Run to try it out. You should be able to debug with the same run configuration.
    pydev_runssettings.png