Welcome to mirror list, hosted at ThFree Co, Russian Federation.

registry.c « registry « libwinpr « winpr - github.com/FreeRDP/FreeRDP.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0c148b5a61b01797e938b37d6b82901f9f1e835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/**
 * WinPR: Windows Portable Runtime
 * Windows Registry
 *
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <winpr/registry.h>

/*
 * Windows registry MSDN pages:
 * Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724880/
 * Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724875/
 */

#if !defined(_WIN32) || defined(_UWP)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <winpr/crt.h>
#include <assert.h>

#include "registry_reg.h"

static Reg* instance = NULL;

static Reg* RegGetInstance(void)
{
	if (!instance)
		instance = reg_open(1);

	return instance;
}

LONG RegCloseKey(HKEY hKey)
{
	return 0;
}

LONG RegCopyTreeW(HKEY hKeySrc, LPCWSTR lpSubKey, HKEY hKeyDest)
{
	return 0;
}

LONG RegCopyTreeA(HKEY hKeySrc, LPCSTR lpSubKey, HKEY hKeyDest)
{
	return 0;
}

LONG RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, DWORD dwOptions,
                     REGSAM samDesired, LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult,
                     LPDWORD lpdwDisposition)
{
	return 0;
}

LONG RegCreateKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, DWORD dwOptions,
                     REGSAM samDesired, LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult,
                     LPDWORD lpdwDisposition)
{
	return 0;
}

LONG RegDeleteKeyExW(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved)
{
	return 0;
}

LONG RegDeleteKeyExA(HKEY hKey, LPCSTR lpSubKey, REGSAM samDesired, DWORD Reserved)
{
	return 0;
}

LONG RegDeleteTreeW(HKEY hKey, LPCWSTR lpSubKey)
{
	return 0;
}

LONG RegDeleteTreeA(HKEY hKey, LPCSTR lpSubKey)
{
	return 0;
}

LONG RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
{
	return 0;
}

LONG RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
{
	return 0;
}

LONG RegDisablePredefinedCacheEx(void)
{
	return 0;
}

LONG RegEnumKeyExW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcName, LPDWORD lpReserved,
                   LPWSTR lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
{
	return 0;
}

LONG RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcName, LPDWORD lpReserved,
                   LPSTR lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
{
	return 0;
}

LONG RegEnumValueW(HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, LPDWORD lpcchValueName,
                   LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
{
	return 0;
}

LONG RegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName, LPDWORD lpcchValueName,
                   LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData)
{
	return 0;
}

LONG RegFlushKey(HKEY hKey)
{
	return 0;
}

LONG RegGetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation,
                       PSECURITY_DESCRIPTOR pSecurityDescriptor, LPDWORD lpcbSecurityDescriptor)
{
	return 0;
}

LONG RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD dwFlags, LPDWORD pdwType,
                  PVOID pvData, LPDWORD pcbData)
{
	return 0;
}

LONG RegGetValueA(HKEY hkey, LPCSTR lpSubKey, LPCSTR lpValue, DWORD dwFlags, LPDWORD pdwType,
                  PVOID pvData, LPDWORD pcbData)
{
	return 0;
}

LONG RegLoadAppKeyW(LPCWSTR lpFile, PHKEY phkResult, REGSAM samDesired, DWORD dwOptions,
                    DWORD Reserved)
{
	return 0;
}

LONG RegLoadAppKeyA(LPCSTR lpFile, PHKEY phkResult, REGSAM samDesired, DWORD dwOptions,
                    DWORD Reserved)
{
	return 0;
}

LONG RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile)
{
	return 0;
}

LONG RegLoadKeyA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile)
{
	return 0;
}

LONG RegLoadMUIStringW(HKEY hKey, LPCWSTR pszValue, LPWSTR pszOutBuf, DWORD cbOutBuf,
                       LPDWORD pcbData, DWORD Flags, LPCWSTR pszDirectory)
{
	return 0;
}

LONG RegLoadMUIStringA(HKEY hKey, LPCSTR pszValue, LPSTR pszOutBuf, DWORD cbOutBuf, LPDWORD pcbData,
                       DWORD Flags, LPCSTR pszDirectory)
{
	return 0;
}

LONG RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent,
                             BOOL fAsynchronous)
{
	return 0;
}

LONG RegOpenCurrentUser(REGSAM samDesired, PHKEY phkResult)
{
	return 0;
}

LONG RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
{
	return 0;
}

LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
{
	RegKey* pKey;
	Reg* reg = RegGetInstance();

	if (!reg)
		return -1;

	if (hKey != HKEY_LOCAL_MACHINE)
		return ERROR_FILE_NOT_FOUND;

	assert(reg->root_key);
	pKey = reg->root_key->subkeys;

	while (pKey != NULL)
	{
		assert(lpSubKey);

		if (pKey->subname && (_stricmp(pKey->subname, lpSubKey) == 0))
		{
			*phkResult = (HKEY)pKey;
			return ERROR_SUCCESS;
		}

		pKey = pKey->next;
	}

	*phkResult = NULL;

	return ERROR_FILE_NOT_FOUND;
}

LONG RegOpenUserClassesRoot(HANDLE hToken, DWORD dwOptions, REGSAM samDesired, PHKEY phkResult)
{
	return 0;
}

LONG RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved,
                      LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen,
                      LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen,
                      LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
{
	return 0;
}

LONG RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved,
                      LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen,
                      LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen,
                      LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
{
	return 0;
}

LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType,
                      LPBYTE lpData, LPDWORD lpcbData)
{
	return ERROR_FILE_NOT_FOUND;
}

LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType,
                      LPBYTE lpData, LPDWORD lpcbData)
{
	RegKey* key;
	RegVal* pValue;

	WINPR_UNUSED(lpReserved);

	key = (RegKey*)hKey;
	assert(key);

	pValue = key->values;

	while (pValue != NULL)
	{
		if (strcmp(pValue->name, lpValueName) == 0)
		{
			if (lpType)
				*lpType = pValue->type;

			if (pValue->type == REG_DWORD)
			{
				DWORD* pData = (DWORD*)lpData;

				if (lpcbData)
				{
					DWORD size = *lpcbData;
					*lpcbData = sizeof(DWORD);
					if (pData)
					{
						if (size < *lpcbData)
							return ERROR_MORE_DATA;
					}
				}

				if (pData != NULL)
				{
					DWORD size;
					assert(lpcbData);

					size = *lpcbData;
					*lpcbData = sizeof(DWORD);
					if (size < sizeof(DWORD))
						return ERROR_MORE_DATA;
					*pData = pValue->data.dword;
				}
				else if (lpcbData != NULL)
					*lpcbData = sizeof(DWORD);
				return ERROR_SUCCESS;
			}
			else if (pValue->type == REG_SZ)
			{
				size_t length;
				char* pData = (char*)lpData;

				length = strnlen(pValue->data.string, INT_MAX);

				if (pData != NULL)
				{
					DWORD size;
					assert(lpcbData);

					size = *lpcbData;
					*lpcbData = length;
					if (size < length)
						return ERROR_MORE_DATA;
					memcpy(pData, pValue->data.string, length);
					pData[length] = '\0';
				}
				else if (lpcbData)
					*lpcbData = (UINT32)length;

				return ERROR_SUCCESS;
			}
		}

		pValue = pValue->next;
	}

	return ERROR_FILE_NOT_FOUND;
}

LONG RegRestoreKeyW(HKEY hKey, LPCWSTR lpFile, DWORD dwFlags)
{
	return 0;
}

LONG RegRestoreKeyA(HKEY hKey, LPCSTR lpFile, DWORD dwFlags)
{
	return 0;
}

LONG RegSaveKeyExW(HKEY hKey, LPCWSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
                   DWORD Flags)
{
	return 0;
}

LONG RegSaveKeyExA(HKEY hKey, LPCSTR lpFile, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
                   DWORD Flags)
{
	return 0;
}

LONG RegSetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation,
                       PSECURITY_DESCRIPTOR pSecurityDescriptor)
{
	return 0;
}

LONG RegSetValueExW(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType,
                    const BYTE* lpData, DWORD cbData)
{
	return 0;
}

LONG RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, const BYTE* lpData,
                    DWORD cbData)
{
	return 0;
}

LONG RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey)
{
	return 0;
}

LONG RegUnLoadKeyA(HKEY hKey, LPCSTR lpSubKey)
{
	return 0;
}

#endif