Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

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

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 << "
Could Not Load Library";
            return 0;
        }
        else {
            std::cout << "
Library Loaded Successfully";
        }
        FNPTR fn = (FNPTR)GetProcAddress(hInst, "MasterLogin");
        if (!fn) {
            std::cout << "
Faliled 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;
    }
question from:https://stackoverflow.com/questions/65860426/0xc0000005-access-violation-executing-location-0x00000000-error-in-loading-dll

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...