Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!alan From: alan@Apple.COM (Alan Mimms) Newsgroups: comp.sys.mac.programmer Subject: Re: Interesting problem with GetResource('dctb', id) Keywords: ResourceManager 'dctb'/'actb' SpecialCase Message-ID: <5065@internal.Apple.COM> Date: 6 Nov 89 19:10:18 GMT References: <232@fwi.uva.nl> Organization: Apple Computer Inc, Cupertino, CA Lines: 72 In article <232@fwi.uva.nl> dolf@fwi.uva.nl (Dolf Starreveld) writes: > >I am currently working on a program that needs to copy a 'dctb' resource >from one file to another. Since the program must also copy other resources >I have written a general purpose "CopyResource" routine. The routine itself >was extensively tested and seemed to work, but ..... >The copying of the 'dctb' resource was only recently added and things >started to go wrong. After lots of debugging I found out that after executing >the following statement: > inHandle = GetResource('dctb', 10000); >"inHandle" contains a valid handle, but not a handle to a resource. I entered >TMON to find out more and: >1) Just before executing the statement the 'dctb' resource is not > loaded in the heap. >2) Just after the statement, the 'dctb' resource is loaded, but > immediately following it, the heap contains another relocatable > block of exactly the same size of the resource (48 bytes). >3) The GetResource call returns a handle to this last block instead > of to the actually loaded resource. > >Since my program continues to do a GetResInfo call on the handle returned, >I get into problems. The handle is not a handle to a resource and the >call sets ResError != 0. Furthermore, the &resID is set to -1 and the >&resType is set to four zero bytes. This is what finally causes another >program using the copied resource file to crash. > >I moved the GetResource call to very early in my program (just after ToolBox >initialization), just to be sure the heap was not already corrupt. I also >tried using other values for the ID (100 instead of 10000). The net result >was the same in all cases: two blocks appear on the heap and the wrong >handle is returned to me. > >Is this a bug in the system software? Am I doing something wrong? >Any suggestions? > >BTW. For those who think it is important, I am using THINK C 4.0 on an >8Mb Mac IIcx, system 6.0.4b15. >Before you start screaming about using 6.0.4b15, you should know that >the problems were already there when I still used 6.0.3. I have not tested >with other versions. > >--dolf > >Dolf Starreveld Phone: +31 20 592 5056/+31 20 592 5022, TELEX: 10262 HEF NL >EMAIL: dolf@fwi.uva.nl (dolf%fwi.uva.nl@hp4nl.nluug.nl) >SNAIL: Dept. of Math. and Computing Science, University of Amsterdam, > Kruislaan 409, NL-1098 SJ Amsterdam, The Netherlands SOME version of the system software introduced a "feature" in which 'dctb' and 'actb' resources are CLONED when they're retrieved by GetResource and related calls. A colleague of mine discovered this recently. You MAY be able to get around this with either Get1Resource calls or with the sequence SetResLoad (false); GetResource (...); SetResLoad (true); LoadResource (...); Anyone in System Software care to comment? Also, please note that you really SHOULD go ahead an upgrade to 6.0.4 final since there were a few bugs fixed in the last few versions of 6.0.4 after b15 (I THINK). Hope this helps. -- Alan Mimms My opinions are generally Communications Product Development Group pretty worthless, but Apple Computer they *are* my own... "The company has new jobs and Jobs has a new company" -- Harry Anderson