Read Me About MemoryBasedBundle.txt

Read Me About MemoryBasedBundle
===============================
1.1
 
MemoryBasedBundle is a sample that shows how to execute Mach-O code from memory, rather than from a file.  If you're trying to port from CFM to Mach-O, and you're looking for a replacement for GetMemFragment, this is the sample is for you.
 
This sample works on Mac OS X 10.3 and later.  On earlier systems a critical routine, NSCreateObjectFileImageFromMemory, is present but not implemented (it always returns an error).
 
Packing List
------------
The sample contains the following items:
 
o Read Me About MemoryBasedBundle.txt -- This file.
o Tool.c -- C source for the tool.
o Bundle.c -- C source for the bundle that the tool loads.
o Bundle-Info.plist -- The bundle's plist.
o MemoryBasedBundle.xcodeproj -- An Xcode 2.1 project that builds everything.
o MemoryBasedBundle.xcode -- An Xcode 1.5 project that builds everything.
o build -- Pre-built binaries.
 
Using the Sample
----------------
To use the sample, run Terminal, change in to the "build" directory, and run the following command.
 
$ ./MemoryBasedBundle -nsmem Bundle.bundle
Hello Cruel World!
... from NSCreateObjectFileImageFromMemory
 
You can also use "-cf" to load the bundle using CFBundle, and "-ns" to load the bundle using low-level dyld APIs.  Both of these techniques load the bundle from a file, so stand in contrast to "-nsmem", which is the only technique that loads the bundle from memory.
 
Building the Sample
-------------------
The sample was built using Xcode 2.1 on Mac OS X 10.4.  You should be able to just open the project and choose Build from the Build menu.  This will build the MemoryBasedBundle tool and the Bundle.bundle bundle in the "Build" directory.
 
How it Works
------------
The critical routine is NSCreateObjectFileImageFromMemory from <mach-o/dyld.h>.  This allows you to prepare a Mach-O image from a memory buffer.  It's more-or-less equivalent to the CFM routine GetMemFragment.
 
Credits and Version History
---------------------------
If you find any problems with this sample, mail <dts@apple.com> and I'll try to fix them up.
 
1.0 (Mar 2005) shipped only to internal reviewers.
 
1.0.1 (Mar 2005) was the first shipping version.
 
1.1 (Jul 2005) includes a project that will produce universal binaries. This was made more difficult by the need to work around a bug in NSCreateObjectFileImageFromMemory.  See "Tool.c" for details.
 
Share and Enjoy.
 
Apple Developer Technical Support
Networking, Communications, Hardware
 
23 Jul 2005
 
$Log: Read\040Me\040About\040MemoryBasedBundle.txt,v $
Revision 1.3  2005/07/22 15:57:21  eskimo1
Update for version 1.1.
 
Revision 1.2  2005/03/16 16:55:00  eskimo1
Update for version 1.0.1.
 
Revision 1.1  2005/03/10 17:33:20  eskimo1
First checked in.