ReactOS  0.4.14-dev-98-gb0d4763
statreg.h
Go to the documentation of this file.
1 /*
2  * ReactOS ATL
3  *
4  * Copyright 2005 Jacek Caban
5  * Copyright 2009 Andrew Hill <ash77@reactos.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #pragma once
23 
24 class IRegistrarBase : public IUnknown
25 {
26 public:
27  virtual HRESULT STDMETHODCALLTYPE AddReplacement(LPCOLESTR key, LPCOLESTR item) = 0;
29 };
30 
31 namespace ATL
32 {
33 
34 class CRegObject : public IRegistrarBase
35 {
36 public:
37  typedef struct rep_list_str
38  {
41  int key_len;
42  struct rep_list_str *next;
43  } rep_list;
44 
45  typedef struct
46  {
50  } strbuf;
51 
53 
54 public:
56  {
57  m_rep = NULL;
58  }
59 
61  {
62  HRESULT hResult;
63 
64  hResult = ClearReplacements();
65  ATLASSERT(SUCCEEDED(hResult));
66  (void)hResult;
67  }
68 
69  HRESULT STDMETHODCALLTYPE QueryInterface(const IID & /* riid */, void ** /* ppvObject */ )
70  {
71  ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function"));
72  return E_NOTIMPL;
73  }
74 
76  {
77  ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function"));
78  return 1;
79  }
80 
82  {
83  ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function"));
84  return 0;
85  }
86 
88  {
89  int len;
90  rep_list *new_rep;
91 
92  new_rep = reinterpret_cast<rep_list *>(HeapAlloc(GetProcessHeap(), 0, sizeof(rep_list)));
93  if (new_rep == NULL)
94  return E_OUTOFMEMORY;
95 
96  new_rep->key_len = lstrlenW(key);
97  new_rep->key = reinterpret_cast<OLECHAR *>(HeapAlloc(GetProcessHeap(), 0, (new_rep->key_len + 1) * sizeof(OLECHAR)));
98  if (new_rep->key == NULL)
99  {
100  HeapFree(GetProcessHeap(), 0, new_rep);
101  return E_OUTOFMEMORY;
102  }
103  memcpy(new_rep->key, key, (new_rep->key_len + 1) * sizeof(OLECHAR));
104 
105  len = lstrlenW(item) + 1;
106  new_rep->item = reinterpret_cast<OLECHAR *>(HeapAlloc(GetProcessHeap(), 0, len * sizeof(OLECHAR)));
107  if (new_rep->item == NULL)
108  {
109  HeapFree(GetProcessHeap(), 0, new_rep->key);
110  HeapFree(GetProcessHeap(), 0, new_rep);
111  return E_OUTOFMEMORY;
112  }
113  memcpy(new_rep->item, item, len * sizeof(OLECHAR));
114 
115  new_rep->next = m_rep;
116  m_rep = new_rep;
117 
118  return S_OK;
119  }
120 
122  {
123  rep_list *iter;
124  rep_list *iter2;
125 
126  iter = m_rep;
127  while (iter)
128  {
129  iter2 = iter->next;
130  HeapFree(GetProcessHeap(), 0, iter->key);
131  HeapFree(GetProcessHeap(), 0, iter->item);
132  HeapFree(GetProcessHeap(), 0, iter);
133  iter = iter2;
134  }
135 
136  m_rep = NULL;
137  return S_OK;
138  }
139 
140  HRESULT STDMETHODCALLTYPE ResourceRegisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
141  {
142  return RegisterWithResource(resFileName, szID, szType, TRUE);
143  }
144 
145  HRESULT STDMETHODCALLTYPE ResourceUnregisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
146  {
147  return RegisterWithResource(resFileName, szID, szType, FALSE);
148  }
149 
151  {
152  return RegisterWithFile(fileName, TRUE);
153  }
154 
156  {
157  return RegisterWithFile(fileName, FALSE);
158  }
159 
161  {
162  return RegisterWithString(data, TRUE);
163  }
164 
166  {
167  return RegisterWithString(data, FALSE);
168  }
169 
170  HRESULT STDMETHODCALLTYPE ResourceRegister(LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
171  {
172  return ResourceRegisterSz(resFileName, MAKEINTRESOURCEW(nID), szType);
173  }
174 
175  HRESULT STDMETHODCALLTYPE ResourceUnregister(LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
176  {
177  return ResourceUnregisterSz(resFileName, MAKEINTRESOURCEW(nID), szType);
178  }
179 
180 protected:
181  HRESULT STDMETHODCALLTYPE RegisterWithResource(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL doRegister)
182  {
183  return resource_register(resFileName, szID, szType, doRegister);
184  }
185 
186  HRESULT STDMETHODCALLTYPE RegisterWithFile(LPCOLESTR fileName, BOOL doRegister)
187  {
188  return file_register(fileName, doRegister);
189  }
190 
192  {
193  return string_register(data, doRegister);
194  }
195 
196 private:
197  inline LONG RegDeleteTreeX(HKEY parentKey, LPCWSTR subKeyName)
198  {
199  wchar_t szBuffer[256];
200  DWORD dwSize;
201  FILETIME time;
202  HKEY childKey;
203  LONG lRes;
204 
205  ATLASSERT(parentKey != NULL);
206  lRes = RegOpenKeyExW(parentKey, subKeyName, 0, KEY_READ | KEY_WRITE, &childKey);
207  if (lRes != ERROR_SUCCESS)
208  return lRes;
209 
210  dwSize = sizeof(szBuffer) / sizeof(szBuffer[0]);
211  while (RegEnumKeyExW(parentKey, 0, szBuffer, &dwSize, NULL, NULL, NULL, &time) == ERROR_SUCCESS)
212  {
213  lRes = RegDeleteTreeX(childKey, szBuffer);
214  if (lRes != ERROR_SUCCESS)
215  return lRes;
216  dwSize = sizeof(szBuffer) / sizeof(szBuffer[0]);
217  }
218  RegCloseKey(childKey);
219  return RegDeleteKeyW(parentKey, subKeyName);
220  }
221 
223  {
224  buf->str = reinterpret_cast<LPOLESTR>(HeapAlloc(GetProcessHeap(), 0, 128 * sizeof(WCHAR)));
225  if (buf->str == NULL)
226  return E_OUTOFMEMORY;
227  buf->alloc = 128;
228  buf->len = 0;
229  return S_OK;
230  }
231 
232  HRESULT strbuf_write(LPCOLESTR str, strbuf *buf, int len)
233  {
235 
236  if (len == -1)
237  len = lstrlenW(str);
238  if (buf->len + len + 1 >= buf->alloc)
239  {
240  buf->alloc = (buf->len + len) * 2;
241  newBuffer = reinterpret_cast<LPOLESTR>(HeapReAlloc(GetProcessHeap(), 0, buf->str, buf->alloc * sizeof(WCHAR)));
242  if (newBuffer == NULL)
243  return E_OUTOFMEMORY;
244  buf->str = newBuffer;
245  }
246  memcpy(buf->str + buf->len, str, len * sizeof(OLECHAR));
247  buf->len += len;
248  buf->str[buf->len] = '\0';
249  return S_OK;
250  }
251 
252 
253  HRESULT file_register(LPCOLESTR fileName, BOOL do_register)
254  {
255  HANDLE file;
256  DWORD filelen;
257  DWORD len;
258  LPWSTR regstrw;
259  LPSTR regstra;
260  LRESULT lres;
261  HRESULT hResult;
262 
264  if (file != INVALID_HANDLE_VALUE)
265  {
266  filelen = GetFileSize(file, NULL);
267  regstra = reinterpret_cast<LPSTR>(HeapAlloc(GetProcessHeap(), 0, filelen));
268  if (regstra == NULL)
269  return E_OUTOFMEMORY;
270  lres = ReadFile(file, regstra, filelen, NULL, NULL);
271  if (lres == ERROR_SUCCESS)
272  {
273  len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0) + 1;
274  regstrw = reinterpret_cast<LPWSTR>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR)));
275  if (regstrw == NULL)
276  {
277  HeapFree(GetProcessHeap(), 0, regstra);
278  return E_OUTOFMEMORY;
279  }
280  MultiByteToWideChar(CP_ACP, 0, regstra, filelen, regstrw, len);
281  regstrw[len - 1] = '\0';
282 
283  hResult = string_register(regstrw, do_register);
284 
285  HeapFree(GetProcessHeap(), 0, regstrw);
286  }
287  else
288  {
289  hResult = HRESULT_FROM_WIN32(lres);
290  }
291  HeapFree(GetProcessHeap(), 0, regstra);
292  CloseHandle(file);
293  }
294  else
295  {
296  hResult = HRESULT_FROM_WIN32(GetLastError());
297  }
298 
299  return hResult;
300  }
301 
302  HRESULT resource_register(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
303  {
304  HINSTANCE hins;
305  HRSRC src;
306  HGLOBAL regstra;
307  LPWSTR regstrw;
308  DWORD len;
309  DWORD reslen;
310  HRESULT hResult;
311 
312  hins = LoadLibraryExW(resFileName, NULL, LOAD_LIBRARY_AS_DATAFILE);
313  if (hins)
314  {
315  src = FindResourceW(hins, szID, szType);
316  if (src)
317  {
318  regstra = LoadResource(hins, src);
319  reslen = SizeofResource(hins, src);
320  if (regstra)
321  {
322  len = MultiByteToWideChar(CP_ACP, 0, reinterpret_cast<LPCSTR>(regstra), reslen, NULL, 0) + 1;
323  regstrw = reinterpret_cast<LPWSTR>(HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR)));
324  if (regstrw == NULL)
325  return E_OUTOFMEMORY;
326  MultiByteToWideChar(CP_ACP, 0, reinterpret_cast<LPCSTR>(regstra), reslen, regstrw, len);
327  regstrw[len - 1] = '\0';
328 
329  hResult = string_register(regstrw, do_register);
330 
331  HeapFree(GetProcessHeap(), 0, regstrw);
332  }
333  else
334  hResult = HRESULT_FROM_WIN32(GetLastError());
335  }
336  else
337  hResult = HRESULT_FROM_WIN32(GetLastError());
338  FreeLibrary(hins);
339  }
340  else
341  hResult = HRESULT_FROM_WIN32(GetLastError());
342 
343  return hResult;
344  }
345 
346  HRESULT string_register(LPCOLESTR data, BOOL do_register)
347  {
348  strbuf buf;
349  HRESULT hResult;
350 
351  hResult = strbuf_init(&buf);
352  if (FAILED(hResult))
353  return hResult;
354  hResult = do_preprocess(data, &buf);
355  if (SUCCEEDED(hResult))
356  {
357  hResult = do_process_root_key(buf.str, do_register);
358  if (FAILED(hResult) && do_register)
360  }
361 
362  HeapFree(GetProcessHeap(), 0, buf.str);
363  return hResult;
364  }
365 
367  {
368  LPCOLESTR iter;
369  LPCOLESTR iter2;
370  rep_list *rep_iter;
371  HRESULT hResult;
372 
373  iter2 = data;
374  iter = wcschr(data, '%');
375  while (iter)
376  {
377  hResult = strbuf_write(iter2, buf, static_cast<int>(iter - iter2));
378  if (FAILED(hResult))
379  return hResult;
380 
381  iter2 = ++iter;
382  if (!*iter2)
383  return DISP_E_EXCEPTION;
384  iter = wcschr(iter2, '%');
385  if (!iter)
386  return DISP_E_EXCEPTION;
387 
388  if (iter == iter2)
389  {
390  hResult = strbuf_write(L"%", buf, 1);
391  if (FAILED(hResult))
392  return hResult;
393  }
394  else
395  {
396  for (rep_iter = m_rep; rep_iter; rep_iter = rep_iter->next)
397  {
398  if (rep_iter->key_len == iter - iter2 && !_memicmp(iter2, rep_iter->key, rep_iter->key_len * sizeof(wchar_t)))
399  break;
400  }
401  if (!rep_iter)
402  return DISP_E_EXCEPTION;
403 
404  hResult = strbuf_write(rep_iter->item, buf, -1);
405  if (FAILED(hResult))
406  return hResult;
407  }
408 
409  iter2 = ++iter;
410  iter = wcschr(iter, '%');
411  }
412 
413  hResult = strbuf_write(iter2, buf, -1);
414  if (FAILED(hResult))
415  return hResult;
416 
417  return S_OK;
418  }
419 
420  HRESULT get_word(LPCOLESTR *str, strbuf *buf)
421  {
422  LPCOLESTR iter;
423  LPCOLESTR iter2;
424  HRESULT hResult;
425 
426  iter2 = *str;
427  buf->len = 0;
428  buf->str[0] = '\0';
429 
430  while (iswspace (*iter2))
431  iter2++;
432  iter = iter2;
433  if (!*iter)
434  {
435  *str = iter;
436  return S_OK;
437  }
438 
439  if (*iter == '}' || *iter == '=')
440  {
441  hResult = strbuf_write(iter++, buf, 1);
442  if (FAILED(hResult))
443  return hResult;
444  }
445  else if (*iter == '\'')
446  {
447  iter2 = ++iter;
448  iter = wcschr(iter, '\'');
449  if (!iter)
450  {
451  *str = iter;
452  return DISP_E_EXCEPTION;
453  }
454  hResult = strbuf_write(iter2, buf, static_cast<int>(iter - iter2));
455  if (FAILED(hResult))
456  return hResult;
457  iter++;
458  }
459  else
460  {
461  while (*iter && !iswspace(*iter))
462  iter++;
463  hResult = strbuf_write(iter2, buf, static_cast<int>(iter - iter2));
464  if (FAILED(hResult))
465  return hResult;
466  }
467 
468  while (iswspace(*iter))
469  iter++;
470  *str = iter;
471  return S_OK;
472  }
473 
474  inline unsigned int HexToBin(OLECHAR a)
475  {
476  if (a >= '0' && a <= '9')
477  return a - '0';
478  if (a >= 'A' && a <= 'F')
479  return a - 'A' + 10;
480  if (a >= 'a' && a <= 'f')
481  return a - 'a' + 10;
482  ATLASSERT(false);
483  return 0;
484  }
485 
486  HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
487  {
488  LPCOLESTR iter;
489  HRESULT hres;
490  LONG lres;
491  HKEY hkey;
492  strbuf name;
493 
494  enum {
495  NORMAL,
496  NO_REMOVE,
497  IS_VAL,
498  FORCE_REMOVE,
499  DO_DELETE
500  } key_type = NORMAL;
501 
502  static const wchar_t *wstrNoRemove = L"NoRemove";
503  static const wchar_t *wstrForceRemove = L"ForceRemove";
504  static const wchar_t *wstrDelete = L"Delete";
505  static const wchar_t *wstrval = L"val";
506 
507  iter = *pstr;
508  hkey = NULL;
509  hres = get_word(&iter, buf);
510  if (FAILED(hres))
511  return hres;
512  hres = strbuf_init(&name);
513  if (FAILED(hres))
514  return hres;
515 
516  while(buf->str[1] || buf->str[0] != '}')
517  {
518  key_type = NORMAL;
519  if (!lstrcmpiW(buf->str, wstrNoRemove))
520  key_type = NO_REMOVE;
521  else if (!lstrcmpiW(buf->str, wstrForceRemove))
522  key_type = FORCE_REMOVE;
523  else if (!lstrcmpiW(buf->str, wstrval))
524  key_type = IS_VAL;
525  else if (!lstrcmpiW(buf->str, wstrDelete))
526  key_type = DO_DELETE;
527 
528  if (key_type != NORMAL)
529  {
530  hres = get_word(&iter, buf);
531  if (FAILED(hres))
532  break;
533  }
534 
535  if (do_register)
536  {
537  if (key_type == IS_VAL)
538  {
539  hkey = parent_key;
540  hres = strbuf_write(buf->str, &name, -1);
541  if (FAILED(hres))
542  return hres;
543  }
544  else if (key_type == DO_DELETE)
545  {
546  RegDeleteTreeX(parent_key, buf->str);
547  }
548  else
549  {
550  if (key_type == FORCE_REMOVE)
551  RegDeleteTreeX(parent_key, buf->str);
552  lres = RegCreateKeyW(parent_key, buf->str, &hkey);
553  if (lres != ERROR_SUCCESS)
554  {
555  hres = HRESULT_FROM_WIN32(lres);
556  break;
557  }
558  }
559  }
560  else if (key_type != IS_VAL && key_type != DO_DELETE)
561  {
562  hres = strbuf_write(buf->str, &name, -1);
563  if (FAILED(hres))
564  return hres;
565  lres = RegOpenKeyW(parent_key, buf->str, &hkey);
566  if (lres != ERROR_SUCCESS)
567  {
568  }
569  }
570 
571  if (key_type != DO_DELETE && *iter == '=')
572  {
573  iter++;
574  hres = get_word(&iter, buf);
575  if (FAILED(hres))
576  break;
577  if (buf->len != 1)
578  {
580  break;
581  }
582  if (do_register)
583  {
584  switch(buf->str[0])
585  {
586  case 's':
587  hres = get_word(&iter, buf);
588  if (FAILED(hres))
589  break;
590  lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_SZ, (PBYTE)buf->str,
591  (lstrlenW(buf->str) + 1) * sizeof(WCHAR));
592  if (lres != ERROR_SUCCESS)
593  hres = HRESULT_FROM_WIN32(lres);
594  break;
595  case 'e':
596  hres = get_word(&iter, buf);
597  if (FAILED(hres))
598  break;
599  lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_EXPAND_SZ, (PBYTE)buf->str,
600  (lstrlenW(buf->str) + 1) * sizeof(WCHAR));
601  if (lres != ERROR_SUCCESS)
602  hres = HRESULT_FROM_WIN32(lres);
603  break;
604  case 'd':
605  {
606  hres = get_word(&iter, buf);
607  if (FAILED(hres))
608  break;
609  WCHAR *end;
610  DWORD dw;
611  if ((buf->str[0] == '0' && buf->str[1] == 'x') || (buf->str[0] == '&' && buf->str[1] == 'H'))
612  dw = wcstoul(&buf->str[2], &end, 16);
613  else
614  dw = wcstol(&buf->str[0], &end, 10);
615  lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_DWORD, (PBYTE)&dw, sizeof(dw));
616  if (lres != ERROR_SUCCESS)
617  hres = HRESULT_FROM_WIN32(lres);
618  break;
619  }
620  case 'b':
621  {
622  DWORD count;
623  DWORD curIndex;
624 
625  hres = get_word(&iter, buf);
626  if (FAILED(hres))
627  break;
628  count = buf->len;
629  if ((count & 1) != 0)
630  return DISP_E_EXCEPTION;
631  count = count / 2;
632  for (curIndex = 0; curIndex < count; curIndex++)
633  ((BYTE*)buf->str)[curIndex] = (HexToBin(buf->str[curIndex * 2]) << 4) | HexToBin(buf->str[curIndex * 2 + 1]);
634  lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_BINARY, (PBYTE)buf->str, count);
635  if (lres != ERROR_SUCCESS)
636  hres = HRESULT_FROM_WIN32(lres);
637  break;
638  }
639  default:
641  }
642  if (FAILED(hres))
643  break;
644  }
645  else
646  {
647  if (*iter == '-')
648  iter++;
649  hres = get_word(&iter, buf);
650  if (FAILED(hres))
651  break;
652  }
653  }
654  else if(key_type == IS_VAL)
655  {
657  break;
658  }
659 
660  if (key_type != IS_VAL && key_type != DO_DELETE && *iter == '{' && iswspace(iter[1]))
661  {
662  hres = get_word(&iter, buf);
663  if (FAILED(hres))
664  break;
665  hres = do_process_key(&iter, hkey, buf, do_register);
666  if (FAILED(hres))
667  break;
668  }
669 
670  if (!do_register && (key_type == NORMAL || key_type == FORCE_REMOVE))
671  {
672  RegDeleteKeyW(parent_key, name.str);
673  }
674 
675  if (hkey && key_type != IS_VAL)
676  RegCloseKey(hkey);
677  hkey = 0;
678  name.len = 0;
679 
680  hres = get_word(&iter, buf);
681  if (FAILED(hres))
682  break;
683  }
684 
685  HeapFree(GetProcessHeap(), 0, name.str);
686  if (hkey && key_type != IS_VAL)
687  RegCloseKey(hkey);
688  *pstr = iter;
689  return hres;
690  }
691 
692  HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
693  {
694  LPCOLESTR iter;
695  strbuf buf;
696  unsigned int i;
697  HRESULT hResult;
698  static const struct {
699  const wchar_t *name;
700  HKEY key;
701  } root_keys[] = {
702  {L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT},
703  {L"HKEY_CURRENT_USER", HKEY_CURRENT_USER},
704  {L"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE},
705  {L"HKEY_USERS", HKEY_USERS},
706  {L"HKEY_PERFORMANCE_DATA", HKEY_PERFORMANCE_DATA},
707  {L"HKEY_DYN_DATA", HKEY_DYN_DATA},
708  {L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG},
709  {L"HKCR", HKEY_CLASSES_ROOT},
710  {L"HKCU", HKEY_CURRENT_USER},
711  {L"HKLM", HKEY_LOCAL_MACHINE},
712  {L"HKU", HKEY_USERS},
713  {L"HKPD", HKEY_PERFORMANCE_DATA},
714  {L"HKDD", HKEY_DYN_DATA},
715  {L"HKCC", HKEY_CURRENT_CONFIG},
716  };
717 
718  iter = data;
719 
720  hResult = strbuf_init(&buf);
721  if (FAILED(hResult))
722  return hResult;
723  hResult = get_word(&iter, &buf);
724  if (FAILED(hResult))
725  return hResult;
726 
727  while (*iter)
728  {
729  if (!buf.len)
730  {
731  hResult = DISP_E_EXCEPTION;
732  break;
733  }
734  for (i = 0; i < sizeof(root_keys) / sizeof(root_keys[0]); i++)
735  {
736  if (!lstrcmpiW(buf.str, root_keys[i].name))
737  break;
738  }
739  if (i == sizeof(root_keys) / sizeof(root_keys[0]))
740  {
741  hResult = DISP_E_EXCEPTION;
742  break;
743  }
744  hResult = get_word(&iter, &buf);
745  if (FAILED(hResult))
746  break;
747  if (buf.str[1] || buf.str[0] != '{')
748  {
749  hResult = DISP_E_EXCEPTION;
750  break;
751  }
752  hResult = do_process_key(&iter, root_keys[i].key, &buf, do_register);
753  if (FAILED(hResult))
754  break;
755  hResult = get_word(&iter, &buf);
756  if (FAILED(hResult))
757  break;
758  }
759  HeapFree(GetProcessHeap(), 0, buf.str);
760  return hResult;
761  }
762 
763 };
764 
765 }; //namespace ATL
#define HKEY_USERS
Definition: winreg.h:13
#define DISP_E_EXCEPTION
Definition: winerror.h:2518
WCHAR OLECHAR
Definition: compat.h:1933
rep_list * m_rep
Definition: statreg.h:52
HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
Definition: statreg.h:486
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
struct ATL::CRegObject::rep_list_str rep_list
LONG RegDeleteTreeX(HKEY parentKey, LPCWSTR subKeyName)
Definition: statreg.h:197
#define ATLASSERT(x)
Definition: CComVariant.cpp:9
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define HKEY_CURRENT_USER
Definition: winreg.h:11
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:136
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
HRESULT STDMETHODCALLTYPE RegisterWithString(LPCOLESTR data, BOOL doRegister)
Definition: statreg.h:191
HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
Definition: statreg.h:692
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
HRESULT STDMETHODCALLTYPE StringUnregister(LPCOLESTR data)
Definition: statreg.h:165
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HKEY_DYN_DATA
Definition: winreg.h:16
GLuint GLuint end
Definition: gl.h:1545
_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)
__u16 time
Definition: mkdosfs.c:366
HRESULT STDMETHODCALLTYPE RegisterWithFile(LPCOLESTR fileName, BOOL doRegister)
Definition: statreg.h:186
char * LPSTR
Definition: xmlstorage.h:182
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
static LPOLESTR
Definition: stg_prop.c:27
#define lstrlenW
Definition: compat.h:407
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HRESULT STDMETHODCALLTYPE RegisterWithResource(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL doRegister)
Definition: statreg.h:181
HRESULT AddReplacement([in] LPCOLESTR Key, [in] LPCOLESTR item)
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
HRESULT string_register(LPCOLESTR data, BOOL do_register)
Definition: statreg.h:346
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int HexToBin(OLECHAR a)
Definition: statreg.h:474
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HRESULT STDMETHODCALLTYPE ClearReplacements()
Definition: statreg.h:121
HRESULT STDMETHODCALLTYPE ResourceRegisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: statreg.h:140
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
_Check_return_ _CRTIMP int __cdecl _memicmp(_In_reads_bytes_opt_(_Size) const void *_Buf1, _In_reads_bytes_opt_(_Size) const void *_Buf2, _In_ size_t _Size)
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
HRESULT do_preprocess(LPCOLESTR data, strbuf *buf)
Definition: statreg.h:366
Definition: cdmake.c:189
HRESULT strbuf_write(LPCOLESTR str, strbuf *buf, int len)
Definition: statreg.h:232
#define OPEN_EXISTING
Definition: compat.h:426
#define KEY_WRITE
Definition: nt_native.h:1031
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:4895
Definition: rosdlgs.h:5
#define _T(x)
Definition: vfdio.h:22
#define FreeLibrary(x)
Definition: compat.h:405
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static const struct @315 root_keys[]
HRESULT get_word(LPCOLESTR *str, strbuf *buf)
Definition: statreg.h:420
const char file[]
Definition: icontest.c:11
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995
HRESULT STDMETHODCALLTYPE ResourceUnregisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: statreg.h:145
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
typedef void(__stdcall _ATL_TERMFUNC)(DWORD_PTR dw)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define iswspace(_c)
Definition: ctype.h:669
#define NO_REMOVE
Definition: classpnp.h:93
static const WCHAR L[]
Definition: oid.c:1250
HRESULT STDMETHODCALLTYPE QueryInterface(const IID &, void **)
Definition: statreg.h:69
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
#define GENERIC_READ
Definition: compat.h:124
GLenum src
Definition: glext.h:6340
HRESULT STDMETHODCALLTYPE ResourceUnregister(LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
Definition: statreg.h:175
ULONG STDMETHODCALLTYPE AddRef()
Definition: statreg.h:75
HRESULT STDMETHODCALLTYPE AddReplacement(LPCOLESTR key, LPCOLESTR item)
Definition: statreg.h:87
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
struct rep_list_str * next
Definition: statreg.h:42
HRESULT resource_register(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
Definition: statreg.h:302
#define S_OK
Definition: intsafe.h:59
static ATOM item
Definition: dde.c:856
HRESULT STDMETHODCALLTYPE FileRegister(LPCOLESTR fileName)
Definition: statreg.h:150
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define HeapReAlloc
Definition: compat.h:393
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT STDMETHODCALLTYPE StringRegister(LPCOLESTR data)
Definition: statreg.h:160
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
#define MultiByteToWideChar
Definition: compat.h:100
#define CreateFileW
Definition: compat.h:400
HRESULT STDMETHODCALLTYPE ResourceRegister(LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
Definition: statreg.h:170
Definition: name.c:36
static DWORD LPDWORD reslen
Definition: directory.c:51
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
HRESULT strbuf_init(strbuf *buf)
Definition: statreg.h:222
ULONG STDMETHODCALLTYPE Release()
Definition: statreg.h:81
HRESULT STDMETHODCALLTYPE FileUnregister(LPCOLESTR fileName)
Definition: statreg.h:155
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define HKEY_PERFORMANCE_DATA
Definition: winreg.h:14
HRESULT ClearReplacements()
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define REG_DWORD
Definition: sdbapi.c:596
HRESULT file_register(LPCOLESTR fileName, BOOL do_register)
Definition: statreg.h:253
BYTE * PBYTE
Definition: pedump.c:66
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
static const WCHAR szType[]
Definition: table.c:81
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: path.c:42
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
Definition: fci.c:126
#define REG_SZ
Definition: layer.c:22
GLuint const GLchar * name
Definition: glext.h:6031