[WINTRUST] Sync with Wine Staging 4.18. CORE-16441
[reactos.git] / dll / win32 / wintrust / wintrust_main.c
index 5ddad0e..34ce4fe 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-
-#include <config.h>
-
 #include <stdarg.h>
 
 #define NONAMELESSUNION
 
-#include <windef.h>
-#include <winbase.h>
-//#include "winerror.h"
-#include <winreg.h>
-//#include "guiddef.h"
-//#include "wintrust.h"
-#include <softpub.h>
-#include <mscat.h>
-#include <objbase.h>
-#include <winuser.h>
-#include <cryptdlg.h>
-#include <cryptuiapi.h>
-//#include "wintrust_priv.h"
-#include <wine/debug.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "winreg.h"
+#include "guiddef.h"
+#include "wintrust.h"
+#include "softpub.h"
+#include "mscat.h"
+#include "objbase.h"
+#include "winuser.h"
+#include "cryptdlg.h"
+#include "cryptuiapi.h"
+#include "wintrust_priv.h"
+#include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
 
@@ -62,20 +56,6 @@ void WINAPI WINTRUST_Free(void *p)
     HeapFree(GetProcessHeap(), 0, p);
 }
 
-/***********************************************************************
- *             DllMain  (WINTRUST.@)
- */
-BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
-{
-    switch(reason)
-    {
-    case DLL_PROCESS_ATTACH:
-        DisableThreadLibraryCalls( inst );
-        break;
-    }
-    return TRUE;
-}
-
 /***********************************************************************
  *             TrustIsCertificateSelfSigned (WINTRUST.@)
  */
@@ -327,13 +307,11 @@ static LONG WINTRUST_DefaultVerify(HWND hwnd, GUID *actionID,
     goto done;
 
 error:
-    if (provData)
-    {
-        WINTRUST_Free(provData->padwTrustStepErrors);
-        WINTRUST_Free(provData->u.pPDSip);
-        WINTRUST_Free(provData->psPfns);
-        WINTRUST_Free(provData);
-    }
+    WINTRUST_Free(provData->padwTrustStepErrors);
+    WINTRUST_Free(provData->u.pPDSip);
+    WINTRUST_Free(provData->psPfns);
+    WINTRUST_Free(provData);
+
 done:
     TRACE("returning %08x\n", err);
     return err;
@@ -520,13 +498,11 @@ static LONG WINTRUST_CertVerify(HWND hwnd, GUID *actionID,
     goto done;
 
 error:
-    if (provData)
-    {
-        WINTRUST_Free(provData->padwTrustStepErrors);
-        WINTRUST_Free(provData->u.pPDSip);
-        WINTRUST_Free(provData->psPfns);
-        WINTRUST_Free(provData);
-    }
+    WINTRUST_Free(provData->padwTrustStepErrors);
+    WINTRUST_Free(provData->u.pPDSip);
+    WINTRUST_Free(provData->psPfns);
+    WINTRUST_Free(provData);
+
 done:
     TRACE("returning %08x\n", err);
     return err;
@@ -805,7 +781,7 @@ CRYPT_PROVIDER_CERT * WINAPI WTHelperGetProvCertFromChain(
 
     TRACE("(%p %d)\n", pSgnr, idxCert);
 
-    if (idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain)
+    if (!pSgnr || idxCert >= pSgnr->csCertChain || !pSgnr->pasCertChain)
         return NULL;
     cert = &pSgnr->pasCertChain[idxCert];
     TRACE("returning %p\n", cert);