DLL creation process in windows application with CEN XFS
-
Hi To say i am very noob to windows programming world. We are trying to develop windows application + device driver with CEN XFS compliance. http://en.wikipedia.org/wiki/CEN/XFS simple architectural flow:
Windows Application | \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ | XFS APIs | (CEN/XFS SDK DLL) | | | XFS SPIs | |\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_|---XFS Manager | | Service providers (SP) (DEVICE DRIVER)
To understand the SP's functionality, we recently took one of the device vendors SP's DLL for accessing their device and we were able to successfully communicate with their device using our windows application(Eclipse MINGW based). Then we started to check for some sample SP source in internet to try our implementation. (https://drive.google.com/file/d/0B60pejPe6yiSejRGQ3JnLUl4dzA/view) With the linked source we were able to compile and create an output DLL. But , when we tried to access the SP, I always return error. With windows sample application, we just tried to open the device with call (WFSOPEN) which always returned (-15 WFS_ERR_INTERNAL_ERROR ) or (-29 WFS_ERR_INVALID_SERVPROV)
Trial FLow 1 : Application Call to manager: hResult = WFSOpen( "QuantumT", hApp,lpszAppID, dwTraceLevel,dwTimeOut,VER\_SPI\_REQUIRE,&SrvcVersion,&SPIVersion,&hService); manager translates WFSOPEN call to SP's WFPOPEN call: HRESULT WINAPI WFPOpen(HSERVICE hService, LPSTR lpszLogicalName, HAPP hApp, LPSTR lpszAppID, DWORD dwTraceLevel, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID, HPROVIDER hProvider, DWORD dwSPIVersionsRequired, LPWFSVERSION lpSPIVersion, DWORD dwSrvcVersionsRequired, LPWFSVERSION lpSrvcVersion) With above call flow I get (-29 WFS\_ERR\_INVALID\_SERVPROV) as an error for my application
Trial FLow 2 (Just removed WINAPI interface for WFPOPEN in SP):
Application Call to manager:
hResult = WFSOpen("QuantumT",hApp,lpszAppID,dwTraceLevel,dwTimeOut,VER_SPI_REQUIRE,&SrvcVersion,&SPIVersion,&hService);
manager translates WFSOPEN call to SP's WFPOPEN call
HRESULT WFPOpen(HSERVICE hServi
-
Hi To say i am very noob to windows programming world. We are trying to develop windows application + device driver with CEN XFS compliance. http://en.wikipedia.org/wiki/CEN/XFS simple architectural flow:
Windows Application | \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ | XFS APIs | (CEN/XFS SDK DLL) | | | XFS SPIs | |\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_|---XFS Manager | | Service providers (SP) (DEVICE DRIVER)
To understand the SP's functionality, we recently took one of the device vendors SP's DLL for accessing their device and we were able to successfully communicate with their device using our windows application(Eclipse MINGW based). Then we started to check for some sample SP source in internet to try our implementation. (https://drive.google.com/file/d/0B60pejPe6yiSejRGQ3JnLUl4dzA/view) With the linked source we were able to compile and create an output DLL. But , when we tried to access the SP, I always return error. With windows sample application, we just tried to open the device with call (WFSOPEN) which always returned (-15 WFS_ERR_INTERNAL_ERROR ) or (-29 WFS_ERR_INVALID_SERVPROV)
Trial FLow 1 : Application Call to manager: hResult = WFSOpen( "QuantumT", hApp,lpszAppID, dwTraceLevel,dwTimeOut,VER\_SPI\_REQUIRE,&SrvcVersion,&SPIVersion,&hService); manager translates WFSOPEN call to SP's WFPOPEN call: HRESULT WINAPI WFPOpen(HSERVICE hService, LPSTR lpszLogicalName, HAPP hApp, LPSTR lpszAppID, DWORD dwTraceLevel, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID, HPROVIDER hProvider, DWORD dwSPIVersionsRequired, LPWFSVERSION lpSPIVersion, DWORD dwSrvcVersionsRequired, LPWFSVERSION lpSrvcVersion) With above call flow I get (-29 WFS\_ERR\_INVALID\_SERVPROV) as an error for my application
Trial FLow 2 (Just removed WINAPI interface for WFPOPEN in SP):
Application Call to manager:
hResult = WFSOpen("QuantumT",hApp,lpszAppID,dwTraceLevel,dwTimeOut,VER_SPI_REQUIRE,&SrvcVersion,&SPIVersion,&hService);
manager translates WFSOPEN call to SP's WFPOPEN call
HRESULT WFPOpen(HSERVICE hServi
I googled the error message you mention and could not find it in the Windows API. It doesn't look like a Windows error message. I'm afraid the maker of the device might be the only one who could help you with this problem. EDIT: Perhaps this is a call stack corruption caused by removing the
WINAPI
definition.WINAPI
simply means__stdcall
which is the calling convention used by the Windows API.The difficult we do right away... ...the impossible takes slightly longer.
-
I googled the error message you mention and could not find it in the Windows API. It doesn't look like a Windows error message. I'm afraid the maker of the device might be the only one who could help you with this problem. EDIT: Perhaps this is a call stack corruption caused by removing the
WINAPI
definition.WINAPI
simply means__stdcall
which is the calling convention used by the Windows API.The difficult we do right away... ...the impossible takes slightly longer.
So, you suspect this might the issue with SP code which i am currently working with??.
-
So, you suspect this might the issue with SP code which i am currently working with??.
Well, since that is not a Windows error message, I can only assume it is specific to the library you are using.
The difficult we do right away... ...the impossible takes slightly longer.
-
I googled the error message you mention and could not find it in the Windows API. It doesn't look like a Windows error message. I'm afraid the maker of the device might be the only one who could help you with this problem. EDIT: Perhaps this is a call stack corruption caused by removing the
WINAPI
definition.WINAPI
simply means__stdcall
which is the calling convention used by the Windows API.The difficult we do right away... ...the impossible takes slightly longer.
Also i see some difference in Sp's DLL which i created and actual working vendors DLL
Difference noted using PE studio's exported sysmbols option
DLL Created by ME:_WFPCancelAsyncRequest@8,-,1,-,-,.rdata:0x00001096
_WFPClose@12,-,2,-,-,.rdata:0x00001005
_WFPDeregister@20,-,3,-,-,.rdata:0x00001140
_WFPExecute@24,-,4,-,-,.rdata:0x00001131
_WFPGetInfo@24,-,5,-,-,.rdata:0x000010EB
_WFPLock@16,-,6,-,-,.rdata:0x00001023
_WFPOpen@52,-,7,-,-,.rdata:0x0000102D
_WFPRegister@20,-,8,-,-,.rdata:0x00001073
_WFPSetTraceLevel@8,-,9,-,-,.rdata:0x0000113B
_WFPUnloadService@0,-,10,-,-,.rdata:0x0000100A
_WFPUnlock@12,-,11,-,-,.rdata:0x00001082Vendor created DLL:
WFPCancelAsyncRequest,-,1,-,-,.rdata:0x0000C450
WFPClose,-,2,-,-,.rdata:0x0000C6E0
WFPDeregister,-,3,-,-,.rdata:0x0000C7F0
WFPExecute,-,4,-,-,.rdata:0x0000C970
WFPGetInfo,-,5,-,-,.rdata:0x0000DFA0
WFPLock,-,6,-,-,.rdata:0x0000E490
WFPOpen,-,7,-,-,.rdata:0x0000C030
WFPRegister,-,8,-,-,.rdata:0x0000E590
WFPSetTraceLevel,-,9,-,-,.rdata:0x0000E710
WFPUnloadService,-,10,-,-,.rdata:0x0000E770
WFPUnlock,-,11,-,-,.rdata:0x0000E8F0What is the difference.Does export method differ??
-
Also i see some difference in Sp's DLL which i created and actual working vendors DLL
Difference noted using PE studio's exported sysmbols option
DLL Created by ME:_WFPCancelAsyncRequest@8,-,1,-,-,.rdata:0x00001096
_WFPClose@12,-,2,-,-,.rdata:0x00001005
_WFPDeregister@20,-,3,-,-,.rdata:0x00001140
_WFPExecute@24,-,4,-,-,.rdata:0x00001131
_WFPGetInfo@24,-,5,-,-,.rdata:0x000010EB
_WFPLock@16,-,6,-,-,.rdata:0x00001023
_WFPOpen@52,-,7,-,-,.rdata:0x0000102D
_WFPRegister@20,-,8,-,-,.rdata:0x00001073
_WFPSetTraceLevel@8,-,9,-,-,.rdata:0x0000113B
_WFPUnloadService@0,-,10,-,-,.rdata:0x0000100A
_WFPUnlock@12,-,11,-,-,.rdata:0x00001082Vendor created DLL:
WFPCancelAsyncRequest,-,1,-,-,.rdata:0x0000C450
WFPClose,-,2,-,-,.rdata:0x0000C6E0
WFPDeregister,-,3,-,-,.rdata:0x0000C7F0
WFPExecute,-,4,-,-,.rdata:0x0000C970
WFPGetInfo,-,5,-,-,.rdata:0x0000DFA0
WFPLock,-,6,-,-,.rdata:0x0000E490
WFPOpen,-,7,-,-,.rdata:0x0000C030
WFPRegister,-,8,-,-,.rdata:0x0000E590
WFPSetTraceLevel,-,9,-,-,.rdata:0x0000E710
WFPUnloadService,-,10,-,-,.rdata:0x0000E770
WFPUnlock,-,11,-,-,.rdata:0x0000E8F0What is the difference.Does export method differ??
You've hit the nail on the head! The ones on the bottom are exported like so:
extern "C"
{
// Functions
}The ones on the top are exported in C++ fashion, with name mangling. Try exporting your functions as
extern "C"
.The difficult we do right away... ...the impossible takes slightly longer.
-
You've hit the nail on the head! The ones on the bottom are exported like so:
extern "C"
{
// Functions
}The ones on the top are exported in C++ fashion, with name mangling. Try exporting your functions as
extern "C"
.The difficult we do right away... ...the impossible takes slightly longer.
Thanks your tip help me to start some invetigation.All these days we were with LINUX. Migrating to windows seems little difficult for me. Where should :
extern "C"
{}
</pre>
be added??
Because SPITesh.H, the code has the expected tag...
#ifdef __cplusplus
extern "C" {
#endif
SPITEST_API HRESULT WINAPI WFPCancelAsyncRequest(HSERVICE hService, REQUESTID RequestID);
SPITEST_API HRESULT WINAPI WFPClose(HSERVICE hService, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPDeregister(HSERVICE hService, DWORD dwEventClass, HWND hWndReg, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPExecute(HSERVICE hService, DWORD dwCommand, LPVOID lpCmdData, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPGetInfo(HSERVICE hService, DWORD dwCategory, LPVOID lpQueryDetails, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPLock(HSERVICE hService, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPOpen(HSERVICE hService, LPSTR lpszLogicalName, HAPP hApp, LPSTR lpszAppID, DWORD dwTraceLevel, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID, HPROVIDER hProvider, DWORD dwSPIVersionsRequired, LPWFSVERSION lpSPIVersion, DWORD dwSrvcVersionsRequired, LPWFSVERSION lpSrvcVersion);
SPITEST_API HRESULT WINAPI WFPRegister(HSERVICE hService, DWORD dwEventClass, HWND hWndReg, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPSetTraceLevel(HSERVICE hService, DWORD dwTraceLevel);
SPITEST_API HRESULT WINAPI WFPUnloadService();
SPITEST_API HRESULT WINAPI WFPUnlock(HSERVICE hService, HWND hWnd, REQUESTID ReqID);
#ifdef __cplusplus
};
#endif -
Thanks your tip help me to start some invetigation.All these days we were with LINUX. Migrating to windows seems little difficult for me. Where should :
extern "C"
{}
</pre>
be added??
Because SPITesh.H, the code has the expected tag...
#ifdef __cplusplus
extern "C" {
#endif
SPITEST_API HRESULT WINAPI WFPCancelAsyncRequest(HSERVICE hService, REQUESTID RequestID);
SPITEST_API HRESULT WINAPI WFPClose(HSERVICE hService, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPDeregister(HSERVICE hService, DWORD dwEventClass, HWND hWndReg, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPExecute(HSERVICE hService, DWORD dwCommand, LPVOID lpCmdData, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPGetInfo(HSERVICE hService, DWORD dwCategory, LPVOID lpQueryDetails, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPLock(HSERVICE hService, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPOpen(HSERVICE hService, LPSTR lpszLogicalName, HAPP hApp, LPSTR lpszAppID, DWORD dwTraceLevel, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID, HPROVIDER hProvider, DWORD dwSPIVersionsRequired, LPWFSVERSION lpSPIVersion, DWORD dwSrvcVersionsRequired, LPWFSVERSION lpSrvcVersion);
SPITEST_API HRESULT WINAPI WFPRegister(HSERVICE hService, DWORD dwEventClass, HWND hWndReg, HWND hWnd, REQUESTID ReqID);
SPITEST_API HRESULT WINAPI WFPSetTraceLevel(HSERVICE hService, DWORD dwTraceLevel);
SPITEST_API HRESULT WINAPI WFPUnloadService();
SPITEST_API HRESULT WINAPI WFPUnlock(HSERVICE hService, HWND hWnd, REQUESTID ReqID);
#ifdef __cplusplus
};
#endifWhat you show inside SPITesh.H is the correct placement. Is that your file or the original vendor's file? In Visual Studio, when you compile the code as C++, it should automatically define
__cplusplus
. If it doesn't, then it might be that your source file extension is".c"
when it should be".cpp".
The difficult we do right away... ...the impossible takes slightly longer.
-
What you show inside SPITesh.H is the correct placement. Is that your file or the original vendor's file? In Visual Studio, when you compile the code as C++, it should automatically define
__cplusplus
. If it doesn't, then it might be that your source file extension is".c"
when it should be".cpp".
The difficult we do right away... ...the impossible takes slightly longer.
Yes, I sm trying to follow the same. but still it is doing no good. https://drive.google.com/file/d/0B60pejPe6yiSejRGQ3JnLUl4dzA/view[^] The link contains the project ref files i made sure all files are CPP and Extern C just for the headers. What else should i look ifor?? is there some settings that i should set in VS 2010 Express
-
Yes, I sm trying to follow the same. but still it is doing no good. https://drive.google.com/file/d/0B60pejPe6yiSejRGQ3JnLUl4dzA/view[^] The link contains the project ref files i made sure all files are CPP and Extern C just for the headers. What else should i look ifor?? is there some settings that i should set in VS 2010 Express
Try placing the
#ifdef __cplusplus
extern "C" {
#endif
// Functions
#ifdef __cplusplus
};
#endifin the CPP file also, surrounding the functions you want to export. I think that is the issue.
The difficult we do right away... ...the impossible takes slightly longer.
-
Try placing the
#ifdef __cplusplus
extern "C" {
#endif
// Functions
#ifdef __cplusplus
};
#endifin the CPP file also, surrounding the functions you want to export. I think that is the issue.
The difficult we do right away... ...the impossible takes slightly longer.
NO luck still.... :(
-
Try placing the
#ifdef __cplusplus
extern "C" {
#endif
// Functions
#ifdef __cplusplus
};
#endifin the CPP file also, surrounding the functions you want to export. I think that is the issue.
The difficult we do right away... ...the impossible takes slightly longer.
If possible can you just try downloading the code and check with your MS VS version??
-
NO luck still.... :(
I'm sorry. Maybe someone else will have some better ideas. :sigh:
The difficult we do right away... ...the impossible takes slightly longer.
-
If possible can you just try downloading the code and check with your MS VS version??
I did. It won't compile because of a number of undefined symbols in
SpiTest.cpp
.Quote:
2 IntelliSense: cannot open source file "xfsconf.h" d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 7 1 spi_QuantumT_bcr 3 IntelliSense: identifier "WFMOpenKey" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 150 13 spi_QuantumT_bcr 4 IntelliSense: identifier "WFS_CFG_MACHINE_XFS_ROOT" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 150 24 spi_QuantumT_bcr 5 IntelliSense: identifier "WFMQueryValue" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 154 8 spi_QuantumT_bcr 6 IntelliSense: identifier "WFMCloseKey" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 161 2 spi_QuantumT_bcr
The difficult we do right away... ...the impossible takes slightly longer.
-
I did. It won't compile because of a number of undefined symbols in
SpiTest.cpp
.Quote:
2 IntelliSense: cannot open source file "xfsconf.h" d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 7 1 spi_QuantumT_bcr 3 IntelliSense: identifier "WFMOpenKey" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 150 13 spi_QuantumT_bcr 4 IntelliSense: identifier "WFS_CFG_MACHINE_XFS_ROOT" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 150 24 spi_QuantumT_bcr 5 IntelliSense: identifier "WFMQueryValue" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 154 8 spi_QuantumT_bcr 6 IntelliSense: identifier "WFMCloseKey" is undefined d:\Richard\Documents\Visual Studio 2013\Projects\spi_QuantumT_bcr\spi_QuantumT_bcr\SpiTest.cpp 161 2 spi_QuantumT_bcr
The difficult we do right away... ...the impossible takes slightly longer.
XFSMANAGER INSTALLER: ftp://ftp.cencenelec.eu/CEN/WhatWeDo/Fields/ICT/eBusiness/WS/XFS/CWA15748/XFS310SDKInstall.zip
That is the libray link.
-
XFSMANAGER INSTALLER: ftp://ftp.cencenelec.eu/CEN/WhatWeDo/Fields/ICT/eBusiness/WS/XFS/CWA15748/XFS310SDKInstall.zip
That is the libray link.
I'm sorry, I'm not going to install anything on my development machine. Take a look at this article: extern "C"[^]
The difficult we do right away... ...the impossible takes slightly longer.
-
I'm sorry, I'm not going to install anything on my development machine. Take a look at this article: extern "C"[^]
The difficult we do right away... ...the impossible takes slightly longer.
No problem , I will try some option too...