ReactOS 0.4.16-dev-320-g3bd9ddc
ATL::CRegObject Class Reference

#include <statreg.h>

Inheritance diagram for ATL::CRegObject:
Collaboration diagram for ATL::CRegObject:

Classes

struct  rep_list_str
 
struct  strbuf
 

Public Types

typedef struct ATL::CRegObject::rep_list_str rep_list
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 

Public Member Functions

 CRegObject ()
 
 ~CRegObject ()
 
HRESULT STDMETHODCALLTYPE QueryInterface (const IID &, void **)
 
ULONG STDMETHODCALLTYPE AddRef ()
 
ULONG STDMETHODCALLTYPE Release ()
 
HRESULT STDMETHODCALLTYPE AddReplacement (LPCOLESTR key, LPCOLESTR item)
 
HRESULT STDMETHODCALLTYPE ClearReplacements ()
 
HRESULT STDMETHODCALLTYPE ResourceRegisterSz (LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
 
HRESULT STDMETHODCALLTYPE ResourceUnregisterSz (LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
 
HRESULT STDMETHODCALLTYPE FileRegister (LPCOLESTR fileName)
 
HRESULT STDMETHODCALLTYPE FileUnregister (LPCOLESTR fileName)
 
HRESULT STDMETHODCALLTYPE StringRegister (LPCOLESTR data)
 
HRESULT STDMETHODCALLTYPE StringUnregister (LPCOLESTR data)
 
HRESULT STDMETHODCALLTYPE ResourceRegister (LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
 
HRESULT STDMETHODCALLTYPE ResourceUnregister (LPCOLESTR resFileName, UINT nID, LPCOLESTR szType)
 
- Public Member Functions inherited from IRegistrarBase
HRESULT AddReplacement ([in] LPCOLESTR Key, [in] LPCOLESTR item)
 
HRESULT ClearReplacements ()
 
virtual HRESULT STDMETHODCALLTYPE AddReplacement (LPCOLESTR key, LPCOLESTR item)=0
 
virtual HRESULT STDMETHODCALLTYPE ClearReplacements ()=0
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Public Attributes

rep_listm_rep
 

Protected Member Functions

HRESULT STDMETHODCALLTYPE RegisterWithResource (LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL doRegister)
 
HRESULT STDMETHODCALLTYPE RegisterWithFile (LPCOLESTR fileName, BOOL doRegister)
 
HRESULT STDMETHODCALLTYPE RegisterWithString (LPCOLESTR data, BOOL doRegister)
 

Private Member Functions

LONG RegDeleteTreeX (HKEY parentKey, LPCWSTR subKeyName)
 
HRESULT strbuf_init (strbuf *buf)
 
HRESULT strbuf_write (LPCOLESTR str, strbuf *buf, int len)
 
HRESULT file_register (LPCOLESTR fileName, BOOL do_register)
 
HRESULT resource_register (LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
 
HRESULT string_register (LPCOLESTR data, BOOL do_register)
 
HRESULT do_preprocess (LPCOLESTR data, strbuf *buf)
 
HRESULT get_word (LPCOLESTR *str, strbuf *buf)
 
unsigned int HexToBin (OLECHAR a)
 
HRESULT do_process_key (LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
 
HRESULT do_process_root_key (LPCOLESTR data, BOOL do_register)
 

Detailed Description

Definition at line 34 of file statreg.h.

Member Typedef Documentation

◆ rep_list

Constructor & Destructor Documentation

◆ CRegObject()

ATL::CRegObject::CRegObject ( )
inline

Definition at line 55 of file statreg.h.

56 {
57 m_rep = NULL;
58 }
rep_list * m_rep
Definition: statreg.h:52
#define NULL
Definition: types.h:112

◆ ~CRegObject()

ATL::CRegObject::~CRegObject ( )
inline

Definition at line 60 of file statreg.h.

61 {
62 HRESULT hResult;
63
64 hResult = ClearReplacements();
65 ATLASSERT(SUCCEEDED(hResult));
66 (void)hResult;
67 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
HRESULT STDMETHODCALLTYPE ClearReplacements()
Definition: statreg.h:121
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Member Function Documentation

◆ AddRef()

ULONG STDMETHODCALLTYPE ATL::CRegObject::AddRef ( void  )
inline

Implements IUnknown.

Definition at line 75 of file statreg.h.

76 {
77 ATLASSERT(FALSE && TEXT("statically linked in CRegObject is not a com object. Do not call this function"));
78 return 1;
79 }
#define FALSE
Definition: types.h:117
#define TEXT(s)
Definition: k32.h:26

◆ AddReplacement()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::AddReplacement ( LPCOLESTR  key,
LPCOLESTR  item 
)
inlinevirtual

Implements IRegistrarBase.

Definition at line 87 of file statreg.h.

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 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
WCHAR OLECHAR
Definition: compat.h:2292
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
Definition: copy.c:22
LPOLESTR item
Definition: registrar.c:60
LPOLESTR key
Definition: registrar.c:59
struct rep_list_str * next
Definition: registrar.c:62

Referenced by ATL::CAtlModule::CommonInitRegistrar().

◆ ClearReplacements()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::ClearReplacements ( )
inlinevirtual

Implements IRegistrarBase.

Definition at line 121 of file statreg.h.

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 }

Referenced by ~CRegObject().

◆ do_preprocess()

HRESULT ATL::CRegObject::do_preprocess ( LPCOLESTR  data,
strbuf buf 
)
inlineprivate

Definition at line 366 of file statreg.h.

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 }
HRESULT strbuf_write(LPCOLESTR str, strbuf *buf, int len)
Definition: statreg.h:232
#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 FAILED(hr)
Definition: intsafe.h:51
#define L(x)
Definition: ntvdm.h:50
_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)
#define DISP_E_EXCEPTION
Definition: winerror.h:2518

Referenced by string_register().

◆ do_process_key()

HRESULT ATL::CRegObject::do_process_key ( LPCOLESTR *  pstr,
HKEY  parent_key,
strbuf buf,
BOOL  do_register 
)
inlineprivate

Definition at line 486 of file statreg.h.

487 {
488 LPCOLESTR iter;
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;
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 }
#define NORMAL
Definition: main.h:128
#define RegCloseKey(hKey)
Definition: registry.h:49
unsigned int HexToBin(OLECHAR a)
Definition: statreg.h:474
HRESULT strbuf_init(strbuf *buf)
Definition: statreg.h:222
HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOOL do_register)
Definition: statreg.h:486
LONG RegDeleteTreeX(HKEY parentKey, LPCWSTR subKeyName)
Definition: statreg.h:197
#define NO_REMOVE
Definition: classpnp.h:96
#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
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define get_word()
Definition: iccvid.c:91
#define iswspace(_c)
Definition: ctype.h:669
_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 REG_SZ
Definition: layer.c:22
HRESULT hres
Definition: protocol.c:465
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:146
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by do_process_key(), and do_process_root_key().

◆ do_process_root_key()

HRESULT ATL::CRegObject::do_process_root_key ( LPCOLESTR  data,
BOOL  do_register 
)
inlineprivate

Definition at line 692 of file statreg.h.

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 }
static const struct @322 root_keys[]
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 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 string_register().

◆ file_register()

HRESULT ATL::CRegObject::file_register ( LPCOLESTR  fileName,
BOOL  do_register 
)
inlineprivate

Definition at line 253 of file statreg.h.

254 {
255 HANDLE file;
256 DWORD filelen;
257 DWORD len;
258 LPWSTR regstrw;
259 LPSTR regstra;
260 LRESULT lres;
261 HRESULT hResult;
262
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);
293 }
294 else
295 {
296 hResult = HRESULT_FROM_WIN32(GetLastError());
297 }
298
299 return hResult;
300 }
HRESULT string_register(LPCOLESTR data, BOOL do_register)
Definition: statreg.h:346
#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 HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
Definition: fci.c:127
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LRESULT
Definition: windef.h:209
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by RegisterWithFile().

◆ FileRegister()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::FileRegister ( LPCOLESTR  fileName)
inline

Definition at line 150 of file statreg.h.

151 {
152 return RegisterWithFile(fileName, TRUE);
153 }
HRESULT STDMETHODCALLTYPE RegisterWithFile(LPCOLESTR fileName, BOOL doRegister)
Definition: statreg.h:186
#define TRUE
Definition: types.h:120

◆ FileUnregister()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::FileUnregister ( LPCOLESTR  fileName)
inline

Definition at line 155 of file statreg.h.

156 {
157 return RegisterWithFile(fileName, FALSE);
158 }

◆ get_word()

HRESULT ATL::CRegObject::get_word ( LPCOLESTR *  str,
strbuf buf 
)
inlineprivate

Definition at line 420 of file statreg.h.

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 }
const WCHAR * str

◆ HexToBin()

unsigned int ATL::CRegObject::HexToBin ( OLECHAR  a)
inlineprivate

Definition at line 474 of file statreg.h.

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 }
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by do_process_key().

◆ QueryInterface()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::QueryInterface ( const IID ,
void **   
)
inline

Definition at line 69 of file statreg.h.

70 {
71 ATLASSERT(FALSE && TEXT("statically linked in CRegObject is not a com object. Do not call this function"));
72 return E_NOTIMPL;
73 }
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RegDeleteTreeX()

LONG ATL::CRegObject::RegDeleteTreeX ( HKEY  parentKey,
LPCWSTR  subKeyName 
)
inlineprivate

Definition at line 197 of file statreg.h.

198 {
199 wchar_t szBuffer[256];
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 }
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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:2504
__u16 time
Definition: mkdosfs.c:8
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031

Referenced by do_process_key(), and RegDeleteTreeX().

◆ RegisterWithFile()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::RegisterWithFile ( LPCOLESTR  fileName,
BOOL  doRegister 
)
inlineprotected

Definition at line 186 of file statreg.h.

187 {
188 return file_register(fileName, doRegister);
189 }
HRESULT file_register(LPCOLESTR fileName, BOOL do_register)
Definition: statreg.h:253

Referenced by FileRegister(), and FileUnregister().

◆ RegisterWithResource()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::RegisterWithResource ( LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType,
BOOL  doRegister 
)
inlineprotected

Definition at line 181 of file statreg.h.

182 {
183 return resource_register(resFileName, szID, szType, doRegister);
184 }
HRESULT resource_register(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL do_register)
Definition: statreg.h:302

Referenced by ResourceRegisterSz(), and ResourceUnregisterSz().

◆ RegisterWithString()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::RegisterWithString ( LPCOLESTR  data,
BOOL  doRegister 
)
inlineprotected

Definition at line 191 of file statreg.h.

192 {
193 return string_register(data, doRegister);
194 }

Referenced by StringRegister(), and StringUnregister().

◆ Release()

ULONG STDMETHODCALLTYPE ATL::CRegObject::Release ( void  )
inline

Implements IUnknown.

Definition at line 81 of file statreg.h.

82 {
83 ATLASSERT(FALSE && TEXT("statically linked in CRegObject is not a com object. Do not call this function"));
84 return 0;
85 }

◆ resource_register()

HRESULT ATL::CRegObject::resource_register ( LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType,
BOOL  do_register 
)
inlineprivate

Definition at line 302 of file statreg.h.

303 {
304 HINSTANCE hins;
305 HRSRC src;
306 HGLOBAL regstra;
307 LPWSTR regstrw;
308 DWORD len;
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 }
#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:368
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by RegisterWithResource().

◆ ResourceRegister()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::ResourceRegister ( LPCOLESTR  resFileName,
UINT  nID,
LPCOLESTR  szType 
)
inline

Definition at line 170 of file statreg.h.

171 {
172 return ResourceRegisterSz(resFileName, MAKEINTRESOURCEW(nID), szType);
173 }
HRESULT STDMETHODCALLTYPE ResourceRegisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: statreg.h:140
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by ATL::CAtlModule::UpdateRegistryFromResource().

◆ ResourceRegisterSz()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::ResourceRegisterSz ( LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType 
)
inline

Definition at line 140 of file statreg.h.

141 {
142 return RegisterWithResource(resFileName, szID, szType, TRUE);
143 }
HRESULT STDMETHODCALLTYPE RegisterWithResource(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType, BOOL doRegister)
Definition: statreg.h:181

Referenced by ResourceRegister(), and ATL::CAtlModule::UpdateRegistryFromResource().

◆ ResourceUnregister()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::ResourceUnregister ( LPCOLESTR  resFileName,
UINT  nID,
LPCOLESTR  szType 
)
inline

Definition at line 175 of file statreg.h.

176 {
177 return ResourceUnregisterSz(resFileName, MAKEINTRESOURCEW(nID), szType);
178 }
HRESULT STDMETHODCALLTYPE ResourceUnregisterSz(LPCOLESTR resFileName, LPCOLESTR szID, LPCOLESTR szType)
Definition: statreg.h:145

Referenced by ATL::CAtlModule::UpdateRegistryFromResource().

◆ ResourceUnregisterSz()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::ResourceUnregisterSz ( LPCOLESTR  resFileName,
LPCOLESTR  szID,
LPCOLESTR  szType 
)
inline

Definition at line 145 of file statreg.h.

146 {
147 return RegisterWithResource(resFileName, szID, szType, FALSE);
148 }

Referenced by ResourceUnregister(), and ATL::CAtlModule::UpdateRegistryFromResource().

◆ strbuf_init()

HRESULT ATL::CRegObject::strbuf_init ( strbuf buf)
inlineprivate

Definition at line 222 of file statreg.h.

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 }
static LPOLESTR
Definition: stg_prop.c:27

Referenced by do_process_key(), do_process_root_key(), and string_register().

◆ strbuf_write()

HRESULT ATL::CRegObject::strbuf_write ( LPCOLESTR  str,
strbuf buf,
int  len 
)
inlineprivate

Definition at line 232 of file statreg.h.

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 }
#define HeapReAlloc
Definition: compat.h:734
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995

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

◆ string_register()

HRESULT ATL::CRegObject::string_register ( LPCOLESTR  data,
BOOL  do_register 
)
inlineprivate

Definition at line 346 of file statreg.h.

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 }
HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
Definition: statreg.h:692
HRESULT do_preprocess(LPCOLESTR data, strbuf *buf)
Definition: statreg.h:366

Referenced by file_register(), RegisterWithString(), and resource_register().

◆ StringRegister()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::StringRegister ( LPCOLESTR  data)
inline

Definition at line 160 of file statreg.h.

161 {
163 }
HRESULT STDMETHODCALLTYPE RegisterWithString(LPCOLESTR data, BOOL doRegister)
Definition: statreg.h:191

◆ StringUnregister()

HRESULT STDMETHODCALLTYPE ATL::CRegObject::StringUnregister ( LPCOLESTR  data)
inline

Definition at line 165 of file statreg.h.

166 {
168 }

Member Data Documentation

◆ m_rep

rep_list* ATL::CRegObject::m_rep

Definition at line 52 of file statreg.h.

Referenced by AddReplacement(), ClearReplacements(), CRegObject(), and do_preprocess().


The documentation for this class was generated from the following file: