You should use a pointer rather than a DWORD
. On the C# side IntPtr
is probably fine. Perhaps a delegate would be better. Hard to tell for sure with no code.
On the C++ side you could use void*
but better might be a properly typed function pointer:
typedef DWORD (__stdcall *ThreadProc)(void*);
Rather than defining this yourself you can use LPTHREAD_START_ROUTINE
.
Any of these options will work for both 32 and 64 bit.
However, do note that the injected DLL must have the same bitness as the target process. You cannot inject 64 bit DLL into 32 bit process and vice versa. What's more you cannot inject into a 64 bit process by calling CreateRemoteThread
from a 32 bit process.