mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 09:55:50 +00:00
wintrust: Use nameless unions/structs.
This commit is contained in:
parent
dd44930b44
commit
04ffca6e16
|
@ -21,7 +21,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#define NONAMELESSUNION
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
@ -147,8 +147,8 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
|
|||
DWORD fileNameLen, fileNameLenBytes;
|
||||
LPWSTR ptr;
|
||||
|
||||
fileNameLen = link->u.pwszFile ?
|
||||
lstrlenW(link->u.pwszFile) * sizeof(WCHAR) : 0;
|
||||
fileNameLen = link->pwszFile ?
|
||||
lstrlenW(link->pwszFile) * sizeof(WCHAR) : 0;
|
||||
CRYPT_EncodeLen(fileNameLen, NULL, &fileNameLenBytes);
|
||||
CRYPT_EncodeLen(1 + fileNameLenBytes + fileNameLen, NULL,
|
||||
&lenBytes);
|
||||
|
@ -173,7 +173,7 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
|
|||
*pbEncoded++ = ASN_CONTEXT;
|
||||
CRYPT_EncodeLen(fileNameLen, pbEncoded, &fileNameLenBytes);
|
||||
pbEncoded += fileNameLenBytes;
|
||||
for (ptr = link->u.pwszFile; ptr && *ptr; ptr++)
|
||||
for (ptr = link->pwszFile; ptr && *ptr; ptr++)
|
||||
{
|
||||
*(WCHAR *)pbEncoded = hton16(*ptr);
|
||||
pbEncoded += sizeof(WCHAR);
|
||||
|
@ -185,14 +185,14 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
|
|||
case SPC_MONIKER_LINK_CHOICE:
|
||||
{
|
||||
DWORD classIdLenBytes, dataLenBytes, dataLen;
|
||||
CRYPT_DATA_BLOB classId = { sizeof(link->u.Moniker.ClassId),
|
||||
(BYTE *)link->u.Moniker.ClassId };
|
||||
CRYPT_DATA_BLOB classId = { sizeof(link->Moniker.ClassId),
|
||||
(BYTE *)link->Moniker.ClassId };
|
||||
|
||||
CRYPT_EncodeLen(classId.cbData, NULL, &classIdLenBytes);
|
||||
CRYPT_EncodeLen(link->u.Moniker.SerializedData.cbData, NULL,
|
||||
CRYPT_EncodeLen(link->Moniker.SerializedData.cbData, NULL,
|
||||
&dataLenBytes);
|
||||
dataLen = 2 + classIdLenBytes + classId.cbData +
|
||||
dataLenBytes + link->u.Moniker.SerializedData.cbData;
|
||||
dataLenBytes + link->Moniker.SerializedData.cbData;
|
||||
CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
|
||||
bytesNeeded = 1 + dataLen + lenBytes;
|
||||
if (!pbEncoded)
|
||||
|
@ -217,9 +217,9 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
|
|||
CRYPT_AsnEncodeOctets(X509_ASN_ENCODING, NULL, &classId,
|
||||
pbEncoded, &size);
|
||||
pbEncoded += size;
|
||||
size = 1 + dataLenBytes + link->u.Moniker.SerializedData.cbData;
|
||||
size = 1 + dataLenBytes + link->Moniker.SerializedData.cbData;
|
||||
CRYPT_AsnEncodeOctets(X509_ASN_ENCODING, NULL,
|
||||
&link->u.Moniker.SerializedData, pbEncoded, &size);
|
||||
&link->Moniker.SerializedData, pbEncoded, &size);
|
||||
pbEncoded += size;
|
||||
ret = TRUE;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
|
|||
/* Check for invalid characters in URL */
|
||||
ret = TRUE;
|
||||
urlLen = 0;
|
||||
for (ptr = link->u.pwszUrl; ptr && *ptr && ret; ptr++)
|
||||
for (ptr = link->pwszUrl; ptr && *ptr && ret; ptr++)
|
||||
if (*ptr > 0x7f)
|
||||
{
|
||||
*pcbEncoded = 0;
|
||||
|
@ -260,7 +260,7 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
|
|||
*pbEncoded++ = ASN_CONTEXT;
|
||||
CRYPT_EncodeLen(urlLen, pbEncoded, &lenBytes);
|
||||
pbEncoded += lenBytes;
|
||||
for (ptr = link->u.pwszUrl; ptr && *ptr; ptr++)
|
||||
for (ptr = link->pwszUrl; ptr && *ptr; ptr++)
|
||||
*pbEncoded++ = (BYTE)*ptr;
|
||||
}
|
||||
}
|
||||
|
@ -1256,10 +1256,10 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
|
|||
|
||||
link->dwLinkChoice = SPC_URL_LINK_CHOICE;
|
||||
for (i = 0; i < dataLen; i++)
|
||||
link->u.pwszUrl[i] =
|
||||
link->pwszUrl[i] =
|
||||
*(pbEncoded + 1 + lenBytes + i);
|
||||
link->u.pwszUrl[i] = '\0';
|
||||
TRACE("returning url %s\n", debugstr_w(link->u.pwszUrl));
|
||||
link->pwszUrl[i] = '\0';
|
||||
TRACE("returning url %s\n", debugstr_w(link->pwszUrl));
|
||||
}
|
||||
break;
|
||||
case ASN_CONSTRUCTOR | ASN_CONTEXT | 1:
|
||||
|
@ -1306,13 +1306,13 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
|
|||
/* pwszFile pointer was set by caller, copy it
|
||||
* before overwriting it
|
||||
*/
|
||||
link->u.Moniker.SerializedData.pbData =
|
||||
(BYTE *)link->u.pwszFile;
|
||||
memcpy(link->u.Moniker.ClassId, classId.pbData,
|
||||
link->Moniker.SerializedData.pbData =
|
||||
(BYTE *)link->pwszFile;
|
||||
memcpy(link->Moniker.ClassId, classId.pbData,
|
||||
classId.cbData);
|
||||
memcpy(link->u.Moniker.SerializedData.pbData,
|
||||
memcpy(link->Moniker.SerializedData.pbData,
|
||||
data.pbData, data.cbData);
|
||||
link->u.Moniker.SerializedData.cbData = data.cbData;
|
||||
link->Moniker.SerializedData.cbData = data.cbData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1344,10 +1344,10 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
|
|||
|
||||
link->dwLinkChoice = SPC_FILE_LINK_CHOICE;
|
||||
for (i = 0; i < dataLen / sizeof(WCHAR); i++)
|
||||
link->u.pwszFile[i] =
|
||||
link->pwszFile[i] =
|
||||
hton16(*(const WORD *)(ptr + i * sizeof(WCHAR)));
|
||||
link->u.pwszFile[realDataLen / sizeof(WCHAR)] = '\0';
|
||||
TRACE("returning file %s\n", debugstr_w(link->u.pwszFile));
|
||||
link->pwszFile[realDataLen / sizeof(WCHAR)] = '\0';
|
||||
TRACE("returning file %s\n", debugstr_w(link->pwszFile));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1366,7 +1366,7 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
|
|||
PSPC_LINK link = pvStructInfo;
|
||||
|
||||
link->dwLinkChoice = SPC_FILE_LINK_CHOICE;
|
||||
link->u.pwszFile[0] = '\0';
|
||||
link->pwszFile[0] = '\0';
|
||||
ret = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -1408,7 +1408,7 @@ BOOL WINAPI WVTAsn1SpcLinkDecode(DWORD dwCertEncodingType,
|
|||
{
|
||||
SPC_LINK *link = pvStructInfo;
|
||||
|
||||
link->u.pwszFile =
|
||||
link->pwszFile =
|
||||
(LPWSTR)((BYTE *)pvStructInfo + sizeof(SPC_LINK));
|
||||
ret = CRYPT_AsnDecodeSPCLinkInternal(dwCertEncodingType,
|
||||
lpszStructType, pbEncoded, cbEncoded, dwFlags, pvStructInfo,
|
||||
|
@ -1773,7 +1773,7 @@ static BOOL WINAPI CRYPT_AsnDecodeSPCLinkPointer(DWORD dwCertEncodingType,
|
|||
/* Set imageData's pointer if necessary */
|
||||
if (size > sizeof(SPC_LINK))
|
||||
{
|
||||
(*pLink)->u.pwszUrl =
|
||||
(*pLink)->pwszUrl =
|
||||
(LPWSTR)((BYTE *)*pLink + sizeof(SPC_LINK));
|
||||
}
|
||||
ret = CRYPT_AsnDecodeSPCLinkInternal(dwCertEncodingType,
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
|
||||
#define NONAMELESSUNION
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -86,25 +85,25 @@ static DWORD SOFTPUB_OpenFile(CRYPT_PROVIDER_DATA *data)
|
|||
* typically have hFile as NULL rather than INVALID_HANDLE_VALUE. Check
|
||||
* for both.
|
||||
*/
|
||||
if (!data->pWintrustData->u.pFile->hFile ||
|
||||
data->pWintrustData->u.pFile->hFile == INVALID_HANDLE_VALUE)
|
||||
if (!data->pWintrustData->pFile->hFile ||
|
||||
data->pWintrustData->pFile->hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
data->pWintrustData->u.pFile->hFile =
|
||||
CreateFileW(data->pWintrustData->u.pFile->pcwszFilePath, GENERIC_READ,
|
||||
data->pWintrustData->pFile->hFile =
|
||||
CreateFileW(data->pWintrustData->pFile->pcwszFilePath, GENERIC_READ,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (data->pWintrustData->u.pFile->hFile != INVALID_HANDLE_VALUE)
|
||||
if (data->pWintrustData->pFile->hFile != INVALID_HANDLE_VALUE)
|
||||
data->fOpenedFile = TRUE;
|
||||
else
|
||||
err = GetLastError();
|
||||
}
|
||||
if (!err)
|
||||
GetFileTime(data->pWintrustData->u.pFile->hFile, &data->sftSystemTime,
|
||||
GetFileTime(data->pWintrustData->pFile->hFile, &data->sftSystemTime,
|
||||
NULL, NULL);
|
||||
TRACE("returning %ld\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Assumes data->pWintrustData->u.pFile exists. Sets data->pPDSip->gSubject to
|
||||
/* Assumes data->pWintrustData->pFile exists. Sets data->pPDSip->gSubject to
|
||||
* the file's subject GUID.
|
||||
*/
|
||||
static DWORD SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data)
|
||||
|
@ -112,13 +111,13 @@ static DWORD SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data)
|
|||
DWORD err = ERROR_SUCCESS;
|
||||
|
||||
if (!WVT_ISINSTRUCT(WINTRUST_FILE_INFO,
|
||||
data->pWintrustData->u.pFile->cbStruct, pgKnownSubject) ||
|
||||
!data->pWintrustData->u.pFile->pgKnownSubject)
|
||||
data->pWintrustData->pFile->cbStruct, pgKnownSubject) ||
|
||||
!data->pWintrustData->pFile->pgKnownSubject)
|
||||
{
|
||||
if (!CryptSIPRetrieveSubjectGuid(
|
||||
data->pWintrustData->u.pFile->pcwszFilePath,
|
||||
data->pWintrustData->u.pFile->hFile,
|
||||
&data->u.pPDSip->gSubject))
|
||||
data->pWintrustData->pFile->pcwszFilePath,
|
||||
data->pWintrustData->pFile->hFile,
|
||||
&data->pPDSip->gSubject))
|
||||
{
|
||||
LARGE_INTEGER fileSize;
|
||||
DWORD sipError = GetLastError();
|
||||
|
@ -127,7 +126,7 @@ static DWORD SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data)
|
|||
* TRUST_E_SUBJECT_FORM_UNKNOWN, rather than whatever
|
||||
* CryptSIPRetrieveSubjectGuid returns.
|
||||
*/
|
||||
if (GetFileSizeEx(data->pWintrustData->u.pFile->hFile, &fileSize)
|
||||
if (GetFileSizeEx(data->pWintrustData->pFile->hFile, &fileSize)
|
||||
&& !fileSize.QuadPart)
|
||||
err = TRUST_E_SUBJECT_FORM_UNKNOWN;
|
||||
else
|
||||
|
@ -135,22 +134,22 @@ static DWORD SOFTPUB_GetFileSubject(CRYPT_PROVIDER_DATA *data)
|
|||
}
|
||||
}
|
||||
else
|
||||
data->u.pPDSip->gSubject = *data->pWintrustData->u.pFile->pgKnownSubject;
|
||||
data->pPDSip->gSubject = *data->pWintrustData->pFile->pgKnownSubject;
|
||||
TRACE("returning %ld\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Assumes data->u.pPDSip exists, and its gSubject member set.
|
||||
* Allocates data->u.pPDSip->pSip and loads it, if possible.
|
||||
/* Assumes data->pPDSip exists, and its gSubject member set.
|
||||
* Allocates data->pPDSip->pSip and loads it, if possible.
|
||||
*/
|
||||
static DWORD SOFTPUB_GetSIP(CRYPT_PROVIDER_DATA *data)
|
||||
{
|
||||
DWORD err = ERROR_SUCCESS;
|
||||
|
||||
data->u.pPDSip->pSip = data->psPfns->pfnAlloc(sizeof(SIP_DISPATCH_INFO));
|
||||
if (data->u.pPDSip->pSip)
|
||||
data->pPDSip->pSip = data->psPfns->pfnAlloc(sizeof(SIP_DISPATCH_INFO));
|
||||
if (data->pPDSip->pSip)
|
||||
{
|
||||
if (!CryptSIPLoad(&data->u.pPDSip->gSubject, 0, data->u.pPDSip->pSip))
|
||||
if (!CryptSIPLoad(&data->pPDSip->gSubject, 0, data->pPDSip->pSip))
|
||||
err = GetLastError();
|
||||
}
|
||||
else
|
||||
|
@ -159,8 +158,8 @@ static DWORD SOFTPUB_GetSIP(CRYPT_PROVIDER_DATA *data)
|
|||
return err;
|
||||
}
|
||||
|
||||
/* Assumes data->u.pPDSip has been loaded, and data->u.pPDSip->pSip allocated.
|
||||
* Calls data->u.pPDSip->pSip->pfGet to construct data->hMsg.
|
||||
/* Assumes data->pPDSip has been loaded, and data->pPDSip->pSip allocated.
|
||||
* Calls data->pPDSip->pSip->pfGet to construct data->hMsg.
|
||||
*/
|
||||
static DWORD SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file,
|
||||
LPCWSTR filePath)
|
||||
|
@ -170,17 +169,17 @@ static DWORD SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file,
|
|||
LPBYTE buf = NULL;
|
||||
DWORD size = 0;
|
||||
|
||||
data->u.pPDSip->psSipSubjectInfo =
|
||||
data->pPDSip->psSipSubjectInfo =
|
||||
data->psPfns->pfnAlloc(sizeof(SIP_SUBJECTINFO));
|
||||
if (!data->u.pPDSip->psSipSubjectInfo)
|
||||
if (!data->pPDSip->psSipSubjectInfo)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
data->u.pPDSip->psSipSubjectInfo->cbSize = sizeof(SIP_SUBJECTINFO);
|
||||
data->u.pPDSip->psSipSubjectInfo->pgSubjectType = &data->u.pPDSip->gSubject;
|
||||
data->u.pPDSip->psSipSubjectInfo->hFile = file;
|
||||
data->u.pPDSip->psSipSubjectInfo->pwsFileName = filePath;
|
||||
data->u.pPDSip->psSipSubjectInfo->hProv = data->hProv;
|
||||
ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo,
|
||||
data->pPDSip->psSipSubjectInfo->cbSize = sizeof(SIP_SUBJECTINFO);
|
||||
data->pPDSip->psSipSubjectInfo->pgSubjectType = &data->pPDSip->gSubject;
|
||||
data->pPDSip->psSipSubjectInfo->hFile = file;
|
||||
data->pPDSip->psSipSubjectInfo->pwsFileName = filePath;
|
||||
data->pPDSip->psSipSubjectInfo->hProv = data->hProv;
|
||||
ret = data->pPDSip->pSip->pfGet(data->pPDSip->psSipSubjectInfo,
|
||||
&data->dwEncoding, 0, &size, 0);
|
||||
if (!ret)
|
||||
return TRUST_E_NOSIGNATURE;
|
||||
|
@ -189,7 +188,7 @@ static DWORD SOFTPUB_GetMessageFromFile(CRYPT_PROVIDER_DATA *data, HANDLE file,
|
|||
if (!buf)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
ret = data->u.pPDSip->pSip->pfGet(data->u.pPDSip->psSipSubjectInfo,
|
||||
ret = data->pPDSip->pSip->pfGet(data->pPDSip->psSipSubjectInfo,
|
||||
&data->dwEncoding, 0, &size, buf);
|
||||
if (ret)
|
||||
{
|
||||
|
@ -308,7 +307,7 @@ static BOOL SOFTPUB_HashPEFile(HANDLE file, HCRYPTHASH hash)
|
|||
|
||||
static DWORD SOFTPUB_VerifyImageHash(CRYPT_PROVIDER_DATA *data, HANDLE file)
|
||||
{
|
||||
SPC_INDIRECT_DATA_CONTENT *indirect = (SPC_INDIRECT_DATA_CONTENT *)data->u.pPDSip->psIndirectData;
|
||||
SPC_INDIRECT_DATA_CONTENT *indirect = (SPC_INDIRECT_DATA_CONTENT *)data->pPDSip->psIndirectData;
|
||||
DWORD err, hash_size, length;
|
||||
BYTE *hash_data;
|
||||
BOOL release_prov = FALSE;
|
||||
|
@ -448,14 +447,14 @@ static DWORD SOFTPUB_DecodeInnerContent(CRYPT_PROVIDER_DATA *data)
|
|||
err = GetLastError();
|
||||
goto error;
|
||||
}
|
||||
data->u.pPDSip->psIndirectData = data->psPfns->pfnAlloc(size);
|
||||
if (!data->u.pPDSip->psIndirectData)
|
||||
data->pPDSip->psIndirectData = data->psPfns->pfnAlloc(size);
|
||||
if (!data->pPDSip->psIndirectData)
|
||||
{
|
||||
err = ERROR_OUTOFMEMORY;
|
||||
goto error;
|
||||
}
|
||||
ret = CryptDecodeObject(data->dwEncoding, oid, buf, size, 0,
|
||||
data->u.pPDSip->psIndirectData, &size);
|
||||
data->pPDSip->psIndirectData, &size);
|
||||
if (!ret)
|
||||
err = GetLastError();
|
||||
|
||||
|
@ -470,9 +469,9 @@ static DWORD SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data)
|
|||
{
|
||||
DWORD err = ERROR_SUCCESS;
|
||||
|
||||
if (data->pWintrustData->u.pCert &&
|
||||
if (data->pWintrustData->pCert &&
|
||||
WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(WINTRUST_CERT_INFO,
|
||||
data->pWintrustData->u.pCert->cbStruct, psCertContext))
|
||||
data->pWintrustData->pCert->cbStruct, psCertContext))
|
||||
{
|
||||
if (data->psPfns)
|
||||
{
|
||||
|
@ -484,8 +483,8 @@ static DWORD SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data)
|
|||
* add a cert to it
|
||||
*/
|
||||
if (WVT_ISINSTRUCT(WINTRUST_CERT_INFO,
|
||||
data->pWintrustData->u.pCert->cbStruct, psftVerifyAsOf) &&
|
||||
data->pWintrustData->u.pCert->psftVerifyAsOf)
|
||||
data->pWintrustData->pCert->cbStruct, psftVerifyAsOf) &&
|
||||
data->pWintrustData->pCert->psftVerifyAsOf)
|
||||
data->sftSystemTime = signer.sftVerifyAsOf;
|
||||
else
|
||||
{
|
||||
|
@ -498,13 +497,13 @@ static DWORD SOFTPUB_LoadCertMessage(CRYPT_PROVIDER_DATA *data)
|
|||
if (ret)
|
||||
{
|
||||
ret = data->psPfns->pfnAddCert2Chain(data, 0, FALSE, 0,
|
||||
data->pWintrustData->u.pCert->psCertContext);
|
||||
data->pWintrustData->pCert->psCertContext);
|
||||
if (WVT_ISINSTRUCT(WINTRUST_CERT_INFO,
|
||||
data->pWintrustData->u.pCert->cbStruct, pahStores))
|
||||
data->pWintrustData->pCert->cbStruct, pahStores))
|
||||
for (i = 0;
|
||||
ret && i < data->pWintrustData->u.pCert->chStores; i++)
|
||||
ret && i < data->pWintrustData->pCert->chStores; i++)
|
||||
ret = data->psPfns->pfnAddStore2Chain(data,
|
||||
data->pWintrustData->u.pCert->pahStores[i]);
|
||||
data->pWintrustData->pCert->pahStores[i]);
|
||||
}
|
||||
if (!ret)
|
||||
err = GetLastError();
|
||||
|
@ -519,7 +518,7 @@ static DWORD SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data)
|
|||
{
|
||||
DWORD err = ERROR_SUCCESS;
|
||||
|
||||
if (!data->pWintrustData->u.pFile)
|
||||
if (!data->pWintrustData->pFile)
|
||||
{
|
||||
err = ERROR_INVALID_PARAMETER;
|
||||
goto error;
|
||||
|
@ -533,8 +532,8 @@ static DWORD SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data)
|
|||
err = SOFTPUB_GetSIP(data);
|
||||
if (err)
|
||||
goto error;
|
||||
err = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->u.pFile->hFile,
|
||||
data->pWintrustData->u.pFile->pcwszFilePath);
|
||||
err = SOFTPUB_GetMessageFromFile(data, data->pWintrustData->pFile->hFile,
|
||||
data->pWintrustData->pFile->pcwszFilePath);
|
||||
if (err)
|
||||
goto error;
|
||||
err = SOFTPUB_CreateStoreFromMessage(data);
|
||||
|
@ -543,15 +542,15 @@ static DWORD SOFTPUB_LoadFileMessage(CRYPT_PROVIDER_DATA *data)
|
|||
err = SOFTPUB_DecodeInnerContent(data);
|
||||
if (err)
|
||||
goto error;
|
||||
err = SOFTPUB_VerifyImageHash(data, data->pWintrustData->u.pFile->hFile);
|
||||
err = SOFTPUB_VerifyImageHash(data, data->pWintrustData->pFile->hFile);
|
||||
|
||||
error:
|
||||
if (err && data->fOpenedFile && data->pWintrustData->u.pFile)
|
||||
if (err && data->fOpenedFile && data->pWintrustData->pFile)
|
||||
{
|
||||
/* The caller won't expect the file to be open on failure, so close it.
|
||||
*/
|
||||
CloseHandle(data->pWintrustData->u.pFile->hFile);
|
||||
data->pWintrustData->u.pFile->hFile = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(data->pWintrustData->pFile->hFile);
|
||||
data->pWintrustData->pFile->hFile = INVALID_HANDLE_VALUE;
|
||||
data->fOpenedFile = FALSE;
|
||||
}
|
||||
return err;
|
||||
|
@ -562,19 +561,19 @@ static DWORD SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data)
|
|||
DWORD err;
|
||||
HANDLE catalog = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (!data->pWintrustData->u.pCatalog)
|
||||
if (!data->pWintrustData->pCatalog)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
catalog = CreateFileW(data->pWintrustData->u.pCatalog->pcwszCatalogFilePath,
|
||||
catalog = CreateFileW(data->pWintrustData->pCatalog->pcwszCatalogFilePath,
|
||||
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (catalog == INVALID_HANDLE_VALUE)
|
||||
return GetLastError();
|
||||
if (!CryptSIPRetrieveSubjectGuid(
|
||||
data->pWintrustData->u.pCatalog->pcwszCatalogFilePath, catalog,
|
||||
&data->u.pPDSip->gSubject))
|
||||
data->pWintrustData->pCatalog->pcwszCatalogFilePath, catalog,
|
||||
&data->pPDSip->gSubject))
|
||||
{
|
||||
err = GetLastError();
|
||||
goto error;
|
||||
|
@ -583,7 +582,7 @@ static DWORD SOFTPUB_LoadCatalogMessage(CRYPT_PROVIDER_DATA *data)
|
|||
if (err)
|
||||
goto error;
|
||||
err = SOFTPUB_GetMessageFromFile(data, catalog,
|
||||
data->pWintrustData->u.pCatalog->pcwszCatalogFilePath);
|
||||
data->pWintrustData->pCatalog->pcwszCatalogFilePath);
|
||||
if (err)
|
||||
goto error;
|
||||
err = SOFTPUB_CreateStoreFromMessage(data);
|
||||
|
@ -1087,7 +1086,7 @@ static void WINTRUST_CreateChainPolicyCreateInfo(
|
|||
chainPara->RequestedUsage.dwType = 0;
|
||||
chainPara->RequestedUsage.Usage.cUsageIdentifier = 0;
|
||||
}
|
||||
info->u.cbSize = sizeof(WTD_GENERIC_CHAIN_POLICY_CREATE_INFO);
|
||||
info->cbSize = sizeof(WTD_GENERIC_CHAIN_POLICY_CREATE_INFO);
|
||||
info->hChainEngine = NULL;
|
||||
info->pChainPara = chainPara;
|
||||
if (data->dwProvFlags & CPD_REVOCATION_CHECK_END_CERT)
|
||||
|
@ -1204,7 +1203,7 @@ HRESULT WINAPI GenericChainCertificateTrust(CRYPT_PROVIDER_DATA *data)
|
|||
|
||||
TRACE("(%p)\n", data);
|
||||
|
||||
if (policyData && policyData->u.cbSize !=
|
||||
if (policyData && policyData->cbSize !=
|
||||
sizeof(WTD_GENERIC_CHAIN_POLICY_CREATE_INFO))
|
||||
{
|
||||
err = ERROR_INVALID_PARAMETER;
|
||||
|
@ -1396,7 +1395,7 @@ HRESULT WINAPI GenericChainFinalProv(CRYPT_PROVIDER_DATA *data)
|
|||
{
|
||||
for (i = 0; i < data->csSigners; i++)
|
||||
{
|
||||
signers[i].u.cbSize =
|
||||
signers[i].cbSize =
|
||||
sizeof(WTD_GENERIC_CHAIN_POLICY_SIGNER_INFO);
|
||||
signers[i].pChainContext =
|
||||
data->pasSigners[i].pChainContext;
|
||||
|
@ -1442,13 +1441,13 @@ HRESULT WINAPI SoftpubCleanup(CRYPT_PROVIDER_DATA *data)
|
|||
CertCloseStore(data->pahStores[i], 0);
|
||||
data->psPfns->pfnFree(data->pahStores);
|
||||
|
||||
if (data->u.pPDSip)
|
||||
if (data->pPDSip)
|
||||
{
|
||||
data->psPfns->pfnFree(data->u.pPDSip->pSip);
|
||||
data->psPfns->pfnFree(data->u.pPDSip->pCATSip);
|
||||
data->psPfns->pfnFree(data->u.pPDSip->psSipSubjectInfo);
|
||||
data->psPfns->pfnFree(data->u.pPDSip->psSipCATSubjectInfo);
|
||||
data->psPfns->pfnFree(data->u.pPDSip->psIndirectData);
|
||||
data->psPfns->pfnFree(data->pPDSip->pSip);
|
||||
data->psPfns->pfnFree(data->pPDSip->pCATSip);
|
||||
data->psPfns->pfnFree(data->pPDSip->psSipSubjectInfo);
|
||||
data->psPfns->pfnFree(data->pPDSip->psSipCATSubjectInfo);
|
||||
data->psPfns->pfnFree(data->pPDSip->psIndirectData);
|
||||
}
|
||||
|
||||
if (WVT_ISINSTRUCT(CRYPT_PROVIDER_DATA, data->cbStruct, pSigState) && data->pSigState)
|
||||
|
@ -1462,10 +1461,10 @@ HRESULT WINAPI SoftpubCleanup(CRYPT_PROVIDER_DATA *data)
|
|||
|
||||
if (data->fOpenedFile &&
|
||||
data->pWintrustData->dwUnionChoice == WTD_CHOICE_FILE &&
|
||||
data->pWintrustData->u.pFile)
|
||||
data->pWintrustData->pFile)
|
||||
{
|
||||
CloseHandle(data->pWintrustData->u.pFile->hFile);
|
||||
data->pWintrustData->u.pFile->hFile = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(data->pWintrustData->pFile->hFile);
|
||||
data->pWintrustData->pFile->hFile = INVALID_HANDLE_VALUE;
|
||||
data->fOpenedFile = FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define NONAMELESSUNION
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
|
@ -92,7 +90,7 @@ BOOL WINAPI TrustIsCertificateSelfSigned( PCCERT_CONTEXT cert )
|
|||
if (directoryName)
|
||||
{
|
||||
ret = CertCompareCertificateName(cert->dwCertEncodingType,
|
||||
&directoryName->u.DirectoryName, &cert->pCertInfo->Issuer)
|
||||
&directoryName->DirectoryName, &cert->pCertInfo->Issuer)
|
||||
&& CertCompareIntegerBlob(&info->AuthorityCertSerialNumber,
|
||||
&cert->pCertInfo->SerialNumber);
|
||||
}
|
||||
|
@ -213,10 +211,10 @@ static CRYPT_PROVIDER_DATA *WINTRUST_AllocateProviderData(void)
|
|||
goto oom;
|
||||
provData->cdwTrustStepErrors = TRUSTERROR_MAX_STEPS;
|
||||
|
||||
provData->u.pPDSip = WINTRUST_Alloc(sizeof(PROVDATA_SIP));
|
||||
if (!provData->u.pPDSip)
|
||||
provData->pPDSip = WINTRUST_Alloc(sizeof(PROVDATA_SIP));
|
||||
if (!provData->pPDSip)
|
||||
goto oom;
|
||||
provData->u.pPDSip->cbStruct = sizeof(PROVDATA_SIP);
|
||||
provData->pPDSip->cbStruct = sizeof(PROVDATA_SIP);
|
||||
|
||||
provData->psPfns = WINTRUST_Alloc(sizeof(CRYPT_PROVIDER_FUNCTIONS));
|
||||
if (!provData->psPfns)
|
||||
|
@ -228,7 +226,7 @@ oom:
|
|||
if (provData)
|
||||
{
|
||||
WINTRUST_Free(provData->padwTrustStepErrors);
|
||||
WINTRUST_Free(provData->u.pPDSip);
|
||||
WINTRUST_Free(provData->pPDSip);
|
||||
WINTRUST_Free(provData->psPfns);
|
||||
WINTRUST_Free(provData);
|
||||
}
|
||||
|
@ -312,7 +310,7 @@ static LONG WINTRUST_DefaultVerify(HWND hwnd, GUID *actionID,
|
|||
|
||||
error:
|
||||
WINTRUST_Free(provData->padwTrustStepErrors);
|
||||
WINTRUST_Free(provData->u.pPDSip);
|
||||
WINTRUST_Free(provData->pPDSip);
|
||||
WINTRUST_Free(provData->psPfns);
|
||||
WINTRUST_Free(provData);
|
||||
|
||||
|
@ -335,7 +333,7 @@ static LONG WINTRUST_DefaultClose(HWND hwnd, GUID *actionID,
|
|||
err = provData->psPfns->pfnCleanupPolicy(provData);
|
||||
|
||||
WINTRUST_Free(provData->padwTrustStepErrors);
|
||||
WINTRUST_Free(provData->u.pPDSip);
|
||||
WINTRUST_Free(provData->pPDSip);
|
||||
WINTRUST_Free(provData->psPfns);
|
||||
WINTRUST_Free(provData);
|
||||
data->hWVTStateData = NULL;
|
||||
|
@ -371,7 +369,7 @@ static LONG WINTRUST_PublishedSoftware(HWND hwnd, GUID *actionID,
|
|||
TRACE("subjectFile->lpPath: %s\n", debugstr_w(subjectFile->lpPath));
|
||||
fileInfo.pcwszFilePath = subjectFile->lpPath;
|
||||
fileInfo.hFile = subjectFile->hFile;
|
||||
wintrust_data.u.pFile = &fileInfo;
|
||||
wintrust_data.pFile = &fileInfo;
|
||||
wintrust_data.dwUnionChoice = WTD_CHOICE_FILE;
|
||||
wintrust_data.dwUIChoice = WTD_UI_NONE;
|
||||
|
||||
|
@ -395,16 +393,16 @@ static HRESULT WINAPI WINTRUST_CertVerifyObjTrust(CRYPT_PROVIDER_DATA *data)
|
|||
switch (data->pWintrustData->dwUnionChoice)
|
||||
{
|
||||
case WTD_CHOICE_BLOB:
|
||||
if (data->pWintrustData->u.pBlob &&
|
||||
if (data->pWintrustData->pBlob &&
|
||||
WVT_IS_CBSTRUCT_GT_MEMBEROFFSET(WINTRUST_BLOB_INFO,
|
||||
data->pWintrustData->u.pBlob->cbStruct, pbMemObject) &&
|
||||
data->pWintrustData->u.pBlob->cbMemObject ==
|
||||
data->pWintrustData->pBlob->cbStruct, pbMemObject) &&
|
||||
data->pWintrustData->pBlob->cbMemObject ==
|
||||
sizeof(CERT_VERIFY_CERTIFICATE_TRUST) &&
|
||||
data->pWintrustData->u.pBlob->pbMemObject)
|
||||
data->pWintrustData->pBlob->pbMemObject)
|
||||
{
|
||||
CERT_VERIFY_CERTIFICATE_TRUST *pCert =
|
||||
(CERT_VERIFY_CERTIFICATE_TRUST *)
|
||||
data->pWintrustData->u.pBlob->pbMemObject;
|
||||
data->pWintrustData->pBlob->pbMemObject;
|
||||
|
||||
if (pCert->cbSize == sizeof(CERT_VERIFY_CERTIFICATE_TRUST) &&
|
||||
pCert->pccert)
|
||||
|
@ -503,7 +501,7 @@ static LONG WINTRUST_CertVerify(HWND hwnd, GUID *actionID,
|
|||
|
||||
error:
|
||||
WINTRUST_Free(provData->padwTrustStepErrors);
|
||||
WINTRUST_Free(provData->u.pPDSip);
|
||||
WINTRUST_Free(provData->pPDSip);
|
||||
WINTRUST_Free(provData->psPfns);
|
||||
WINTRUST_Free(provData);
|
||||
|
||||
|
@ -641,19 +639,19 @@ static void dump_wintrust_data(WINTRUST_DATA *data)
|
|||
switch (data->dwUnionChoice)
|
||||
{
|
||||
case WTD_CHOICE_FILE:
|
||||
dump_file_info(data->u.pFile);
|
||||
dump_file_info(data->pFile);
|
||||
break;
|
||||
case WTD_CHOICE_CATALOG:
|
||||
dump_catalog_info(data->u.pCatalog);
|
||||
dump_catalog_info(data->pCatalog);
|
||||
break;
|
||||
case WTD_CHOICE_BLOB:
|
||||
dump_blob_info(data->u.pBlob);
|
||||
dump_blob_info(data->pBlob);
|
||||
break;
|
||||
case WTD_CHOICE_SIGNER:
|
||||
dump_sgnr_info(data->u.pSgnr);
|
||||
dump_sgnr_info(data->pSgnr);
|
||||
break;
|
||||
case WTD_CHOICE_CERT:
|
||||
dump_cert_info(data->u.pCert);
|
||||
dump_cert_info(data->pCert);
|
||||
break;
|
||||
}
|
||||
TRACE("dwStateAction: %ld\n", data->dwStateAction);
|
||||
|
@ -828,7 +826,7 @@ LPCWSTR WINAPI WTHelperGetFileName(WINTRUST_DATA *data)
|
|||
{
|
||||
TRACE("%p\n",data);
|
||||
if (data->dwUnionChoice == WTD_CHOICE_FILE)
|
||||
return data->u.pFile->pcwszFilePath;
|
||||
return data->pFile->pcwszFilePath;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
@ -840,7 +838,7 @@ HANDLE WINAPI WTHelperGetFileHandle(WINTRUST_DATA *data)
|
|||
{
|
||||
TRACE("%p\n",data);
|
||||
if (data->dwUnionChoice == WTD_CHOICE_FILE)
|
||||
return data->u.pFile->hFile;
|
||||
return data->pFile->hFile;
|
||||
else
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue