Juan Lang : crypt32: Ex encode/ decode functions should call non-Ex versions if no Ex version is available.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 13 06:31:21 CDT 2007


Module: wine
Branch: master
Commit: 038b53c301364c1775c823b8ad561c494be91413
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=038b53c301364c1775c823b8ad561c494be91413

Author: Juan Lang <juan.lang at gmail.com>
Date:   Fri Aug 10 11:18:33 2007 -0700

crypt32: Ex encode/decode functions should call non-Ex versions if no Ex version is available.

---

 dlls/crypt32/decode.c |   32 +++++++++++++++++++++++++++++++-
 dlls/crypt32/encode.c |   32 +++++++++++++++++++++++++++++++-
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 5601862..669b125 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -4168,7 +4168,37 @@ BOOL WINAPI CryptDecodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
         ret = decodeFunc(dwCertEncodingType, lpszStructType, pbEncoded,
          cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo);
     else
-        SetLastError(ERROR_FILE_NOT_FOUND);
+    {
+        static HCRYPTOIDFUNCSET decodeObjectSet = NULL;
+        CryptDecodeObjectFunc pCryptDecodeObject;
+
+        /* Try CryptDecodeObject function.  Don't call CryptDecodeObject
+         * directly, as that could cause an infinite loop.
+         */
+        if (!decodeObjectSet)
+            decodeObjectSet =
+             CryptInitOIDFunctionSet(CRYPT_OID_DECODE_OBJECT_FUNC, 0);
+        CryptGetOIDFunctionAddress(decodeObjectSet, dwCertEncodingType,
+         lpszStructType, 0, (void **)&pCryptDecodeObject, &hFunc);
+        if (pCryptDecodeObject)
+        {
+            if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
+            {
+                ret = pCryptDecodeObject(dwCertEncodingType, lpszStructType,
+                 pbEncoded, cbEncoded, dwFlags, NULL, pcbStructInfo);
+                if (ret && (ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara,
+                 pvStructInfo, pcbStructInfo, *pcbStructInfo)))
+                    ret = pCryptDecodeObject(dwCertEncodingType, lpszStructType,
+                     pbEncoded, cbEncoded, dwFlags, *(BYTE **)pvStructInfo,
+                     pcbStructInfo);
+            }
+            else
+                ret = pCryptDecodeObject(dwCertEncodingType, lpszStructType,
+                 pbEncoded, cbEncoded, dwFlags, pvStructInfo, pcbStructInfo);
+        }
+        else
+            SetLastError(ERROR_FILE_NOT_FOUND);
+    }
     if (hFunc)
         CryptFreeOIDFunctionAddress(hFunc, 0);
     return ret;
diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index 591a1e0..aa650bd 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -3513,7 +3513,37 @@ BOOL WINAPI CryptEncodeObjectEx(DWORD dwCertEncodingType, LPCSTR lpszStructType,
         ret = encodeFunc(dwCertEncodingType, lpszStructType, pvStructInfo,
          dwFlags, pEncodePara, pvEncoded, pcbEncoded);
     else
-        SetLastError(ERROR_FILE_NOT_FOUND);
+    {
+        static HCRYPTOIDFUNCSET encodeObjectSet = NULL;
+        CryptEncodeObjectFunc pCryptEncodeObject;
+
+        /* Try CryptEncodeObject function.  Don't call CryptEncodeObject
+         * directly, as that could cause an infinite loop.
+         */
+        if (!encodeObjectSet)
+            encodeObjectSet =
+             CryptInitOIDFunctionSet(CRYPT_OID_ENCODE_OBJECT_FUNC, 0);
+        CryptGetOIDFunctionAddress(encodeObjectSet, dwCertEncodingType,
+         lpszStructType, 0, (void **)&pCryptEncodeObject, &hFunc);
+        if (pCryptEncodeObject)
+        {
+            if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
+            {
+                ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType,
+                 pvStructInfo, NULL, pcbEncoded);
+                if (ret && (ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
+                 pvEncoded, pcbEncoded, *pcbEncoded)))
+                    ret = pCryptEncodeObject(dwCertEncodingType,
+                     lpszStructType, pvStructInfo, *(BYTE **)pvEncoded,
+                     pcbEncoded);
+            }
+            else
+                ret = pCryptEncodeObject(dwCertEncodingType, lpszStructType,
+                 pvStructInfo, pvEncoded, pcbEncoded);
+        }
+        else
+            SetLastError(ERROR_FILE_NOT_FOUND);
+    }
     if (hFunc)
         CryptFreeOIDFunctionAddress(hFunc, 0);
     return ret;




More information about the wine-cvs mailing list