Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!spdcc!mirror!rayssd!galaxia!mrsoft!mrr From: mrr@mrsoft.Newport.RI.US (Mark Rinfret) Newsgroups: comp.sys.mac.programmer Subject: How do I expand system heap from an INIT? Message-ID: Date: 10 Aug 90 12:05:35 GMT Lines: 41 I've written a device driver which supports inter-application messages and symbol management. It works great under MultiFinder and it also works great under Finder when TMON is running :-). When run with Finder sans TMON, the system usually crashes on my first attempt to start an application. The problem, I'm certain, is that it requires more system heap than is available from the standard system. I don't want to modify the boot blocks, so I need a way for the INIT (which installs the driver) to expand the system heap. I gather (from some snooping through TMON Startup) that the way to do this is roughly as follows: - Copy the INIT resource onto the stack. I believe this is necessary since the current application zone will be trashed when the heap is expanded (right?). - adjust the stack pointer (saving original) - jump into relocated code at next instruction (_ReleaseResource) - call SetAppBase with (ApplZone + additional size) - perform other chores (install driver, etc.) - restore stack pointer - return Everything works fine (or appears to) until I restore the stack pointer. It appears to be off by a longword (no simple explanation - I've done my "stack arithmetic") and I end up back at the top of the INIT code. Forcing the stack pointer to the correct value (tried it once) caused a crash. I've spent a fair amount of time tracking this problem. Before I pursue it further, I'd like to know if I'm on the right track with regard to system heap expansion. If anyone has some sample code for "doing it right", I'd very much appreciate it if you'd send me a copy. Thanks very much. Mark -- ################################################################# # Mark R. Rinfret, MRSoft Home: 401-846-7639 # # mrr@mrsoft, galaxia!mrsoft!mrr Work: 401-849-9930 x301 # #################################################################