11 void dprintf(char* fmt, ...)
17 vsprintf(buffer,fmt,args);
18 WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
23 #define MAX_NAME_LEN 500
25 BOOL DumpRegKey(TCHAR* KeyPath, HKEY hKey)
30 keyPath[0] = _T('\0');
32 dprintf("\n[%s]\n", KeyPath);
36 LONG errCode = RegOpenKeyEx(hKey, keyPath, 0, KEY_READ, &hNewKey);
37 if (errCode == ERROR_SUCCESS) {
38 TCHAR Name[MAX_NAME_LEN];
39 DWORD cName = MAX_NAME_LEN;
40 FILETIME LastWriteTime;
42 while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) {
46 dprintf("\n[%s\\%s]\n", KeyPath, Name);
48 errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hSubKey);
49 if (errCode == ERROR_SUCCESS) {
50 TCHAR SubName[MAX_NAME_LEN];
51 DWORD cSubName = MAX_NAME_LEN;
52 // if (RegEnumKeyEx(hSubKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
53 while (RegEnumKeyEx(hSubKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
54 dprintf("\t%s (%d)\n", SubName, dwCount);
55 cSubName = MAX_NAME_LEN;
61 //AddEntryToTree(hwndTV, pnmtv->itemNew.hItem, Name, NULL, dwCount);
74 BOOL _DumpRegKey(TCHAR* KeyPath, HKEY hKey)
78 LONG errCode = RegOpenKeyEx(hKey, NULL, 0, KEY_READ, &hNewKey);
79 if (errCode == ERROR_SUCCESS) {
80 TCHAR Name[MAX_NAME_LEN];
81 DWORD cName = MAX_NAME_LEN;
82 FILETIME LastWriteTime;
84 TCHAR* pKeyName = &KeyPath[_tcslen(KeyPath)];
85 while (RegEnumKeyEx(hNewKey, dwIndex, Name, &cName, NULL, NULL, NULL, &LastWriteTime) == ERROR_SUCCESS) {
88 _tcscat(KeyPath, _T("\\"));
89 _tcscat(KeyPath, Name);
90 dprintf("\n[%s]\n", KeyPath);
91 errCode = RegOpenKeyEx(hNewKey, Name, 0, KEY_READ, &hSubKey);
92 if (errCode == ERROR_SUCCESS) {
94 _DumpRegKey(KeyPath, hSubKey);
96 TCHAR SubName[MAX_NAME_LEN];
97 DWORD cSubName = MAX_NAME_LEN;
98 // if (RegEnumKeyEx(hSubKey, 0, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
99 while (RegEnumKeyEx(hSubKey, dwCount, SubName, &cSubName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
100 dprintf("\t%s (%d)\n", SubName, dwCount);
101 cSubName = MAX_NAME_LEN;
106 RegCloseKey(hSubKey);
107 cName = MAX_NAME_LEN;
108 *pKeyName = _T('\0');
111 RegCloseKey(hNewKey);
118 BOOL DumpRegKey(TCHAR* KeyPath, HKEY hKey)
120 dprintf("\n[%s]\n", KeyPath);
121 return _DumpRegKey(KeyPath, hKey);
124 void RegKeyPrint(int which)
126 TCHAR szKeyPath[1000];
130 strcpy(szKeyPath, _T("HKEY_CLASSES_ROOT"));
131 DumpRegKey(szKeyPath, HKEY_CLASSES_ROOT);
134 strcpy(szKeyPath, _T("HKEY_CURRENT_USER"));
135 DumpRegKey(szKeyPath, HKEY_CURRENT_USER);
138 strcpy(szKeyPath, _T("HKEY_LOCAL_MACHINE"));
139 DumpRegKey(szKeyPath, HKEY_LOCAL_MACHINE);
142 strcpy(szKeyPath, _T("HKEY_USERS"));
143 DumpRegKey(szKeyPath, HKEY_USERS);
146 strcpy(szKeyPath, _T("HKEY_CURRENT_CONFIG"));
147 DumpRegKey(szKeyPath, HKEY_CURRENT_CONFIG);
150 // DumpRegKey(szKeyPath, HKEY_CLASSES_ROOT);
151 // DumpRegKey(szKeyPath, HKEY_CURRENT_USER);
152 // DumpRegKey(szKeyPath, HKEY_LOCAL_MACHINE);
153 // DumpRegKey(szKeyPath, HKEY_USERS);
154 // DumpRegKey(szKeyPath, HKEY_CURRENT_CONFIG);
155 dprintf("unimplemented...\n");
161 int main(int argc, char* argv[])
164 TCHAR szKeyPath[1000];
168 InputHandle = GetStdHandle(STD_INPUT_HANDLE);
169 OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
173 // if (0 == _tcsstr(argv[1], _T("HKLM"))) {
175 if (strstr(argv[1], _T("help"))) {
177 } else if (strstr(argv[1], _T("HKCR"))) {
179 } else if (strstr(argv[1], _T("HKCU"))) {
181 } else if (strstr(argv[1], _T("HKLM"))) {
183 } else if (strstr(argv[1], _T("HKU"))) {
185 } else if (strstr(argv[1], _T("HKCC"))) {
187 } else if (strstr(argv[1], _T("HKRR"))) {
190 dprintf("started with argc = %d, argv[1] = %s (unknown?)\n", argc, argv[1]);
194 dprintf("choose test :\n");
195 dprintf(" 0 = Exit\n");
196 dprintf(" 1 = HKEY_CLASSES_ROOT\n");
197 dprintf(" 2 = HKEY_CURRENT_USER\n");
198 dprintf(" 3 = HKEY_LOCAL_MACHINE\n");
199 dprintf(" 4 = HKEY_USERS\n");
200 dprintf(" 5 = HKEY_CURRENT_CONFIG\n");
201 dprintf(" 6 = REGISTRY ROOT\n");
202 ReadConsoleA(InputHandle, Buffer, 3, &Result, NULL) ;
212 RegKeyPrint(Buffer[0]/* - '0'*/);
215 dprintf("invalid input.\n");
224 [HKEY_LOCAL_MACHINE\HARDWARE]
226 [HKEY_LOCAL_MACHINE\HARDWARE\ACPI]
228 [HKEY_LOCAL_MACHINE\HARDWARE\ACPI\DSDT]
230 [HKEY_LOCAL_MACHINE\HARDWARE\ACPI\DSDT\VIA694]
232 [HKEY_LOCAL_MACHINE\HARDWARE\ACPI\DSDT\VIA694\AWRDACPI]