GetProcAddress can not find procedure (returns NULL) from another CPP (obj file)

-5

//Source.cpp

extern "C"

    __declspec(dllexport) int Sum(int a, int b) {
        return a + b;
    }

//main.cpp

HMODULE hModule = GetModuleHandle(NULL);
typedef int (*DLLFunc)(int, int);
DLLFunc func = (DLLFunc)GetProcAddress(hModule, "Sum");
int c = func(4, 5);

func is 0x00000000

UPD: There is no export table as well Also, optimizations are turned off, debug mode.

GetLastError gives 127 - "The specified procedure could not be found. "

c++
winapi
asked on Stack Overflow Dec 26, 2018 by CEO at Apartico • edited Dec 26, 2018 by CEO at Apartico

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0