ReactOS 0.4.15-dev-7906-g1b85a5f
shimdbg.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <ntndk.h>
Include dependency graph for shimdbg.c:

Go to the source code of this file.

Classes

struct  tagATTRINFO
 

Macros

#define DPFLTR_ERROR_LEVEL   0
 
#define TAG_TYPE_MASK   0xF000
 
#define TAG_TYPE_DWORD   0x4000
 
#define TAG_TYPE_QWORD   0x5000
 
#define TAG_TYPE_STRINGREF   0x6000
 
#define ATTRIBUTE_AVAILABLE   0x1
 
#define ATTRIBUTE_FAILED   0x2
 
#define REG_BINARY   ( 3 )
 

Typedefs

typedef WORD TAG
 
typedef UINT64 QWORD
 
typedef struct tagATTRINFO ATTRINFO
 
typedef struct tagATTRINFOPATTRINFO
 

Functions

NTSYSAPI ULONG NTAPI vDbgPrintEx (_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
 
void xprintf (const char *fmt,...)
 
void CallApphelp (APPHELPCACHESERVICECLASS Service, PAPPHELP_CACHE_SERVICE_LOOKUP CacheEntry)
 
HANDLE MapFile (char *filename, UNICODE_STRING *PathName, int MapIt)
 
void CallApphelpWithImage (char *filename, int MapIt, APPHELPCACHESERVICECLASS Service, char *ServiceName)
 
int IsOpt (char *argv, const char *check)
 
int HandleImageArg (int argc, char *argv[], int *pn, char MapItChar, APPHELPCACHESERVICECLASS Service, char *ServiceName)
 
static LPCWSTR (WINAPI *pSdbTagToString)(TAG)
 
static BOOL (WINAPI *pSdbGetFileAttributes)(LPCWSTR
 
static BOOL InitApphelp ()
 
int HandleDumpAttributes (int argc, char *argv[], int *pn, const char *opt)
 
void hexdump (unsigned char *p, unsigned int len)
 
void DumpRegistryData (int IncludeDump)
 
int _getch ()
 
int main (int argc, char *argv[])
 

Variables

static PVOID hdll
 
static PATTRINFO LPDWORD
 
UNICODE_STRING AppCompatCacheKey = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatCache")
 
OBJECT_ATTRIBUTES AppCompatKeyAttributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(&AppCompatCacheKey, OBJ_CASE_INSENSITIVE)
 
UNICODE_STRING AppCompatCacheValue = RTL_CONSTANT_STRING(L"AppCompatCache")
 

Macro Definition Documentation

◆ ATTRIBUTE_AVAILABLE

#define ATTRIBUTE_AVAILABLE   0x1

Definition at line 111 of file shimdbg.c.

◆ ATTRIBUTE_FAILED

#define ATTRIBUTE_FAILED   0x2

Definition at line 112 of file shimdbg.c.

◆ DPFLTR_ERROR_LEVEL

#define DPFLTR_ERROR_LEVEL   0

Definition at line 14 of file shimdbg.c.

◆ REG_BINARY

#define REG_BINARY   ( 3 )

Definition at line 230 of file shimdbg.c.

◆ TAG_TYPE_DWORD

#define TAG_TYPE_DWORD   0x4000

Definition at line 107 of file shimdbg.c.

◆ TAG_TYPE_MASK

#define TAG_TYPE_MASK   0xF000

Definition at line 106 of file shimdbg.c.

◆ TAG_TYPE_QWORD

#define TAG_TYPE_QWORD   0x5000

Definition at line 108 of file shimdbg.c.

◆ TAG_TYPE_STRINGREF

#define TAG_TYPE_STRINGREF   0x6000

Definition at line 109 of file shimdbg.c.

Typedef Documentation

◆ ATTRINFO

◆ PATTRINFO

◆ QWORD

static QWORD

Definition at line 104 of file shimdbg.c.

◆ TAG

typedef WORD TAG

Definition at line 103 of file shimdbg.c.

Function Documentation

◆ _getch()

int _getch ( )

Definition at line 16 of file getch.c.

17{
18 DWORD NumberOfCharsRead = 0;
19 char c;
20 HANDLE ConsoleHandle;
21 BOOL RestoreMode;
22 DWORD ConsoleMode;
23
24 if (char_avail) {
25 c = ungot_char;
26 char_avail = 0;
27 } else {
28 /*
29 * _getch() is documented to NOT echo characters. Testing shows it
30 * doesn't wait for a CR either. So we need to switch off
31 * ENABLE_ECHO_INPUT and ENABLE_LINE_INPUT if they're currently
32 * switched on.
33 */
34 ConsoleHandle = (HANDLE) _get_osfhandle(stdin->_file);
35 RestoreMode = GetConsoleMode(ConsoleHandle, &ConsoleMode) &&
36 (0 != (ConsoleMode &
38 if (RestoreMode) {
39 SetConsoleMode(ConsoleHandle,
40 ConsoleMode & (~ (ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT)));
41 }
43 &c,
44 1,
45 &NumberOfCharsRead,
46 NULL);
47 if (RestoreMode) {
48 SetConsoleMode(ConsoleHandle, ConsoleMode);
49 }
50 }
51 if (c == 10)
52 c = 13;
53 return c;
54}
#define NULL
Definition: types.h:112
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1195
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLubyte * c
Definition: glext.h:8905
#define stdin
Definition: stdio.h:98
#define c
Definition: ke_i.h:80
_CRTIMP intptr_t __cdecl _get_osfhandle(_In_ int _FileHandle)
PVOID HANDLE
Definition: typedefs.h:73
int char_avail
Definition: ungetch.c:15
int ungot_char
Definition: ungetch.c:16
#define ENABLE_ECHO_INPUT
Definition: wincon.h:80
#define ENABLE_LINE_INPUT
Definition: wincon.h:79

Referenced by _cgets(), _getche(), _tmain(), abort(), DumpFont(), GetPass(), gl_getc(), gl_getcx(), gl_getpass(), main(), MainUsage(), PrintHelp(), ShowAppList(), TestEventsGeneration(), Wait(), and wmain().

◆ BOOL()

static BOOL ( WINAPI pSdbGetFileAttributes)
static

◆ CallApphelp()

void CallApphelp ( APPHELPCACHESERVICECLASS  Service,
PAPPHELP_CACHE_SERVICE_LOOKUP  CacheEntry 
)

Definition at line 27 of file shimdbg.c.

29{
31 xprintf("NtApphelpCacheControl returned 0x%x\n", (unsigned int)Status);
32}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtApphelpCacheControl(_In_ APPHELPCACHESERVICECLASS Service, _In_opt_ PAPPHELP_CACHE_SERVICE_LOOKUP ServiceData)
Definition: apphelp.c:728
@ Service
Definition: ntsecapi.h:292
void xprintf(const char *fmt,...)
Definition: shimdbg.c:16

Referenced by CallApphelpWithImage(), and main().

◆ CallApphelpWithImage()

void CallApphelpWithImage ( char filename,
int  MapIt,
APPHELPCACHESERVICECLASS  Service,
char ServiceName 
)

Definition at line 59 of file shimdbg.c.

61{
62 UNICODE_STRING PathName = {0};
64
65 HANDLE FileHandle = MapFile(filename, &PathName, MapIt);
66
67 xprintf("Calling %s %s mapping\n", ServiceName, (MapIt ? "with" : "without"));
68
69 RtlInitUnicodeString(&CacheEntry.ImageName, PathName.Buffer);
70 CacheEntry.ImageHandle = FileHandle ? FileHandle : (HANDLE)-1;
71 CallApphelp(Service, &CacheEntry);
72 // we piggy-back on the PathName, so let the Cleanup take care of the string
73 //RtlFreeUnicodeString(&CacheEntry.ImageName);
74
75 if (FileHandle)
77 RtlFreeUnicodeString(&PathName);
78}
static WCHAR ServiceName[]
Definition: browser.c:19
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
const char * filename
Definition: ioapi.h:137
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
void CallApphelp(APPHELPCACHESERVICECLASS Service, PAPPHELP_CACHE_SERVICE_LOOKUP CacheEntry)
Definition: shimdbg.c:27
HANDLE MapFile(char *filename, UNICODE_STRING *PathName, int MapIt)
Definition: shimdbg.c:34
UNICODE_STRING ImageName
Definition: pstypes.h:986

Referenced by HandleImageArg().

◆ DumpRegistryData()

void DumpRegistryData ( int  IncludeDump)

Definition at line 261 of file shimdbg.c.

262{
265 KEY_VALUE_PARTIAL_INFORMATION KeyValueObject;
266 PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation = &KeyValueObject;
267 ULONG KeyInfoSize, ResultSize;
268
269 xprintf("Dumping AppCompatCache registry key\n");
270
272
274 KeyValuePartialInformation, KeyValueInformation,
275 sizeof(KeyValueObject), &ResultSize);
276
278 {
279 KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + KeyValueInformation->DataLength;
280 KeyValueInformation = malloc(KeyInfoSize);
281 if (KeyValueInformation != NULL)
282 {
284 KeyValuePartialInformation, KeyValueInformation,
285 KeyInfoSize, &ResultSize);
286 }
287 }
288
289 if (NT_SUCCESS(Status) && KeyValueInformation->Type == REG_BINARY)
290 {
291 ULONG crc;
292 if (IncludeDump)
293 hexdump(KeyValueInformation->Data, KeyValueInformation->DataLength);
294 crc = RtlComputeCrc32(0, KeyValueInformation->Data, KeyValueInformation->DataLength);
295 xprintf("Len: %lu, Crc: 0x%lx\n", KeyValueInformation->DataLength, crc);
296 }
297 else
298 {
299 xprintf("Failed reading AppCompatCache from registry (0x%lx)\n", Status);
300 }
301
302 if (KeyValueInformation != &KeyValueObject)
303 free(KeyValueInformation);
304
305 if (KeyHandle)
307}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define RtlComputeCrc32
Definition: compat.h:810
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
UNICODE_STRING AppCompatCacheValue
Definition: shimdbg.c:229
OBJECT_ATTRIBUTES AppCompatKeyAttributes
Definition: shimdbg.c:228
#define REG_BINARY
Definition: shimdbg.c:230
void hexdump(unsigned char *p, unsigned int len)
Definition: shimdbg.c:234
uint32_t ULONG
Definition: typedefs.h:59

Referenced by main().

◆ HandleDumpAttributes()

int HandleDumpAttributes ( int  argc,
char argv[],
int pn,
const char opt 
)

Definition at line 158 of file shimdbg.c.

159{
162 DWORD num_attr, n;
163 int argn = *pn;
164 const char* arg;
165
166 if (!InitApphelp())
167 return 1;
168
169 if (strlen(argv[argn]) > (strlen(opt)+1))
170 {
171 arg = argv[argn] + strlen(opt);
172 }
173 else if (argn+1 >= argc)
174 {
175 xprintf("Error: no image name specified\n");
176 return 1;
177 }
178 else
179 {
180 arg = argv[argn+1];
181 (*pn) += 1;
182 }
183
185
186 if (pSdbGetFileAttributes(FileName.Buffer, &attr, &num_attr))
187 {
188 xprintf("Dumping attributes for %s\n", arg);
189 for (n = 0; n < num_attr; ++n)
190 {
191 TAG tagType;
192 LPCWSTR tagName;
194 continue;
195
196 tagName = pSdbTagToString(attr[n].type);
197
198 tagType = attr[n].type & TAG_TYPE_MASK;
199 switch (tagType)
200 {
201 case TAG_TYPE_DWORD:
202 xprintf("<%ls>0x%lx</%ls>\n", tagName, attr[n].dwattr, tagName);
203 break;
205 xprintf("<%ls>%ls</%ls>\n", tagName, attr[n].lpattr, tagName);
206 break;
207 case TAG_TYPE_QWORD:
208 xprintf("<%ls>0x%I64x</%ls>\n", tagName, attr[n].qwattr, tagName);
209 break;
210 default:
211 xprintf("<!-- Unknown tag type: 0x%x (from 0x%x)\n", tagType, attr[n].type);
212 break;
213 }
214 }
215 xprintf("Done\n");
216 }
217 else
218 {
219 xprintf("Unable to get attributes from %s\n", arg);
220 }
221
222
224 return 0;
225}
static int argc
Definition: ServiceArgs.c:12
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct _FileName FileName
Definition: fatprocs.h:896
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
GLbitfield flags
Definition: glext.h:7161
static int pints_t pn[]
Definition: server.c:129
#define argv
Definition: mplay32.c:18
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define TAG_TYPE_DWORD
Definition: shimdbg.c:107
#define TAG_TYPE_QWORD
Definition: shimdbg.c:108
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109
#define ATTRIBUTE_AVAILABLE
Definition: shimdbg.c:111
static BOOL InitApphelp()
Definition: shimdbg.c:131
#define TAG_TYPE_MASK
Definition: shimdbg.c:106
Definition: fs_rec.h:143
Definition: cookie.c:202
void * arg
Definition: msvc.h:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by main().

◆ HandleImageArg()

int HandleImageArg ( int  argc,
char argv[],
int pn,
char  MapItChar,
APPHELPCACHESERVICECLASS  Service,
char ServiceName 
)

Definition at line 88 of file shimdbg.c.

90{
91 int n = *pn;
92 if (n+1 < argc)
93 {
94 int MapIt = argv[n][1] == MapItChar;
96 (*pn) += 1;
97 return 0;
98 }
99 xprintf("Error: no image name specified\n");
100 return 1;
101}
void CallApphelpWithImage(char *filename, int MapIt, APPHELPCACHESERVICECLASS Service, char *ServiceName)
Definition: shimdbg.c:59

Referenced by main().

◆ hexdump()

void hexdump ( unsigned char p,
unsigned int  len 
)

Definition at line 234 of file shimdbg.c.

235{
236 unsigned char *line = p;
237 unsigned int i, thisline, offset = 0;
238
239 while (offset < len)
240 {
241 xprintf("%04x ", offset);
242 thisline = len - offset;
243 if (thisline > 16)
244 thisline = 16;
245
246 for (i = 0; i < thisline; i++)
247 xprintf("%02x ", line[i]);
248
249 for (; i < 16; i++)
250 xprintf(" ");
251
252 for (i = 0; i < thisline; i++)
253 xprintf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
254
255 xprintf("\n");
256 offset += thisline;
257 line += thisline;
258 }
259}
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
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
Definition: parser.c:49

Referenced by DumpRegistryData().

◆ InitApphelp()

static BOOL InitApphelp ( )
static

Definition at line 131 of file shimdbg.c.

132{
133 if (!hdll)
134 {
135 static UNICODE_STRING DllName = RTL_CONSTANT_STRING(L"apphelp.dll");
136 static ANSI_STRING SdbTagToString = RTL_CONSTANT_STRING("SdbTagToString");
137 static ANSI_STRING SdbGetFileAttributes = RTL_CONSTANT_STRING("SdbGetFileAttributes");
138 static ANSI_STRING SdbFreeFileAttributes = RTL_CONSTANT_STRING("SdbFreeFileAttributes");
139 if (!NT_SUCCESS(LdrLoadDll(NULL, NULL, &DllName, &hdll)))
140 {
141 xprintf("Unable to load apphelp.dll\n");
142 return FALSE;
143 }
144 if (!NT_SUCCESS(LdrGetProcedureAddress(hdll, &SdbTagToString, 0, (PVOID)&pSdbTagToString)) ||
145 !NT_SUCCESS(LdrGetProcedureAddress(hdll, &SdbGetFileAttributes, 0, (PVOID)&pSdbGetFileAttributes)) ||
146 !NT_SUCCESS(LdrGetProcedureAddress(hdll, &SdbFreeFileAttributes, 0, (PVOID)&pSdbFreeFileAttributes)))
147 {
149 hdll = NULL;
150 xprintf("Unable to resolve functions\n");
151 return FALSE;
152 }
153 }
154 return TRUE;
155}
BOOL WINAPI SdbFreeFileAttributes(PATTRINFO attr_info)
Definition: sdbfileattr.c:214
LPCWSTR WINAPI SdbTagToString(TAG tag)
Definition: sdbapi.c:752
BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
Definition: sdbfileattr.c:239
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI LdrUnloadDll(_In_ PVOID BaseAddress)
Definition: ldrapi.c:1331
NTSTATUS NTAPI DECLSPEC_HOTPATCH LdrLoadDll(_In_opt_ PWSTR SearchPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_ PVOID *BaseAddress)
Definition: ldrapi.c:312
NTSTATUS NTAPI LdrGetProcedureAddress(_In_ PVOID BaseAddress, _In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING Name, _In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG Ordinal, _Out_ PVOID *ProcedureAddress)
Definition: ldrapi.c:829
#define L(x)
Definition: ntvdm.h:50
static PVOID hdll
Definition: shimdbg.c:126
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by HandleDumpAttributes().

◆ IsOpt()

int IsOpt ( char argv,
const char check 
)

Definition at line 80 of file shimdbg.c.

81{
82 if( argv && (argv[0] == '-' || argv[0] == '/') ) {
83 return !_strnicmp(argv + 1, check, strlen(check));
84 }
85 return 0;
86}
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define check(expected, result)
Definition: dplayx.c:32

Referenced by main().

◆ LPCWSTR()

static LPCWSTR ( WINAPI pSdbTagToString)
static

◆ main()

int main ( int argc  ,
char argv[] 
)

Definition at line 311 of file shimdbg.c.

312{
313 int n, unhandled = 0, keepopen = 0;
314
315 for (n = 1; n < argc; ++n)
316 {
317 char* arg = argv[n];
318 if (IsOpt(arg, "d"))
319 {
320 xprintf("Calling ApphelpCacheServiceDump\n");
322 unhandled = 0;
323 }
324 else if (IsOpt(arg, "h"))
325 {
326 DumpRegistryData(arg[1] == 'h');
327 unhandled = 0;
328 }
329 else if (IsOpt(arg, "f"))
330 {
331 xprintf("Calling ApphelpCacheServiceFlush\n");
333 unhandled = 0;
334 }
335 else if (IsOpt(arg, "z"))
336 {
337 xprintf("Calling ApphelpDBGReadRegistry\n");
339 unhandled = 0;
340 }
341 else if (IsOpt(arg, "x"))
342 {
343 xprintf("Calling ApphelpDBGWriteRegistry\n");
345 unhandled = 0;
346 }
347 else if (IsOpt(arg, "l"))
348 {
349 unhandled |= HandleImageArg(argc, argv, &n, 'l',
350 ApphelpCacheServiceLookup, "ApphelpCacheServiceLookup");
351 }
352 else if (IsOpt(arg, "u"))
353 {
354 unhandled |= HandleImageArg(argc, argv, &n, 'u',
355 ApphelpCacheServiceUpdate, "ApphelpCacheServiceUpdate");
356 }
357 else if (IsOpt(arg, "r"))
358 {
359 unhandled |= HandleImageArg(argc, argv, &n, 'r',
360 ApphelpCacheServiceRemove, "ApphelpCacheServiceRemove");
361 }
362 else if (IsOpt(arg, "a"))
363 {
364 unhandled |= HandleDumpAttributes(argc, argv, &n, "a");
365 }
366 else if (IsOpt(arg, "k"))
367 {
368 keepopen = 1;
369 }
370 else
371 {
372 unhandled = 1;
373 }
374 }
375 if (unhandled || argc == 1)
376 {
377 xprintf("Usage: %s [-d|-z|-x|-h|-H|-f|-[l|L] <image>|-[u|U] <image>|-[r|R] <image>|-k]\n", argv[0]);
378 xprintf(" -d: Dump shim cache over debug output\n");
379 xprintf(" -z: DEBUG Read shim cache from registry\n");
380 xprintf(" -x: DEBUG Write shim cache to registry\n");
381 xprintf(" -h: Hexdump shim registry key\n");
382 xprintf(" -H: Crc + Length from shim registry key only\n");
383 xprintf(" -f: Flush (clear) the shim cache\n");
384 xprintf(" -l: Lookup <image> in the shim cache\n");
385 xprintf(" -L: Lookup <image> in the shim cache without mapping it\n");
386 xprintf(" -u: Update (insert) <image> in the shim cache\n");
387 xprintf(" -U: Update (insert) <image> in the shim cache without mapping it\n");
388 xprintf(" -r: Remove <image> from the shim cache\n");
389 xprintf(" -R: Remove <image> from the shim cache without mapping it\n");
390 xprintf(" -a: Dump file attributes as used in the appcompat database\n");
391 xprintf(" -k: Keep the console open\n");
392 }
393 if (keepopen)
394 {
395 _getch();
396 }
397 return unhandled;
398}
@ ApphelpDBGReadRegistry
Definition: pstypes.h:979
@ ApphelpCacheServiceLookup
Definition: pstypes.h:973
@ ApphelpCacheServiceRemove
Definition: pstypes.h:974
@ ApphelpCacheServiceUpdate
Definition: pstypes.h:975
@ ApphelpCacheServiceDump
Definition: pstypes.h:977
@ ApphelpDBGWriteRegistry
Definition: pstypes.h:980
@ ApphelpCacheServiceFlush
Definition: pstypes.h:976
int _getch()
Definition: getch.c:16
int HandleDumpAttributes(int argc, char *argv[], int *pn, const char *opt)
Definition: shimdbg.c:158
void DumpRegistryData(int IncludeDump)
Definition: shimdbg.c:261
int IsOpt(char *argv, const char *check)
Definition: shimdbg.c:80
int HandleImageArg(int argc, char *argv[], int *pn, char MapItChar, APPHELPCACHESERVICECLASS Service, char *ServiceName)
Definition: shimdbg.c:88

◆ MapFile()

HANDLE MapFile ( char filename,
UNICODE_STRING PathName,
int  MapIt 
)

Definition at line 34 of file shimdbg.c.

35{
36 OBJECT_ATTRIBUTES LocalObjectAttributes;
41 if (MapIt)
42 {
43 InitializeObjectAttributes(&LocalObjectAttributes, PathName,
47 &LocalObjectAttributes, &IoStatusBlock,
50 if (!NT_SUCCESS(Status))
51 {
52 xprintf("Failed opening the file, using a NULL handle\n");
54 }
55 }
56 return FileHandle;
57}
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_EXECUTE
Definition: nt_native.h:642

Referenced by CallApphelpWithImage().

◆ vDbgPrintEx()

NTSYSAPI ULONG NTAPI vDbgPrintEx ( _In_ ULONG  ComponentId,
_In_ ULONG  Level,
_In_z_ PCCH  Format,
_In_ va_list  ap 
)

Referenced by xprintf().

◆ xprintf()

void xprintf ( const char fmt,
  ... 
)

Definition at line 16 of file shimdbg.c.

17{
18 va_list ap;
19
20 va_start(ap, fmt);
21 vprintf(fmt, ap);
23 va_end(ap);
24}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
#define DPFLTR_ERROR_LEVEL
Definition: shimdbg.c:14
Definition: dsound.c:943
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by CallApphelp(), CallApphelpWithImage(), DumpRegistryData(), extract_test_proc(), HandleDumpAttributes(), HandleImageArg(), hexdump(), InitApphelp(), main(), MapFile(), print_version(), run_test(), and run_tests().

Variable Documentation

◆ AppCompatCacheKey

UNICODE_STRING AppCompatCacheKey = RTL_CONSTANT_STRING(L"\\Registry\\MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\AppCompatCache")

Definition at line 227 of file shimdbg.c.

◆ AppCompatCacheValue

UNICODE_STRING AppCompatCacheValue = RTL_CONSTANT_STRING(L"AppCompatCache")

Definition at line 229 of file shimdbg.c.

Referenced by DumpRegistryData().

◆ AppCompatKeyAttributes

◆ hdll

◆ LPDWORD

Definition at line 128 of file shimdbg.c.