> Wow! I didn't know I could modify a Palm's program counter.
Well, you could execute an instruction, which will bump the PC to the next
instruction. Or you could call a function. Or you could do an indirect jump
through a function pointer. Or you could modify the return address on the stack
(after getting the A6 register)...
> Finally, I tracked the errors down to StrCopy().
>
> static void foo()
> {
> Char badboy[100];
> StrCopy(badboy, "I cause program counter modifications\0");
> }
Looks fine to me, assuming that there are 100 bytes available on the stack at
the time you call foo(). That "\0" at the end of your string looks silly, but
it shouldn't cause any problems.
I'll bet that creating a new project, slapping in the above function, and
calling it won't turn up any problems. I'm guessing the source of your crash is
elsewhere.
> Can anyone tell me what I did wrong? Do I have to do badboy =
> MemPtrNew(100); everytime I want to use StrCopy(), or StrPrintF() and
> such?
No, you don't have to call MemPtrNew. Doing a StrCopy to a stack-based array of
chars should be OK, as long as the source is smaller than the destination.
-- Keith
[EMAIL PROTECTED] on 08/03/2000 01:14:32 AM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/US/PALM)
Subject: Safe way to do StrCopy()?
I am getting lots of "CmdReadRemoteMem error: invalid response command"
message spitted at me by Codewarrior's debugging log. There's also quite
a few "CmdGetRemote RtnName error" stuff. At one point I got a popup
window informing me that "remote device program counter has been
modified". Wow! I didn't know I could modify a Palm's program counter.
(Hmmmm.... maybe that's how Robert Morris was inspired)
Finally, I tracked the errors down to StrCopy().
I did my string copies like this:
static void foo()
{
Char badboy[100];
StrCopy(badboy, "I cause program counter modifications\0");
}
Can anyone tell me what I did wrong? Do I have to do badboy =
MemPtrNew(100); everytime I want to use StrCopy(), or StrPrintF() and
such?
I've search the knowledge base for CmdReadRemoteMem, but posts have been
merely problems getting CW to talk to either POSE or the unit.
Optimization has been turned way down (to the left).
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/