0

我需要创建一个指向指针数组的指针,使用这种WFSPINKEYDETAILEXCEN / XFS 结构创建多个键。

有问题的结构..指向以 null 结尾的指向关键详细结构的指针数组。

typedef struct _wfs_pin_key_detail_ex
{
    LPSTR lpsKeyName;
    DWORD dwUse;
    BYTE bGeneration;
    BYTE bVersion;
    BYTE bActivatingDate[4];
    BYTE bExpiryDate[4];
    BOOL bLoaded;
} WFSPINKEYDETAILEX, * LPWFSPINKEYDETAILEX;

结构 WFSRESULT:

typedef struct _wfs_result
{
    REQUESTID       RequestID;
    HSERVICE        hService;
    SYSTEMTIME      tsTimestamp;
    HRESULT         hResult;
    union {
        DWORD       dwCommandCode;
        DWORD       dwEventID;
    } u;
    LPVOID          lpBuffer;
} WFSRESULT, *LPWFSRESULT;

我的程序:

HRESULT WINAPI WFPGetInfo(HSERVICE hService, DWORD dwCategory, LPVOID lpQueryDetails, DWORD dwTimeOut, HWND hWnd, REQUESTID ReqID) {
    WFSPINKEYDETAILEX** ppPinKeyDetail;
    WFSRESULT * lpWFSResult;
    HRESULT result;
    const int PINKEYS = 1;

    result = WFMAllocateBuffer(sizeof(WFSRESULT), WFS_MEM_ZEROINIT | WFS_MEM_SHARE, (void**)&lpWFSResult); 

    if(result != WFS_SUCCESS){
        return WFS_ERR_INTERNAL_ERROR;
    }

    result = WFMAllocateMore(sizeof(WFSPINKEYDETAILEX*) * (PINKEYS+1), lpWFSResult, (void**)&ppPinKeyDetail);

    lpWFSResult->hService=hService;
    lpWFSResult->RequestID=ReqID;
    lpWFSResult->u.dwCommandCode=WFS_INF_PIN_KEY_DETAIL_EX;
    lpWFSResult->hResult=WFS_SUCCESS;

    if(dwCategory == WFS_INF_PIN_KEY_DETAIL_EX){
        for(int i = 0; i < PINKEYS; i++){
            result = WFMAllocateMore(sizeof(WFSPINKEYDETAILEX), lpWFSResult, (void**)&ppPinKeyDetail[i]);
        }

        //This block repeats 5 times with different values...

        WFSPINKEYDETAILEX& ppKeyDetail(*ppPinKeyDetail[0]);
        ppKeyDetail.lpsKeyName = (LPSTR) "DEVICE_KBPK";
        ppKeyDetail.dwUse = WFS_PIN_USESECURECONSTRUCT;
        ppKeyDetail.bLoaded = TRUE;
        ppKeyDetail.bVersion = 0xFF;
        ppKeyDetail.bGeneration = 0xFF;
        ppKeyDetail.bActivatingDate[0] = 0xFF;
        ppKeyDetail.bActivatingDate[1] = 0xFF;
        ppKeyDetail.bActivatingDate[2] = 0xFF;
        ppKeyDetail.bActivatingDate[3] = 0xFF;
        ppKeyDetail.bExpiryDate[0] = 0xFF;
        ppKeyDetail.bExpiryDate[1] = 0xFF;
        ppKeyDetail.bExpiryDate[2] = 0xFF;
        ppKeyDetail.bExpiryDate[3] = 0xFF;

        //This block repeats 5 times with different values...
        //...

        lpWFSResult->lpBuffer = ppPinKeyDetail;
    }
}

最终程序编译,问题是当我在应用程序中作为服务提供者运行时,它忽略了这个键数组。

使用服务提供者准备好的应用程序日志:

Key: DEVICE_KBPK.                                    
dwUses: 1024.                                        
bLoaded: 1.                                          
bGeneration: FF.                                     
bVersion: FF.                                        
bActivatingDate: FF FF FF FF.                        
bExpiryDate: FF FF FF FF.                            
Generation unpack: .                                 
Version unpack: .                                    
ActivatingDate unpack: .                             
Expiry Date unpack: .                                
Key added to vector.  

当我使用我的服务提供者(来自本主题)时,它会导致 JAVA Crash。

主应用程序在 java 中完成,并通过 JNA 使用 DLL

4

0 回答 0