如何通过dll中的地址调用函数
How to call function in dll through its address
我需要通过dll中的函数地址调用它。有可能吗?
这是dll中的函数:
HMODULE handle
void sethandle(HMODULE a)
{
handle=a;
}
您应该使用GetModuleHandle
和GetProcAddress
函数,以下代码:
LPCWSTR lpszModule = L"kernel32.dll"; // here should be your dll file path name.
HMODULE hModule = GetModuleHandleW(lpszModule);
if (hModule)
{
typedef void(*fn)(HMODULE);
fn pF = (fn)GetProcAddress(hModule, "sethandle");
// use it, like this: pF(a)
}
相关文章:
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 调用 lua 函数的地址为 C/C++?
- 在 Microsoft Access SQL 中调用自定义 DLL 函数时传递的内存地址无效
- 为什么使用存储在虚拟方法表中的地址调用虚拟函数的函数会返回垃圾?
- 指针在函数调用后更改其地址
- 获取要在C++中动态调用的回调函数的地址
- 地址处的 C++ 值与函数调用后的预期值不同
- NRVO不应该保证局部命名变量和调用站点变量采用相同的地址吗?
- 使用来自 Dll 的偏移地址调用成员函数
- 如何使用函数指针从其内存地址调用成员函数
- 通过已知地址调用函数?C++
- C++ 尝试通过内存中的地址调用函数时程序崩溃(如何修复?
- 从地址调用函数时,C 程序崩溃
- 如何通过dll中的地址调用函数
- 如何从成员的地址调用成员函数
- 在c/c++中通过函数在内存中的地址调用函数
- 显示 new() 在 malloc 返回的地址调用对象的构造函数的源代码
- 通过函数地址调用另一个类的函数
- 按地址调用函数
- 按地址调用函数失败