Thursday, July 30, 2009

Dll help pls(error in c++ code)?

ok here is the dll





#include %26lt;windows.h%26gt;


#include %26lt;stdio.h%26gt;


#include %26lt;stdlib.h%26gt;


#include "stealth.h"





DWORD dwThreadID = 0;





void MainLoop()


{


while(1)


{








Sleep(10);


}





}








BOOL APIENTRY DllMain( HANDLE hModule,


DWORD ul_reason_for_call,


LPVOID lpReserved


)


{


if(ul_reason_for_call==DLL_PROCESS_AT...


{





loadDriver("\\0001.sys",true,"0001",... Driver");


CreateThread(NULL,0,(LPTHREAD_START_... %26lt;-------


if(unlinkThread((int)dwThreadID) != 1)


{


MessageBox(0,"Invalid Operating System Detected!","Error",MB_ICONERROR);


ExitProcess(0);


return FALSE;


}





return TRUE;


}


return TRUE;


}





im using dev-c++ compiler





and im getting an error on this line


so can someone help me fix this

Dll help pls(error in c++ code)?
The problem is the signature of MainLoop. If you write MainLoop properly, you won't need the (LPTHREAD_START_ROUTINE) cast.





The thread function needs to take a pointer to void and return a DWORD.





It should look like this:


DWORD MainLoop (void * pdata)





When using function pointers, having the correct signature is required. Anything else will cause crazy errors. Feel lucky you got a compiler error. If you got it to compile, the runtime errors would be very hard to diagnose.





The pdata parameter allows you to pass context data to the thread, this way you can start off different threads with different data.


No comments:

Post a Comment