Implementing NEW service provide (SP) with CEN-XFS compliance

折月煮酒 提交于 2019-12-03 05:12:05

Those export comparisons look like you are using wrong calling convention.
Change all your SPI exports from WINAPI to __cdecl (just remove the WINAPI as __cdecl is the default) and it should make the difference.

And why the difference in return codes in your examples:
First example doesn't even get to the WFPOpen call, because the manager doesn't find the correct WFPOpen symbol after DLL load -> Invalid ServiceProvider.

Second case seams to go in to the WFPOpen, but the first test fails -> INTERNAL_ERROR:
if(!g_hMutex ||!g_hLib ||!g_hMsgQueueEvent) return WFS_ERR_INTERNAL_ERROR;

So after calling convention fix you need to check your initailization code in more detail to see why it fails.

One thing I found out by looking those tested globals is that you should NEVER ever call LoadLibrary from code that is executed in DLLMain.

You could just create the mutex and save the DLL module handle in DLLMain and do rest of the initialization like library loading at the begining of the WFPOpen.

One can't simply return WFS_SUCCESS from WFPOpen. The following is a very coarse description of the minimal implementation:
1. Fill the version structure (One of the parameters is a pointer for this)
2. Return WFS_SUCCESS or an error code.
3. If WFPOpen returns WFS_SUCCESS then an asynchronous response is expected by the caller. So you have to send that WFS_OPEN_COMPLETE message with all the required information to the given (hwnd parameter) message window handle.

See more detailed information from the following document (SPI API is chapter 6).
ftp://ftp.cenorm.be/CWA/CEN/WS-XFS/CWA16374/CWA16374-1-2011_December.pdf

this code is ok. I think You should Search in registery for "QuantumT", may be it has not register there.

logical service names: 1- regedit 2- HKEY_CURRENT_USER/XFS/LOGICAL_SERVICES/

I use "JournalPrinter1" and WFSOpen return Success to me.

The calling convention is already defined in XFSSPI.H, I don't think you should change it.

You need to add a .def file to your solution with the "correct" exported name of the functions, and set it as your solution Module Definition File Properties->Linker->Input->Module Definition File:

EXPORTS
WFPCancelAsyncRequest
WFPClose
WFPDeregister
WFPExecute
WFPGetInfo
WFPLock
WFPOpen
WFPRegister
WFPSetTraceLevel
WFPUnloadService
WFPUnlock

I got my SPI WFPOpen function called this way.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!