[英]passing arguments to funcyion in dll C++
Im getting garbage value in function in dll. 我在dll函数中获取垃圾值。
in FUNC1(int) im getting garbage value, any help?? 在FUNC1(int)中即时获取垃圾值,有帮助吗?
.h of dll dll的.h
class __declspec(dllexport) Class1
{
public:
bool __stdcall FUNC1(int);
}
FUNC1 definition FUNC1定义
bool Class1::FUNC1(int i)
{
//here im getting i as some garbage value
(500==i) ? return true: return false;
}
this is how im calling FUNC1 这就是我如何调用FUNC1
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),FUNC1);
if(lpfnGetProcessID == NULL)
{
return false;
}
typedef int (__stdcall * pICFUNC)(int);
pICFUNC dllFunc;
dllFunc = pICFUNC(lpfnGetProcessID);
int op = dllFunc(500);
FUNC1 is declared as a function, but the definition is a method of "Class". FUNC1被声明为函数,但是定义是“ Class”的方法。 Since they don't match, the implementation will expect to have a this pointer and a parameter on the stack.
由于它们不匹配,因此该实现将期望在堆栈上具有this指针和参数。 The caller is only pushing the i parameter, the implementation will be looking for it at the incorrect memory location.
调用方仅推送i参数,实现将在错误的内存位置中查找它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.