Article # 31, added by Geoworks, historical record
| first | previous | index | next | last |

How to un/relocate objects and their class pointers.




If you're storing objects in a VM file and want to perform the object
relocation manually (not something I recommend, since VM manager can do
this for you), this article will give you a summary of what steps to take.
It is assumed you've read the article titled "Using
ObjDoRelocation and ObjDoUnRelocation." 

To save objects to a VM file and do the unrelocation yourself, first you
must unrelocate the class pointer of the object. This is done by
dereferencing the optr to the object chunk. Unrelocate the first dword of
the object data, the class pointer, using ObjDoUnRelocation with the
relocation type RELOC_RELOC_ENTRY_POINT. Save the relocated class pointer
somewhere (not where it is now, somewhere else; the object needs a valid
class pointer for just a little bit longer). Then unrelocate the optr to
the object, so you can save it to the file. 

Later when you read in the object from file, perform the relocation on the
optr of the object, then using that optr dereference a pointer to the
object chunk and relocate the class pointer, using the "unrelocated" class
pointer saved earlier.