i want to write a program in C++ which takes a dll file and prints the exports and imports of it . i use loadLibrary function like the code below . but it always go to the first if and return error , it looks like that the file is not loading or it is empty . does anybody know what is the problem or knows a better way ?
#include <windows.h>
int main() {
HINSTANCE hDLL = LoadLibrary("mylibrary.dll");
if (hDLL == NULL) {
// Handle error here
return 1;
}
// Now that the DLL is loaded, you can call functions from it using GetProcAddress
typedef void (*MyFunction)();
MyFunction myFunction = (MyFunction)GetProcAddress(hDLL, "myFunction");
if (myFunction == NULL) {
// Handle error here
return 1;
}
// Call the function
myFunction();
// Free the DLL when you're done using it
FreeLibrary(hDLL);
return 0;
}
i have tried some ways but none of them take me to the right point