shasderias
June 30th, 2010, 11:24
I am trying to write a program that reads some data from another program which is basically an array of 1024 16bit integers. Said program spins off a thread, the thread does some I/O with hardware and the data retrieved is stored into the array. The thread that does the reading appears to be totally self-contained, it calls another DLL that does the hardware I/O and updates the screen itself. Never communicating with the main thread. The data I need is thus stored only in a single location.
The problem is thus: the data is stored in the stack of the thread and changes upon each program reload. How can I retrieve the address from within my own program.
What does not (appear) to work:
1) searching for a pointer to any point in thread's data block/stack, the thread does truly appear to be self-contained, at no point in time is there a pointer to any address within the thread's stack/data block that does not reside in the thread's own stack/data block.
2) upon each restart, the memory allocated for the thread changes, thus I am unable to locate a static offset
What I have considered:
1) Trying to locate the CreateThread function, finding the address in which the handle to the thread is stored, reading that, then attempting to retrieve the thread's data block, but I am unable to determine how I can go from thread handle -> address of thread's data block
2) injecting code/patching the program to somehow write out the memory location. The program I am working with is used for a realtime application, I do not want to risk crashing it
Any advice is appreciated, thank you
Some extra information I am unsure if it would be useful:
1) Program written in Delphi6
2) The data is always stored at a fixed offset from the thread's stack, if I can somehow get the base address of the thread, I'd be fine
3) There are multiple threads spun off for different purposes, considered enumerating the threads, picking the one that isn't the main thread, does not work for this reason
4) Data block of thread has a pointer to the thread's stack, thus the address of the data block would work just fine
The problem is thus: the data is stored in the stack of the thread and changes upon each program reload. How can I retrieve the address from within my own program.
What does not (appear) to work:
1) searching for a pointer to any point in thread's data block/stack, the thread does truly appear to be self-contained, at no point in time is there a pointer to any address within the thread's stack/data block that does not reside in the thread's own stack/data block.
2) upon each restart, the memory allocated for the thread changes, thus I am unable to locate a static offset
What I have considered:
1) Trying to locate the CreateThread function, finding the address in which the handle to the thread is stored, reading that, then attempting to retrieve the thread's data block, but I am unable to determine how I can go from thread handle -> address of thread's data block
2) injecting code/patching the program to somehow write out the memory location. The program I am working with is used for a realtime application, I do not want to risk crashing it
Any advice is appreciated, thank you
Some extra information I am unsure if it would be useful:
1) Program written in Delphi6
2) The data is always stored at a fixed offset from the thread's stack, if I can somehow get the base address of the thread, I'd be fine
3) There are multiple threads spun off for different purposes, considered enumerating the threads, picking the one that isn't the main thread, does not work for this reason
4) Data block of thread has a pointer to the thread's stack, thus the address of the data block would work just fine