how to see what is ordinal x in my dll

2019-08-16 08:53发布

问题:

The client has reported me that my dll gives "ordinal 5 not located" error when loading it. To see what ordinal 5 is, I have found this:

How can I call a exported function using ordinal number

But the example in the answer of there gives me error.

#include <windows.h>
#include <winuser.h>
#include <winbase.h>

int main()
{
    const wchar_t str[200] = 
    L"D:\\mydll.dll";
    HANDLE mydll = LoadLibrary(str);

    int ordinal = 5;
    FARPROC fn = GetProcAddress(mydll, MAKEINTRESOURCE(ordinal));

    return 0;
}

The error is:

main.cpp:15: error: invalid conversion from 'HANDLE {aka void*}' to 'HMODULE {aka HINSTANCE__*}' [-fpermissive] FARPROC fn = GetProcAddress(mydll, MAKEINTRESOURCE(ordinal));

main.cpp:15: error: cannot convert 'LPWSTR {aka > wchar_t*}' to 'LPCSTR {aka const char*}' for argument '2' to 'int (attribute((stdcall)) * GetProcAddress(HMODULE, LPCSTR))()' FARPROC fn = GetProcAddress(mydll, MAKEINTRESOURCE(ordinal));

Any idea on what I am trying to do? How can I find what is problem with loading my dll? What is ordinal 5?