To fix the issue you can do I'm passing a struct to CreateThread() function. The same code on another machine works fine. But on my machine, "SendItem" always becomes 0xccccccc Bad Ptr>. Does anyone know why?
should help you out The problem here is that your thread function has the wrong calling convention. You need to declare it with the stdcall convention:
function ThreadProc(param: Pointer) : DWORD; stdcall;
TBlah = class(TThread)
procedure Execute; override;
b := TBlah.Create(True);
b.fe := 42;
seems to work fine You can create a structure that holds all relevant data and pass a pointer to an instance of that structure (filled with the appropriate parameters) to CreateThread() In your thread creation function you will need to cast the LPVOID back to a pointer to your structure to use it.
C - Passing struct addresses as function arguments
I wish this helpful for you Assuming you set 'chunk' in the initialize data code then the pointer in the remote address space will be referencing the address in the local process. The easy way to get around this would be to make chunk an array (probably the last member of the struct) and allocate a block large enough to hold chunk's data.