Quote:
@whose
Not sure how it is possible to misunderstand what I wrote , but it is "the second case".
Easy... FindTask(NULL) gives back the pointer to the task control block of the
calling task (here: program A, the patching one).
If you want to get the task control block pointer of a foreign task (program B, the one calling the patched functions), you have to supply a task identifier (the task name) in order to give FindTask() a chance to work properly
Thats why it was very confusing. You tried to find your own task, and then it should have been as easy as nothing to use the solution mentioned by thomas/colinw
Back to topic: I dont think that there is a very simple solution to trace back the task who is calling a patched OS function, and its even more complicated to get more information about this tasks internals (like globals and function entry points). Lots of register ping pong and stack backtrace, not to mention segments, relocation/symbol tables etc. etc.
Finding the calling task should be the easiest part, as there is a global task list. IIRC it contains all information necessary to find out, which task "owns" a certain address (the callers return address on the stack).
With this information, you should be able to find the tasks task control block pointer and over there the contents of the WBStartup message, including WBArgs.
Edit: I could imagine that this is the way FindTask(NULL) works internally. Backtracing the callers return address, found on the stack.
Obviously this couldnt work from within library functions (even patched ones), as FindTask(NULL) would find a return address belonging to the library´s code segment, which is not registered with the global task list. FindTask(NULL) should return an error indication then.
Edited by whose on 2011/6/30 1:16:40
Edited by whose on 2011/6/30 1:20:36