0

Why does it load my DLL but the pointer to the Proc returns 0? It loads the DLL and says "DLL Loaded" but it just won't say "Function Found." Help me please :)?

#include <windows.h>
#include <iostream>


//DLL Function: void DLL_EXPORT Theading(HANDLE hThread, DWORD ThreadID, void* FunctionToPass);

typedef void (*CThread)(HANDLE hTThread, DWORD TThreadID, void* FuncToPass);

void FunctionToPassX()
{
    std::cout<<"meh";
}

int main()
{
    HINSTANCE h = LoadLibrary(TEXT("Threading.dll"));
    if (h)
    {
        std::cout<<"DLL Loaded";
        CThread* TThread = (CThread*)(GetProcAddress(h, "Threading"));

        if (NULL != TThread)
        {
            std::cout<<"Function Found";
        }
        FreeLibrary(h);
    }

	std::cin.get();
    return 0;

}
3
Contributors
3
Replies
7
Views
5 Years
Discussion Span
Last Post by triumphost
0

I believe this happens due to a typo; Theading vs. Threading .

THANK YOU!!!! I cannot believe I didn't notice that.. man u have good eyes. I'll mark the thread solved. Rep++

Completed my DLL :D

#include <windows.h>
#include <iostream>


//DLL Function: void DLL_EXPORT Theading(HANDLE hThread, DWORD ThreadID, void* FunctionToPass);

typedef void (*CThread)(HANDLE hTThread, DWORD TThreadID, void* FuncToPass);

void FunctionToPassX()
{
    std::cout<<"meh";
}

int main()
{
    HINSTANCE h = LoadLibrary(TEXT("Threading.dll"));
    if (h)
    {
        std::cout<<"DLL Loaded.\n";
        CThread TThread;
        TThread = (CThread) GetProcAddress(h, "Threading");

        if (NULL != TThread)
        {
            std::cout<<"Function Found.";
            HANDLE HThread;
            DWORD TThreadID = 1;
            TThread(HThread, TThreadID, (void*) FunctionToPassX);
        }
        FreeLibrary(h);
    }

	std::cin.get();
    return 0;

}

Edited by triumphost: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.