ReactOS  0.4.15-dev-4872-g8a3db97
reg.c File Reference
#include <stdio.h>
#include "reg.h"
#include <wine/debug.h>
Include dependency graph for reg.c:

Go to the source code of this file.

Enumerations

enum  operations {
  REG_ADD, REG_COPY, REG_DELETE, REG_EXPORT,
  REG_IMPORT, REG_QUERY, REG_INVALID
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (reg)
 
void output_writeconsole (const WCHAR *str, DWORD wlen)
 
static void output_formatstring (const WCHAR *fmt, va_list va_args)
 
void WINAPIV output_message (unsigned int id,...)
 
void WINAPIV output_string (const WCHAR *fmt,...)
 
BOOL ask_confirm (unsigned int msgid, WCHAR *reg_info)
 
static BOOL path_rootname_cmp (const WCHAR *input_path, const WCHAR *rootkey_name)
 
HKEY path_get_rootkey (const WCHAR *path)
 
static BOOL sane_path (const WCHAR *key)
 
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)
 
static BOOL is_help_switch (const WCHAR *s)
 
static enum operations get_operation (const WCHAR *str, int *op_help)
 
int __cdecl wmain (int argc, WCHAR *argvW[])
 

Variables

struct {
   HKEY   key
 
   const WCHAR *   short_name
 
   const WCHAR *   long_name
 
root_rels []
 
const struct reg_type_rels type_rels []
 

Enumeration Type Documentation

◆ operations

Enumerator
REG_ADD 
REG_COPY 
REG_DELETE 
REG_EXPORT 
REG_IMPORT 
REG_QUERY 
REG_INVALID 

Definition at line 285 of file reg.c.

285  {
286  REG_ADD,
287  REG_COPY,
288  REG_DELETE,
289  REG_EXPORT,
290  REG_IMPORT,
291  REG_QUERY,
293 };
Definition: reg.c:291
Definition: reg.c:287
Definition: reg.c:286

Function Documentation

◆ ask_confirm()

BOOL ask_confirm ( unsigned int  msgid,
WCHAR reg_info 
)

Definition at line 127 of file reg.c.

128 {
129  HMODULE hmod;
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));
140  LoadStringW(hmod, STRING_DEFAULT_VALUE, defval, ARRAY_SIZE(defval));
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 }
#define STRING_NO
Definition: resource.h:29
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
void WINAPIV output_message(unsigned int id,...)
Definition: reg.c:92
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define FALSE
Definition: types.h:117
const WCHAR * str
#define STRING_YES
Definition: resource.h:28
#define STD_INPUT_HANDLE
Definition: winbase.h:264
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define STRING_DEFAULT_VALUE
Definition: resource.h:40
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
#define STRING_YESNO
Definition: resource.h:31
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define towupper(c)
Definition: wctype.h:99

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 L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
int _cdecl swprintf(const WCHAR *,...)
static DWORD path_len
Definition: batch.c:31
#define malloc
Definition: debug_ros.c:4

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 }
#define lstrlenW
Definition: compat.h:609
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * long_name
Definition: reg.c:30
int _cdecl swprintf(const WCHAR *,...)
#define lstrcpyW
Definition: compat.h:608
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
#define ARRAY_SIZE(a)
Definition: main.h:24
#define malloc
Definition: debug_ros.c:4
static const struct @2 root_rels[]
Definition: copy.c:22

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

◆ get_operation()

static enum operations get_operation ( const WCHAR str,
int op_help 
)
static

Definition at line 295 of file reg.c.

296 {
297  struct op_info { const WCHAR *op; int id; int help_id; };
298 
299  static const struct op_info op_array[] =
300  {
301  { L"add", REG_ADD, STRING_ADD_USAGE },
302  { L"copy", REG_COPY, STRING_COPY_USAGE },
303  { L"delete", REG_DELETE, STRING_DELETE_USAGE },
304  { L"export", REG_EXPORT, STRING_EXPORT_USAGE },
305  { L"import", REG_IMPORT, STRING_IMPORT_USAGE },
306  { L"query", REG_QUERY, STRING_QUERY_USAGE },
307  { NULL, -1, 0 }
308  };
309 
310  const struct op_info *ptr;
311 
312  for (ptr = op_array; ptr->op; ptr++)
313  {
314  if (!lstrcmpiW(str, ptr->op))
315  {
316  *op_help = ptr->help_id;
317  return ptr->id;
318  }
319  }
320 
321  return REG_INVALID;
322 }
Definition: reg.c:291
#define STRING_QUERY_USAGE
Definition: resource.h:50
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
Definition: reg.c:287
#define L(x)
Definition: ntvdm.h:50
#define STRING_EXPORT_USAGE
Definition: resource.h:48
#define STRING_COPY_USAGE
Definition: resource.h:46
static PVOID ptr
Definition: dispmode.c:27
const WCHAR * str
#define STRING_IMPORT_USAGE
Definition: resource.h:49
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT op
Definition: effect.c:236
#define STRING_DELETE_USAGE
Definition: resource.h:47
#define NULL
Definition: types.h:112
GLenum GLuint id
Definition: glext.h:5579
Definition: reg.c:286
#define STRING_ADD_USAGE
Definition: resource.h:45

Referenced by wmain().

◆ 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 }
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
#define towupper(c)
Definition: wctype.h:99

Referenced by is_switch(), and reg_export().

◆ is_help_switch()

static BOOL is_help_switch ( const WCHAR s)
static

Definition at line 280 of file reg.c.

281 {
282  return (is_switch(s, '?') || is_switch(s, 'h'));
283 }
GLdouble s
Definition: gl.h:2039
BOOL is_switch(const WCHAR *s, const WCHAR c)
Definition: reg.c:272

Referenced by wmain().

◆ 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 }
#define lstrlenW
Definition: compat.h:609
#define FALSE
Definition: types.h:117
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
BOOL is_char(const WCHAR s, const WCHAR c)
Definition: reg.c:267

Referenced by is_help_switch().

◆ output_formatstring()

static void output_formatstring ( const WCHAR fmt,
va_list  va_args 
)
static

Definition at line 76 of file reg.c.

77 {
78  WCHAR *str;
79  DWORD len;
80 
82  fmt, 0, 0, (WCHAR *)&str, 0, &va_args);
83  if (len == 0 && GetLastError() != NO_ERROR)
84  {
85  WINE_FIXME("Could not format string: le=%u, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
86  return;
87  }
89  LocalFree(str);
90 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:418
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define NO_ERROR
Definition: dderror.h:5
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:416
const WCHAR * str
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
void output_writeconsole(const WCHAR *str, DWORD wlen)
Definition: reg.c:53
Definition: dsound.c:943
#define WINE_FIXME
Definition: debug.h:366

Referenced by output_message(), and output_string().

◆ 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 }
#define free
Definition: debug_ros.c:5
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define va_end(ap)
Definition: acmsvcex.h:90
static void output_formatstring(const WCHAR *fmt, va_list va_args)
Definition: reg.c:76
char * va_list
Definition: acmsvcex.h:78
__wchar_t WCHAR
Definition: xmlstorage.h:180
va_start(ap, x)
GLenum GLsizei len
Definition: glext.h:6722
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define malloc
Definition: debug_ros.c:4
Definition: dsound.c:943
#define WINE_FIXME
Definition: debug.h:366

Referenced by ask_confirm(), ask_overwrite_value(), get_file_handle(), get_regdata(), key_name_state(), output_error(), parse_registry_key(), parse_win31_line_state(), query_value(), reg_add(), reg_copy(), reg_delete(), reg_export(), reg_import(), reg_query(), run_add(), run_delete(), run_query(), sane_path(), unescape_string(), and wmain().

◆ 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 }
#define va_end(ap)
Definition: acmsvcex.h:90
static void output_formatstring(const WCHAR *fmt, va_list va_args)
Definition: reg.c:76
char * va_list
Definition: acmsvcex.h:78
va_start(ap, x)
Definition: dsound.c:943

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 {
55  DWORD count, ret;
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 
70  WideCharToMultiByte(GetConsoleOutputCP(), 0, str, wlen, msgA, len, NULL, NULL);
72  free(msgA);
73  }
74 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define WideCharToMultiByte
Definition: compat.h:111
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleW(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1447
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define free
Definition: debug_ros.c:5
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define FALSE
Definition: types.h:117
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
Definition: console.c:2451
const WCHAR * str
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
#define NULL
Definition: types.h:112
#define malloc
Definition: debug_ros.c:4

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 }
#define TRUE
Definition: types.h:120
void WINAPIV output_message(unsigned int id,...)
Definition: reg.c:92
#define lstrlenW
Definition: compat.h:609
#define FALSE
Definition: types.h:117
#define STRING_INVALID_SYSTEM_KEY
Definition: resource.h:54
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL sane_path(const WCHAR *key)
Definition: reg.c:179
HKEY path_get_rootkey(const WCHAR *path)
Definition: reg.c:165
GLfloat GLfloat p
Definition: glext.h:8902
Definition: copy.c:22

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 }
static BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name)
Definition: reg.c:157
unsigned long DWORD
Definition: ntddk_ex.h:95
const WCHAR * short_name
Definition: reg.c:29
const WCHAR * long_name
Definition: reg.c:30
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
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
static const struct @2 root_rels[]
Definition: copy.c:22

Referenced by parse_key_name(), and parse_registry_key().

◆ path_rootname_cmp()

static BOOL path_rootname_cmp ( const WCHAR input_path,
const WCHAR rootkey_name 
)
inlinestatic

Definition at line 157 of file reg.c.

158 {
159  DWORD length = lstrlenW(rootkey_name);
160 
161  return (!_wcsnicmp(input_path, rootkey_name, length) &&
162  (input_path[length] == 0 || input_path[length] == '\\'));
163 }
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define lstrlenW
Definition: compat.h:609
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by path_get_rootkey().

◆ sane_path()

static BOOL sane_path ( const WCHAR key)
static

Definition at line 179 of file reg.c.

180 {
181  unsigned int i = lstrlenW(key);
182 
183  if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
184  {
186  return FALSE;
187  }
188 
189  if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
190  {
192  return FALSE;
193  }
194 
195  return TRUE;
196 }
#define TRUE
Definition: types.h:120
void WINAPIV output_message(unsigned int id,...)
Definition: reg.c:92
#define lstrlenW
Definition: compat.h:609
#define FALSE
Definition: types.h:117
#define STRING_INVALID_KEY
Definition: resource.h:52
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
#define STRING_NO_REMOTE
Definition: resource.h:53
Definition: copy.c:22

Referenced by parse_registry_key().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( reg  )

◆ wmain()

int __cdecl wmain ( int  argc,
WCHAR argvW[] 
)

Definition at line 324 of file reg.c.

325 {
326  int op, op_help;
327 
328  if (argc == 1)
329  {
332  return 1;
333  }
334 
335  if (is_help_switch(argvW[1]))
336  {
338  return 0;
339  }
340 
341  op = get_operation(argvW[1], &op_help);
342 
343  if (op == REG_INVALID)
344  {
347  return 1;
348  }
349  else if (argc == 2) /* Valid operation, no arguments supplied */
350  goto invalid;
351 
352  if (is_help_switch(argvW[2]))
353  {
354  if (argc > 3) goto invalid;
355 
356  output_message(op_help);
358  return 0;
359  }
360 
361  if (op == REG_ADD)
362  return reg_add(argc, argvW);
363 
364  if (op == REG_COPY)
365  return reg_copy(argc, argvW);
366 
367  if (op == REG_DELETE)
368  return reg_delete(argc, argvW);
369 
370  if (op == REG_EXPORT)
371  return reg_export(argc, argvW);
372 
373  if (op == REG_IMPORT)
374  return reg_import(argc, argvW);
375 
376  return reg_query(argc, argvW);
377 
378 invalid:
381  return 1;
382 }
static const WCHAR invalid[]
Definition: assoc.c:39
static int argc
Definition: ServiceArgs.c:12
#define STRING_USAGE
Definition: resource.h:44
#define STRING_REG_VIEW_USAGE
Definition: resource.h:51
int reg_export(int argc, WCHAR *argvW[])
Definition: export.c:347
void WINAPIV output_message(unsigned int id,...)
Definition: reg.c:92
static BOOL is_help_switch(const WCHAR *s)
Definition: reg.c:280
Definition: reg.c:287
int reg_add(int argc, WCHAR *argvW[])
Definition: add.c:227
static enum operations get_operation(const WCHAR *str, int *op_help)
Definition: reg.c:295
#define STRING_FUNC_HELP
Definition: resource.h:34
int reg_query(int argc, WCHAR *argvW[])
Definition: query.c:339
_CRTIMP wchar_t *__cdecl _wcsupr(_Inout_z_ wchar_t *_String)
int reg_import(int argc, WCHAR *argvW[])
Definition: import.c:975
#define STRING_INVALID_SYNTAX
Definition: resource.h:33
#define STRING_REG_HELP
Definition: resource.h:43
UINT op
Definition: effect.c:236
int reg_delete(int argc, WCHAR *argvW[])
Definition: delete.c:134
int reg_copy(int argc, WCHAR *argvW[])
Definition: copy.c:193
Definition: reg.c:286
#define STRING_INVALID_OPTION
Definition: resource.h:55

Variable Documentation

◆ key

Definition at line 28 of file reg.c.

Referenced by ___w64_mingwthr_add_key_dtor(), FxRegKey::__drv_maxIRQL(), ATL::CRegKey::_DoDeleteKeyTree(), _test_key_exists(), _test_key_not_exists(), _TIFFFindFieldByName(), ACTION_RegisterMIMEInfo(), add_param(), add_userkey(), AddDisplayDevice(), AddDlg_OnCommand(), afm_parse_kern_data(), afm_parse_kern_pairs(), afm_parse_track_kern(), afm_parser_next_key(), afm_parser_parse(), afm_parser_skip_section(), apply_image_attributes(), arbfp_blit_type_compare(), bsearch(), btrfs_read_sys_chunk_array(), cache_container_set_size(), CategoryMgr_FindClosestCategory(), CDecodeEnvelopedMsg_CrtlDecrypt(), CDecodeSignedMsg_VerifySignatureWithKey(), CertGetPublicKeyLength(), check_dirid(), cleanup_eventlog(), COM_OpenKeyForCLSID(), COMCAT_ICatInformation_GetCategoryDesc(), COMCAT_ICatInformation_IsClassOfCategories(), COMCAT_RegisterClassCategories(), compare_function_decl_rb(), compare_function_rb(), compare_hlsl_types_rb(), CountUniqueItems_Aux(), create_diff_row_query(), create_key_string(), create_monodata(), create_new_eventlog(), create_server(), CRYPT_CreateKeyProv(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_GetFuncFromReg(), CRYPT_ImportKeyTrans(), CRYPT_ImportSystemRootCertsToReg(), CRYPT_LoadSIPFunc(), CRYPT_RegOpenStore(), CRYPT_RegWriteToReg(), CRYPT_VerifySignature(), CRYPTDLG_CheckOnlineCRL(), CryptGetDefaultOIDDllList(), CryptRegisterDefaultOIDFunction(), CryptSIPRetrieveSubjectGuid(), CryptUnregisterDefaultOIDFunction(), d3dcompiler_shader_reflection_type_compare(), d3drm_animation2_AddPositionKey(), d3drm_animation2_AddRotateKey(), d3drm_animation2_AddScaleKey(), d3drm_animation2_DeleteKey(), d3drm_animation2_GetKeys(), DECLARE_INTERFACE_(), deformat_component(), deformat_environment(), deformat_file(), DEVENUM_ICreateDevEnum_CreateClassEnumerator(), dictInsertBefore(), DllRegisterServer(), dump_child_(), EDIT_CheckCombo(), ensure_useragent(), env_absent(), env_present(), export_is_key_exportable(), export_registry_key(), IconCache::extract(), fetch_machine_product(), CFontInfo::File(), font_absent(), font_present(), ft_hash_str_insert(), ft_hash_str_lookup(), FTP_Connect(), get_cert_mgr_usages(), get_default_proxy_reg_value(), get_install_root(), hhp_pair::get_key(), get_key_state(), get_key_value(), get_mono_path_from_registry(), get_reg_dword(), get_shell_icon_size(), GetInstalledVersion_WowUser(), GetScanCode(), glsl_program_key_compare(), hash_bucket(), hash_insert(), HashFindFreeKeyBlock(), HashInsert(), hhp_pair::hhp_pair(), I_CryptReadTrustedPublisherDWORDValueFromRegistry(), ICInfo(), ICInstall(), ICRemove(), inf_value_parse(), init_driver(), InitLogs(), InputProcessorProfiles_EnableLanguageProfile(), InputProcessorProfiles_EnableLanguageProfileByDefault(), InputProcessorProfiles_IsEnabledLanguageProfile(), install_inf_file(), INTERNET_LoadProxySettings(), INTERNET_SaveProxySettings(), iocp_async_closesocket(), iocp_async_read(), iocp_async_read_closesocket(), iocp_async_read_thread(), iocp_async_read_thread_closesocket(), is_key_empty(), ITERATE_InstallService(), ITERATE_RemoveIniValuesOnInstall(), ITERATE_RemoveIniValuesOnUninstall(), ITERATE_WriteIniValues(), ITERATE_WriteRegistryValues(), load_sys_chunks(), MMDevEnum_GetDefaultAudioEndpoint(), MMDevice_Create(), MMDevPropStore_OpenPropKey(), MSI_EnumComponentQualifiers(), msi_publish_install_properties(), msi_validate_product_id(), NdrDllRegisterProxy(), notif_thread_proc(), ok_keys_(), okChildInt_(), okChildIntBroken_(), okChildPath_(), okChildString_(), ole_server(), pa_absent(), pa_present(), param_rb_compare(), pf_absent(), pf_present(), pp_absent(), pp_present(), ppc_absent(), ppc_present(), process_hook_section(), ProcessKeys(), PROFILE_DeleteAllKeys(), PROFILE_DeleteKey(), PROFILE_Find(), PROFILE_Free(), PROFILE_GetSection(), PROFILE_Load(), PROFILE_Save(), pub_absent(), pub_present(), rci_absent(), rci_present(), rdssl_sign_ok(), CFontCache::Read(), read_oid_info(), register_codepages(), register_interfaces(), register_key_defvalueA(), register_key_defvalueW(), register_verb(), RegisterTypeLib(), rei_absent(), rei_present(), resolve_keypath(), RestoreTypedURLs(), rmi_absent(), rmi_present(), rp_absent(), rp_present(), rpi_absent(), rpi_present(), ru_absent(), ru_present(), save_cert_mgr_usages(), search_ini(), SECUR32_initializeProviders(), set_ldids(), ATL::CSimpleMap< CStringW, CStringW >::SetAtIndex(), ATL::CRegKey::SetKeyValue(), Settings_GetOutputPath(), Settings_GetShouldWriteDump(), SETUPDI_CreateDevKey(), SETUPDI_OpenDevKey(), SETUPDI_OpenDrvKey(), SetupDiCreateDeviceInterfaceRegKeyA(), SetupDiCreateDevRegKeyA(), SetupDiCreateDevRegKeyW(), SetupDiOpenClassRegKeyExW(), SetupDiOpenDevRegKey(), ATL::CRegKey::SetValue(), SHGetObjectCompatFlags(), SHGetShellKey(), si_compar(), sparse_array_add(), sqliteKeywordCode(), sr_absent(), sr_present(), START_TEST(), sti_compar(), TABLE_set_int(), TABLE_set_string(), test__lfind_s(), test_Add(), test_animation(), test_autocreation(), test_comparemode(), test_completion(), test_completion_port(), test_device_interface_key(), test_dik_codes(), test_Exists(), test_findOIDInfo(), test_get_profiles_dir(), test_hash_value(), test_header(), test_IACLCustomMRU_Continue(), test_IACLCustomMRU_TypedURLs(), test_ICInfo(), test_IEnumVARIANT(), test_import_hmac(), test_install_from(), test_interfaces(), test_internet_features(), test_Item(), test_Keys(), test_ldap_parse_sort_control(), test_long_value_name(), test_NonExistentPath(), test_notify(), test_NtCreateKey(), test_NtOpenKey(), test_NtQueryKey(), test_NtQueryValueKey(), test_NtSetValueKey(), test_null_provider(), test_perflib_key(), test_publish_components(), test_readTrustedPublisherDWORD(), test_redirection(), test_reg_delete_key(), test_register_device_iface(), test_register_font(), test_registerDefaultOIDFunction(), test_registerOIDInfo(), test_registry(), test_registry_property_a(), test_registry_property_w(), test_RegNotifyChangeKeyValue(), test_RegOpenCurrentUser(), test_RegPolicyFlags(), test_Remove(), test_save(), test_self_registration(), test_SHGetFolderPathA(), test_SHRegCloseUSKey(), test_signed_msg_encoding(), test_signed_msg_update(), test_sioAddressListChange(), test_symlinks(), test_synchronous_WSAIoctl(), testAcquireCertPrivateKey(), testAcquireSecurityContext(), testCreateSelfSignCert(), testExportPublicKey(), testGetPublicKeyLength(), testImportPublicKey(), Tests_Insert_And_Delete(), testSignCert(), TIFFFindField(), TLB_register_interface(), TOOLBAR_Save(), TransformView_delete_row(), TransformView_insert_row(), TransformView_set_row(), TreeNodeMake(), tt_face_get_kerning(), TuiEditBox(), TuiMessageBoxCritical(), UpdateKeyStateFromMsg(), urlcache_hash_entry_create(), usp10_compare_script_range(), VARIANT_GetNamedFormat(), verify_mru_(), wine_get_sortkey(), wined3d_ffp_frag_program_key_compare(), wined3d_ffp_vertex_program_key_compare(), WinHttpGetDefaultProxyConfiguration(), WinHttpSetDefaultProxyConfiguration(), WintrustGetRegPolicyFlags(), WintrustSetRegPolicyFlags(), write_superblocks(), wrv_absent(), wrv_present(), xmlDictExists(), xmlDictGrow(), xmlDictLookup(), xmlDictQLookup(), xmlHashAddEntry3(), xmlHashGrow(), xmlHashLookup3(), xmlHashQLookup3(), xmlHashRemoveEntry3(), xmlHashUpdateEntry3(), and xsltAddKey().

◆ long_name

const WCHAR* long_name

Definition at line 30 of file reg.c.

Referenced by get_long_key(), lfn_check_orphaned(), lfn_get(), and path_get_rootkey().

◆ root_rels

const { ... } root_rels[]
Initial value:
=
{
{HKEY_LOCAL_MACHINE, L"HKLM", L"HKEY_LOCAL_MACHINE"},
{HKEY_CURRENT_USER, L"HKCU", L"HKEY_CURRENT_USER"},
{HKEY_CLASSES_ROOT, L"HKCR", L"HKEY_CLASSES_ROOT"},
{HKEY_USERS, L"HKU", L"HKEY_USERS"},
{HKEY_CURRENT_CONFIG, L"HKCC", L"HKEY_CURRENT_CONFIG"},
}
#define HKEY_USERS
Definition: winreg.h:13
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define L(x)
Definition: ntvdm.h:50
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by get_long_key(), and path_get_rootkey().

◆ short_name

◆ type_rels

const struct reg_type_rels type_rels[]
Initial value:
=
{
{REG_NONE, L"REG_NONE"},
{REG_SZ, L"REG_SZ"},
{REG_EXPAND_SZ, L"REG_EXPAND_SZ"},
{REG_BINARY, L"REG_BINARY"},
{REG_DWORD, L"REG_DWORD"},
{REG_DWORD_LITTLE_ENDIAN, L"REG_DWORD_LITTLE_ENDIAN"},
{REG_DWORD_BIG_ENDIAN, L"REG_DWORD_BIG_ENDIAN"},
{REG_MULTI_SZ, L"REG_MULTI_SZ"},
}
#define REG_BINARY
Definition: nt_native.h:1496
#define L(x)
Definition: ntvdm.h:50
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define REG_DWORD_LITTLE_ENDIAN
Definition: nt_native.h:1498
#define REG_DWORD_BIG_ENDIAN
Definition: nt_native.h:1499
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define REG_NONE
Definition: nt_native.h:1492
#define REG_DWORD
Definition: sdbapi.c:596
#define REG_SZ
Definition: layer.c:22

Definition at line 41 of file reg.c.

Referenced by reg_type_to_wchar(), and wchar_get_type().