We cant send this back to Wine so were going to get lots of conflicts when synchronizing with Wine and thus wasting a lot of Gé's time. What is needed is to make the ReactOS environment more like Wine or submit patches to Wine to make the Wine environment more like Windows' environment. So removing WINE_EXCEPTION_FILTER is not the way to do it since then it won't work on Wine. ReactOS grew 40% in 2004 just because of reusing code from Wine, so sharing code is definitely beneficial to both ReactOS and Wine.
Casper Hornstrup wrote:
We can’t send this back to Wine so we’re going to get lots of conflicts when synchronizing with Wine and thus wasting a lot of Gé's time. What is needed is to make the ReactOS environment more like Wine or submit patches to Wine to make the Wine environment more like Windows' environment. So removing WINE_EXCEPTION_FILTER is not the way to do it since then it won't work on Wine. ReactOS grew 40% in 2004 just because of reusing code from Wine, so sharing code is definitely beneficial to both ReactOS and Wine.
I also don't understand why these changes are necessary, it just makes future synchronizations much more difficult than necessary. It should be possible to use crypt32 almost unmodified in reactos.
- Thomas
From: Thomas Weidenmueller
I also don't understand why these changes are necessary, it just makes future synchronizations much more difficult than necessary. It should be possible to use crypt32 almost unmodified in reactos.
Let me be the first to say that I'd like to see the code remain as close as possible to the Wine code. The problem is that we don't handle the Wine SEH macros correctly at the moment. I've run into this before, it is the reason ole32.dll hasn't been synced since Wine-20050830. I know Filip worked on defining the Wine SEH macros in terms of our PSEH macros, I think he hit a blocker though.
GvG
Ge van Geldorp wrote:
Let me be the first to say that I'd like to see the code remain as close as possible to the Wine code. The problem is that we don't handle the Wine SEH macros correctly at the moment. I've run into this before, it is the reason ole32.dll hasn't been synced since Wine-20050830. I know Filip worked on defining the Wine SEH macros in terms of our PSEH macros, I think he hit a blocker though.
I spent some time fixing the wine exception macros in ReactOS. See the attached file ros-wineexcept.patch.
However, wine's crypt32 is not fully portable, they forgot to add some headers and they re-defined ASN_OCTETSTRING which is supposed to be defined in snmp.h. I'm sure they'd accept that patch. See wine-crypt32.patch which is against wine HEAD.
Both patches enables our build system to build crypt32 unmodified. A patch to convert the current modified version in our tree into wine's HEAD version + wine-crypt32.patch is attached, see ros-crypt32-to-winehead.patch.
However, the downside is that crypt32 still needs a hack in the crypt32.xml file: <define name="sigsetjmp(a,b)">setjmp(a)</define> We don't have sigsetjmp and I'm not really sure how to handle this properly.
Please commit and/or email the patch to wine-patches if appropriate, I'm not sure if the patch is any good or just yet another bad hack. Comments appreciated.
- 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 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" @@ -38,6 +39,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 16:43:27 -0000 @@ -31,6 +31,7 @@ * MSDN, especially: * http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cry... */ +#include "config.h" #include <assert.h> #include <stdarg.h> #include <stdio.h> @@ -44,6 +45,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 +56,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: include/wine/exception.h =================================================================== --- include/wine/exception.h (revision 19323) +++ include/wine/exception.h (working copy) @@ -65,8 +65,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. @@ -130,8 +130,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) @@ -155,11 +155,6 @@ 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 +178,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 +188,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 19323) +++ 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;
Index: cert.c =================================================================== --- cert.c (revision 19323) +++ 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,23 @@ * 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" +#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 +317,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 +343,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 +2665,7 @@ return NULL; }
- _SEH_TRY + __TRY { const WINE_CONTEXT_INTERFACE *contextInterface = NULL; const WINE_CERT_PROP_HEADER *hdr = NULL; @@ -2821,12 +2822,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); context = NULL; } - _SEH_END + __ENDTRY return context; }
@@ -3313,15 +3314,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 +3326,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 19323) +++ 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 19323) +++ crypt32.xml (working copy) @@ -1,17 +1,20 @@ <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> + <define name="sigsetjmp(a,b)">setjmp(a)</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 19323) +++ 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 19323) +++ encode.c (working copy) @@ -31,15 +31,24 @@ * MSDN, especially: * http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cry... */ +#include "config.h" +#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 +56,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 +179,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 +735,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_PUBLIC_KEY_INFO *info = (const CERT_PUBLIC_KEY_INFO *)pvStructInfo; @@ -731,12 +750,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 +765,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_SIGNED_CONTENT_INFO *info = (const CERT_SIGNED_CONTENT_INFO *)pvStructInfo; @@ -762,12 +781,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 +800,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_INFO *info = (const CERT_INFO *)pvStructInfo; struct AsnEncodeSequenceItem items[10] = { @@ -831,12 +850,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 +960,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRL_INFO *info = (const CRL_INFO *)pvStructInfo; struct AsnEncodeSequenceItem items[7] = { @@ -975,12 +994,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 +1038,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; const CERT_EXTENSIONS *exts = (const CERT_EXTENSIONS *)pvStructInfo; @@ -1059,12 +1078,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1308,7 +1327,7 @@ BOOL ret; CRYPT_DER_BLOB *blobs = NULL;
- _SEH_TRY + __TRY { DWORD bytesNeeded = 0, lenBytes, i;
@@ -1376,12 +1395,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 +1411,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_NAME_INFO *info = (const CERT_NAME_INFO *)pvStructInfo; DWORD bytesNeeded = 0, lenBytes, size, i; @@ -1438,12 +1457,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1490,15 +1509,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 +1529,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 +1569,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 +1590,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_ALT_NAME_INFO *info = (const CERT_ALT_NAME_INFO *)pvStructInfo; @@ -1635,12 +1654,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1650,7 +1669,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_BASIC_CONSTRAINTS2_INFO *info = (const CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; @@ -1672,12 +1691,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 +1706,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const BLOBHEADER *hdr = (const BLOBHEADER *)pvStructInfo; @@ -1713,12 +1732,12 @@ pcbEncoded); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1728,7 +1747,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_DATA_BLOB *blob = (const CRYPT_DATA_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes; @@ -1758,12 +1777,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 +1793,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes, dataBytes; @@ -1829,12 +1848,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1844,7 +1863,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 +1887,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 +1912,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD significantBytes, lenBytes; BYTE padByte = 0, bytesNeeded; @@ -1967,12 +1986,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1982,7 +2001,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD significantBytes, lenBytes; BYTE bytesNeeded; @@ -2038,12 +2057,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2074,7 +2093,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime; /* sorry, magic number: enough for tag, len, YYMMDDHHMMSSZ\0. I use a @@ -2117,12 +2136,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2132,7 +2151,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime; /* sorry, magic number: enough for tag, len, YYYYMMDDHHMMSSZ\0. I use a @@ -2166,12 +2185,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2181,7 +2200,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime;
@@ -2196,12 +2215,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 +2230,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; const CRYPT_SEQUENCE_OF_ANY *seq = @@ -2245,12 +2264,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2823,7 +2842,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 +2863,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 +2954,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 +2991,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 +3143,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 +3171,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 +3342,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { ret = CRYPT_AsnDecodeExtensionsInternal(dwCertEncodingType, lpszStructType, pbEncoded, cbEncoded, @@ -3348,12 +3367,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3366,7 +3385,7 @@ TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pszObjId, *pcbObjId);
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_OBJECTIDENTIFIER) { @@ -3463,12 +3482,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3481,7 +3500,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { DWORD dataLen;
@@ -3565,12 +3584,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3582,7 +3601,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCE)) { @@ -3694,12 +3713,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3708,7 +3727,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SETOF)) { @@ -3809,12 +3828,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3824,7 +3843,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCEOF)) { @@ -3919,12 +3938,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4001,7 +4020,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_PUBLIC_KEY_INFO, Algorithm), @@ -4017,12 +4036,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 +4164,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 +4191,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_SEQUENCEOF) { @@ -4238,7 +4257,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 +4289,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4336,7 +4355,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_BASIC_CONSTRAINTS2_INFO, fCA), CRYPT_AsnDecodeBool, @@ -4350,12 +4369,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 +4392,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(struct DECODED_RSA_PUB_KEY, modulus), @@ -4424,12 +4443,12 @@ LocalFree(decodedKey); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4496,7 +4515,7 @@ TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo);
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4527,12 +4546,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4609,7 +4628,7 @@ TRACE("(%p, %ld, 0x%08lx, %p, %p, %p)\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo);
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4635,12 +4654,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 +4675,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 +4711,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 +4776,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4784,12 +4803,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4856,7 +4875,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4883,12 +4902,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4903,7 +4922,7 @@ *pcbStructInfo = sizeof(int); return TRUE; } - _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_ENUMERATED) { @@ -4951,12 +4970,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4988,7 +5007,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { ret = TRUE; if (len >= 3 && (*pbEncoded == '+' || *pbEncoded == '-')) @@ -5039,12 +5058,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5061,7 +5080,7 @@ *pcbStructInfo = sizeof(FILETIME); return TRUE; } - _SEH_TRY + __TRY { ret = TRUE; if (pbEncoded[0] == ASN_UTCTIME) @@ -5130,12 +5149,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5150,7 +5169,7 @@ *pcbStructInfo = sizeof(FILETIME); return TRUE; } - _SEH_TRY + __TRY { ret = TRUE; if (pbEncoded[0] == ASN_GENERALTIME) @@ -5225,12 +5244,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5240,7 +5259,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_UTCTIME) ret = CRYPT_AsnDecodeUtcTime(dwCertEncodingType, lpszStructType, @@ -5256,12 +5275,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5271,7 +5290,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_SEQUENCEOF) { @@ -5359,12 +5378,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 19323) +++ 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 19323) +++ 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 19323) +++ 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
Thomas Weidenmueller wrote:
However, the downside is that crypt32 still needs a hack in the crypt32.xml file: <define name="sigsetjmp(a,b)">setjmp(a)</define> We don't have sigsetjmp and I'm not really sure how to handle this properly.
I just noticed sigsetjmp is only used in wine's __EXCEPT macro, it could simply be changed to setjmp. I attached the fixed patches.
- Thomas
Index: include/wine/exception.h =================================================================== --- include/wine/exception.h (revision 19323) +++ include/wine/exception.h (working copy) @@ -65,8 +65,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 +101,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 +130,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) @@ -155,11 +155,6 @@ 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 +178,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 +188,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 19323) +++ 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;
Index: cert.c =================================================================== --- cert.c (revision 19323) +++ 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,23 @@ * 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" +#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 +317,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 +343,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 +2665,7 @@ return NULL; }
- _SEH_TRY + __TRY { const WINE_CONTEXT_INTERFACE *contextInterface = NULL; const WINE_CERT_PROP_HEADER *hdr = NULL; @@ -2821,12 +2822,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); context = NULL; } - _SEH_END + __ENDTRY return context; }
@@ -3313,15 +3314,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 +3326,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 19323) +++ 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 19323) +++ 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 19323) +++ 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 19323) +++ encode.c (working copy) @@ -31,15 +31,24 @@ * MSDN, especially: * http://msdn.microsoft.com/library/en-us/seccrypto/security/constants_for_cry... */ +#include "config.h" +#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 +56,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 +179,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 +735,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_PUBLIC_KEY_INFO *info = (const CERT_PUBLIC_KEY_INFO *)pvStructInfo; @@ -731,12 +750,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 +765,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_SIGNED_CONTENT_INFO *info = (const CERT_SIGNED_CONTENT_INFO *)pvStructInfo; @@ -762,12 +781,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 +800,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_INFO *info = (const CERT_INFO *)pvStructInfo; struct AsnEncodeSequenceItem items[10] = { @@ -831,12 +850,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 +960,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRL_INFO *info = (const CRL_INFO *)pvStructInfo; struct AsnEncodeSequenceItem items[7] = { @@ -975,12 +994,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 +1038,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; const CERT_EXTENSIONS *exts = (const CERT_EXTENSIONS *)pvStructInfo; @@ -1059,12 +1078,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1308,7 +1327,7 @@ BOOL ret; CRYPT_DER_BLOB *blobs = NULL;
- _SEH_TRY + __TRY { DWORD bytesNeeded = 0, lenBytes, i;
@@ -1376,12 +1395,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 +1411,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_NAME_INFO *info = (const CERT_NAME_INFO *)pvStructInfo; DWORD bytesNeeded = 0, lenBytes, size, i; @@ -1438,12 +1457,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1490,15 +1509,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 +1529,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 +1569,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 +1590,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_ALT_NAME_INFO *info = (const CERT_ALT_NAME_INFO *)pvStructInfo; @@ -1635,12 +1654,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1650,7 +1669,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CERT_BASIC_CONSTRAINTS2_INFO *info = (const CERT_BASIC_CONSTRAINTS2_INFO *)pvStructInfo; @@ -1672,12 +1691,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 +1706,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const BLOBHEADER *hdr = (const BLOBHEADER *)pvStructInfo; @@ -1713,12 +1732,12 @@ pcbEncoded); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1728,7 +1747,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_DATA_BLOB *blob = (const CRYPT_DATA_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes; @@ -1758,12 +1777,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 +1793,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { const CRYPT_BIT_BLOB *blob = (const CRYPT_BIT_BLOB *)pvStructInfo; DWORD bytesNeeded, lenBytes, dataBytes; @@ -1829,12 +1848,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1844,7 +1863,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 +1887,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 +1912,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD significantBytes, lenBytes; BYTE padByte = 0, bytesNeeded; @@ -1967,12 +1986,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -1982,7 +2001,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD significantBytes, lenBytes; BYTE bytesNeeded; @@ -2038,12 +2057,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2074,7 +2093,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime; /* sorry, magic number: enough for tag, len, YYMMDDHHMMSSZ\0. I use a @@ -2117,12 +2136,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2132,7 +2151,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime; /* sorry, magic number: enough for tag, len, YYYYMMDDHHMMSSZ\0. I use a @@ -2166,12 +2185,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2181,7 +2200,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { SYSTEMTIME sysTime;
@@ -2196,12 +2215,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 +2230,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded, dataLen, lenBytes, i; const CRYPT_SEQUENCE_OF_ANY *seq = @@ -2245,12 +2264,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -2823,7 +2842,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 +2863,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 +2954,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 +2991,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 +3143,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 +3171,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 +3342,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { ret = CRYPT_AsnDecodeExtensionsInternal(dwCertEncodingType, lpszStructType, pbEncoded, cbEncoded, @@ -3348,12 +3367,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3366,7 +3385,7 @@ TRACE("%p, %ld, %08lx, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pszObjId, *pcbObjId);
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_OBJECTIDENTIFIER) { @@ -3463,12 +3482,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3481,7 +3500,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { DWORD dataLen;
@@ -3565,12 +3584,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3582,7 +3601,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCE)) { @@ -3694,12 +3713,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3708,7 +3727,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SETOF)) { @@ -3809,12 +3828,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -3824,7 +3843,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == (ASN_CONSTRUCTOR | ASN_SEQUENCEOF)) { @@ -3919,12 +3938,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4001,7 +4020,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_PUBLIC_KEY_INFO, Algorithm), @@ -4017,12 +4036,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 +4164,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 +4191,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_SEQUENCEOF) { @@ -4238,7 +4257,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 +4289,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4336,7 +4355,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(CERT_BASIC_CONSTRAINTS2_INFO, fCA), CRYPT_AsnDecodeBool, @@ -4350,12 +4369,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 +4392,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { struct AsnDecodeSequenceItem items[] = { { offsetof(struct DECODED_RSA_PUB_KEY, modulus), @@ -4424,12 +4443,12 @@ LocalFree(decodedKey); } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4496,7 +4515,7 @@ TRACE("%p, %ld, %08lx, %p, %p, %ld\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, *pcbStructInfo);
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4527,12 +4546,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4609,7 +4628,7 @@ TRACE("(%p, %ld, 0x%08lx, %p, %p, %p)\n", pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo);
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4635,12 +4654,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 +4675,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 +4711,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 +4776,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4784,12 +4803,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4856,7 +4875,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { DWORD bytesNeeded;
@@ -4883,12 +4902,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4903,7 +4922,7 @@ *pcbStructInfo = sizeof(int); return TRUE; } - _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_ENUMERATED) { @@ -4951,12 +4970,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -4988,7 +5007,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { ret = TRUE; if (len >= 3 && (*pbEncoded == '+' || *pbEncoded == '-')) @@ -5039,12 +5058,12 @@ } } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5061,7 +5080,7 @@ *pcbStructInfo = sizeof(FILETIME); return TRUE; } - _SEH_TRY + __TRY { ret = TRUE; if (pbEncoded[0] == ASN_UTCTIME) @@ -5130,12 +5149,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5150,7 +5169,7 @@ *pcbStructInfo = sizeof(FILETIME); return TRUE; } - _SEH_TRY + __TRY { ret = TRUE; if (pbEncoded[0] == ASN_GENERALTIME) @@ -5225,12 +5244,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5240,7 +5259,7 @@ { BOOL ret;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_UTCTIME) ret = CRYPT_AsnDecodeUtcTime(dwCertEncodingType, lpszStructType, @@ -5256,12 +5275,12 @@ ret = FALSE; } } - _SEH_EXCEPT(page_fault) + __EXCEPT(page_fault) { SetLastError(STATUS_ACCESS_VIOLATION); ret = FALSE; } - _SEH_END + __ENDTRY return ret; }
@@ -5271,7 +5290,7 @@ { BOOL ret = TRUE;
- _SEH_TRY + __TRY { if (pbEncoded[0] == ASN_SEQUENCEOF) { @@ -5359,12 +5378,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 19323) +++ 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 19323) +++ 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 19323) +++ 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
Thomas Weidenmueller wrote:
Please commit and/or email the patch to wine-patches if appropriate, I'm not sure if the patch is any good or just yet another bad hack. Comments appreciated.
I'll happily send the patch to wine-patches on your behalf. However, I want to know why the addition of the headers below are needed so that I can make our headers more compatible so that changes aren't needed in the future. AFAICS, ntstatus.h is only needed for STATUS_ACCESS_VIOLATION, but this should be defined by winnt.h that is included somewhere. Why is winternl.h needed?
- 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 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" @@ -38,6 +39,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 16:43:27 -0000 @@ -31,6 +31,7 @@
*/ +#include "config.h" #include <assert.h> #include <stdarg.h> #include <stdio.h> @@ -44,6 +45,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 +56,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)
Robert Shearman wrote:
I'll happily send the patch to wine-patches on your behalf. However, I want to know why the addition of the headers below are needed so that I can make our headers more compatible so that changes aren't needed in the future. AFAICS, ntstatus.h is only needed for STATUS_ACCESS_VIOLATION, but this should be defined by winnt.h that is included somewhere. Why is winternl.h needed?
Obviously winnt.h isn't included. In PSDK/ReactOS winnt.h is only included by windef.h, which is included by dde.h, windows.h, winldap.h and winternl.h. Since the code doesn't include any of the mentioned files, there's no way winnt.h could be included. While talking about headers, are there any plans for precompiled headers in wine?
- Thomas
Thomas Weidenmueller wrote:
Obviously winnt.h isn't included. In PSDK/ReactOS winnt.h is only included by windef.h, which is included by dde.h, windows.h, winldap.h and winternl.h. Since the code doesn't include any of the mentioned files, there's no way winnt.h could be included. While talking about headers, are there any plans for precompiled headers in wine?
Sorry, my bad...windef.h is included... looks like #include_next "windef.h" in our include/wine/windef.h is broken. However, most other code in wine also includes ntstatus.h from what I've seen.
- Thomas
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.
@@ -38,6 +39,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"
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;
Thomas Weidenmueller wrote:
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.
I have no problem with including ntstatus.h, even though it is not strictly necessary as it is just defines. However, I don't like the idea of including winternl.h as crypt32 (specifically high level things like certificate handling) shouldn't need to depend on low-level and undocumented structures, defines and function declarations. Can you tell me what errors you get without including winternl.h?
Robert Shearman wrote:
I have no problem with including ntstatus.h, even though it is not strictly necessary as it is just defines. However, I don't like the idea of including winternl.h as crypt32 (specifically high level things like certificate handling) shouldn't need to depend on low-level and undocumented structures, defines and function declarations. Can you tell me what errors you get without including winternl.h?
The problem is it can't find the type definition of NTSTATUS. It is defined in the PSDK in several places, but none of the files is included by winnt.h, windows.h or friends. Basically, it's defined in lmaccess.h, ntsecapi.h, subauth.h, wincred.h and winternl.h. I think latter makes most sense considering that ntsecapi.h mostly contains LSA stuff.
- Thomas
Thomas Weidenmueller wrote:
Robert Shearman wrote:
I have no problem with including ntstatus.h, even though it is not strictly necessary as it is just defines. However, I don't like the idea of including winternl.h as crypt32 (specifically high level things like certificate handling) shouldn't need to depend on low-level and undocumented structures, defines and function declarations. Can you tell me what errors you get without including winternl.h?
The problem is it can't find the type definition of NTSTATUS. It is defined in the PSDK in several places, but none of the files is included by winnt.h, windows.h or friends. Basically, it's defined in lmaccess.h, ntsecapi.h, subauth.h, wincred.h and winternl.h. I think latter makes most sense considering that ntsecapi.h mostly contains LSA stuff.
The same is true for wine; NTSTATUS isn't declared in any of the headers it includes and it isn't needed because it isn't used by the crypt32 code. I assume the problem is in the exception code, which should include any necessary headers itself or else contain the necessary typedefs. I'll send a patch for the snmp.h problem though.
Robert Shearman wrote:
The same is true for wine; NTSTATUS isn't declared in any of the headers it includes and it isn't needed because it isn't used by the crypt32 code. I assume the problem is in the exception code, which should include any necessary headers itself or else contain the necessary typedefs.
Yes that sounds like it, I'll fix that. Thanks for the hint. But I think that ntstatus.h is still necessary because crypt32 uses STATUS_* definitions.
- Thomas
Robert Shearman wrote:
The same is true for wine; NTSTATUS isn't declared in any of the headers it includes and it isn't needed because it isn't used by the crypt32 code. I assume the problem is in the exception code, which should include any necessary headers itself or else contain the necessary typedefs. I'll send a patch for the snmp.h problem though.
Actually, the problem is that the STATUS_* codes are defined inconsistently. In the PSDK some are defined in two places:
winnt.h: #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L)
ntstatus.h: #define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L)
As you can see using ntstatus.h assumes that NTSTATUS is defined (most likely by including winternl.h). So it looks like including winnt.h would be a better solution and in fact ntstatus.h can't be included without winternl.h.
- Thomas
The problem is wine does not accpect some patch and some other patch is reactos spefic and some other is for both windows and reactos but it will break wine.
----- Original Message ----- From: "Casper Hornstrup" ch@csh-consult.dk To: ros-dev@reactos.org Sent: den 18 November 2005 09:58 Subject: [ros-dev] RE: [ros-diffs] [cwittich] 19320: got a lot of crypt32stuff working
We can't send this back to Wine so we're going to get lots of conflicts when synchronizing with Wine and thus wasting a lot of Gé's time. What is needed is to make the ReactOS environment more like Wine or submit patches to Wine to make the Wine environment more like Windows' environment. So removing WINE_EXCEPTION_FILTER is not the way to do it since then it won't work on Wine. ReactOS grew 40% in 2004 just because of reusing code from Wine, so sharing code is definitely beneficial to both ReactOS and Wine.
_______________________________________________ Ros-dev mailing list Ros-dev@reactos.org http://www.reactos.org/mailman/listinfo/ros-dev
Magnus Olsen wrote:
The problem is wine does not accpect some patch
That is usually for technical reasons (like the extra header includes proposed by Thomas that were needed because of the ReactOS exception handlers).
and some other patch is reactos spefic
Then you find a way of minimizing the scope of the patch, e.g. by putting ReactOS only functionality in another file and adding a line or two to hook into this file. We also try to do the same in Wine, e.g. for the Shell UnixFS.
and some other is for both windows and reactos but it will break wine.
Then you could try to fix the problem, or else describe the problem enough so that a Wine developer can fix it. For instance, GvG proposed that we change the way statuses are defined in our Wine to be compatible with ReactOS and the Platform SDK by causing a compile failure when including both winnt.h and ntstatus.h.
Sweeping problems under the carpet, especially without understanding why they are happening doesn't improve either project.