ReactOS 0.4.17-dev-736-g75e91de
registrar.c File Reference
#include "atlbase.h"
#include "wine/debug.h"
Include dependency graph for registrar.c:

Go to the source code of this file.

Classes

struct  rep_list_str
 
struct  Registrar
 
struct  strbuf
 

Macros

#define COBJMACROS
 

Typedefs

typedef struct rep_list_str rep_list
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (atl)
 
static Registrarimpl_from_IRegistrar (IRegistrar *iface)
 
static void strbuf_init (strbuf *buf)
 
static void strbuf_write (LPCOLESTR str, strbuf *buf, int len)
 
static int xdigit_to_int (WCHAR c)
 
static HRESULT get_word (LPCOLESTR *str, strbuf *buf)
 
static HRESULT do_preprocess (const Registrar *This, LPCOLESTR data, strbuf *buf)
 
static HRESULT do_process_key (LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
 
static HRESULT do_process_root_key (LPCOLESTR data, BOOL do_register)
 
static HRESULT string_register (Registrar *This, LPCOLESTR data, BOOL do_register)
 
static HRESULT resource_register (Registrar *This, LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
 
static HRESULT file_register (Registrar *This, LPCOLESTR fileName, BOOL do_register)
 
static HRESULT WINAPI Registrar_QueryInterface (IRegistrar *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI Registrar_AddRef (IRegistrar *iface)
 
static ULONG WINAPI Registrar_Release (IRegistrar *iface)
 
static HRESULT WINAPI Registrar_AddReplacement (IRegistrar *iface, LPCOLESTR Key, LPCOLESTR item)
 
static HRESULT WINAPI Registrar_ClearReplacements (IRegistrar *iface)
 
static HRESULT WINAPI Registrar_ResourceRegisterSz (IRegistrar *iface, LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
 
static HRESULT WINAPI Registrar_ResourceUnregisterSz (IRegistrar *iface, LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
 
static HRESULT WINAPI Registrar_FileRegister (IRegistrar *iface, LPCOLESTR fileName)
 
static HRESULT WINAPI Registrar_FileUnregister (IRegistrar *iface, LPCOLESTR fileName)
 
static HRESULT WINAPI Registrar_StringRegister (IRegistrar *iface, LPCOLESTR data)
 
static HRESULT WINAPI Registrar_StringUnregister (IRegistrar *iface, LPCOLESTR data)
 
static HRESULT WINAPI Registrar_ResourceRegister (IRegistrar *iface, LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
 
static HRESULT WINAPI Registrar_ResourceUnregister (IRegistrar *iface, LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
 
HRESULT WINAPI AtlCreateRegistrar (IRegistrar **ret)
 
HRESULT WINAPI AtlUpdateRegistryFromResourceD (HINSTANCE inst, LPCOLESTR res, BOOL bRegister, struct _ATL_REGMAP_ENTRY *pMapEntries, IRegistrar *pReg)
 

Variables

struct {
   WCHAR   name [22]
 
   HKEY   key
 
root_keys []
 
static const IRegistrarVtbl RegistrarVtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 19 of file registrar.c.

Typedef Documentation

◆ rep_list

Function Documentation

◆ AtlCreateRegistrar()

HRESULT WINAPI AtlCreateRegistrar ( IRegistrar **  ret)

Definition at line 687 of file registrar.c.

688{
689 Registrar *registrar;
690
691 registrar = calloc(1, sizeof(*registrar));
692 if(!registrar)
693 return E_OUTOFMEMORY;
694
695 registrar->IRegistrar_iface.lpVtbl = &RegistrarVtbl;
696 registrar->ref = 1;
697
698 *ret = &registrar->IRegistrar_iface;
699 return S_OK;
700}
IRegistrar IRegistrar_iface
Definition: registrar.c:59
LONG ref
Definition: registrar.c:60
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const IRegistrarVtbl RegistrarVtbl
Definition: registrar.c:668
return ret
Definition: mutex.c:147
#define S_OK
Definition: intsafe.h:52
#define calloc
Definition: rosglue.h:14

Referenced by AtlUpdateRegistryFromResourceD(), and RegistrarCF_CreateInstance().

◆ AtlUpdateRegistryFromResourceD()

HRESULT WINAPI AtlUpdateRegistryFromResourceD ( HINSTANCE  inst,
LPCOLESTR  res,
BOOL  bRegister,
struct _ATL_REGMAP_ENTRY pMapEntries,
IRegistrar pReg 
)

Definition at line 705 of file registrar.c.

707{
708 const struct _ATL_REGMAP_ENTRY *iter;
710 IRegistrar *registrar;
712
714 FIXME("hinst %p: did not get module name\n", inst);
715 return E_FAIL;
716 }
717
718 TRACE("%p (%s), %s, %d, %p, %p\n", inst, debugstr_w(module_name),
719 debugstr_w(res), bRegister, pMapEntries, pReg);
720
721 if(pReg) {
722 registrar = pReg;
723 }else {
724 hres = AtlCreateRegistrar(&registrar);
725 if(FAILED(hres))
726 return hres;
727 }
728
729 IRegistrar_AddReplacement(registrar, L"MODULE", module_name);
730
731 for (iter = pMapEntries; iter && iter->szKey; iter++)
732 IRegistrar_AddReplacement(registrar, iter->szKey, iter->szData);
733
734 if(bRegister)
735 hres = IRegistrar_ResourceRegisterSz(registrar, module_name, res, L"REGISTRY");
736 else
737 hres = IRegistrar_ResourceUnregisterSz(registrar, module_name, res, L"REGISTRY");
738
739 if(registrar != pReg)
740 IRegistrar_Release(registrar);
741 return hres;
742}
#define FIXME(fmt,...)
Definition: precomp.h:53
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:171
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI AtlCreateRegistrar(IRegistrar **ret)
Definition: registrar.c:687
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
#define L(x)
Definition: resources.c:13
GLuint res
Definition: glext.h:9613
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
HRESULT hres
Definition: protocol.c:465
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
Definition: atlbase.h:242
LPCOLESTR szKey
Definition: atlbase.h:243
LPCOLESTR szData
Definition: atlbase.h:244

Referenced by AtlModuleUpdateRegistryFromResourceD().

◆ do_preprocess()

static HRESULT do_preprocess ( const Registrar This,
LPCOLESTR  data,
strbuf buf 
)
static

Definition at line 148 of file registrar.c.

149{
150 LPCOLESTR iter, iter2 = data;
151 rep_list *rep_iter;
152
153 iter = wcschr(data, '%');
154 while(iter) {
155 strbuf_write(iter2, buf, iter-iter2);
156
157 iter2 = ++iter;
158 if(!*iter2)
159 return DISP_E_EXCEPTION;
160 iter = wcschr(iter2, '%');
161 if(!iter)
162 return DISP_E_EXCEPTION;
163
164 if(iter == iter2) {
165 strbuf_write(L"%", buf, 1);
166 }else {
167 for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) {
168 if(rep_iter->key_len == iter-iter2
169 && !wcsnicmp(iter2, rep_iter->key, rep_iter->key_len))
170 break;
171 }
172 if(!rep_iter) {
173 WARN("Could not find replacement: %s\n", debugstr_wn(iter2, iter-iter2));
174 return DISP_E_EXCEPTION;
175 }
176
177 strbuf_write(rep_iter->item, buf, -1);
178 }
179
180 iter2 = ++iter;
181 iter = wcschr(iter, '%');
182 }
183
184 strbuf_write(iter2, buf, -1);
185 TRACE("%s\n", debugstr_w(buf->str));
186
187 return S_OK;
188}
#define WARN(fmt,...)
Definition: precomp.h:61
static void strbuf_write(LPCOLESTR str, strbuf *buf, int len)
Definition: registrar.c:82
#define wcschr
Definition: compat.h:17
#define wcsnicmp
Definition: compat.h:14
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define debugstr_wn
Definition: kernel32.h:33
LPOLESTR item
Definition: registrar.c:53
LPOLESTR key
Definition: registrar.c:52
struct rep_list_str * next
Definition: registrar.c:55
#define DISP_E_EXCEPTION
Definition: winerror.h:3621

Referenced by string_register().

◆ do_process_key()

static HRESULT do_process_key ( LPCOLESTR *  pstr,
HKEY  parent_key,
strbuf buf,
BOOL  do_register 
)
static

Definition at line 190 of file registrar.c.

191{
192 LPCOLESTR iter;
194 LONG lres;
195 HKEY hkey = 0;
196 strbuf name;
197
198 enum {
199 NORMAL,
200 NO_REMOVE,
201 IS_VAL,
202 FORCE_REMOVE,
203 DO_DELETE
204 } key_type = NORMAL;
205
206 iter = *pstr;
207 hres = get_word(&iter, buf);
208 if(FAILED(hres))
209 return hres;
211
212 while(buf->str[1] || buf->str[0] != '}') {
213 key_type = NORMAL;
214 if(!lstrcmpiW(buf->str, L"NoRemove"))
215 key_type = NO_REMOVE;
216 else if(!lstrcmpiW(buf->str, L"ForceRemove"))
217 key_type = FORCE_REMOVE;
218 else if(!lstrcmpiW(buf->str, L"val"))
219 key_type = IS_VAL;
220 else if(!lstrcmpiW(buf->str, L"Delete"))
221 key_type = DO_DELETE;
222
223 if(key_type != NORMAL) {
224 hres = get_word(&iter, buf);
225 if(FAILED(hres))
226 break;
227 }
228 TRACE("name = %s\n", debugstr_w(buf->str));
229
230 if(do_register) {
231 if(key_type == IS_VAL) {
232 hkey = parent_key;
233 strbuf_write(buf->str, &name, -1);
234 }else if(key_type == DO_DELETE) {
235 TRACE("Deleting %s\n", debugstr_w(buf->str));
236 RegDeleteTreeW(parent_key, buf->str);
237 }else {
238 if(key_type == FORCE_REMOVE)
239 RegDeleteTreeW(parent_key, buf->str);
240 lres = RegCreateKeyW(parent_key, buf->str, &hkey);
241 if(lres != ERROR_SUCCESS) {
242 WARN("Could not create(open) key: %08lx\n", lres);
243 hres = HRESULT_FROM_WIN32(lres);
244 break;
245 }
246 }
247 }else if(key_type != IS_VAL && key_type != DO_DELETE) {
248 strbuf_write(buf->str, &name, -1);
249 lres = RegOpenKeyW(parent_key, buf->str, &hkey);
250 if(lres != ERROR_SUCCESS)
251 WARN("Could not open key %s: %08lx\n", debugstr_w(name.str), lres);
252 }
253
254 if(key_type != DO_DELETE && *iter == '=') {
255 iter++;
256 hres = get_word(&iter, buf);
257 if(FAILED(hres))
258 break;
259 if(buf->len != 1) {
260 WARN("Wrong registry type: %s\n", debugstr_w(buf->str));
262 break;
263 }
264 if(do_register) {
265 switch(buf->str[0]) {
266 case 's':
267 hres = get_word(&iter, buf);
268 if(FAILED(hres))
269 break;
270 lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_SZ, (PBYTE)buf->str,
271 (lstrlenW(buf->str)+1)*sizeof(WCHAR));
272 if(lres != ERROR_SUCCESS) {
273 WARN("Could set value of key: %08lx\n", lres);
274 hres = HRESULT_FROM_WIN32(lres);
275 break;
276 }
277 break;
278 case 'd': {
279 DWORD dw;
280 hres = get_word(&iter, buf);
281 if(FAILED(hres))
282 break;
283 dw = wcstoul(buf->str, NULL, 10);
284 lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_DWORD,
285 (PBYTE)&dw, sizeof(dw));
286 if(lres != ERROR_SUCCESS) {
287 WARN("Could set value of key: %08lx\n", lres);
288 hres = HRESULT_FROM_WIN32(lres);
289 break;
290 }
291 break;
292 }
293 case 'b': {
294 BYTE *bytes;
295 DWORD count;
296 DWORD i;
297 hres = get_word(&iter, buf);
298 if(FAILED(hres))
299 break;
300 count = (lstrlenW(buf->str) + 1) / 2;
301 bytes = malloc(count);
302 if(bytes == NULL) {
304 break;
305 }
306 for(i = 0; i < count && buf->str[2*i]; i++) {
307 int d1, d2;
308 if((d1 = xdigit_to_int(buf->str[2*i])) == -1 || (d2 = xdigit_to_int(buf->str[2*i + 1])) == -1) {
309 hres = E_FAIL;
310 break;
311 }
312 bytes[i] = (d1 << 4) | d2;
313 }
314 if(SUCCEEDED(hres)) {
315 lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_BINARY,
316 bytes, count);
317 if(lres != ERROR_SUCCESS) {
318 WARN("Could not set value of key: 0x%08lx\n", lres);
319 hres = HRESULT_FROM_WIN32(lres);
320 }
321 }
322 free(bytes);
323 break;
324 }
325 default:
326 WARN("Wrong resource type: %s\n", debugstr_w(buf->str));
328 };
329 if(FAILED(hres))
330 break;
331 }else {
332 if(*iter == '-')
333 iter++;
334 hres = get_word(&iter, buf);
335 if(FAILED(hres))
336 break;
337 }
338 }else if(key_type == IS_VAL) {
339 WARN("value not set!\n");
341 break;
342 }
343
344 if(key_type != IS_VAL && key_type != DO_DELETE && *iter == '{' && iswspace(iter[1])) {
345 hres = get_word(&iter, buf);
346 if(FAILED(hres))
347 break;
348 hres = do_process_key(&iter, hkey, buf, do_register);
349 if(FAILED(hres))
350 break;
351 }
352
353 TRACE("%x %x\n", do_register, key_type);
354 if(!do_register && (key_type == NORMAL || key_type == FORCE_REMOVE)) {
355 TRACE("Deleting %s\n", debugstr_w(name.str));
356 RegDeleteKeyW(parent_key, name.str);
357 }
358
359 if(hkey && key_type != IS_VAL)
360 RegCloseKey(hkey);
361 hkey = 0;
362 name.len = 0;
363
364 hres = get_word(&iter, buf);
365 if(FAILED(hres))
366 break;
367 }
368
369 free(name.str);
370 if(hkey && key_type != IS_VAL)
371 RegCloseKey(hkey);
372 *pstr = iter;
373 return hres;
374}
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define NORMAL
Definition: main.h:128
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NO_REMOVE
Definition: classpnp.h:96
LSTATUS WINAPI RegDeleteTreeW(_In_ HKEY, _In_opt_ LPCWSTR)
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
static int xdigit_to_int(WCHAR c)
Definition: registrar.c:95
static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
Definition: registrar.c:190
WCHAR name[22]
Definition: registrar.c:32
static void strbuf_init(strbuf *buf)
Definition: registrar.c:75
#define lstrlenW
Definition: compat.h:750
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
_ACRTIMP __msvcrt_ulong __cdecl wcstoul(const wchar_t *, wchar_t **, int)
Definition: wcs.c:2917
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
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 get_word()
Definition: iccvid.c:91
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define REG_SZ
Definition: layer.c:22
#define REG_BINARY
Definition: nt_native.h:1499
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:615
#define iswspace(_c)
Definition: ctype.h:669
Definition: name.c:39
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
unsigned char BYTE
Definition: xxhash.c:193

Referenced by do_process_key(), and do_process_root_key().

◆ do_process_root_key()

static HRESULT do_process_root_key ( LPCOLESTR  data,
BOOL  do_register 
)
static

Definition at line 376 of file registrar.c.

377{
378 LPCOLESTR iter = data;
379 strbuf buf;
381 unsigned int i;
382
384 hres = get_word(&iter, &buf);
385 if(FAILED(hres))
386 goto done;
387
388 while(*iter) {
389 if(!buf.len) {
390 WARN("ward.len == 0, failed\n");
392 break;
393 }
394 for(i=0; i<ARRAY_SIZE(root_keys); i++) {
395 if(!lstrcmpiW(buf.str, root_keys[i].name))
396 break;
397 }
398 if(i == ARRAY_SIZE(root_keys)) {
399 WARN("Wrong root key name: %s\n", debugstr_w(buf.str));
401 break;
402 }
403 hres = get_word(&iter, &buf);
404 if(FAILED(hres))
405 break;
406 if(buf.str[1] || buf.str[0] != '{') {
407 WARN("Failed, expected '{', got %s\n", debugstr_w(buf.str));
409 break;
410 }
411 hres = do_process_key(&iter, root_keys[i].key, &buf, do_register);
412 if(FAILED(hres)) {
413 WARN("Processing key failed: %08lx\n", hres);
414 break;
415 }
416 hres = get_word(&iter, &buf);
417 if(FAILED(hres))
418 break;
419 }
420
421done:
422 free(buf.str);
423 return hres;
424}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct @314 root_keys[]
Definition: copy.c:22

Referenced by string_register().

◆ file_register()

static HRESULT file_register ( Registrar This,
LPCOLESTR  fileName,
BOOL  do_register 
)
static

Definition at line 491 of file registrar.c.

492{
493 HANDLE file;
494 DWORD filelen, len;
495 LPWSTR regstrw;
496 LPSTR regstra;
498
501 filelen = GetFileSize(file, NULL);
502 regstra = malloc(filelen);
503 if(ReadFile(file, regstra, filelen, NULL, NULL)) {
504 len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0)+1;
505 regstrw = calloc(len, sizeof(WCHAR));
506 MultiByteToWideChar(CP_ACP, 0, regstra, filelen, regstrw, len);
507 regstrw[len-1] = '\0';
508
509 hres = string_register(This, regstrw, do_register);
510
511 free(regstrw);
512 }else {
513 WARN("Failed to read file %s\n", debugstr_w(fileName));
515 }
516 free(regstra);
518 }else {
519 WARN("Could not open file %s\n", debugstr_w(fileName));
521 }
522
523 return hres;
524}
static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register)
Definition: registrar.c:426
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define MultiByteToWideChar
Definition: compat.h:110
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
GLenum GLsizei len
Definition: glext.h:6722
Definition: fci.c:123
uint16_t * LPWSTR
Definition: typedefs.h:56
char * LPSTR
Definition: typedefs.h:51
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by Registrar_FileRegister(), and Registrar_FileUnregister().

◆ get_word()

static HRESULT get_word ( LPCOLESTR *  str,
strbuf buf 
)
static

Definition at line 103 of file registrar.c.

104{
105 LPCOLESTR iter, iter2 = *str;
106
107 buf->len = 0;
108 buf->str[0] = '\0';
109
110 while(iswspace(*iter2))
111 iter2++;
112 iter = iter2;
113 if(!*iter) {
114 *str = iter;
115 return S_OK;
116 }
117
118 if(*iter == '}' || *iter == '=') {
119 strbuf_write(iter++, buf, 1);
120 }else if(*iter == '\'') {
121 for (;;)
122 {
123 iter2 = ++iter;
124 iter = wcschr(iter, '\'');
125 if(!iter) {
126 WARN("Unexpected end of script\n");
127 *str = iter;
128 return DISP_E_EXCEPTION;
129 }
130 if (iter[1] != '\'') break;
131 iter++;
132 strbuf_write(iter2, buf, iter-iter2);
133 }
134 strbuf_write(iter2, buf, iter-iter2);
135 iter++;
136 }else {
137 while(*iter && !iswspace(*iter))
138 iter++;
139 strbuf_write(iter2, buf, iter-iter2);
140 }
141
142 while(iswspace(*iter))
143 iter++;
144 *str = iter;
145 return S_OK;
146}
const WCHAR * str

◆ impl_from_IRegistrar()

◆ Registrar_AddRef()

static ULONG WINAPI Registrar_AddRef ( IRegistrar iface)
static

Definition at line 540 of file registrar.c.

541{
544 TRACE("(%p) ->%ld\n", This, ref);
545 return ref;
546}
#define InterlockedIncrement
Definition: armddk.h:53
static Registrar * impl_from_IRegistrar(IRegistrar *iface)
Definition: registrar.c:70
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ Registrar_AddReplacement()

static HRESULT WINAPI Registrar_AddReplacement ( IRegistrar iface,
LPCOLESTR  Key,
LPCOLESTR  item 
)
static

Definition at line 561 of file registrar.c.

562{
564 int len;
565 rep_list *new_rep;
566
567 TRACE("(%p)->(%s %s)\n", This, debugstr_w(Key), debugstr_w(item));
568
569 new_rep = malloc(sizeof(*new_rep));
570
571 new_rep->key_len = lstrlenW(Key);
572 new_rep->key = malloc((new_rep->key_len + 1) * sizeof(OLECHAR));
573 memcpy(new_rep->key, Key, (new_rep->key_len+1)*sizeof(OLECHAR));
574
575 len = lstrlenW(item)+1;
576 new_rep->item = malloc(len*sizeof(OLECHAR));
577 memcpy(new_rep->item, item, len*sizeof(OLECHAR));
578
579 new_rep->next = This->rep;
580 This->rep = new_rep;
581
582 return S_OK;
583}
WCHAR OLECHAR
Definition: compat.h:2292
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

◆ Registrar_ClearReplacements()

static HRESULT WINAPI Registrar_ClearReplacements ( IRegistrar iface)
static

Definition at line 585 of file registrar.c.

586{
588 rep_list *iter, *iter2;
589
590 TRACE("(%p)\n", This);
591
592 if(!This->rep)
593 return S_OK;
594
595 iter = This->rep;
596 while(iter) {
597 iter2 = iter->next;
598 free(iter->key);
599 free(iter->item);
600 free(iter);
601 iter = iter2;
602 }
603
604 This->rep = NULL;
605 return S_OK;
606}

◆ Registrar_FileRegister()

static HRESULT WINAPI Registrar_FileRegister ( IRegistrar iface,
LPCOLESTR  fileName 
)
static

Definition at line 624 of file registrar.c.

625{
627 TRACE("(%p)->(%s)\n", This, debugstr_w(fileName));
628 return file_register(This, fileName, TRUE);
629}
#define TRUE
Definition: types.h:120
static HRESULT file_register(Registrar *This, LPCOLESTR fileName, BOOL do_register)
Definition: registrar.c:491

◆ Registrar_FileUnregister()

static HRESULT WINAPI Registrar_FileUnregister ( IRegistrar iface,
LPCOLESTR  fileName 
)
static

Definition at line 631 of file registrar.c.

632{
634 FIXME("(%p)->(%s)\n", This, debugstr_w(fileName));
635 return file_register(This, fileName, FALSE);
636}
#define FALSE
Definition: types.h:117

◆ Registrar_QueryInterface()

static HRESULT WINAPI Registrar_QueryInterface ( IRegistrar iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 526 of file registrar.c.

527{
528 TRACE("(%p)->(%s %p\n", iface, debugstr_guid(riid), ppvObject);
529
531 || IsEqualGUID(&IID_IRegistrar, riid)
532 || IsEqualGUID(&IID_IRegistrarBase, riid)) {
533 IRegistrar_AddRef(iface);
534 *ppvObject = iface;
535 return S_OK;
536 }
537 return E_NOINTERFACE;
538}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ Registrar_Release()

static ULONG WINAPI Registrar_Release ( IRegistrar iface)
static

Definition at line 548 of file registrar.c.

549{
552
553 TRACE("(%p) ->%ld\n", This, ref);
554 if(!ref) {
555 IRegistrar_ClearReplacements(iface);
556 free(This);
557 }
558 return ref;
559}
#define InterlockedDecrement
Definition: armddk.h:52

◆ Registrar_ResourceRegister()

static HRESULT WINAPI Registrar_ResourceRegister ( IRegistrar iface,
LPCOLESTR  resFileName,
UINT  nID,
LPCOLESTR  szType 
)
static

Definition at line 652 of file registrar.c.

654{
656 TRACE("(%p)->(%s %d %s)\n", iface, debugstr_w(resFileName), nID, debugstr_w(szType));
657 return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, TRUE);
658}
static HRESULT resource_register(Registrar *This, LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
Definition: registrar.c:449
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ Registrar_ResourceRegisterSz()

static HRESULT WINAPI Registrar_ResourceRegisterSz ( IRegistrar iface,
LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType 
)
static

Definition at line 608 of file registrar.c.

610{
612 TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
613 return resource_register(This, resFileName, szID, szType, TRUE);
614}

◆ Registrar_ResourceUnregister()

static HRESULT WINAPI Registrar_ResourceUnregister ( IRegistrar iface,
LPCOLESTR  resFileName,
UINT  nID,
LPCOLESTR  szType 
)
static

Definition at line 660 of file registrar.c.

662{
664 TRACE("(%p)->(%s %d %s)\n", This, debugstr_w(resFileName), nID, debugstr_w(szType));
665 return resource_register(This, resFileName, MAKEINTRESOURCEW(nID), szType, FALSE);
666}

◆ Registrar_ResourceUnregisterSz()

static HRESULT WINAPI Registrar_ResourceUnregisterSz ( IRegistrar iface,
LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType 
)
static

Definition at line 616 of file registrar.c.

618{
620 TRACE("(%p)->(%s %s %s)\n", This, debugstr_w(resFileName), debugstr_w(szID), debugstr_w(szType));
621 return resource_register(This, resFileName, szID, szType, FALSE);
622}

◆ Registrar_StringRegister()

static HRESULT WINAPI Registrar_StringRegister ( IRegistrar iface,
LPCOLESTR  data 
)
static

Definition at line 638 of file registrar.c.

639{
641 TRACE("(%p)->(%s)\n", This, debugstr_w(data));
642 return string_register(This, data, TRUE);
643}

◆ Registrar_StringUnregister()

static HRESULT WINAPI Registrar_StringUnregister ( IRegistrar iface,
LPCOLESTR  data 
)
static

Definition at line 645 of file registrar.c.

646{
648 TRACE("(%p)->(%s)\n", This, debugstr_w(data));
649 return string_register(This, data, FALSE);
650}

◆ resource_register()

static HRESULT resource_register ( Registrar This,
LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType,
BOOL  do_register 
)
static

Definition at line 449 of file registrar.c.

451{
452 HINSTANCE hins;
453 HRSRC src;
454 LPSTR regstra;
455 LPWSTR regstrw;
458
459 hins = LoadLibraryExW(resFileName, NULL, LOAD_LIBRARY_AS_DATAFILE);
460 if(hins) {
461 src = FindResourceW(hins, szID, szType);
462 if(src) {
463 regstra = LoadResource(hins, src);
464 reslen = SizeofResource(hins, src);
465 if(regstra) {
466 len = MultiByteToWideChar(CP_ACP, 0, regstra, reslen, NULL, 0)+1;
467 regstrw = calloc(len, sizeof(WCHAR));
468 MultiByteToWideChar(CP_ACP, 0, regstra, reslen, regstrw, len);
469 regstrw[len-1] = '\0';
470
471 hres = string_register(This, regstrw, do_register);
472
473 free(regstrw);
474 }else {
475 WARN("could not load resource\n");
477 }
478 }else {
479 WARN("Could not find source\n");
481 }
482 FreeLibrary(hins);
483 }else {
484 WARN("Could not load resource file\n");
486 }
487
488 return hres;
489}
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
GLenum src
Definition: glext.h:6340
static DWORD LPDWORD reslen
Definition: directory.c:51
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338

Referenced by Registrar_ResourceRegister(), Registrar_ResourceRegisterSz(), Registrar_ResourceUnregister(), and Registrar_ResourceUnregisterSz().

◆ strbuf_init()

static void strbuf_init ( strbuf buf)
static

◆ strbuf_write()

static void strbuf_write ( LPCOLESTR  str,
strbuf buf,
int  len 
)
static

Definition at line 82 of file registrar.c.

83{
84 if(len == -1)
85 len = lstrlenW(str);
86 if(buf->len+len+1 >= buf->alloc) {
87 buf->alloc = (buf->len+len)<<1;
88 buf->str = realloc(buf->str, buf->alloc*sizeof(WCHAR));
89 }
90 memcpy(buf->str+buf->len, str, len*sizeof(OLECHAR));
91 buf->len += len;
92 buf->str[buf->len] = '\0';
93}
#define realloc
Definition: debug_ros.c:6

Referenced by do_preprocess(), do_process_key(), and get_word().

◆ string_register()

static HRESULT string_register ( Registrar This,
LPCOLESTR  data,
BOOL  do_register 
)
static

Definition at line 426 of file registrar.c.

427{
428 strbuf buf;
430
431 TRACE("(%p %s %x)\n", This, debugstr_w(data), do_register);
432
435 if(FAILED(hres)) {
436 WARN("preprocessing failed!\n");
437 free(buf.str);
438 return hres;
439 }
440
441 hres = do_process_root_key(buf.str, do_register);
442 if(FAILED(hres) && do_register)
444
445 free(buf.str);
446 return hres;
447}
static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf)
Definition: registrar.c:148
static HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
Definition: registrar.c:376

Referenced by file_register(), Registrar_StringRegister(), Registrar_StringUnregister(), and resource_register().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( atl  )

◆ xdigit_to_int()

static int xdigit_to_int ( WCHAR  c)
static

Definition at line 95 of file registrar.c.

96{
97 if('0' <= c && c <= '9') return c - '0';
98 if('a' <= c && c <= 'f') return c - 'a' + 10;
99 if('A' <= c && c <= 'F') return c - 'A' + 10;
100 return -1;
101}
const GLubyte * c
Definition: glext.h:8905

Referenced by do_process_key().

Variable Documentation

◆ key

Definition at line 33 of file registrar.c.

Referenced by test_registrar().

◆ name

WCHAR name[22]

Definition at line 32 of file registrar.c.

Referenced by do_process_key().

◆ RegistrarVtbl

const IRegistrarVtbl RegistrarVtbl
static
Initial value:
= {
}
static HRESULT WINAPI Registrar_QueryInterface(IRegistrar *iface, REFIID riid, void **ppvObject)
Definition: registrar.c:526
static HRESULT WINAPI Registrar_StringRegister(IRegistrar *iface, LPCOLESTR data)
Definition: registrar.c:638
static HRESULT WINAPI Registrar_ResourceUnregisterSz(IRegistrar *iface, LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: registrar.c:616
static HRESULT WINAPI Registrar_FileRegister(IRegistrar *iface, LPCOLESTR fileName)
Definition: registrar.c:624
static HRESULT WINAPI Registrar_StringUnregister(IRegistrar *iface, LPCOLESTR data)
Definition: registrar.c:645
static ULONG WINAPI Registrar_AddRef(IRegistrar *iface)
Definition: registrar.c:540
static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface)
Definition: registrar.c:585
static ULONG WINAPI Registrar_Release(IRegistrar *iface)
Definition: registrar.c:548
static HRESULT WINAPI Registrar_FileUnregister(IRegistrar *iface, LPCOLESTR fileName)
Definition: registrar.c:631
static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key, LPCOLESTR item)
Definition: registrar.c:561
static HRESULT WINAPI Registrar_ResourceRegister(IRegistrar *iface, LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
Definition: registrar.c:652
static HRESULT WINAPI Registrar_ResourceRegisterSz(IRegistrar *iface, LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: registrar.c:608
static HRESULT WINAPI Registrar_ResourceUnregister(IRegistrar *iface, LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
Definition: registrar.c:660

Definition at line 668 of file registrar.c.

Referenced by AtlCreateRegistrar().

◆ 

const struct { ... } root_keys[]
Initial value:
= {
{L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT},
{L"HKEY_CURRENT_USER", HKEY_CURRENT_USER},
{L"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE},
{L"HKEY_USERS", HKEY_USERS},
{L"HKEY_PERFORMANCE_DATA", HKEY_PERFORMANCE_DATA},
{L"HKEY_DYN_DATA", HKEY_DYN_DATA},
{L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG},
{L"HKCR", HKEY_CLASSES_ROOT},
{L"HKCU", HKEY_CURRENT_USER},
{L"HKU", HKEY_USERS},
{L"HKDD", HKEY_DYN_DATA},
}
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_DYN_DATA
Definition: winreg.h:16
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_PERFORMANCE_DATA
Definition: winreg.h:14
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_USERS
Definition: winreg.h:13

Referenced by do_process_root_key(), and ATL::CRegObject::do_process_root_key().