ReactOS 0.4.15-dev-7928-g68a8619
reg.h File Reference
#include <stdlib.h>
#include <windows.h>
#include "resource.h"
Include dependency graph for reg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  reg_type_rels
 

Macros

#define MAX_SUBKEY_LEN   257
 

Functions

void output_writeconsole (const WCHAR *str, DWORD wlen)
 
void WINAPIV output_message (unsigned int id,...)
 
void WINAPIV output_string (const WCHAR *fmt,...)
 
BOOL ask_confirm (unsigned int msgid, WCHAR *reg_info)
 
HKEY path_get_rootkey (const WCHAR *path)
 
WCHARbuild_subkey_path (WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len)
 
WCHARget_long_key (HKEY root, WCHAR *path)
 
BOOL parse_registry_key (const WCHAR *key, HKEY *root, WCHAR **path)
 
BOOL is_char (const WCHAR s, const WCHAR c)
 
BOOL is_switch (const WCHAR *s, const WCHAR c)
 
int reg_add (int argc, WCHAR *argvW[])
 
int reg_copy (int argc, WCHAR *argvW[])
 
int reg_delete (int argc, WCHAR *argvW[])
 
int reg_export (int argc, WCHAR *argvW[])
 
int reg_import (int argc, WCHAR *argvW[])
 
int reg_query (int argc, WCHAR *argvW[])
 

Variables

const struct reg_type_rels type_rels [8]
 

Macro Definition Documentation

◆ MAX_SUBKEY_LEN

#define MAX_SUBKEY_LEN   257

Definition at line 26 of file reg.h.

Function Documentation

◆ ask_confirm()

BOOL ask_confirm ( unsigned int  msgid,
WCHAR reg_info 
)

Definition at line 127 of file reg.c.

128{
130 WCHAR Ybuffer[4];
131 WCHAR Nbuffer[4];
132 WCHAR defval[32];
133 WCHAR answer[MAX_PATH];
134 WCHAR *str;
135 DWORD count;
136
138 LoadStringW(hmod, STRING_YES, Ybuffer, ARRAY_SIZE(Ybuffer));
139 LoadStringW(hmod, STRING_NO, Nbuffer, ARRAY_SIZE(Nbuffer));
141
142 str = (reg_info && *reg_info) ? reg_info : defval;
143
144 while (1)
145 {
146 output_message(msgid, str);
149 answer[0] = towupper(answer[0]);
150 if (answer[0] == Ybuffer[0])
151 return TRUE;
152 if (answer[0] == Nbuffer[0])
153 return FALSE;
154 }
155}
void WINAPIV output_message(unsigned int id,...)
Definition: reg.c:92
#define STRING_NO
Definition: resource.h:29
#define STRING_DEFAULT_VALUE
Definition: resource.h:40
#define STRING_YESNO
Definition: resource.h:31
#define STRING_YES
Definition: resource.h:28
#define ARRAY_SIZE(A)
Definition: main.h:33
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleW(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1174
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:143
const WCHAR * str
#define towupper(c)
Definition: wctype.h:99
#define STD_INPUT_HANDLE
Definition: winbase.h:267
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by get_file_handle(), run_add(), and run_delete().

◆ build_subkey_path()

WCHAR * build_subkey_path ( WCHAR path,
DWORD  path_len,
WCHAR subkey_name,
DWORD  subkey_len 
)

Definition at line 198 of file reg.c.

199{
200 WCHAR *subkey_path;
201
202 subkey_path = malloc((path_len + subkey_len + 2) * sizeof(WCHAR));
203 swprintf(subkey_path, L"%s\\%s", path, subkey_name);
204
205 return subkey_path;
206}
#define malloc
Definition: debug_ros.c:4
#define swprintf
Definition: precomp.h:40
static DWORD path_len
Definition: batch.c:31
#define L(x)
Definition: ntvdm.h:50

Referenced by export_registry_data(), query_all(), and query_value().

◆ get_long_key()

WCHAR * get_long_key ( HKEY  root,
WCHAR path 
)

Definition at line 208 of file reg.c.

209{
210 int i, len;
211 WCHAR *long_key;
212
213 for (i = 0; i < ARRAY_SIZE(root_rels); i++)
214 {
215 if (root == root_rels[i].key)
216 break;
217 }
218
220
221 if (!path)
222 {
223 long_key = malloc((len + 1) * sizeof(WCHAR));
224 lstrcpyW(long_key, root_rels[i].long_name);
225 return long_key;
226 }
227
228 len += lstrlenW(path) + 1; /* add one for the concatenating backslash */
229 long_key = malloc((len + 1) * sizeof(WCHAR));
230 swprintf(long_key, L"%s\\%s", root_rels[i].long_name, path);
231 return long_key;
232}
static const struct @2 root_rels[]
const WCHAR * long_name
Definition: reg.c:30
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
GLenum GLsizei len
Definition: glext.h:6722
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
Definition: copy.c:22

Referenced by reg_delete(), reg_export(), and reg_query().

◆ is_char()

BOOL is_char ( const WCHAR  s,
const WCHAR  c 
)

Definition at line 267 of file reg.c.

268{
269 return (s == c || s == towupper(c));
270}
GLdouble s
Definition: gl.h:2039
const GLubyte * c
Definition: glext.h:8905

Referenced by is_switch(), and reg_export().

◆ is_switch()

BOOL is_switch ( const WCHAR s,
const WCHAR  c 
)

Definition at line 272 of file reg.c.

273{
274 if (lstrlenW(s) > 2)
275 return FALSE;
276
277 return ((s[0] == '/' || s[0] == '-') && is_char(s[1], c));
278}
BOOL is_char(const WCHAR s, const WCHAR c)
Definition: reg.c:267

Referenced by is_help_switch().

◆ output_message()

void WINAPIV output_message ( unsigned int  id,
  ... 
)

Definition at line 92 of file reg.c.

93{
94 WCHAR *fmt = NULL;
95 int len;
96 va_list va_args;
97
98 if (!(len = LoadStringW(GetModuleHandleW(NULL), id, (WCHAR *)&fmt, 0)))
99 {
100 WINE_FIXME("LoadString failed with %d\n", GetLastError());
101 return;
102 }
103
104 len++;
105 fmt = malloc(len * sizeof(WCHAR));
106 if (!fmt) return;
107
109
110 va_start(va_args, id);
111 output_formatstring(fmt, va_args);
112 va_end(va_args);
113
114 free(fmt);
115}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
static void output_formatstring(const WCHAR *fmt, va_list va_args)
Definition: reg.c:76
#define free
Definition: debug_ros.c:5
#define WINE_FIXME
Definition: debug.h:366
Definition: dsound.c:943
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

◆ output_string()

void WINAPIV output_string ( const WCHAR fmt,
  ... 
)

Definition at line 117 of file reg.c.

118{
119 va_list va_args;
120
121 va_start(va_args, fmt);
122 output_formatstring(fmt, va_args);
123 va_end(va_args);
124}

Referenced by output_value(), query_all(), query_value(), and run_query().

◆ output_writeconsole()

void output_writeconsole ( const WCHAR str,
DWORD  wlen 
)

Definition at line 53 of file reg.c.

54{
56
58 if (!ret)
59 {
60 DWORD len;
61 char *msgA;
62
63 /* On Windows WriteConsoleW() fails if the output is redirected. So fall
64 * back to WriteFile(), assuming the console encoding is still the right
65 * one in that case.
66 */
68 msgA = malloc(len);
69
72 free(msgA);
73 }
74}
#define WideCharToMultiByte
Definition: compat.h:111
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2451
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleW(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1447
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
int ret
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268

Referenced by get_file_handle(), and output_formatstring().

◆ parse_registry_key()

BOOL parse_registry_key ( const WCHAR key,
HKEY root,
WCHAR **  path 
)

Definition at line 234 of file reg.c.

235{
236 WCHAR *p;
237
238 if (!sane_path(key))
239 return FALSE;
240
242 if (!*root)
243 {
245 return FALSE;
246 }
247
248 *path = wcschr(key, '\\');
249
250 if (!*path)
251 return TRUE;
252
253 (*path)++;
254
255 if (!**path)
256 {
258 return FALSE;
259 }
260
261 p = *path + lstrlenW(*path) - 1;
262 if (*p == '\\') *p = 0;
263
264 return TRUE;
265}
HKEY path_get_rootkey(const WCHAR *path)
Definition: reg.c:165
static BOOL sane_path(const WCHAR *key)
Definition: reg.c:179
#define STRING_INVALID_SYSTEM_KEY
Definition: resource.h:54
#define wcschr
Definition: compat.h:17
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by reg_add(), reg_copy(), reg_delete(), reg_export(), and reg_query().

◆ path_get_rootkey()

HKEY path_get_rootkey ( const WCHAR path)

Definition at line 165 of file reg.c.

166{
167 DWORD i;
168
169 for (i = 0; i < ARRAY_SIZE(root_rels); i++)
170 {
173 return root_rels[i].key;
174 }
175
176 return NULL;
177}
const WCHAR * short_name
Definition: reg.c:29
static BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name)
Definition: reg.c:157

Referenced by parse_key_name(), and parse_registry_key().

◆ reg_add()

int reg_add ( int  argc,
WCHAR argvW[] 
)

Definition at line 227 of file add.c.

228{
229 HKEY root;
230 WCHAR *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0';
231 BOOL value_empty = FALSE, force = FALSE;
232 REGSAM sam = 0;
233 int i;
234
235 if (!parse_registry_key(argvW[2], &root, &path))
236 return 1;
237
238 for (i = 3; i < argc; i++)
239 {
240 WCHAR *str;
241
242 if (argvW[i][0] != '/' && argvW[i][0] != '-')
243 goto invalid;
244
245 str = &argvW[i][1];
246
247 if (!lstrcmpiW(str, L"ve"))
248 {
249 if (value_empty) goto invalid;
250 value_empty = TRUE;
251 continue;
252 }
253 else if (!lstrcmpiW(str, L"reg:32"))
254 {
255 if (sam & KEY_WOW64_32KEY) goto invalid;
257 continue;
258 }
259 else if (!lstrcmpiW(str, L"reg:64"))
260 {
261 if (sam & KEY_WOW64_64KEY) goto invalid;
263 continue;
264 }
265 else if (!str[0] || str[1])
266 goto invalid;
267
268 switch (towlower(*str))
269 {
270 case 'v':
271 if (value_name || !(value_name = argvW[++i]))
272 goto invalid;
273 break;
274 case 't':
275 if (type || !(type = argvW[++i]))
276 goto invalid;
277 break;
278 case 'd':
279 if (data || !(data = argvW[++i]))
280 goto invalid;
281 break;
282 case 's':
283 str = argvW[++i];
284 if (separator || !str || lstrlenW(str) != 1)
285 goto invalid;
286 separator = str[0];
287 break;
288 case 'f':
289 if (force) goto invalid;
290 force = TRUE;
291 break;
292 default:
293 goto invalid;
294 }
295 }
296
297 if (value_name && value_empty)
298 goto invalid;
299
301 goto invalid;
302
303 return run_add(root, path, sam, value_name, value_empty, type, separator, data, force);
304
305invalid:
308 return 1;
309}
static int argc
Definition: ServiceArgs.c:12
static int run_add(HKEY root, WCHAR *path, REGSAM sam, WCHAR *value_name, BOOL value_empty, WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
Definition: add.c:161
static REGSAM sam
Definition: query.c:143
BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path)
Definition: reg.c:234
#define STRING_INVALID_SYNTAX
Definition: resource.h:33
#define STRING_FUNC_HELP
Definition: resource.h:34
struct _root root
static const WCHAR separator[]
Definition: asmname.c:65
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
static const WCHAR invalid[]
Definition: assoc.c:39
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
#define towlower(c)
Definition: wctype.h:97
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46

Referenced by wmain().

◆ reg_copy()

int reg_copy ( int  argc,
WCHAR argvW[] 
)

Definition at line 193 of file copy.c.

194{
195 struct key src, dest;
196 BOOL recurse = FALSE, force = FALSE;
197 REGSAM sam = 0;
198 int i;
199
200 if (argc == 3)
201 goto invalid;
202
203 if (!parse_registry_key(argvW[2], &src.root, &src.subkey))
204 return 1;
205
206 if (!parse_registry_key(argvW[3], &dest.root, &dest.subkey))
207 return 1;
208
209 for (i = 4; i < argc; i++)
210 {
211 WCHAR *str;
212
213 if (argvW[i][0] != '/' && argvW[i][0] != '-')
214 goto invalid;
215
216 str = &argvW[i][1];
217
218 if (!lstrcmpiW(str, L"reg:32"))
219 {
220 if (sam & KEY_WOW64_32KEY) goto invalid;
222 continue;
223 }
224 else if (!lstrcmpiW(str, L"reg:64"))
225 {
226 if (sam & KEY_WOW64_64KEY) goto invalid;
228 continue;
229 }
230 else if (!str[0] || str[1])
231 goto invalid;
232
233 switch (towlower(*str))
234 {
235 case 's':
236 if (recurse) goto invalid;
237 recurse = TRUE;
238 break;
239 case 'f':
240 if (force) goto invalid;
241 force = TRUE;
242 break;
243 default:
244 goto invalid;
245 }
246 }
247
249 goto invalid;
250
251 if (src.root == dest.root && !lstrcmpiW(src.subkey, dest.subkey))
252 {
254 return 1;
255 }
256
257 src.path = src.subkey;
258
259 return run_copy(&src, &dest, sam, recurse, force);
260
261invalid:
264 return 1;
265}
static int run_copy(struct key *src, struct key *dest, REGSAM sam, BOOL recurse, BOOL force)
Definition: copy.c:80
#define STRING_COPY_SRC_DEST_SAME
Definition: resource.h:67
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

Referenced by wmain().

◆ reg_delete()

int reg_delete ( int  argc,
WCHAR argvW[] 
)

Definition at line 134 of file delete.c.

135{
136 HKEY root;
137 WCHAR *path, *key_name, *value_name = NULL;
138 BOOL value_all = FALSE, value_empty = FALSE, force = FALSE;
139 REGSAM sam = 0;
140 int i;
141
142 if (!parse_registry_key(argvW[2], &root, &path))
143 return 1;
144
145 for (i = 3; i < argc; i++)
146 {
147 WCHAR *str;
148
149 if (argvW[i][0] != '/' && argvW[i][0] != '-')
150 goto invalid;
151
152 str = &argvW[i][1];
153
154 if (!lstrcmpiW(str, L"va"))
155 {
156 if (value_all) goto invalid;
157 value_all = TRUE;
158 continue;
159 }
160 else if (!lstrcmpiW(str, L"ve"))
161 {
162 if (value_empty) goto invalid;
163 value_empty = TRUE;
164 continue;
165 }
166 else if (!lstrcmpiW(str, L"reg:32"))
167 {
168 if (sam & KEY_WOW64_32KEY) goto invalid;
170 continue;
171 }
172 else if (!lstrcmpiW(str, L"reg:64"))
173 {
174 if (sam & KEY_WOW64_64KEY) goto invalid;
176 continue;
177 }
178 else if (!str[0] || str[1])
179 goto invalid;
180
181 switch (towlower(*str))
182 {
183 case 'v':
184 if (value_name || !(value_name = argvW[++i]))
185 goto invalid;
186 break;
187 case 'f':
188 if (force) goto invalid;
189 force = TRUE;
190 break;
191 default:
192 goto invalid;
193 }
194 }
195
196 if ((value_name && value_empty) || (value_name && value_all) || (value_empty && value_all))
197 goto invalid;
198
200 goto invalid;
201
203
204 return run_delete(root, path, sam, key_name, value_name, value_empty, value_all, force);
205
206invalid:
209 return 1;
210}
static int run_delete(HKEY root, WCHAR *path, REGSAM sam, WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL value_all, BOOL force)
Definition: delete.c:38
WCHAR * get_long_key(HKEY root, WCHAR *path)
Definition: reg.c:208

Referenced by wmain().

◆ reg_export()

int reg_export ( int  argc,
WCHAR argvW[] 
)

Definition at line 347 of file export.c.

348{
349 HKEY root, hkey;
351 BOOL overwrite_file = FALSE;
352 REGSAM sam = 0;
354 int i, ret;
355
356 if (argc < 4) goto invalid;
357
358 if (!parse_registry_key(argvW[2], &root, &path))
359 return 1;
360
361 for (i = 4; i < argc; i++)
362 {
363 WCHAR *str;
364
365 if (argvW[i][0] != '/' && argvW[i][0] != '-')
366 goto invalid;
367
368 str = &argvW[i][1];
369
370 if (is_char(*str, 'y') && !str[1])
371 overwrite_file = TRUE;
372 else if (!lstrcmpiW(str, L"reg:32"))
373 {
374 if (sam & KEY_WOW64_32KEY) goto invalid;
376 continue;
377 }
378 else if (!lstrcmpiW(str, L"reg:64"))
379 {
380 if (sam & KEY_WOW64_64KEY) goto invalid;
382 continue;
383 }
384 else
385 goto invalid;
386 }
387
389 goto invalid;
390
391 if (RegOpenKeyExW(root, path, 0, KEY_READ|sam, &hkey))
392 {
394 return 1;
395 }
396
398
399 hFile = get_file_handle(argvW[3], overwrite_file);
404
405 RegCloseKey(hkey);
406
407 return ret;
408
409invalid:
412 return 1;
413}
static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file)
Definition: export.c:314
static void export_newline(HANDLE hFile)
Definition: export.c:175
static void export_file_header(HANDLE hFile)
Definition: export.c:302
static int export_registry_data(HANDLE hFile, HKEY hkey, WCHAR *path, REGSAM sam)
Definition: export.c:228
#define STRING_KEY_NONEXIST
Definition: resource.h:38
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define CloseHandle
Definition: compat.h:739
_In_ HANDLE hFile
Definition: mswsock.h:90
#define KEY_READ
Definition: nt_native.h:1023

Referenced by wmain().

◆ reg_import()

int reg_import ( int  argc,
WCHAR argvW[] 
)

Definition at line 980 of file import.c.

981{
982 WCHAR *filename, *pos;
983 FILE *fp;
984 BYTE s[2];
985 struct parser parser;
986
987 if (argc > 4) goto invalid;
988
989 parser.sam = 0;
990
991 if (argc == 4)
992 {
993 WCHAR *str = argvW[3];
994
995 if (*str != '/' && *str != '-')
996 goto invalid;
997
998 str++;
999
1000 if (!lstrcmpiW(str, L"reg:32"))
1002 else if (!lstrcmpiW(str, L"reg:64"))
1004 else
1005 goto invalid;
1006 }
1007
1008 filename = argvW[2];
1009
1010 fp = _wfopen(filename, L"rb");
1011 if (!fp)
1012 {
1014 return 1;
1015 }
1016
1017 if (fread(s, sizeof(WCHAR), 1, fp) != 1)
1018 goto error;
1019
1020 parser.is_unicode = (s[0] == 0xff && s[1] == 0xfe);
1022
1023 parser.file = fp;
1024 parser.two_wchars[0] = s[0];
1025 parser.two_wchars[1] = s[1];
1026 parser.reg_version = -1;
1027 parser.hkey = NULL;
1030 parser.parse_type = 0;
1031 parser.data_type = 0;
1032 parser.data = NULL;
1033 parser.data_size = 0;
1036
1038
1039 /* parser main loop */
1040 while (pos)
1042
1044 goto error;
1045
1047 close_key(&parser);
1048
1049 fclose(fp);
1050 return 0;
1051
1052error:
1053 fclose(fp);
1054 return 1;
1055
1056invalid:
1059 return 1;
1060}
#define STRING_FILE_NOT_FOUND
Definition: resource.h:8
static WCHAR * get_lineA(FILE *fp)
Definition: import.c:870
@ HEADER
Definition: import.c:60
@ REG_VERSION_INVALID
Definition: import.c:442
static WCHAR * get_lineW(FILE *fp)
Definition: import.c:928
static WCHAR *(* get_line)(FILE *)
Definition: import.c:55
static const parser_state_func parser_funcs[NB_PARSER_STATES]
Definition: import.c:119
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
const char * filename
Definition: ioapi.h:137
#define error(str)
Definition: mkdosfs.c:1605
#define close_key(k)
Definition: reg_test.h:52
Definition: import.c:81
BOOL is_unicode
Definition: import.c:84
BOOL backslash
Definition: import.c:94
enum parser_state state
Definition: import.c:95
WCHAR * value_name
Definition: import.c:89
REGSAM sam
Definition: import.c:86
WCHAR two_wchars[2]
Definition: import.c:83
short int reg_version
Definition: import.c:85
DWORD data_size
Definition: import.c:93
void * data
Definition: import.c:92
HKEY hkey
Definition: import.c:87
DWORD data_type
Definition: import.c:91
DWORD parse_type
Definition: import.c:90
WCHAR * key_name
Definition: import.c:88
FILE * file
Definition: import.c:82
unsigned char BYTE
Definition: xxhash.c:193

Referenced by wmain().

◆ reg_query()

int reg_query ( int  argc,
WCHAR argvW[] 
)

Definition at line 339 of file query.c.

340{
341 HKEY root;
342 WCHAR *path, *key_name, *value_name = NULL;
343 BOOL value_empty = FALSE, recurse = FALSE;
344 int i;
345
346 if (!parse_registry_key(argvW[2], &root, &path))
347 return 1;
348
349 for (i = 3; i < argc; i++)
350 {
351 WCHAR *str;
352
353 if (argvW[i][0] != '/' && argvW[i][0] != '-')
354 goto invalid;
355
356 str = &argvW[i][1];
357
358 if (!lstrcmpiW(str, L"ve"))
359 {
360 if (value_empty) goto invalid;
361 value_empty = TRUE;
362 continue;
363 }
364 else if (!lstrcmpiW(str, L"reg:32"))
365 {
366 if (sam & KEY_WOW64_32KEY) goto invalid;
368 continue;
369 }
370 else if (!lstrcmpiW(str, L"reg:64"))
371 {
372 if (sam & KEY_WOW64_64KEY) goto invalid;
374 continue;
375 }
376 else if (!str[0] || str[1])
377 goto invalid;
378
379 switch (towlower(*str))
380 {
381 case 'v':
382 if (value_name || !(value_name = argvW[++i]))
383 goto invalid;
384 break;
385 case 's':
386 if (recurse) goto invalid;
387 recurse = TRUE;
388 break;
389 default:
390 goto invalid;
391 }
392 }
393
394 if (value_name && value_empty)
395 goto invalid;
396
398 goto invalid;
399
401
402 return run_query(root, path, key_name, value_name, value_empty, recurse);
403
404invalid:
407 return 1;
408}
static int run_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL recurse)
Definition: query.c:311

Referenced by wmain().

Variable Documentation

◆ type_rels

const struct reg_type_rels type_rels[8]
extern

Definition at line 41 of file reg.c.

Referenced by reg_type_to_wchar(), and wchar_get_type().