I have run into a little problem and was wondering if anyone knew the cause of the problem and how to solve it.
Basicly, I inject my DLL into a process (testing using firefox.exe and iexplore.exe), and the code in the DLL starts a second thread. The thread just doesnt seem to trigger for some reason.
#include "win.h"
DWORD WINAPI ThreadMain(LPVOID lpParam);
BOOL APIENTRY DllMain(HANDLE hinstance, DWORD dwReason, LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
DWORD ThreadID;
HANDLE ThreadHandle = CreateThread
(
NULL, //Choose default security
0, //Default stack size
ThreadMain, //Routine to execute
NULL, //Thread parameter (LPVOID)
0, //Immediately run the thread
&ThreadID //Thread Id
);
MessageBox(NULL, L"From main thread", L"From main thread", MB_OK);
while(true);
}
}
DWORD WINAPI ThreadMain(LPVOID lpParam)
{
MessageBox(NULL, L"From new thread", L"From new thread", MB_OK);
while(true);
}
Only the message box from the main thread is displayed.
Anyone have any ideas? I've used threads before and not had a problem, but never from a DLL so I am wondering if it is something to do with that. I've tried _beginthread, _beginthreadex, CreateThread, etc.
I'm using Win7 64 bit.
Look forward to your response
Thanks












