-
November 27th, 2014, 05:53 AM
#1
Code works only on computer, when it was compiled
Hello.
For some reason this code dont work on other computers, but work on computer, where it was compiled. Any idea why?
Code:
#include <windows.h>
int WINAPI DllThread()
{
for (;;)
{
HMODULE hModule = NULL;
while (!hModule)
{
hModule = LoadLibraryA("scripter.dll");
Sleep(100);
}
if (GetAsyncKeyState(VK_INSERT))
{
hModule = LoadLibraryA("Proxy.dll");
return 0;
}
}
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)DllThread, NULL, NULL, NULL);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
-
November 27th, 2014, 06:27 AM
#2
Re: Code works only on computer, when it was compiled
You are using local paths for "Proxy.dll" and "scripter.dll".
The probability that they will be the same on some other PC is very close to zero...
Victor Nijegorodov
-
November 27th, 2014, 06:31 AM
#3
Re: Code works only on computer, when it was compiled
They are same and they exist.
-
November 27th, 2014, 07:02 AM
#4
Re: Code works only on computer, when it was compiled
See http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx and in particular the return value & GetLastError part. It will tell you exactly why it doesn't work
-
November 27th, 2014, 07:06 AM
#5
Re: Code works only on computer, when it was compiled
Originally Posted by xManiac
They are same and they exist.
What are "same"? The "current working directories" on all these PCs are the same and they contain both dlls?
BTW, if you checked the return value of LoadLibraryA and call the GetLastError in case LoadLibraryA failed then you could understand the reason of the problem.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|