0xC0000005: Access violation executing location 0x00000000 Error in Loading DLL Library in C++ Console Application

1

I want to load the DLL library in C++ windows console application but I faced to bellow error:

Exception thrown at 0x00000000 in Token_DLL_Test_1.exe: 0xC0000005: Access violation executing location 0x00000000.

The DLL function definition is:

  • Return Data Type: uint8_t
  • Argument 1 Data Type: uint8_t* - Act as String
  • Argument 2 Data Type: uint8_t - Act as Int
  • Argument 3 Data Type: uint8_t* - Act as String
  • Argument 4 Data Type: uint8_t - Act as Int And my C++ code is like bellow:
    #include <iostream>
    #include <Windows.h>
    
    typedef uint8_t(*FNPTR)(uint8_t*, uint8_t, uint8_t*, uint8_t);
    int main()
    {   
        HINSTANCE hInst = LoadLibrary(L"DLL.dll");
        if (!hInst) {
            std::cout << "\nCould Not Load Library";
            return 0;
        }
        else {
            std::cout << "\nLibrary Loaded Successfully";
        }
        FNPTR fn = (FNPTR)GetProcAddress(hInst, "MasterLogin");
        if (!fn) {
            std::cout << "\nFaliled To Load MasterLogin Function";
            return 0;
        }
        uint8_t name[5];
        uint8_t nameLen = 5;
        memmove(name, "Admin", 5);
        uint8_t pass[6];
        memmove(pass, "123456", 6);
        uint8_t passLen = 6;
        uint8_t res = fn(name, nameLen, pass, passLen);
        std::cout << res;
        return 0;
    }
c++
dll
asked on Stack Overflow Jan 23, 2021 by Hojat Sajadinia • edited Jan 23, 2021 by Hojat Sajadinia

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0