ESP的值在函数调用错误中未正确保存 [英] The value of ESP was not properly saved across a function call error
问题描述
ESP的值在函数调用中未正确保存
我从DLL项目开始:
这是我的device_manager_interface.hpp: p>
#ifndef __DEVICE_MANAGER_INTERFACE_HPP__
#define __DEVICE_MANAGER_INTERFACE_HPP__
#include< QtCore>
class DeviceManagerInterface
{
public:
virtual BCR * getDeviceBCR()= 0;
。
。
。
};
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(DeviceManagerInterface,some_info);
QT_END_NAMESPACE
#endif // __ DEVICE_MANAGER_INTERFACE_HPP__
这是我的device_manager .hpp:
#ifndef __DEVICE_MANAGER_BASE_HPP__
#define __DEVICE_MANAGER_BASE_HPP__
#includedevice_manager_interface。 hpp
class DeviceManager:public DeviceManagerInterface
{
public:
DeviceManager();
虚拟BCR * getDeviceBCR();
。
。
。
protected:
virtual void initilzeAvailableDevices(DeviceList device_list);
virtual WORD startup();
。
。
。
};
#endif // __ DEVICE_MANAGER_BASE_HPP__
这是我的device_manager.cpp: / p>
#includedevice_manager.hpp
DeviceManager :: DeviceManager()
{
}
void WINAPI DeviceManager :: initilzeAvailableDevices(DeviceList device_list)
{
WORD wfs_version = startup();
。
。
。
}
WORD DeviceManager :: startup()
{
WFSVERSION wfs_version;
HRESULT hRes;
hRes = WFSStartUp(SUPPORTED_VERSIONS,& wfs_version);
WORD version = wfs_version.wVersion;
返回版本;
}
WFSStartUp是包含在 xfsapi.h
并定义如下。
HRESULT extern WINAPI WFSStartUp(DWORD dwVersionsRequired,LPWFSVERSION lpWFSVersion);
这是我的device_manager_impl.hpp:
#ifndef __DEVICE_MANAGER_WINCORE_HPP__
#define __DEVICE_MANAGER_WINCORE_HPP__
#includedevice_manager.hpp
class DeviceManagerImpl:public QObject,DeviceManager
{
Q_OBJECT
Q_INTERFACES(DeviceManagerInterface)
public:
DeviceManagerImpl();
protected:
。
。
。
};
#endif // __ DEVICE_MANAGER_WINCORE_HPP__
这是我的device_manager_impl.cpp: / p>
#includedevice_manager_impl.hpp
#includexfsapi.h
#define BRAND_NAMEWINCORE
DeviceManagerImpl :: DeviceManagerImpl()
{
m_brand_name = BRAND_NAME;
fill_map_logical_names();
DeviceList device_list = detectAvailableDevices();
DeviceManager :: initilzeAvailableDevices(device_list);
}
Q_EXPORT_PLUGIN2(device_manager_impl,DeviceManagerImpl);
此项目提供一个名为WINCORE.dll的DLL文件。
这是我如何加载这个.dll:
QPluginLoader * pluginLoader = new QPluginLoader(filename);
QObject * plugin = pluginLoader-> instance();
filename
包含WINCORE.dll路径这是正确的。我的问题是 DeviceManager
类中的 startup()
。当它要返回版本
时,我收到错误。我做错了什么?
我终于找到了如何解决这个问题!
右键单击项目,选择属性,转到配置属性,选择 C / C ++ ,然后选择代码生成。
将基本运行时间检查更改为默认
。
将 Struct Member Alliance 更改为 1字节(/ ZP1)
。
我真的希望这也适合你们。
最好的问候
I made a .dll file with QT and I load it in my application. When it's about to return from one function, I receive:
The value of ESP was not properly saved across a function call
I start with the DLL project:
This is my device_manager_interface.hpp:
#ifndef __DEVICE_MANAGER_INTERFACE_HPP__
#define __DEVICE_MANAGER_INTERFACE_HPP__
#include <QtCore>
class DeviceManagerInterface
{
public:
virtual BCR * getDeviceBCR() = 0 ;
.
.
.
};
QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(DeviceManagerInterface,"some_info");
QT_END_NAMESPACE
#endif //__DEVICE_MANAGER_INTERFACE_HPP__
This my device_manager.hpp:
#ifndef __DEVICE_MANAGER_BASE_HPP__
#define __DEVICE_MANAGER_BASE_HPP__
#include "device_manager_interface.hpp"
class DeviceManager : public DeviceManagerInterface
{
public:
DeviceManager();
virtual BCR * getDeviceBCR();
.
.
.
protected:
virtual void initilzeAvailableDevices(DeviceList device_list);
virtual WORD startup();
.
.
.
};
#endif //__DEVICE_MANAGER_BASE_HPP__
This is my device_manager.cpp:
#include "device_manager.hpp"
DeviceManager::DeviceManager()
{
}
void WINAPI DeviceManager::initilzeAvailableDevices(DeviceList device_list)
{
WORD wfs_version = startup();
.
.
.
}
WORD DeviceManager::startup()
{
WFSVERSION wfs_version;
HRESULT hRes;
hRes = WFSStartUp(SUPPORTED_VERSIONS, &wfs_version);
WORD version = wfs_version.wVersion;
return version;
}
WFSStartUp is function containing in xfsapi.h
and defined like this.
HRESULT extern WINAPI WFSStartUp ( DWORD dwVersionsRequired, LPWFSVERSION lpWFSVersion);
This is my device_manager_impl.hpp:
#ifndef __DEVICE_MANAGER_WINCORE_HPP__
#define __DEVICE_MANAGER_WINCORE_HPP__
#include "device_manager.hpp"
class DeviceManagerImpl : public QObject, DeviceManager
{
Q_OBJECT
Q_INTERFACES(DeviceManagerInterface)
public:
DeviceManagerImpl();
protected:
.
.
.
};
#endif //__DEVICE_MANAGER_WINCORE_HPP__
This is my device_manager_impl.cpp:
#include "device_manager_impl.hpp"
#include "xfsapi.h"
#define BRAND_NAME "WINCORE"
DeviceManagerImpl::DeviceManagerImpl()
{
m_brand_name = BRAND_NAME;
fill_map_logical_names();
DeviceList device_list = detectAvailableDevices();
DeviceManager::initilzeAvailableDevices(device_list);
}
Q_EXPORT_PLUGIN2(device_manager_impl, DeviceManagerImpl);
This project provides a DLL file called WINCORE.dll.
This is how I load this .dll:
QPluginLoader* pluginLoader = new QPluginLoader(filename);
QObject *plugin = pluginLoader->instance();
The filename
contains the WINCORE.dll path and it's correct. My problem is startup()
in the DeviceManager
class. When it wants to return version
, I get the error. What am I doing wrong?
I finally found how to fix this problem!
Right click on your Project , Choose Properties , Go to Configuration Properties , Select C/C++ then select Code Generation .
Change Basic Run Time Check to Default
.
Change Struct Member Alliance to 1 Byte (/Zp1)
.
I really hope this work for you guys too.
Best Regards
这篇关于ESP的值在函数调用错误中未正确保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!