2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2005 Juan Lang
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "i_cryptasn1tls.h"
30 #include "crypt32_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(crypt);
35 static HCRYPTPROV hDefProv;
37 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
41 case DLL_PROCESS_ATTACH:
42 DisableThreadLibraryCalls(hInstance);
43 crypt_oid_init(hInstance);
45 case DLL_PROCESS_DETACH:
48 default_chain_engine_free();
49 if (hDefProv) CryptReleaseContext(hDefProv, 0);
55 HCRYPTPROV CRYPT_GetDefaultProvider(void)
58 CryptAcquireContextW(&hDefProv, NULL, MS_ENHANCED_PROV_W,
59 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
63 typedef void * HLRUCACHE;
65 /* this function is called by Internet Explorer when it is about to verify a
66 * downloaded component. The first parameter appears to be a pointer to an
67 * unknown type, native fails unless it points to a buffer of at least 20 bytes.
68 * The second parameter appears to be an out parameter, whatever it's set to is
69 * passed (by cryptnet.dll) to I_CryptFlushLruCache.
71 BOOL WINAPI I_CryptCreateLruCache(void *unknown, HLRUCACHE *out)
73 FIXME("(%p, %p): stub!\n", unknown, out);
74 *out = (void *)0xbaadf00d;
78 BOOL WINAPI I_CryptFindLruEntry(DWORD unk0, DWORD unk1)
80 FIXME("(%08x, %08x): stub!\n", unk0, unk1);
84 BOOL WINAPI I_CryptFindLruEntryData(DWORD unk0, DWORD unk1, DWORD unk2)
86 FIXME("(%08x, %08x, %08x): stub!\n", unk0, unk1, unk2);
90 BOOL WINAPI I_CryptCreateLruEntry(HLRUCACHE h, DWORD unk0, DWORD unk1)
92 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
96 DWORD WINAPI I_CryptFlushLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
98 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
102 HLRUCACHE WINAPI I_CryptFreeLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
104 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
108 LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
110 return HeapAlloc(GetProcessHeap(), 0, cbSize);
113 LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
115 return HeapReAlloc(GetProcessHeap(), 0, pv, cbSize);
118 VOID WINAPI CryptMemFree(LPVOID pv)
120 HeapFree(GetProcessHeap(), 0, pv);
123 DWORD WINAPI I_CryptAllocTls(void)
128 LPVOID WINAPI I_CryptDetachTls(DWORD dwTlsIndex)
132 ret = TlsGetValue(dwTlsIndex);
133 TlsSetValue(dwTlsIndex, NULL);
137 LPVOID WINAPI I_CryptGetTls(DWORD dwTlsIndex)
139 return TlsGetValue(dwTlsIndex);
142 BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue)
144 return TlsSetValue(dwTlsIndex, lpTlsValue);
147 BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown)
149 TRACE("(%d, %d)\n", dwTlsIndex, unknown);
150 return TlsFree(dwTlsIndex);
153 BOOL WINAPI I_CryptGetOssGlobal(DWORD x)
159 HCRYPTPROV WINAPI I_CryptGetDefaultCryptProv(DWORD reserved)
163 TRACE("(%08x)\n", reserved);
167 SetLastError(E_INVALIDARG);
168 return (HCRYPTPROV)0;
170 ret = CRYPT_GetDefaultProvider();
171 CryptContextAddRef(ret, NULL, 0);
175 BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name,
178 static const WCHAR safer[] = {
179 'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
180 'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
181 'C','e','r','t','i','f','i','c','a','t','e','s','\\',
182 'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',
183 'S','a','f','e','r',0 };
188 TRACE("(%s, %p)\n", debugstr_w(name), value);
191 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, safer, &key);
192 if (rc == ERROR_SUCCESS)
194 DWORD size = sizeof(DWORD);
196 if (!RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)value, &size))
203 DWORD WINAPI I_CryptInstallOssGlobal(DWORD x, DWORD y, DWORD z)
207 FIXME("%08x %08x %08x, return value %d\n", x, y, z,ret);
211 BOOL WINAPI I_CryptInstallAsn1Module(ASN1module_t x, DWORD y, void* z)
213 FIXME("(%p %08x %p): stub\n", x, y, z);
217 BOOL WINAPI I_CryptUninstallAsn1Module(HCRYPTASN1MODULE x)
219 FIXME("(%08x): stub\n", x);
223 ASN1decoding_t WINAPI I_CryptGetAsn1Decoder(HCRYPTASN1MODULE x)
225 FIXME("(%08x): stub\n", x);
229 ASN1encoding_t WINAPI I_CryptGetAsn1Encoder(HCRYPTASN1MODULE x)
231 FIXME("(%08x): stub\n", x);
235 BOOL WINAPI CryptFormatObject(DWORD dwCertEncodingType, DWORD dwFormatType,
236 DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
237 const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, DWORD *pcbFormat)
239 FIXME("(%08x, %d, %d, %p, %s, %p, %d, %p, %p): stub\n",
240 dwCertEncodingType, dwFormatType, dwFormatStrType, pFormatStruct,
241 debugstr_a(lpszStructType), pbEncoded, cbEncoded, pbFormat, pcbFormat);