GetProcAddress fails
GetProcAddress fails
本文关键字:fails GetProcAddress 更新时间:2023-10-16
我在动态库中有一个fucntion,看起来像:
namespace Dll {
int MyDll::getQ() {
srand(time(0));
int q = rand();
while (!isPrime(q) || q < 100) {
q = rand();
}
return q;
}
}
函数getq((.h文件:
#ifdef _EXPORT
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT __declspec(dllimport)
#endif
namespace Dll
{
class MyDll
{
public:
static DLL_EXPORT int __stdcall getQ();
}
}
最终来自另一个Consoleapp的代码和平:
typedef int(__stdcall *CUSTOM_FUNCTION)();
int main()
{
HINSTANCE hinstance;
CUSTOM_FUNCTION proccAddress;
BOOL freeLibrarySuccess;
BOOL proccAddressSuccess = FALSE;
int result;
hinstance = LoadLibrary(TEXT("Dll.dll"));
if (hinstance != NULL)
{
proccAddress = (CUSTOM_FUNCTION)GetProcAddress(hinstance, "getQ");
if (proccAddress != NULL)
{
proccAddressSuccess = TRUE;
result = (*proccAddress)();
printf("function calledn");
printf("%d", result);
}
freeLibrarySuccess = FreeLibrary(hinstance);
}
if (!hinstance)
printf("Unable to call the dlln");
if (!proccAddressSuccess)
printf("Unable to call the functionn");
}
所以我尝试了几次修复,但是我总是"无法调用该功能"。代码连接到库,因此问题在功能附近。如果有人将我指向我的错误,我会很感激。
您缺少外部" C"。
如果您不这样做,则名称将被c 弄糊,而您只能使用getQ
名称找到它们。此外,这样做并不可靠,因为名称杂交可能会改变。
另一个主题是:_stdcall vs _cdecl
相关文章:
- 使用 NTAllocateVirtualMemory 和 GetProcAddress 的内存分配问题不起作用
- GetProcAddress vs __declspec( dllimport )
- 'dll_file'可以是"0":这不符合函数的规范'GetProcAddress'
- 如何将 GetProcAddress 与 JNA 一起使用?
- Travis-CI Complex Makefile fails
- GetProcAddress 无法正常工作
- OpenCV: fs.open fails
- 从 GetProcAddress 获取的函数指针在使用 stdlib 时会使程序崩溃
- 如何使用 WinDbg 查找"GetProcAddress"函数的进程名称
- GetProcAddress fails
- NetUserGetInfo fails
- C++ - bind() fails
- MS Detours - DetourAttach fails
- 在 GetProcAddress 的 lpProcName 中是否有 DLL 函数修饰的参考
- 为什么传统的 GetProcAddress 到 std::function 并不简单
- 为什么 GetProcAddress 在实现时会引发异常
- ld fails to find glfw3
- Visual Studio 2017 .Net Core 2.0 Angular Publish Fails
- SHGetKnownFolderItem - fails on Wow64
- GetProcAddress 在 c++ 中返回错误代码 127