c++ running a exported dll function from a injected dll

So I have this dll I made
Here:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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, "DLL loaded", "DLL Injection Successful!", 0);
}


I want to inject the dll to a program and then run Initialize() from the program I make to inject the dll.
I have no idea how to do this >.<
How can I do this?
You need header file(s) where all the accessible functions/classes are listed. Then either you add the dll project to your solution and reference it (everything is done automatically) or you add the *.lib file to your project.

Either way you need the headers and make sure that if you write __declspec(dllexport) inside your dll you need to write __declspec(dllimport) outside. The usual way to do it is a #define
Topic archived. No new replies allowed.