ReactOS  0.4.13-dev-443-g10f00f8
sdbpapi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagMEMMAPPED
 

Macros

#define SdbAlloc(size)   SdbpAlloc(size)
 
#define SdbReAlloc(mem, size, oldSize)   SdbpReAlloc(mem, size, oldSize)
 
#define SdbFree(mem)   SdbpFree(mem)
 
#define WINAPIV
 
#define SHIM_ERR(fmt, ...)   do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
 
#define SHIM_WARN(fmt, ...)   do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
 
#define SHIM_INFO(fmt, ...)   do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
 

Typedefs

typedef struct tagMEMMAPPED MEMMAPPED
 
typedef struct tagMEMMAPPEDPMEMMAPPED
 
typedef enum _SHIM_LOG_LEVEL SHIM_LOG_LEVEL
 

Enumerations

enum  _SHIM_LOG_LEVEL { SHIM_ERR = 1, SHIM_WARN = 2, SHIM_INFO = 3 }
 

Functions

void SdbpHeapInit (void)
 
void SdbpHeapDeinit (void)
 
LPVOID SdbpAlloc (SIZE_T size)
 
LPVOID SdbpReAlloc (LPVOID mem, SIZE_T size, SIZE_T oldSize)
 
void SdbpFree (LPVOID mem)
 
BOOL WINAPI SdbpOpenMemMappedFile (LPCWSTR path, PMEMMAPPED mapping)
 
void WINAPI SdbpCloseMemMappedFile (PMEMMAPPED mapping)
 
PDB WINAPI SdbpCreate (LPCWSTR path, PATH_TYPE type, BOOL write)
 
void WINAPI SdbpFlush (PDB pdb)
 
DWORD SdbpStrlen (PCWSTR string)
 
DWORD SdbpStrsize (PCWSTR string)
 
BOOL WINAPI SdbpCheckTagType (TAG tag, WORD type)
 
BOOL WINAPI SdbpCheckTagIDType (PDB pdb, TAGID tagid, WORD type)
 
BOOL WINAPIV ShimDbgPrint (SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format,...)
 

Variables

ULONG g_ShimDebugLevel
 

Macro Definition Documentation

◆ SdbAlloc

#define SdbAlloc (   size)    SdbpAlloc(size)

Definition at line 35 of file sdbpapi.h.

◆ SdbFree

#define SdbFree (   mem)    SdbpFree(mem)

Definition at line 37 of file sdbpapi.h.

◆ SdbReAlloc

#define SdbReAlloc (   mem,
  size,
  oldSize 
)    SdbpReAlloc(mem, size, oldSize)

Definition at line 36 of file sdbpapi.h.

◆ SHIM_ERR

#define SHIM_ERR (   fmt,
  ... 
)    do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)

Definition at line 76 of file sdbpapi.h.

◆ SHIM_INFO

#define SHIM_INFO (   fmt,
  ... 
)    do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)

Definition at line 78 of file sdbpapi.h.

◆ SHIM_WARN

#define SHIM_WARN (   fmt,
  ... 
)    do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)

Definition at line 77 of file sdbpapi.h.

◆ WINAPIV

#define WINAPIV

Definition at line 64 of file sdbpapi.h.

Typedef Documentation

◆ MEMMAPPED

◆ PMEMMAPPED

◆ SHIM_LOG_LEVEL

Enumeration Type Documentation

◆ _SHIM_LOG_LEVEL

Enumerator
SHIM_ERR 
SHIM_WARN 
SHIM_INFO 

Definition at line 67 of file sdbpapi.h.

67  {
68  SHIM_ERR = 1,
69  SHIM_WARN = 2,
70  SHIM_INFO = 3,
enum _SHIM_LOG_LEVEL SHIM_LOG_LEVEL
#define SHIM_INFO(fmt,...)
Definition: sdbpapi.h:78
#define SHIM_ERR(fmt,...)
Definition: sdbpapi.h:76
#define SHIM_WARN(fmt,...)
Definition: sdbpapi.h:77

Function Documentation

◆ SdbpAlloc()

LPVOID SdbpAlloc ( SIZE_T  size)

Definition at line 55 of file sdbapi.c.

60 {
62 #if SDBAPI_DEBUG_ALLOC
63  SdbpInsertAllocation(mem, size, line, file);
64 #endif
65  return mem;
66 }
Definition: parser.c:48
static HANDLE SdbpHeap(void)
Definition: sdbapi.c:50
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
GLsizeiptr size
Definition: glext.h:5919
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: mem.c:156
Definition: fci.c:126

◆ SdbpCheckTagIDType()

BOOL WINAPI SdbpCheckTagIDType ( PDB  pdb,
TAGID  tagid,
WORD  type 
)

Definition at line 261 of file sdbapi.c.

262 {
263  TAG tag = SdbGetTagFromTagID(pdb, tagid);
264  if (tag == TAG_NULL)
265  return FALSE;
266  return SdbpCheckTagType(tag, type);
267 }
static PDB pdb
Definition: db.cpp:170
BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type)
Definition: sdbapi.c:254
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: ecma_167.h:138
#define TAG_NULL
Definition: apphelp.c:43
Definition: fs_rec.h:142
TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid)
Definition: sdbread.c:93

Referenced by SdbEndWriteListTag(), SdbGetBinaryTagData(), SdbReadBinaryTag(), SdbReadDWORDTag(), SdbReadQWORDTag(), and SdbReadWORDTag().

◆ SdbpCheckTagType()

BOOL WINAPI SdbpCheckTagType ( TAG  tag,
WORD  type 
)

Definition at line 254 of file sdbapi.c.

255 {
256  if ((tag & TAG_TYPE_MASK) != type)
257  return FALSE;
258  return TRUE;
259 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: ecma_167.h:138
#define TAG_TYPE_MASK
Definition: shimdbg.c:106

Referenced by SdbBeginWriteListTag(), SdbpCheckTagIDType(), SdbWriteBinaryTag(), SdbWriteBinaryTagFromFile(), SdbWriteDWORDTag(), SdbWriteNULLTag(), SdbWriteQWORDTag(), SdbWriteStringRefTag(), SdbWriteStringTag(), and SdbWriteWORDTag().

◆ SdbpCloseMemMappedFile()

void WINAPI SdbpCloseMemMappedFile ( PMEMMAPPED  mapping)

Definition at line 244 of file sdbapi.c.

245 {
246  /* Prevent a VAD warning */
247  if (mapping->view)
249  NtClose(mapping->section);
250  NtClose(mapping->file);
251  RtlZeroMemory(mapping, sizeof(*mapping));
252 }
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3780
#define NtCurrentProcess()
Definition: nt_native.h:1657
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by SdbGetFileAttributes(), and SdbWriteBinaryTagFromFile().

◆ SdbpCreate()

PDB WINAPI SdbpCreate ( LPCWSTR  path,
PATH_TYPE  type,
BOOL  write 
)

Definition at line 93 of file sdbapi.c.

94 {
99  PDB pdb;
100 
101  if (type == DOS_PATH)
102  {
104  return NULL;
105  }
106  else
107  {
109  }
110 
111  /* SdbAlloc zeroes the memory. */
112  pdb = (PDB)SdbAlloc(sizeof(DB));
113  if (!pdb)
114  {
115  SHIM_ERR("Failed to allocate memory for shim database\n");
116  return NULL;
117  }
118 
120 
124 
125  pdb->for_write = write;
126 
127  if (type == DOS_PATH)
129 
130  if (!NT_SUCCESS(Status))
131  {
133  SHIM_ERR("Failed to create shim database file: %lx\n", Status);
134  return NULL;
135  }
136 
137  return pdb;
138 }
#define FILE_GENERIC_READ
Definition: nt_native.h:653
static PDB pdb
Definition: db.cpp:170
Definition: sdbtypes.h:24
LONG NTSTATUS
Definition: precomp.h:26
VOID * PDB
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define FILE_SHARE_READ
Definition: compat.h:125
#define write
Definition: acwin.h:73
#define SdbAlloc(size)
Definition: sdbpapi.h:35
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
Definition: cookie.c:170
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
__u8 attr
Definition: mkdosfs.c:359
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define FILE_OPEN
Definition: from_kernel.h:54
Definition: services.c:325
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
void WINAPI SdbCloseDatabase(PDB pdb)
Definition: sdbapi.c:373
#define FILE_SUPERSEDE
Definition: from_kernel.h:53
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)

Referenced by SdbCreateDatabase(), and SdbpOpenDatabase().

◆ SdbpFlush()

void WINAPI SdbpFlush ( PDB  pdb)

Definition at line 140 of file sdbapi.c.

141 {
144 
145  ASSERT(pdb->for_write);
146  Status = NtWriteFile(pdb->file, NULL, NULL, NULL, &io,
147  pdb->data, pdb->write_iter, NULL, NULL);
148  if (!NT_SUCCESS(Status))
149  SHIM_WARN("failed with 0x%lx\n", Status);
150 }
static PDB pdb
Definition: db.cpp:170
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
Status
Definition: gdiplustypes.h:24
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:100

Referenced by SdbCloseDatabaseWrite().

◆ SdbpFree()

void SdbpFree ( LPVOID  mem)

Definition at line 81 of file sdbapi.c.

86 {
87 #if SDBAPI_DEBUG_ALLOC
88  SdbpRemoveAllocation(mem, line, file);
89 #endif
90  RtlFreeHeap(SdbpHeap(), 0, mem);
91 }
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
Definition: parser.c:48
static HANDLE SdbpHeap(void)
Definition: sdbapi.c:50
Definition: mem.c:156
Definition: fci.c:126

◆ SdbpHeapDeinit()

void SdbpHeapDeinit ( void  )

Definition at line 42 of file sdbapi.c.

43 {
44 #if SDBAPI_DEBUG_ALLOC
45  SdbpDebugHeapDeinit();
46 #endif
48 }
NTSYSAPI PVOID NTAPI RtlDestroyHeap(IN PVOID HeapHandle)
static HANDLE g_Heap
Definition: sdbapi.c:33

Referenced by DllMain().

◆ SdbpHeapInit()

void SdbpHeapInit ( void  )

Definition at line 34 of file sdbapi.c.

35 {
36  g_Heap = RtlCreateHeap(HEAP_GROWABLE, NULL, 0, 0x10000, NULL, NULL);
37 #if SDBAPI_DEBUG_ALLOC
38  SdbpDebugHeapInit(g_Heap);
39 #endif
40 }
smooth NULL
Definition: ftsmooth.c:416
#define HEAP_GROWABLE
Definition: nt_native.h:1693
NTSYSAPI PVOID NTAPI RtlCreateHeap(IN ULONG Flags, IN PVOID HeapBase OPTIONAL, IN ULONG ReserveSize OPTIONAL, IN ULONG CommitSize OPTIONAL, IN PVOID Lock OPTIONAL, IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL)
static HANDLE g_Heap
Definition: sdbapi.c:33

Referenced by DllMain().

◆ SdbpOpenMemMappedFile()

BOOL WINAPI SdbpOpenMemMappedFile ( LPCWSTR  path,
PMEMMAPPED  mapping 
)

Definition at line 170 of file sdbapi.c.

171 {
175  FILE_STANDARD_INFORMATION FileStandard;
177 
178  RtlZeroMemory(mapping, sizeof(*mapping));
179 
181 
184 
186  {
188  {
189  SHIM_ERR("Failed to convert %S to Nt path: 0x%lx\n", path, Status);
190  return FALSE;
191  }
195  }
196 
197  if (!NT_SUCCESS(Status))
198  {
199  SHIM_ERR("Failed to open file %S: 0x%lx\n", path, Status);
200  return FALSE;
201  }
202 
204  if (!NT_SUCCESS(Status))
205  {
206  /* Special case */
208  {
209  NtClose(mapping->file);
210  mapping->file = mapping->section = NULL;
211  return TRUE;
212  }
213  SHIM_ERR("Failed to create mapping for file: 0x%lx\n", Status);
214  goto err_out;
215  }
216 
217  Status = NtQueryInformationFile(mapping->file, &IoStatusBlock, &FileStandard, sizeof(FileStandard), FileStandardInformation);
218  if (!NT_SUCCESS(Status))
219  {
220  SHIM_ERR("Failed to read file info for file: 0x%lx\n", Status);
221  goto err_out;
222  }
223 
224  mapping->mapped_size = mapping->size = FileStandard.EndOfFile.LowPart;
225  Status = NtMapViewOfSection(mapping->section, NtCurrentProcess(), (PVOID*)&mapping->view, 0, 0, 0, &mapping->mapped_size, ViewUnmap, 0, PAGE_READONLY);
226  if (!NT_SUCCESS(Status))
227  {
228  SHIM_ERR("Failed to map view of file: 0x%lx\n", Status);
229  goto err_out;
230  }
231 
232  return TRUE;
233 
234 err_out:
235  if (!mapping->view)
236  {
237  if (mapping->section)
238  NtClose(mapping->section);
239  NtClose(mapping->file);
240  }
241  return FALSE;
242 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3371
#define SECTION_QUERY
Definition: nt_native.h:1287
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_READ
Definition: compat.h:125
#define SEC_COMMIT
Definition: mmtypes.h:99
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3552
smooth NULL
Definition: ftsmooth.c:416
#define NtCurrentProcess()
Definition: nt_native.h:1657
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:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define SECTION_MAP_READ
Definition: compat.h:128
ULONG LowPart
Definition: typedefs.h:104
#define GENERIC_READ
Definition: compat.h:124
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
struct _FileName FileName
Definition: fatprocs.h:884
Definition: services.c:325
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define PAGE_READONLY
Definition: compat.h:127
#define FileStandardInformation
Definition: propsheet.cpp:61
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define STANDARD_RIGHTS_REQUIRED
Definition: nt_native.h:63
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_MAPPED_FILE_SIZE_ZERO
Definition: ntstatus.h:508
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:281
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)

Referenced by SdbGetFileAttributes(), and SdbWriteBinaryTagFromFile().

◆ SdbpReAlloc()

LPVOID SdbpReAlloc ( LPVOID  mem,
SIZE_T  size,
SIZE_T  oldSize 
)

Definition at line 68 of file sdbapi.c.

73 {
75 #if SDBAPI_DEBUG_ALLOC
76  SdbpUpdateAllocation(mem, newmem, size, line, file);
77 #endif
78  return newmem;
79 }
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2561
Definition: parser.c:48
static HANDLE SdbpHeap(void)
Definition: sdbapi.c:50
GLsizeiptr size
Definition: glext.h:5919
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: mem.c:156
Definition: fci.c:126

◆ SdbpStrlen()

DWORD SdbpStrlen ( PCWSTR  string)

Definition at line 152 of file sdbapi.c.

153 {
154  return (DWORD)wcslen(string);
155 }
unsigned long DWORD
Definition: ntddk_ex.h:95
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by HashAddString(), SdbGetAppPatchDir(), SdbpBuildSignMediaId(), SdbpCreate(), SdbpStrsize(), and Sdbwcscpy().

◆ SdbpStrsize()

DWORD SdbpStrsize ( PCWSTR  string)

Definition at line 157 of file sdbapi.c.

158 {
159  return (SdbpStrlen(string) + 1) * sizeof(WCHAR);
160 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD SdbpStrlen(PCWSTR string)
Definition: sdbapi.c:152

Referenced by SdbpStrDup().

◆ ShimDbgPrint()

BOOL WINAPIV ShimDbgPrint ( SHIM_LOG_LEVEL  Level,
PCSTR  FunctionName,
PCSTR  Format,
  ... 
)

Outputs diagnostic info.

Parameters
[in]LevelThe level to log this message with, choose any of [SHIM_ERR, SHIM_WARN, SHIM_INFO].
[in]FunctionNameThe function this log should be attributed to.
[in]FormatThe format string.
...Variable arguments providing additional information.
Returns
Success: TRUE Failure: FALSE.

Definition at line 106 of file apphelp.c.

107 {
108  char Buffer[512];
109  va_list ArgList;
110  char* Current = Buffer;
111  const char* LevelStr;
112  size_t Length = sizeof(Buffer);
113 
114  if (g_ShimDebugLevel == ~0)
116 
117  if (Level > g_ShimDebugLevel)
118  return FALSE;
119 
120  switch (Level)
121  {
122  case SHIM_ERR:
123  LevelStr = "Err ";
125  break;
126  case SHIM_WARN:
127  LevelStr = "Warn";
129  break;
130  case SHIM_INFO:
131  LevelStr = "Info";
133  break;
134  default:
135  LevelStr = "User";
137  break;
138  }
139  StringCchPrintfExA(Current, Length, &Current, &Length, STRSAFE_NULL_ON_FAILURE, "[%s][%-20s] ", LevelStr, FunctionName);
140 
141  va_start(ArgList, Format);
142  StringCchVPrintfExA(Current, Length, &Current, &Length, STRSAFE_NULL_ON_FAILURE, Format, ArgList);
143  va_end(ArgList);
144 
145 #if defined(APPCOMPAT_USE_DBGPRINTEX) && APPCOMPAT_USE_DBGPRINTEX
147 #else
148  DbgPrint("%s", Buffer);
149  return TRUE;
150 #endif
151 }
#define TRUE
Definition: types.h:120
#define DbgPrint
Definition: loader.c:25
STRSAFEAPI StringCchVPrintfExA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCSTR pszFormat, va_list argList)
Definition: strsafe.h:650
#define DPFLTR_INFO_LEVEL
Definition: kdtypes.h:33
#define DPFLTR_MASK
Definition: kdtypes.h:34
NTSYSAPI ULONG __cdecl DbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ _Printf_format_string_ PCSTR Format,...)
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
STRSAFEAPI StringCchPrintfExA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCSTR pszFormat,...)
Definition: strsafe.h:575
#define DPFLTR_WARNING_LEVEL
Definition: kdtypes.h:31
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG g_ShimDebugLevel
Definition: apphelp.c:35
void ApphelppInitDebugLevel(void)
Definition: apphelp.c:38
#define DPFLTR_ERROR_LEVEL
Definition: main.cpp:32
#define DPFLTR_APPCOMPAT_ID
Definition: apphelp.c:27
#define va_start(ap, A)
Definition: acmsvcex.h:91
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1252
#define STRSAFE_NULL_ON_FAILURE
Definition: ntstrsafe.h:47
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Variable Documentation

◆ g_ShimDebugLevel

ULONG g_ShimDebugLevel

Definition at line 35 of file apphelp.c.

Referenced by ApphelppInitDebugLevel(), ShimDbgPrint(), and update_loglevel().