Robert Shearman wrote:
Thomas Weidenmueller wrote:
Index: dlls/crypt32/cert.c
RCS file: /home/wine/wine/dlls/crypt32/cert.c,v retrieving revision 1.21 diff -u -r1.21 cert.c --- dlls/crypt32/cert.c 31 Oct 2005 10:04:06 -0000 1.21 +++ dlls/crypt32/cert.c 18 Nov 2005 16:31:05 -0000 @@ -27,6 +27,7 @@
- registering and enumerating physical stores and locations.)
- Many flags, options and whatnot are unimplemented.
*/ +#include "config.h" #include <assert.h> #include <stdarg.h> #include "windef.h"
Why is this necessary? If it's for the USE_COMPILER_EXCEPTIONS then it should be specified as a define on the command line for the compiler, rather than as a config option.
When I didn't include config.h got the following: include/wine/port.h:25:3: error: #error You must include config.h to use this header
I however just noticed that our wine/exception.h incorrectly includes wine/port.h because of some sig* functions/types/definitions or whatever they are. Fixing this made this change obsolete in the attached patches.
I guess our wine/windef.h is the reason why we need ntstatus.h and winternl.h, but I haven't checked yet. Honestly, these headers are kind of a mess... Just including public headers and one private header file for undocumented stuff would be much clearer, especially if precompiled headers were used, that'd simplify things a lot, I guess.
- Thomas
Index: dlls/crypt32/cert.c =================================================================== RCS file: /home/wine/wine/dlls/crypt32/cert.c,v retrieving revision 1.21 diff -u -r1.21 cert.c --- dlls/crypt32/cert.c 31 Oct 2005 10:04:06 -0000 1.21 +++ dlls/crypt32/cert.c 18 Nov 2005 19:04:36 -0000 @@ -38,6 +38,8 @@ #include "wine/debug.h" #include "wine/list.h" #include "excpt.h" +#include "ntstatus.h" +#include "winternl.h" #include "wine/exception.h" #include "crypt32_private.h"
Index: dlls/crypt32/encode.c =================================================================== RCS file: /home/wine/wine/dlls/crypt32/encode.c,v retrieving revision 1.32 diff -u -r1.32 encode.c --- dlls/crypt32/encode.c 28 Oct 2005 10:09:26 -0000 1.32 +++ dlls/crypt32/encode.c 18 Nov 2005 19:04:30 -0000 @@ -44,6 +44,8 @@ #include "wincrypt.h" #include "winreg.h" #include "snmp.h" +#include "winternl.h" +#include "ntstatus.h" #include "wine/debug.h" #include "wine/exception.h"
@@ -53,7 +55,9 @@ /* a few asn.1 tags we need */ #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) +#ifndef ASN_OCTETSTRING #define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04) +#endif #define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a) #define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11) #define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12)
Index: cert.c =================================================================== --- cert.c (revision 19327) +++ cert.c (working copy) @@ -1,6 +1,5 @@ /* - * Copyright 2002 - Mike McCormack for CodeWeavers + * Copyright 2002 Mike McCormack for CodeWeavers * Copyright 2004,2005 Juan Lang * * This library is free software; you can redistribute it and/or @@ -28,18 +27,22 @@ * registering and enumerating physical stores and locations.) * - Many flags, options and whatnot are unimplemented. */ +#include <assert.h> +#include <stdarg.h> +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "winreg.h" +#include "winuser.h" +#include "wincrypt.h" +#include "wine/debug.h" +#include "wine/list.h" +#include "excpt.h" +#include "ntstatus.h" +#include "winternl.h" +#include "wine/exception.h" +#include "crypt32_private.h"
-#include "precomp.h" - -#define NONAMELESSUNION - -static _SEH_FILTER(page_fault) -{ - if (_SEH_GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) - return _SEH_EXECUTE_HANDLER; - return _SEH_CONTINUE_SEARCH; -} - WINE_DEFAULT_DEBUG_CHANNEL(crypt);
#define WINE_CRYPTCERTSTORE_MAGIC 0x74726563 @@ -313,14 +316,12 @@ DWORD cbElement, DWORD dwContextTypeFlags, DWORD *pdwContentType);
/* filter for page-fault exceptions */ -/* static WINE_EXCEPTION_FILTER(page_fault) { if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_CONTINUE_SEARCH; } -*/
static void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, HCRYPTPROV hCryptProv, DWORD dwFlags, CertStoreType type) @@ -341,7 +342,6 @@ * be a PWINE_CERT_CONTEXT, and increments pCertContext's reference count. * Also sets the hCertStore member of the reference to store. */ - static void CRYPT_InitCertRef(PWINE_CERT_CONTEXT_REF ref, PWINE_CERT_CONTEXT context, HCERTSTORE store) { @@ -2664,7 +2664,7 @@ return NULL; }
- _SEH_TRY + __TRY { const WINE_CONTEXT_INTERFACE *contextInterface = NULL; const WINE_CERT_PROP_HEADER *hdr = NULL; @@ -2821,12 +2821,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); context = NULL; } - _SEH_END + __ENDTRY return context; }
@@ -3313,15 +3313,6 @@ return ret; }
-BOOL WINAPI CryptEncryptMessage( PCRYPT_ENCRYPT_MESSAGE_PARA pEncryptMessagePara, - DWORD dwCert, PCCERT_CONTEXT pccertCert[], - const BYTE* pbEncrypted, DWORD dwEncrypted, - BYTE* pbBlob, DWORD* dwEncryptedBlob) -{ - UNIMPLEMENTED; - return FALSE; -} - HCRYPTOIDFUNCSET WINAPI CryptInitOIDFunctionSet(LPCSTR pszFuncName, DWORD dwFlags) { FIXME("stub: %s %lx\n", debugstr_a(pszFuncName), dwFlags); @@ -3334,42 +3325,3 @@ FIXME("stub: %lx %s %s\n", dwEncodingType, debugstr_a(pszFuncName), debugstr_w(pwszDll)); return FALSE; } - -DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, - DWORD dwType, DWORD dwFlags, - LPVOID pvType, LPWSTR pszName, - DWORD dwName) -{ - UNIMPLEMENTED; - return ERROR_CALL_NOT_IMPLEMENTED; -} - -DWORD WINAPI CertGetNameStringA(PCCERT_CONTEXT pCertContext, - DWORD dwType, DWORD dwFlags, - LPVOID pvType, LPSTR pszName, - DWORD dwName) -{ - UNIMPLEMENTED; - return ERROR_CALL_NOT_IMPLEMENTED; -} - - -DWORD WINAPI CertNameToStrA(DWORD dwCertEncoding, - PCERT_NAME_BLOB pCertName, - DWORD dwType, LPSTR psz, - DWORD dwSZ) -{ - UNIMPLEMENTED; - return ERROR_CALL_NOT_IMPLEMENTED; -} - -DWORD WINAPI CertNameToStrW(DWORD dwCertEncoding, - PCERT_NAME_BLOB pCertName, - DWORD dwType, LPWSTR psz, - DWORD dwSZ) -{ - UNIMPLEMENTED; - return ERROR_CALL_NOT_IMPLEMENTED; -} - - Index: crypt32.def =================================================================== --- crypt32.def (revision 19327) +++ crypt32.def (working copy) @@ -1,105 +0,0 @@ -LIBRARY CRYPT32.DLL -EXPORTS - -CertAddEncodedCRLToStore@24 @1022 - -CertAddSerializedElementToStore@32 @1028 -CertAddStoreToCollection@16 @1029 -CertAlgIdToOID@4 @1030 -CertCloseStore@8 @1031 - -CertDeleteCRLFromStore@4 @1044 - -CertDeleteCertificateFromStore@4 @1046 - -CertFindAttribute@12 @1062 - -CertFindCertificateInStore@24 @1066 - -CertFindExtension@12 @1068 -CertFindRDNAttr@8 @1069 - -CertFreeCRLContext@4 @1072 -CertFreeCTLContext@4 @1073 - -CertFreeCertificateContext@4 @1076 - -CertGetCTLContextProperty@16 @1079 - -CertGetCertificateContextProperty@16 @1081 - -CertGetNameStringA@24 @1085 -CertGetNameStringW@24 @1086 - -CertNameToStrA@20 @1093 -CertNameToStrW@20 @1094 -CertOIDToAlgId@4 @1095 - -CertOpenSystemStoreA@8 @1097 -CertOpenSystemStoreW@8 @1098 - -CertRemoveStoreFromCollection@8 @1104 - -CertSerializeCTLStoreElement@16 @1108 -CertSerializeCertificateStoreElement@16 @1109 - -CertSetCTLContextProperty@16 @1111 -CertSetCertificateContextProperty@16 @1113 - -CertVerifyTimeValidity@8 @1126 - -CryptDecodeObjectEx@32 @1138 - -CryptEncodeObject@20 @1141 - -CryptEncryptMessage@28 @1143 - -CryptExportPublicKeyInfo@20 @1149 -CryptExportPublicKeyInfoEx@32 @1150 - -CryptGetOIDFunctionValue@28 @1163 -CryptHashCertificate@28 @1164 - -CryptImportPublicKeyInfo@16 @1169 -CryptImportPublicKeyInfoEx@28 @1170 - -CryptMemAlloc@4 @1175 -CryptMemFree@4 @1176 -CryptMemRealloc@8 @1177 - -CryptProtectData@28 @1193 - -CryptRegisterDefaultOIDFunction@16 @1195 -CryptRegisterOIDFunction@20 @1196 - -CryptSIPAddProvider@4 @1198 - -CryptSIPLoad@12 @1201 -CryptSIPRemoveProvider@4 @1203 - -CryptSIPRetrieveSubjectGuid@12 @1205 - -CryptSetOIDFunctionValue@28 @1210 - -CryptSignCertificate@36 @1214 - -CryptUnprotectData@28 @1221 - -CryptUnregisterOIDFunction@12 @1223 - -CryptVerifyCertificateSignature@20 -CryptVerifyCertificateSignatureEx@32 @1226 - -I_CryptCreateLruCache@8 @1240 - -I_CryptDetachTls@4 @1242 - -I_CryptFindLruEntryData@4 @1247 - -I_CryptFlushLruCache@4 @1249 -I_CryptFreeLruCache@4 @1250 -I_CryptFreeTls@8 @1251 - -I_CryptGetTls@4 @1260 - -I_CryptSetTls@8 @1268 \ No newline at end of file Index: crypt32.xml =================================================================== --- crypt32.xml (revision 19327) +++ crypt32.xml (working copy) @@ -1,17 +1,19 @@ <module name="crypt32" type="win32dll" baseaddress="${BASEADDRESS_CRYPT32}" installbase="system32" installname="crypt32.dll"> - <importlibrary definition="crypt32.def" /> + <importlibrary definition="crypt32.spec.def" /> <include base="crypt32">.</include> + <include base="ReactOS">include/wine</include> + <define name="__REACTOS__" /> <define name="__USE_W32API" /> <define name="_WIN32_WINNT">0x501</define> - <library>pseh</library> + <define name="WINVER">0x501</define> + <library>wine</library> <library>ntdll</library> <library>kernel32</library> - <library>wine</library> <library>advapi32</library> <file>main.c</file> <file>encode.c</file> <file>cert.c</file> <file>protectdata.c</file> <file>crypt32.rc</file> - <pch>precomp.h</pch> + <file>crypt32.spec</file> </module> Index: crypt32_private.h =================================================================== --- crypt32_private.h (revision 19327) +++ crypt32_private.h (working copy) @@ -19,8 +19,6 @@ #ifndef __CRYPT32_PRIVATE_H__ #define __CRYPT32_PRIVATE_H__
-#define STATUS_ACCESS_VIOLATION 0xC0000005 - /* Returns a handle to the default crypto provider; loads it if necessary. * Returns NULL on failure. */ Index: encode.c =================================================================== --- encode.c (revision 19327) +++ encode.c (working copy) @@ -31,15 +31,23 @@ * MSDN, especially: * http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cry... */ +#include <assert.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h>
-#include "precomp.h" +#define NONAMELESSUNION
-static _SEH_FILTER(page_fault) -{ - if (_SEH_GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) - return _SEH_EXECUTE_HANDLER; - return _SEH_CONTINUE_SEARCH; -} +#include "windef.h" +#include "winbase.h" +#include "excpt.h" +#include "wincrypt.h" +#include "winreg.h" +#include "snmp.h" +#include "winternl.h" +#include "ntstatus.h" +#include "wine/debug.h" +#include "wine/exception.h"
/* This is a bit arbitrary, but to set some limit: */ #define MAX_ENCODED_LEN 0x02000000 @@ -47,7 +55,9 @@ /* a few asn.1 tags we need */ #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) -//#define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04) +#ifndef ASN_OCTETSTRING +#define ASN_OCTETSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x04) +#endif #define ASN_ENUMERATED (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x0a) #define ASN_SETOF (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x11) #define ASN_NUMERICSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x12) @@ -168,6 +178,14 @@ DWORD cbEncoded, DWORD dwFlags, PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo);
+/* filter for page-fault exceptions */ +static WINE_EXCEPTION_FILTER(page_fault) +{ + if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) + return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_CONTINUE_SEARCH; +} + static char *CRYPT_GetKeyName(DWORD dwEncodingType, LPCSTR pszFuncName, LPCSTR pszOID) { @@ -716,7 +734,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_PUBLIC_KEY_INFO *info = (const CERT_PUBLIC_KEY_INFO *)pvStructInfo; @@ -731,12 +749,12 @@ sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -746,7 +764,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_SIGNED_CONTENT_INFO *info = (const CERT_SIGNED_CONTENT_INFO *)pvStructInfo; @@ -762,12 +780,12 @@ sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -781,7 +799,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_INFO *info = (const CERT_INFO *)pvStructInfo; struct AsnEncodeSequenceItem items[10] = { @@ -831,12 +849,12 @@ ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem, dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -941,7 +959,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRL_INFO *info = (const CRL_INFO *)pvStructInfo; struct AsnEncodeSequenceItem items[7] = { @@ -975,12 +993,12 @@ ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem, dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1019,7 +1037,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; const CERT_EXTENSIONS *exts = (const CERT_EXTENSIONS *)pvStructInfo; @@ -1059,12 +1077,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1308,7 +1326,7 @@ BOOL ret; CRYPT_DER_BLOB *blobs = NULL;
- _SEH_TRY + __TRY { DWORD bytesNeeded = 0, lenBytes, i;
@@ -1376,12 +1394,12 @@ CryptMemFree(blobs[i].pbData); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); return FALSE; } - _SEH_END + __ENDTRY CryptMemFree(blobs); return ret; } @@ -1392,7 +1410,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_NAME_INFO *info = (const CERT_NAME_INFO *)pvStructInfo; DWORD bytesNeeded = 0, lenBytes, size, i; @@ -1438,12 +1456,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1490,15 +1508,15 @@ case CERT_ALT_NAME_RFC822_NAME: case CERT_ALT_NAME_DNS_NAME: case CERT_ALT_NAME_URL: - if (entry->pwszURL) + if (entry->u.pwszURL) { DWORD i;
/* Not + 1: don't encode the NULL-terminator */ - dataLen = lstrlenW(entry->pwszURL); + dataLen = lstrlenW(entry->u.pwszURL); for (i = 0; ret && i < dataLen; i++) { - if (entry->pwszURL[i] > 0x7f) + if (entry->u.pwszURL[i] > 0x7f) { SetLastError(CRYPT_E_INVALID_IA5_STRING); ret = FALSE; @@ -1510,7 +1528,7 @@ dataLen = 0; break; case CERT_ALT_NAME_IP_ADDRESS: - dataLen = entry->IPAddress.cbData; + dataLen = entry->u.IPAddress.cbData; break; case CERT_ALT_NAME_REGISTERED_ID: /* FIXME: encode OID */ @@ -1550,11 +1568,11 @@ DWORD i;
for (i = 0; i < dataLen; i++) - *pbEncoded++ = (BYTE)entry->pwszURL[i]; + *pbEncoded++ = (BYTE)entry->u.pwszURL[i]; break; } case CERT_ALT_NAME_IP_ADDRESS: - memcpy(pbEncoded, entry->IPAddress.pbData, dataLen); + memcpy(pbEncoded, entry->u.IPAddress.pbData, dataLen); break; } if (ret) @@ -1571,7 +1589,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_ALT_NAME_INFO *info = (const CERT_ALT_NAME_INFO *)pvStructInfo; @@ -1635,12 +1653,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1650,7 +1668,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_BASIC_CONSTRAINTS2_INFO *info = (const CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; @@ -1672,12 +1690,12 @@ ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, cItem, dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1687,7 +1705,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const BLOBHEADER *hdr = (const BLOBHEADER *)pvStructInfo; @@ -1713,12 +1731,12 @@ pcbEncoded); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1728,7 +1746,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_DATA_BLOB *blob = (const CRYPT_DATA_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes; @@ -1758,12 +1776,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY TRACE("returning %d (%08lx)\n", ret, GetLastError()); return ret; } @@ -1774,7 +1792,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes, dataBytes; @@ -1829,12 +1847,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1844,7 +1862,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo; CRYPT_BIT_BLOB newBlob = { blob->cbData, NULL, blob->cUnusedBits }; @@ -1868,12 +1886,12 @@ &newBlob, dwFlags, pEncodePara, pbEncoded, pcbEncoded); CryptMemFree(newBlob.pbData); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1893,7 +1911,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD significantBytes, lenBytes; BYTE padByte = 0, bytesNeeded; @@ -1967,12 +1985,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1982,7 +2000,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD significantBytes, lenBytes; BYTE bytesNeeded; @@ -2038,12 +2056,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2074,7 +2092,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime; /* sorry, magic number: enough for tag, len, YYMMDDHHMMSSZ\0. I use a @@ -2117,12 +2135,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2132,7 +2150,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime; /* sorry, magic number: enough for tag, len, YYYYMMDDHHMMSSZ\0. I use a @@ -2166,12 +2184,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2181,7 +2199,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime;
@@ -2196,12 +2214,12 @@ lpszStructType, pvStructInfo, dwFlags, pEncodePara, pbEncoded, pcbEncoded); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2211,7 +2229,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; const CRYPT_SEQUENCE_OF_ANY *seq = @@ -2245,12 +2263,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2823,7 +2841,7 @@ TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo);
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_SIGNED_CONTENT_INFO, ToBeSigned), @@ -2844,12 +2862,12 @@ sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2935,7 +2953,7 @@ TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo);
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_INFO, dwVersion), CRYPT_AsnDecodeCertVersion, @@ -2972,12 +2990,12 @@ sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3124,7 +3142,7 @@ TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo);
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CRL_INFO, dwVersion), CRYPT_AsnDecodeCertVersion, @@ -3152,12 +3170,12 @@ sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY
TRACE("Returning %d (%08lx)\n", ret, GetLastError()); return ret; @@ -3323,7 +3341,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { ret = CRYPT_AsnDecodeExtensionsInternal(dwCertEncodingType, lpszStructType, pbEncoded, cbEncoded, @@ -3348,12 +3366,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3366,7 +3384,7 @@ TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pszObjId, *pcbObjId);
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_OBJECTIDENTIFIER) { @@ -3463,12 +3481,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3481,7 +3499,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { DWORD dataLen;
@@ -3565,12 +3583,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3582,7 +3600,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCE)) { @@ -3694,12 +3712,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3708,7 +3726,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SETOF)) { @@ -3809,12 +3827,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3824,7 +3842,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCEOF)) { @@ -3919,12 +3937,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4001,7 +4019,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_PUBLIC_KEY_INFO, Algorithm), @@ -4017,12 +4035,12 @@ sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4145,18 +4163,18 @@ DWORD i;
for (i = 0; i < dataLen; i++) - entry->pwszURL[i] = + entry->u.pwszURL[i] = (WCHAR)pbEncoded[1 + lenBytes + i]; - entry->pwszURL[i] = 0; + entry->u.pwszURL[i] = 0; break; } case 7: /* iPAddress */ /* The next data pointer is in the pwszURL spot, that is, * the first 4 bytes. Need to move it to the next spot. */ - entry->IPAddress.pbData = (LPBYTE)entry->pwszURL; - entry->IPAddress.cbData = dataLen; - memcpy(entry->IPAddress.pbData, pbEncoded + 1 + lenBytes, + entry->u.IPAddress.pbData = (LPBYTE)entry->u.pwszURL; + entry->u.IPAddress.cbData = dataLen; + memcpy(entry->u.IPAddress.pbData, pbEncoded + 1 + lenBytes, dataLen); break; } @@ -4172,7 +4190,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_SEQUENCEOF) { @@ -4238,7 +4256,7 @@ i < cEntry && ptr - pbEncoded - 1 - lenBytes < dataLen; i++) { - info->rgAltEntry[i].pwszURL = + info->rgAltEntry[i].u.pwszURL = (LPWSTR)nextData; size = bytesNeeded; ret = CRYPT_AsnDecodeAltNameEntry(ptr, @@ -4270,12 +4288,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4336,7 +4354,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_BASIC_CONSTRAINTS2_INFO, fCA), CRYPT_AsnDecodeBool, @@ -4350,12 +4368,12 @@ sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4373,7 +4391,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(struct DECODED_RSA_PUB_KEY, modulus), @@ -4424,12 +4442,12 @@ LocalFree(decodedKey); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4496,7 +4514,7 @@ TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo);
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4527,12 +4545,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4609,7 +4627,7 @@ TRACE("(%p, %ld, 0x%08lx, %p, %p, %p)\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo);
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4635,12 +4653,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY TRACE("returning %d (%08lx)\n", ret, GetLastError()); return ret; } @@ -4656,7 +4674,7 @@ *pcbStructInfo = sizeof(int); return TRUE; } - _SEH_TRY + __TRY { BYTE buf[sizeof(CRYPT_INTEGER_BLOB) + sizeof(int)]; CRYPT_INTEGER_BLOB *blob = (CRYPT_INTEGER_BLOB *)buf; @@ -4692,12 +4710,12 @@ else if (GetLastError() == ERROR_MORE_DATA) SetLastError(CRYPT_E_ASN1_LARGE); } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4757,7 +4775,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4784,12 +4802,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4856,7 +4874,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4883,12 +4901,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4903,7 +4921,7 @@ *pcbStructInfo = sizeof(int); return TRUE; } - _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_ENUMERATED) { @@ -4951,12 +4969,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4988,7 +5006,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { ret = TRUE; if (len >= 3 && (*pbEncoded == '+' || *pbEncoded == '-')) @@ -5039,12 +5057,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5061,7 +5079,7 @@ *pcbStructInfo = sizeof(FILETIME); return TRUE; } - _SEH_TRY + __TRY { ret = TRUE; if (pbEncoded[0] == ASN_UTCTIME) @@ -5130,12 +5148,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5150,7 +5168,7 @@ *pcbStructInfo = sizeof(FILETIME); return TRUE; } - _SEH_TRY + __TRY { ret = TRUE; if (pbEncoded[0] == ASN_GENERALTIME) @@ -5225,12 +5243,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5240,7 +5258,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_UTCTIME) ret = CRYPT_AsnDecodeUtcTime(dwCertEncodingType, lpszStructType, @@ -5256,12 +5274,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5271,7 +5289,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_SEQUENCEOF) { @@ -5359,12 +5377,12 @@ return FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
Index: main.c =================================================================== --- main.c (revision 19327) +++ main.c (working copy) @@ -17,54 +17,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include "precomp.h" +#include "config.h" +#include <stdarg.h> +#include <stdio.h>
+#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winreg.h" +#include "winnls.h" +#include "mssip.h" +#include "crypt32_private.h" +#include "wine/debug.h" + WINE_DEFAULT_DEBUG_CHANNEL(crypt);
static HCRYPTPROV hDefProv;
-struct OIDToAlgID -{ - LPCSTR oid; - DWORD algID; -}; - -static const struct OIDToAlgID oidToAlgID[] = { - { szOID_RSA_RSA, CALG_RSA_KEYX }, - { szOID_RSA_MD2RSA, CALG_MD2 }, - { szOID_RSA_MD4RSA, CALG_MD4 }, - { szOID_RSA_MD5RSA, CALG_MD5 }, - { szOID_RSA_SHA1RSA, CALG_SHA }, - { szOID_RSA_DH, CALG_DH_SF }, - { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, - { szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES }, - { szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 }, - { szOID_RSA_MD2, CALG_MD2 }, - { szOID_RSA_MD4, CALG_MD4 }, - { szOID_RSA_MD5, CALG_MD5 }, - { szOID_RSA_RC2CBC, CALG_RC2 }, - { szOID_RSA_RC4, CALG_RC4 }, - { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, - { szOID_ANSI_X942_DH, CALG_DH_SF }, - { szOID_X957_DSA, CALG_DSS_SIGN }, - { szOID_X957_SHA1DSA, CALG_SHA }, - { szOID_OIWSEC_md4RSA, CALG_MD4 }, - { szOID_OIWSEC_md5RSA, CALG_MD5 }, - { szOID_OIWSEC_md4RSA2, CALG_MD4 }, - { szOID_OIWSEC_desCBC, CALG_DES }, - { szOID_OIWSEC_dsa, CALG_DSS_SIGN }, - { szOID_OIWSEC_shaDSA, CALG_SHA }, - { szOID_OIWSEC_shaRSA, CALG_SHA }, - { szOID_OIWSEC_sha, CALG_SHA }, - { szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX }, - { szOID_OIWSEC_sha1, CALG_SHA }, - { szOID_OIWSEC_dsaSHA1, CALG_SHA }, - { szOID_OIWSEC_sha1RSASign, CALG_SHA }, - { szOID_OIWDIR_md2RSA, CALG_MD2 }, - { szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA }, - { szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN }, -}; - BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) { switch (fdwReason) @@ -246,6 +215,48 @@ return FALSE; }
+struct OIDToAlgID +{ + LPCSTR oid; + DWORD algID; +}; + +static const struct OIDToAlgID oidToAlgID[] = { + { szOID_RSA_RSA, CALG_RSA_KEYX }, + { szOID_RSA_MD2RSA, CALG_MD2 }, + { szOID_RSA_MD4RSA, CALG_MD4 }, + { szOID_RSA_MD5RSA, CALG_MD5 }, + { szOID_RSA_SHA1RSA, CALG_SHA }, + { szOID_RSA_DH, CALG_DH_SF }, + { szOID_RSA_SMIMEalgESDH, CALG_DH_EPHEM }, + { szOID_RSA_SMIMEalgCMS3DESwrap, CALG_3DES }, + { szOID_RSA_SMIMEalgCMSRC2wrap, CALG_RC2 }, + { szOID_RSA_MD2, CALG_MD2 }, + { szOID_RSA_MD4, CALG_MD4 }, + { szOID_RSA_MD5, CALG_MD5 }, + { szOID_RSA_RC2CBC, CALG_RC2 }, + { szOID_RSA_RC4, CALG_RC4 }, + { szOID_RSA_DES_EDE3_CBC, CALG_3DES }, + { szOID_ANSI_X942_DH, CALG_DH_SF }, + { szOID_X957_DSA, CALG_DSS_SIGN }, + { szOID_X957_SHA1DSA, CALG_SHA }, + { szOID_OIWSEC_md4RSA, CALG_MD4 }, + { szOID_OIWSEC_md5RSA, CALG_MD5 }, + { szOID_OIWSEC_md4RSA2, CALG_MD4 }, + { szOID_OIWSEC_desCBC, CALG_DES }, + { szOID_OIWSEC_dsa, CALG_DSS_SIGN }, + { szOID_OIWSEC_shaDSA, CALG_SHA }, + { szOID_OIWSEC_shaRSA, CALG_SHA }, + { szOID_OIWSEC_sha, CALG_SHA }, + { szOID_OIWSEC_rsaXchg, CALG_RSA_KEYX }, + { szOID_OIWSEC_sha1, CALG_SHA }, + { szOID_OIWSEC_dsaSHA1, CALG_SHA }, + { szOID_OIWSEC_sha1RSASign, CALG_SHA }, + { szOID_OIWDIR_md2RSA, CALG_MD2 }, + { szOID_INFOSEC_mosaicUpdatedSig, CALG_SHA }, + { szOID_INFOSEC_mosaicKMandUpdSig, CALG_DSS_SIGN }, +}; + LPCSTR WINAPI CertAlgIdToOID(DWORD dwAlgId) { switch (dwAlgId) @@ -319,8 +330,7 @@ LPVOID ret;
ret = TlsGetValue(dwTlsIndex); - - TlsSetValue(dwTlsIndex, NULL); + TlsSetValue(dwTlsIndex, NULL); return ret; }
Index: precomp.h =================================================================== --- precomp.h (revision 19327) +++ precomp.h (working copy) @@ -1,21 +0,0 @@ -#include "config.h" - -#include <assert.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> - -#include <libs/pseh/pseh.h> - -#include "windef.h" -#include "winnt.h" -#include "winbase.h" -#include "wincrypt.h" -#include "winreg.h" -#include "snmp.h" -#include "winnls.h" -#include "mssip.h" -#include "crypt32_private.h" -#include "wine/debug.h" -#include "wine/list.h" - Index: protectdata.c =================================================================== --- protectdata.c (revision 19327) +++ protectdata.c (working copy) @@ -34,8 +34,17 @@ * */
-#include "precomp.h" +#include <stdarg.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h>
+#include "windef.h" +#include "winbase.h" +#include "wincrypt.h" +#include "winreg.h" +#include "wine/debug.h" + WINE_DEFAULT_DEBUG_CHANNEL(crypt);
#define CRYPT32_PROTECTDATA_PROV PROV_RSA_FULL
Index: include/wine/exception.h =================================================================== --- include/wine/exception.h (revision 19327) +++ include/wine/exception.h (working copy) @@ -24,7 +24,6 @@ #include <setjmp.h> #include <windef.h> #include <excpt.h> -#include <wine/port.h>
/* The following definitions allow using exceptions in Wine and Winelib code * @@ -65,8 +64,8 @@
typedef struct _EXCEPTION_REGISTRATION_RECORD { - struct _EXCEPTION_REGISTRATION_RECORD *prev; - PEXCEPTION_HANDLER handler; + struct _EXCEPTION_REGISTRATION_RECORD *Prev; + PEXCEPTION_HANDLER Handler; } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
/* Define this if you want to use your compiler built-in __try/__except support. @@ -101,7 +100,7 @@ __f.frame.Handler = __wine_exception_handler; \ __f.u.filter = (func); \ __wine_push_frame( &__f.frame ); \ - if (sigsetjmp( __f.jmp, 1 )) { \ + if (setjmp( __f.jmp )) { \ const __WINE_FRAME * const __eptr __attribute__((unused)) = &__f; \ do {
@@ -130,8 +129,8 @@ typedef DWORD (CALLBACK *__WINE_FILTER)(PEXCEPTION_POINTERS); typedef void (CALLBACK *__WINE_FINALLY)(BOOL);
-#define WINE_EXCEPTION_FILTER(func) DWORD WINAPI func( EXCEPTION_POINTERS *__eptr ) -#define WINE_FINALLY_FUNC(func) void WINAPI func( BOOL __normal ) +#define WINE_EXCEPTION_FILTER(func) DWORD CALLBACK func( PEXCEPTION_POINTERS __eptr ) +#define WINE_FINALLY_FUNC(func) void CALLBACK func( BOOL __normal )
#define GetExceptionInformation() (__eptr) #define GetExceptionCode() (__eptr->ExceptionRecord->ExceptionCode) @@ -149,17 +148,12 @@ /* finally data */ __WINE_FINALLY finally_func; } u; - sigjmp_buf jmp; + jmp_buf jmp; /* hack to make GetExceptionCode() work in handler */ DWORD ExceptionCode; const struct __tagWINE_FRAME *ExceptionRecord; } __WINE_FRAME;
-extern DWORD __wine_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_REGISTRATION_RECORD *frame, - CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher ); -extern DWORD __wine_finally_handler( PEXCEPTION_RECORD record, EXCEPTION_REGISTRATION_RECORD *frame, - CONTEXT *context, EXCEPTION_REGISTRATION_RECORD **pdispatcher ); - #endif /* USE_COMPILER_EXCEPTIONS */
static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame ) @@ -183,8 +177,8 @@ { #if defined(__GNUC__) && defined(__i386__) __asm__ __volatile__(".byte 0x64\n\tmovl %0,(0)" - : : "r" (frame->prev) : "memory" ); - return frame->prev; + : : "r" (frame->Prev) : "memory" ); + return frame->Prev;
#else NT_TIB *teb = (NT_TIB *)NtCurrentTeb(); @@ -193,7 +187,60 @@ #endif }
+#ifndef USE_COMPILER_EXCEPTIONS
+extern VOID NTAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID); + +static __inline EXCEPTION_DISPOSITION +__wine_exception_handler( struct _EXCEPTION_RECORD *record, void *frame, + struct _CONTEXT *context, void *pdispatcher ) +{ + __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame; + + if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND | EH_NESTED_CALL)) + return ExceptionContinueSearch; + if (wine_frame->u.filter) + { + EXCEPTION_POINTERS ptrs; + ptrs.ExceptionRecord = record; + ptrs.ContextRecord = context; + switch(wine_frame->u.filter( &ptrs )) + { + case EXCEPTION_CONTINUE_SEARCH: + return ExceptionContinueSearch; + case EXCEPTION_CONTINUE_EXECUTION: + return ExceptionContinueExecution; + case EXCEPTION_EXECUTE_HANDLER: + break; + default: + break; + } + } + /* hack to make GetExceptionCode() work in handler */ + wine_frame->ExceptionCode = record->ExceptionCode; + wine_frame->ExceptionRecord = wine_frame; + + RtlUnwind( frame, 0, record, 0 ); + __wine_pop_frame( frame ); + longjmp( wine_frame->jmp, 1 ); +} + + +static __inline EXCEPTION_DISPOSITION +__wine_finally_handler( struct _EXCEPTION_RECORD *record, void *frame, + struct _CONTEXT *context, void *pdispatcher ) +{ + if (record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)) + { + __WINE_FRAME *wine_frame = (__WINE_FRAME *)frame; + wine_frame->u.finally_func( FALSE ); + } + return ExceptionContinueSearch; +} + +#endif /* USE_COMPILER_EXCEPTIONS */ + + /* Wine-specific exceptions codes */
#define EXCEPTION_WINE_STUB 0x80000100 /* stub entry point called */ Index: lib/crt/wine/cppexcept.c =================================================================== --- lib/crt/wine/cppexcept.c (revision 19327) +++ lib/crt/wine/cppexcept.c (working copy) @@ -303,7 +303,7 @@ /* setup an exception block for nested exceptions */
//nested_frame.frame.Handler = catch_function_nested_handler; - nested_frame.frame.handler = (PEXCEPTION_HANDLER)catch_function_nested_handler; + nested_frame.frame.Handler = (PEXCEPTION_HANDLER)catch_function_nested_handler; nested_frame.prev_rec = thread_data->exc_record; nested_frame.cxx_frame = frame; nested_frame.descr = descr;