Advertisement
Guest User

Untitled

a guest
Jan 10th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. DWORD WINAPI MyThread(LPVOID);
  4. DWORD g_threadID;
  5. HMODULE g_hModule;
  6. void __stdcall CallFunction(int&, const char*, DWORD, BYTE);
  7.  
  8. INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
  9. {
  10.     switch(Reason)
  11.     {
  12.     case DLL_PROCESS_ATTACH:
  13.         g_hModule = hDLL;
  14.         DisableThreadLibraryCalls(hDLL);
  15.         CreateThread(NULL, NULL, &MyThread, NULL, NULL, &g_threadID);
  16.     break;
  17.     case DLL_THREAD_ATTACH:
  18.     case DLL_PROCESS_DETACH:
  19.     case DLL_THREAD_DETACH:
  20.         break;
  21.     }
  22.     return TRUE;
  23. }
  24.  
  25. DWORD WINAPI MyThread(LPVOID)
  26. {
  27.     int myInt = 1;
  28.     while(true)
  29.     {
  30.         if(GetAsyncKeyState(VK_F2) & 1)
  31.         {
  32.             CallFunction(myInt, "My custom text", 1, 1);
  33.         }
  34.         else if(GetAsyncKeyState(VK_F3) & 1)
  35.             break;
  36.         Sleep(100);
  37.     }
  38.     FreeLibraryAndExitThread(g_hModule, 0);
  39.     return 0;
  40. }
  41.  
  42. void __stdcall CallFunction(int& param1, const char* param2, DWORD param3, BYTE param4)
  43. {
  44.     typedef void (__stdcall *pFunctionAddress)(int&, const char*, DWORD, BYTE);
  45.     pFunctionAddress pMySecretFunction = (pFunctionAddress)(0x004113C0); // <--- This address is never the same! It will work for one execution and it  will stop working if I restart the test program.
  46.     pMySecretFunction(param1, param2, param3, param4);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement