Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 1 - Resource Manager / Resource Manager Reference
ROM Resources


Inserting the ROM Resource Map

Many system resources are stored in ROM. System software calls the InitResources function during system startup, and the Resource Manager creates a special heap zone in the system heap and builds a resource map that points to the ROM resources.

The Resource Manager normally searches ROM resources only when you use the RGetResource function to get a handle to the resource, and even then only after it searches the System file's resource fork. To search for a resource in ROM before searching the System file's resource fork, your application must first alter the resource search order by inserting the ROM resource map in front of the System file's resource map.

When the value of the global variable RomMapInsert is TRUE, the Resource Manager inserts the ROM resource map before the System file's resource map for the next call only. When the value of RomMapInsert is TRUE, the adjacent variable TmpResLoad determines whether the value of the global variable ResLoad is considered TRUE or FALSE, overriding the actual value of ResLoad for the next call only. The values of the RomMapInsert and TmpResLoad variables are cleared after each call to a Resource Manager routine.

The RGetResource function first calls GetResource. If GetResource cannot locate the requested resource in the resource chain, RGetResource sets RomMapInsert to TRUE, then calls GetResource again.

To set the RomMapInsert and TmpResLoad variables in tandem yourself, you can use two global constants. Set the system global variable RomMapInsert to the global constant mapTrue to insert the ROM resource map with SetResLoad(TRUE). Set RomMapInsert to the global constant mapFalse to insert the ROM resource map with SetResLoad(FALSE).

There is no real resource fork associated with the ROM resources; the ROM resource map has a path number of 1 (an illegal path reference number). There are two ways to determine whether a handle references a ROM resource. First, you can set up RomMapInsert and TmpResLoad and call HomeResFile; if 1 is returned, the handle is to a ROM resource. Second, you can dereference the handle and check whether the master pointer points to ROM by comparing it to the global variable ROMBase.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996