ReactOS 0.4.15-dev-8219-ge8b88cf
main.c
Go to the documentation of this file.
1/*
2 * Copyright 2002 Mike McCormack for CodeWeavers
3 * Copyright 2005 Juan Lang
4 *
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.
9 *
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.
14 *
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
18 */
19
20#include "config.h"
21#include <stdarg.h>
22#include <stdio.h>
23
24#include "windef.h"
25#include "winbase.h"
26#include "wincrypt.h"
27#include "winreg.h"
28#include "winuser.h"
29#include "i_cryptasn1tls.h"
30#include "crypt32_private.h"
31#include "wine/debug.h"
32
34
37
40{
41 0, 0, &prov_param_cs,
44 0, 0, { (DWORD_PTR)(__FILE__ ": prov_param_cs") }
45};
46static CRITICAL_SECTION prov_param_cs = { &prov_param_cs_debug, -1, 0, 0, 0, 0 };
47
49{
50 switch (fdwReason)
51 {
57 break;
59 if (pvReserved) break;
64 break;
65 }
66 return TRUE;
67}
68
70{
71 if (!hDefProv)
72 {
73 HCRYPTPROV prov;
74
77 return hDefProv;
79 NULL);
80 if (hDefProv != prov)
81 CryptReleaseContext(prov, 0);
82 }
83 return hDefProv;
84}
85
86typedef void * HLRUCACHE;
87
88/* this function is called by Internet Explorer when it is about to verify a
89 * downloaded component. The first parameter appears to be a pointer to an
90 * unknown type, native fails unless it points to a buffer of at least 20 bytes.
91 * The second parameter appears to be an out parameter, whatever it's set to is
92 * passed (by cryptnet.dll) to I_CryptFlushLruCache.
93 */
95{
96 FIXME("(%p, %p): stub!\n", unknown, out);
97 *out = (void *)0xbaadf00d;
98 return TRUE;
99}
100
102{
103 FIXME("(%08x, %08x): stub!\n", unk0, unk1);
104 return FALSE;
105}
106
108{
109 FIXME("(%08x, %08x, %08x): stub!\n", unk0, unk1, unk2);
110 return FALSE;
111}
112
114{
115 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
116 return FALSE;
117}
118
120{
121 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
122 return 0;
123}
124
126{
127 FIXME("(%p, %08x, %08x): stub!\n", h, unk0, unk1);
128 return h;
129}
130
132{
133 return HeapAlloc(GetProcessHeap(), 0, cbSize);
134}
135
137{
138 return HeapReAlloc(GetProcessHeap(), 0, pv, cbSize);
139}
140
142{
143 HeapFree(GetProcessHeap(), 0, pv);
144}
145
147{
148 return TlsAlloc();
149}
150
152{
153 LPVOID ret;
154
157 return ret;
158}
159
161{
162 return TlsGetValue(dwTlsIndex);
163}
164
166{
167 return TlsSetValue(dwTlsIndex, lpTlsValue);
168}
169
171{
172 BOOL ret;
173
174 TRACE("(%d, %d)\n", dwTlsIndex, unknown);
175
178 return ret;
179}
180
182{
183 FIXME("%08x\n", x);
184 return FALSE;
185}
186
188{
189 PROV_ENUMALGS prov_algs;
190 DWORD size = sizeof(prov_algs);
191 BOOL ret = FALSE;
192
193 /* This enumeration is not thread safe */
195 if (CryptGetProvParam(prov, PP_ENUMALGS, (BYTE *)&prov_algs, &size, CRYPT_FIRST))
196 {
197 do
198 {
199 if (prov_algs.aiAlgid == algid)
200 {
201 ret = TRUE;
202 break;
203 }
204 } while (CryptGetProvParam(prov, PP_ENUMALGS, (BYTE *)&prov_algs, &size, CRYPT_NEXT));
205 }
207 return ret;
208}
209
211{
212 HCRYPTPROV prov, defprov;
213
214 TRACE("(%08x)\n", algid);
215
216 defprov = CRYPT_GetDefaultProvider();
217
218 if (algid && !is_supported_algid(defprov, algid))
219 {
220 DWORD i = 0, type, size;
221
222 while (CryptEnumProvidersW(i, NULL, 0, &type, NULL, &size))
223 {
225 if (name)
226 {
227 if (CryptEnumProvidersW(i, NULL, 0, &type, name, &size))
228 {
230 {
231 if (is_supported_algid(prov, algid))
232 {
234 return prov;
235 }
236 CryptReleaseContext(prov, 0);
237 }
238 }
240 }
241 i++;
242 }
243
245 return 0;
246 }
247
248 CryptContextAddRef(defprov, NULL, 0);
249 return defprov;
250}
251
253 DWORD *value)
254{
255 static const WCHAR safer[] = {
256 'S','o','f','t','w','a','r','e','\\','P','o','l','i','c','i','e','s','\\',
257 'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
258 'C','e','r','t','i','f','i','c','a','t','e','s','\\',
259 'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r','\\',
260 'S','a','f','e','r',0 };
261 HKEY key;
262 LONG rc;
263 BOOL ret = FALSE;
264
265 TRACE("(%s, %p)\n", debugstr_w(name), value);
266
267 *value = 0;
268 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, safer, &key);
269 if (rc == ERROR_SUCCESS)
270 {
271 DWORD size = sizeof(DWORD);
272
274 ret = TRUE;
276 }
277 return ret;
278}
279
281{
282 static int ret = 8;
283 ret++;
284 FIXME("%08x %08x %08x, return value %d\n", x, y, z,ret);
285 return ret;
286}
287
289{
290 FIXME("(%p %08x %p): stub\n", x, y, z);
291 return TRUE;
292}
293
295{
296 FIXME("(%08x): stub\n", x);
297 return TRUE;
298}
299
301{
302 FIXME("(%08x): stub\n", x);
303 return NULL;
304}
305
307{
308 FIXME("(%08x): stub\n", x);
309 return NULL;
310}
311
313{
314 static int fixme_once;
315 if (!fixme_once++) FIXME("(%p %u %08x): stub\n", data, len, flags);
316 return TRUE;
317}
318
320{
321 static int fixme_once;
322 if (!fixme_once++) FIXME("(%p %u %08x): stub\n", data, len, flags);
323 return TRUE;
324}
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:243
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: debug.h:114
#define RegCloseKey(hKey)
Definition: registry.h:49
HINSTANCE hInstance
Definition: charmap.c:19
void crypt_oid_init(void) DECLSPEC_HIDDEN
Definition: oid.c:1914
void crypt_oid_free(void) DECLSPEC_HIDDEN
Definition: oid.c:1920
void init_empty_store(void) DECLSPEC_HIDDEN
Definition: store.c:1511
void crypt_sip_free(void) DECLSPEC_HIDDEN
Definition: sip.c:610
#define E_INVALIDARG
Definition: ddrawi.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptContextAddRef(HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFlags)
Definition: crypt.c:613
BOOL WINAPI CryptEnumProvidersW(DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName)
Definition: crypt.c:1136
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
BOOL WINAPI CryptGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1688
void default_chain_engine_free(void)
Definition: chain.c:255
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
HCRYPTPROV WINAPI DECLSPEC_HOTPATCH I_CryptGetDefaultCryptProv(ALG_ID algid)
Definition: main.c:210
BOOL WINAPI I_CryptFindLruEntry(DWORD unk0, DWORD unk1)
Definition: main.c:101
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:136
BOOL WINAPI CryptProtectMemory(void *data, DWORD len, DWORD flags)
Definition: main.c:312
ASN1decoding_t WINAPI I_CryptGetAsn1Decoder(HCRYPTASN1MODULE x)
Definition: main.c:300
LPVOID WINAPI I_CryptGetTls(DWORD dwTlsIndex)
Definition: main.c:160
BOOL WINAPI I_CryptReadTrustedPublisherDWORDValueFromRegistry(LPCWSTR name, DWORD *value)
Definition: main.c:252
BOOL WINAPI I_CryptInstallAsn1Module(ASN1module_t x, DWORD y, void *z)
Definition: main.c:288
DWORD WINAPI I_CryptFlushLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
Definition: main.c:119
BOOL WINAPI I_CryptFreeTls(DWORD dwTlsIndex, DWORD unknown)
Definition: main.c:170
DWORD WINAPI I_CryptAllocTls(void)
Definition: main.c:146
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
LPVOID WINAPI I_CryptDetachTls(DWORD dwTlsIndex)
Definition: main.c:151
DWORD WINAPI I_CryptInstallOssGlobal(DWORD x, DWORD y, DWORD z)
Definition: main.c:280
static BOOL is_supported_algid(HCRYPTPROV prov, ALG_ID algid)
Definition: main.c:187
static CRITICAL_SECTION prov_param_cs
Definition: main.c:38
void * HLRUCACHE
Definition: main.c:86
HLRUCACHE WINAPI I_CryptFreeLruCache(HLRUCACHE h, DWORD unk0, DWORD unk1)
Definition: main.c:125
BOOL WINAPI I_CryptGetOssGlobal(DWORD x)
Definition: main.c:181
BOOL WINAPI I_CryptSetTls(DWORD dwTlsIndex, LPVOID lpTlsValue)
Definition: main.c:165
ASN1encoding_t WINAPI I_CryptGetAsn1Encoder(HCRYPTASN1MODULE x)
Definition: main.c:306
static CRITICAL_SECTION_DEBUG prov_param_cs_debug
Definition: main.c:39
BOOL WINAPI I_CryptUninstallAsn1Module(HCRYPTASN1MODULE x)
Definition: main.c:294
BOOL WINAPI I_CryptCreateLruCache(void *unknown, HLRUCACHE *out)
Definition: main.c:94
static HCRYPTPROV hDefProv
Definition: main.c:35
BOOL WINAPI I_CryptFindLruEntryData(DWORD unk0, DWORD unk1, DWORD unk2)
Definition: main.c:107
BOOL WINAPI I_CryptCreateLruEntry(HLRUCACHE h, DWORD unk0, DWORD unk1)
Definition: main.c:113
static HCRYPTPROV CRYPT_GetDefaultProvider(void)
Definition: main.c:69
BOOL WINAPI CryptUnprotectMemory(void *data, DWORD len, DWORD flags)
Definition: main.c:319
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLdouble GLdouble z
Definition: glext.h:5874
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD HCRYPTASN1MODULE
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define debugstr_w
Definition: kernel32.h:32
static LPCSTR DWORD void * pvReserved
Definition: str.c:196
static DWORD unk1
Definition: cursoricon.c:1638
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
static FILE * out
Definition: regtests2xml.c:44
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
ALG_ID aiAlgid
Definition: wincrypt.h:61
Definition: copy.c:22
Definition: name.c:39
#define DWORD_PTR
Definition: treelist.c:76
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define PROV_RSA_AES
Definition: wincrypt.h:2056
#define PP_ENUMALGS
Definition: wincrypt.h:2082
#define CRYPT_FIRST
Definition: wincrypt.h:2060
static const WCHAR MS_ENH_RSA_AES_PROV_W[]
Definition: wincrypt.h:2012
#define CRYPT_NEXT
Definition: wincrypt.h:2061
unsigned int ALG_ID
Definition: wincrypt.h:45
#define WINAPI
Definition: msvc.h:6
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
static DWORD dwTlsIndex
Definition: wintirpc.c:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193