ReactOS 0.4.16-dev-106-g10b08aa
registrar.c File Reference
#include "wine/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 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 = HeapAlloc(GetProcessHeap(), 0, sizeof(*registrar));
692 if(!registrar)
693 return E_OUTOFMEMORY;
694
695 registrar->IRegistrar_iface.lpVtbl = &RegistrarVtbl;
696 registrar->ref = 1;
697 registrar->rep = NULL;
698
699 *ret = &registrar->IRegistrar_iface;
700 return S_OK;
701}
rep_list * rep
Definition: registrar.c:68
IRegistrar IRegistrar_iface
Definition: registrar.c:66
LONG ref
Definition: registrar.c:67
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
static const IRegistrarVtbl RegistrarVtbl
Definition: registrar.c:668
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define S_OK
Definition: intsafe.h:52
int ret

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 706 of file registrar.c.

708{
709 const struct _ATL_REGMAP_ENTRY *iter;
711 IRegistrar *registrar;
713
714 static const WCHAR moduleW[] = {'M','O','D','U','L','E',0};
715 static const WCHAR registryW[] = {'R','E','G','I','S','T','R','Y',0};
716
718 FIXME("hinst %p: did not get module name\n", inst);
719 return E_FAIL;
720 }
721
722 TRACE("%p (%s), %s, %d, %p, %p\n", inst, debugstr_w(module_name),
723 debugstr_w(res), bRegister, pMapEntries, pReg);
724
725 if(pReg) {
726 registrar = pReg;
727 }else {
728 hres = AtlCreateRegistrar(&registrar);
729 if(FAILED(hres))
730 return hres;
731 }
732
733 IRegistrar_AddReplacement(registrar, moduleW, module_name);
734
735 for (iter = pMapEntries; iter && iter->szKey; iter++)
736 IRegistrar_AddReplacement(registrar, iter->szKey, iter->szData);
737
738 if(bRegister)
739 hres = IRegistrar_ResourceRegisterSz(registrar, module_name, res, registryW);
740 else
741 hres = IRegistrar_ResourceUnregisterSz(registrar, module_name, res, registryW);
742
743 if(registrar != pReg)
744 IRegistrar_Release(registrar);
745 return hres;
746}
#define FIXME(fmt,...)
Definition: precomp.h:53
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:170
#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
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
static const WCHAR moduleW[]
Definition: register.c:35
#define TRACE(s)
Definition: solgame.cpp:4
Definition: atlbase.h:242
LPCOLESTR szKey
Definition: atlbase.h:243
LPCOLESTR szData
Definition: atlbase.h:244
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by AtlModuleUpdateRegistryFromResourceD().

◆ do_preprocess()

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

Definition at line 141 of file registrar.c.

142{
143 LPCOLESTR iter, iter2 = data;
144 rep_list *rep_iter;
145 static const WCHAR wstr[] = {'%',0};
146
147 iter = wcschr(data, '%');
148 while(iter) {
149 strbuf_write(iter2, buf, iter-iter2);
150
151 iter2 = ++iter;
152 if(!*iter2)
153 return DISP_E_EXCEPTION;
154 iter = wcschr(iter2, '%');
155 if(!iter)
156 return DISP_E_EXCEPTION;
157
158 if(iter == iter2) {
159 strbuf_write(wstr, buf, 1);
160 }else {
161 for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) {
162 if(rep_iter->key_len == iter-iter2
163 && !_wcsnicmp(iter2, rep_iter->key, rep_iter->key_len))
164 break;
165 }
166 if(!rep_iter) {
167 WARN("Could not find replacement: %s\n", debugstr_wn(iter2, iter-iter2));
168 return DISP_E_EXCEPTION;
169 }
170
171 strbuf_write(rep_iter->item, buf, -1);
172 }
173
174 iter2 = ++iter;
175 iter = wcschr(iter, '%');
176 }
177
178 strbuf_write(iter2, buf, -1);
179 TRACE("%s\n", debugstr_w(buf->str));
180
181 return S_OK;
182}
#define WARN(fmt,...)
Definition: precomp.h:61
static void strbuf_write(LPCOLESTR str, strbuf *buf, int len)
Definition: registrar.c:89
#define wcschr
Definition: compat.h:17
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
_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)
LPOLESTR item
Definition: registrar.c:60
LPOLESTR key
Definition: registrar.c:59
struct rep_list_str * next
Definition: registrar.c:62
#define DISP_E_EXCEPTION
Definition: winerror.h:2518

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 184 of file registrar.c.

185{
186 LPCOLESTR iter;
188 LONG lres;
189 HKEY hkey = 0;
190 strbuf name;
191
192 enum {
193 NORMAL,
194 NO_REMOVE,
195 IS_VAL,
196 FORCE_REMOVE,
197 DO_DELETE
198 } key_type = NORMAL;
199
200 static const WCHAR wstrNoRemove[] = {'N','o','R','e','m','o','v','e',0};
201 static const WCHAR wstrForceRemove[] = {'F','o','r','c','e','R','e','m','o','v','e',0};
202 static const WCHAR wstrDelete[] = {'D','e','l','e','t','e',0};
203 static const WCHAR wstrval[] = {'v','a','l',0};
204
205 iter = *pstr;
206 hres = get_word(&iter, buf);
207 if(FAILED(hres))
208 return hres;
210
211 while(buf->str[1] || buf->str[0] != '}') {
212 key_type = NORMAL;
213 if(!lstrcmpiW(buf->str, wstrNoRemove))
214 key_type = NO_REMOVE;
215 else if(!lstrcmpiW(buf->str, wstrForceRemove))
216 key_type = FORCE_REMOVE;
217 else if(!lstrcmpiW(buf->str, wstrval))
218 key_type = IS_VAL;
219 else if(!lstrcmpiW(buf->str, wstrDelete))
220 key_type = DO_DELETE;
221
222 if(key_type != NORMAL) {
223 hres = get_word(&iter, buf);
224 if(FAILED(hres))
225 break;
226 }
227 TRACE("name = %s\n", debugstr_w(buf->str));
228
229 if(do_register) {
230 if(key_type == IS_VAL) {
231 hkey = parent_key;
232 strbuf_write(buf->str, &name, -1);
233 }else if(key_type == DO_DELETE) {
234 TRACE("Deleting %s\n", debugstr_w(buf->str));
235 RegDeleteTreeW(parent_key, buf->str);
236 }else {
237 if(key_type == FORCE_REMOVE)
238 RegDeleteTreeW(parent_key, buf->str);
239 lres = RegCreateKeyW(parent_key, buf->str, &hkey);
240 if(lres != ERROR_SUCCESS) {
241 WARN("Could not create(open) key: %08x\n", lres);
242 hres = HRESULT_FROM_WIN32(lres);
243 break;
244 }
245 }
246 }else if(key_type != IS_VAL && key_type != DO_DELETE) {
247 strbuf_write(buf->str, &name, -1);
248 lres = RegOpenKeyW(parent_key, buf->str, &hkey);
249 if(lres != ERROR_SUCCESS)
250 WARN("Could not open key %s: %08x\n", debugstr_w(name.str), lres);
251 }
252
253 if(key_type != DO_DELETE && *iter == '=') {
254 iter++;
255 hres = get_word(&iter, buf);
256 if(FAILED(hres))
257 break;
258 if(buf->len != 1) {
259 WARN("Wrong registry type: %s\n", debugstr_w(buf->str));
261 break;
262 }
263 if(do_register) {
264 switch(buf->str[0]) {
265 case 's':
266 hres = get_word(&iter, buf);
267 if(FAILED(hres))
268 break;
269 lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_SZ, (PBYTE)buf->str,
270 (lstrlenW(buf->str)+1)*sizeof(WCHAR));
271 if(lres != ERROR_SUCCESS) {
272 WARN("Could set value of key: %08x\n", lres);
273 hres = HRESULT_FROM_WIN32(lres);
274 break;
275 }
276 break;
277 case 'd': {
278 DWORD dw;
279 hres = get_word(&iter, buf);
280 if(FAILED(hres))
281 break;
282 dw = wcstol(buf->str, NULL, 10);
283 lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_DWORD,
284 (PBYTE)&dw, sizeof(dw));
285 if(lres != ERROR_SUCCESS) {
286 WARN("Could set value of key: %08x\n", lres);
287 hres = HRESULT_FROM_WIN32(lres);
288 break;
289 }
290 break;
291 }
292 case 'b': {
293 BYTE *bytes;
294 DWORD count;
295 DWORD i;
296 hres = get_word(&iter, buf);
297 if(FAILED(hres))
298 break;
299 count = (lstrlenW(buf->str) + 1) / 2;
301 if(bytes == NULL) {
303 break;
304 }
305 for(i = 0; i < count && buf->str[2*i]; i++) {
306 WCHAR digits[3];
307 if(!iswxdigit(buf->str[2*i]) || !iswxdigit(buf->str[2*i + 1])) {
308 hres = E_FAIL;
309 break;
310 }
311 digits[0] = buf->str[2*i];
312 digits[1] = buf->str[2*i + 1];
313 digits[2] = 0;
314 bytes[i] = (BYTE) wcstoul(digits, NULL, 16);
315 }
316 if(SUCCEEDED(hres)) {
317 lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_BINARY,
318 bytes, count);
319 if(lres != ERROR_SUCCESS) {
320 WARN("Could not set value of key: 0x%08x\n", lres);
321 hres = HRESULT_FROM_WIN32(lres);
322 }
323 }
325 break;
326 }
327 default:
328 WARN("Wrong resource type: %s\n", debugstr_w(buf->str));
330 };
331 if(FAILED(hres))
332 break;
333 }else {
334 if(*iter == '-')
335 iter++;
336 hres = get_word(&iter, buf);
337 if(FAILED(hres))
338 break;
339 }
340 }else if(key_type == IS_VAL) {
341 WARN("value not set!\n");
343 break;
344 }
345
346 if(key_type != IS_VAL && key_type != DO_DELETE && *iter == '{' && iswspace(iter[1])) {
347 hres = get_word(&iter, buf);
348 if(FAILED(hres))
349 break;
350 hres = do_process_key(&iter, hkey, buf, do_register);
351 if(FAILED(hres))
352 break;
353 }
354
355 TRACE("%x %x\n", do_register, key_type);
356 if(!do_register && (key_type == NORMAL || key_type == FORCE_REMOVE)) {
357 TRACE("Deleting %s\n", debugstr_w(name.str));
358 RegDeleteKeyW(parent_key, name.str);
359 }
360
361 if(hkey && key_type != IS_VAL)
362 RegCloseKey(hkey);
363 hkey = 0;
364 name.len = 0;
365
366 hres = get_word(&iter, buf);
367 if(FAILED(hres))
368 break;
369 }
370
371 HeapFree(GetProcessHeap(), 0, name.str);
372 if(hkey && key_type != IS_VAL)
373 RegCloseKey(hkey);
374 *pstr = iter;
375 return hres;
376}
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 ERROR_SUCCESS
Definition: deptool.c:10
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 HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
Definition: registrar.c:184
WCHAR name[22]
Definition: registrar.c:32
static void strbuf_init(strbuf *buf)
Definition: registrar.c:82
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
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
#define iswspace(_c)
Definition: ctype.h:669
#define iswxdigit(_c)
Definition: ctype.h:668
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static const int digits[]
Definition: decode.c:71
#define REG_SZ
Definition: layer.c:22
#define REG_BINARY
Definition: nt_native.h:1496
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
Definition: name.c:39
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
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 378 of file registrar.c.

379{
380 LPCOLESTR iter = data;
381 strbuf buf;
383 unsigned int i;
384
386 hres = get_word(&iter, &buf);
387 if(FAILED(hres))
388 return hres;
389
390 while(*iter) {
391 if(!buf.len) {
392 WARN("ward.len == 0, failed\n");
394 break;
395 }
396 for(i=0; i<ARRAY_SIZE(root_keys); i++) {
397 if(!lstrcmpiW(buf.str, root_keys[i].name))
398 break;
399 }
400 if(i == ARRAY_SIZE(root_keys)) {
401 WARN("Wrong root key name: %s\n", debugstr_w(buf.str));
403 break;
404 }
405 hres = get_word(&iter, &buf);
406 if(FAILED(hres))
407 break;
408 if(buf.str[1] || buf.str[0] != '{') {
409 WARN("Failed, expected '{', got %s\n", debugstr_w(buf.str));
411 break;
412 }
413 hres = do_process_key(&iter, root_keys[i].key, &buf, do_register);
414 if(FAILED(hres)) {
415 WARN("Processing key failed: %08x\n", hres);
416 break;
417 }
418 hres = get_word(&iter, &buf);
419 if(FAILED(hres))
420 break;
421 }
422 HeapFree(GetProcessHeap(), 0, buf.str);
423 return hres;
424}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct @322 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 = HeapAlloc(GetProcessHeap(), 0, filelen);
503 if(ReadFile(file, regstra, filelen, NULL, NULL)) {
504 len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0)+1;
505 regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 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 HeapFree(GetProcessHeap(), 0, regstrw);
512 }else {
513 WARN("Failed to read file %s\n", debugstr_w(fileName));
515 }
516 HeapFree(GetProcessHeap(), 0, 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
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
GLenum GLsizei len
Definition: glext.h:6722
Definition: fci.c:127
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Registrar_FileRegister(), and Registrar_FileUnregister().

◆ get_word()

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

Definition at line 102 of file registrar.c.

103{
104 LPCOLESTR iter, iter2 = *str;
105
106 buf->len = 0;
107 buf->str[0] = '\0';
108
109 while(iswspace(*iter2))
110 iter2++;
111 iter = iter2;
112 if(!*iter) {
113 *str = iter;
114 return S_OK;
115 }
116
117 if(*iter == '}' || *iter == '=') {
118 strbuf_write(iter++, buf, 1);
119 }else if(*iter == '\'') {
120 iter2 = ++iter;
121 iter = wcschr(iter, '\'');
122 if(!iter) {
123 WARN("Unexpected end of script\n");
124 *str = iter;
125 return DISP_E_EXCEPTION;
126 }
127 strbuf_write(iter2, buf, iter-iter2);
128 iter++;
129 }else {
130 while(*iter && !iswspace(*iter))
131 iter++;
132 strbuf_write(iter2, buf, iter-iter2);
133 }
134
135 while(iswspace(*iter))
136 iter++;
137 *str = iter;
138 return S_OK;
139}
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) ->%d\n", This, ref);
545 return ref;
546}
#define InterlockedIncrement
Definition: armddk.h:53
static Registrar * impl_from_IRegistrar(IRegistrar *iface)
Definition: registrar.c:77
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 = HeapAlloc(GetProcessHeap(), 0, sizeof(rep_list));
570
571 new_rep->key_len = lstrlenW(Key);
572 new_rep->key = HeapAlloc(GetProcessHeap(), 0, (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 = HeapAlloc(GetProcessHeap(), 0, 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
static ATOM item
Definition: dde.c:856

◆ 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 HeapFree(GetProcessHeap(), 0, iter->key);
599 HeapFree(GetProcessHeap(), 0, iter->item);
600 HeapFree(GetProcessHeap(), 0, 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
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ Registrar_Release()

static ULONG WINAPI Registrar_Release ( IRegistrar iface)
static

Definition at line 548 of file registrar.c.

549{
552
553 TRACE("(%p) ->%d\n", This, ref);
554 if(!ref) {
555 IRegistrar_ClearReplacements(iface);
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 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 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 HeapFree(GetProcessHeap(), 0, 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:342

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 89 of file registrar.c.

90{
91 if(len == -1)
92 len = lstrlenW(str);
93 if(buf->len+len+1 >= buf->alloc) {
94 buf->alloc = (buf->len+len)<<1;
95 buf->str = HeapReAlloc(GetProcessHeap(), 0, buf->str, buf->alloc*sizeof(WCHAR));
96 }
97 memcpy(buf->str+buf->len, str, len*sizeof(OLECHAR));
98 buf->len += len;
99 buf->str[buf->len] = '\0';
100}
#define HeapReAlloc
Definition: compat.h:734

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 HeapFree(GetProcessHeap(), 0, 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 HeapFree(GetProcessHeap(), 0, buf.str);
446 return hres;
447}
static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf)
Definition: registrar.c:141
static HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
Definition: registrar.c:378

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

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( atl  )

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:
= {
{{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0},
{{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0},
{{'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0},
{{'H','K','E','Y','_','U','S','E','R','S',0},
{{'H','K','E','Y','_','P','E','R','F','O','R','M','A','N','C','E','_','D','A','T','A',0},
{{'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0},
{{'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0},
{{'H','K','C','R',0}, HKEY_CLASSES_ROOT},
{{'H','K','C','U',0}, HKEY_CURRENT_USER},
{{'H','K','L','M',0}, HKEY_LOCAL_MACHINE},
{{'H','K','U',0}, HKEY_USERS},
{{'H','K','P','D',0}, HKEY_PERFORMANCE_DATA},
{{'H','K','D','D',0}, HKEY_DYN_DATA},
{{'H','K','C','C',0}, HKEY_CURRENT_CONFIG}
}
#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().