-.- I hate you msvc++. Dll issues

Posts 1–8 of 8 · Page 1 of 1
-.- I hate you msvc++. Dll issues
I have a c++ dll that I made to inject to Diablo 2 I use CreateRemoteThread to call methods in the dll but the dll doesnt work.
So I opened up Dependency Walker and found 2 errors. 1 I dont care about
and 1 that seems like the problem.
The 1 says that a function in the dll is not being exported. I think this is caused by microsoft visual c++ and some compiler options but I dont know how to fix. Anyone know how to fix?
give us more details?
Heres the 2 errors from dependency walker
Code:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Heres my dll code
Code:
#include <windows.h>


BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReason, LPVOID lpReserved) {

    UNREFERENCED_PARAMETER(lpReserved);

    if(ulReason == DLL_PROCESS_ATTACH) {
        DisableThreadLibraryCalls(hModule);
    }


    return (TRUE);
}

extern "C" __declspec(dllexport) void Initialize() {
    MessageBox(0, "Locked and Loaded.", "DLL Injection Successful!", 0);
}
Quote Originally Posted by PsychicSounds View Post
Heres the 2 errors from dependency walker
Code:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Heres my dll code
Code:
#include <windows.h>


BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReason, LPVOID lpReserved) {

    UNREFERENCED_PARAMETER(lpReserved);

    if(ulReason == DLL_PROCESS_ATTACH) {
        DisableThreadLibraryCalls(hModule);
    }


    return (TRUE);
}

extern "C" __declspec(dllexport) void Initialize() {
    MessageBox(0, "Locked and Loaded.", "DLL Injection Successful!", 0);
}
Why don't you just use the CreateThread() call inside the DLLMAIN()?
If you want to see the return value of functions you can just setup a named pipe to another application.
Quote Originally Posted by Fovea View Post
The answer to Why not CreateThread? is found at Best Practices for Creating DLLs
xD thats the article the article that made me want to make it. Im now using CreateRemoteThread() to call the methods instead of __asm but I still need the exporting of the dll to properly work :/
The answer is simple, you are injecting into a suspended process. A suspended process's environment is not ready for normal execution, only when the program reaches entry point will it be ready.

There are two solutions. Solution one is the simplest, let the application run and remove the CREATE_SUSPENDED flag. Solution two entails the suspension of the process, the patching of the entry point to be an infinite loop, dll injection via CreateRemoteThread on an export, check eip against entry point, resumption of the process (main thread), and finally the removal of the infinite loop by restoring the instructions overwritten (do this safely by suspending main thread).
Im sorry but I have no idea how to do that
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us