wininet/tests: Test that for an open HTTP connection InternetQueryDataAvailable succe...
[wine/hacks.git] / dlls / wintrust / wintrust_main.c
blob66ad3228028514a5bd28f055f3c6bfb96eb67f1b
1 /*
2 * Copyright 2001 Rein Klazes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winreg.h"
27 #include "guiddef.h"
28 #include "wintrust.h"
29 #include "softpub.h"
30 #include "mscat.h"
31 #include "objbase.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(wintrust);
38 /***********************************************************************
39 * DllMain (WINTRUST.@)
41 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
43 switch(reason)
45 case DLL_WINE_PREATTACH:
46 return FALSE; /* prefer native version */
47 case DLL_PROCESS_ATTACH:
48 DisableThreadLibraryCalls( inst );
49 break;
51 return TRUE;
54 /***********************************************************************
55 * TrustIsCertificateSelfSigned (WINTRUST.@)
57 BOOL WINAPI TrustIsCertificateSelfSigned( PCCERT_CONTEXT cert )
59 BOOL ret;
61 TRACE("%p\n", cert);
62 ret = CertCompareCertificateName(cert->dwCertEncodingType,
63 &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer);
64 return ret;
67 /***********************************************************************
68 * WinVerifyTrust (WINTRUST.@)
70 * Verifies an object by calling the specified trust provider.
72 * PARAMS
73 * hwnd [I] Handle to a caller window.
74 * ActionID [I] Pointer to a GUID that identifies the action to perform.
75 * ActionData [I] Information used by the trust provider to verify the object.
77 * RETURNS
78 * Success: Zero.
79 * Failure: A TRUST_E_* error code.
81 * NOTES
82 * Trust providers can be found at:
83 * HKLM\SOFTWARE\Microsoft\Cryptography\Providers\Trust\
85 LONG WINAPI WinVerifyTrust( HWND hwnd, GUID *ActionID, LPVOID ActionData )
87 FIXME("%p %s %p\n", hwnd, debugstr_guid(ActionID), ActionData);
88 return ERROR_SUCCESS;
91 /***********************************************************************
92 * WinVerifyTrustEx (WINTRUST.@)
94 HRESULT WINAPI WinVerifyTrustEx( HWND hwnd, GUID *ActionID,
95 WINTRUST_DATA* ActionData )
97 FIXME("%p %s %p\n", hwnd, debugstr_guid(ActionID), ActionData);
98 return S_OK;
101 /***********************************************************************
102 * WTHelperGetProvSignerFromChain (WINTRUST.@)
104 CRYPT_PROVIDER_SGNR * WINAPI WTHelperGetProvSignerFromChain(
105 CRYPT_PROVIDER_DATA *pProvData, DWORD idxSigner, BOOL fCounterSigner,
106 DWORD idxCounterSigner)
108 FIXME("%p %d %d %d\n", pProvData, idxSigner, fCounterSigner,
109 idxCounterSigner);
110 return NULL;
113 /***********************************************************************
114 * WTHelperProvDataFromStateData (WINTRUST.@)
116 CRYPT_PROVIDER_DATA * WINAPI WTHelperProvDataFromStateData(HANDLE hStateData)
118 FIXME("%p\n", hStateData);
119 return NULL;
122 static const WCHAR Software_Publishing[] = {
123 'S','o','f','t','w','a','r','e','\\',
124 'M','i','c','r','o','s','o','f','t','\\',
125 'W','i','n','d','o','w','s','\\',
126 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
127 'W','i','n','t','r','u','s','t','\\',
128 'T','r','u','s','t',' ','P','r','o','v','i','d','e','r','s','\\',
129 'S','o','f','t','w','a','r','e',' ',
130 'P','u','b','l','i','s','h','i','n','g',0 };
131 static const WCHAR State[] = { 'S','t','a','t','e',0 };
133 /***********************************************************************
134 * WintrustGetRegPolicyFlags (WINTRUST.@)
136 void WINAPI WintrustGetRegPolicyFlags( DWORD* pdwPolicyFlags )
138 HKEY key;
139 LONG r;
141 TRACE("%p\n", pdwPolicyFlags);
143 *pdwPolicyFlags = 0;
144 r = RegCreateKeyExW(HKEY_CURRENT_USER, Software_Publishing, 0, NULL, 0,
145 KEY_READ, NULL, &key, NULL);
146 if (!r)
148 DWORD size = sizeof(DWORD);
150 r = RegQueryValueExW(key, State, NULL, NULL, (LPBYTE)pdwPolicyFlags,
151 &size);
152 RegCloseKey(key);
153 if (r)
155 /* Failed to query, create and return default value */
156 *pdwPolicyFlags = WTPF_IGNOREREVOCATIONONTS |
157 WTPF_OFFLINEOKNBU_COM |
158 WTPF_OFFLINEOKNBU_IND |
159 WTPF_OFFLINEOK_COM |
160 WTPF_OFFLINEOK_IND;
161 WintrustSetRegPolicyFlags(*pdwPolicyFlags);
166 /***********************************************************************
167 * WintrustSetRegPolicyFlags (WINTRUST.@)
169 BOOL WINAPI WintrustSetRegPolicyFlags( DWORD dwPolicyFlags)
171 HKEY key;
172 LONG r;
174 TRACE("%x\n", dwPolicyFlags);
176 r = RegCreateKeyExW(HKEY_CURRENT_USER, Software_Publishing, 0,
177 NULL, 0, KEY_WRITE, NULL, &key, NULL);
178 if (!r)
180 r = RegSetValueExW(key, State, 0, REG_DWORD, (LPBYTE)&dwPolicyFlags,
181 sizeof(DWORD));
182 RegCloseKey(key);
184 if (r) SetLastError(r);
185 return r == ERROR_SUCCESS;