I have one question about the callback function set with AlmSetProcAlarm().
I've read here in one thread that I should lock the code resource to ensure the function is there when called from the OS. But also I should protect the app database. At the moment (it's a small freeware tool: lightsafer) I only protect the app database using DmDatabaseProtect(). This works fine as far as I can see. Question is now: Is it sufficient or is it unsafe?
If unsafe: What could possible happen to my callback function ptr? How can I prevent this? What is my code resource? IIRC, PRCExplorer always shows up 2 code resources.
If your application isn't running, and isn't in the ROM, then you probably shouldn't use AlmSetProcAlarm. That routine takes a pointer to your function, so it is your duty to make sure your code will always be at the location you gave. That's easy while you're running, but when you quit, there's a lot of things you need to start to worry about:
- you have to prevent the user from deleting your database (that's the DmDatabaseProtect bit)
- you have to prevent the memory chunk from moving in memory (in 5.x you could usually do this by keeping the code resource locked, but there are issues which could arise e.g. with NVFS systems unless they hacked around that.)
- you have to implement some way to unregister & unprotect your app so the user can delete it (in the obviously unlikely case that they don't want your fine software any more)
- there are probably other pitfalls that don't come to mind right now
In short, it is much easier to use a launch code if you're not running, and besides, you don't really gain much by going the ProcAlarm route anyway, unless you're a part of the ROM.
-David Fedor PalmSource, Inc.
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
