xref: /reactos/dll/appcompat/apphelp/sdbpapi.h (revision 40462c92)
1 /*
2  * PROJECT:     ReactOS Application compatibility module
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Shim engine private functions
5  * COPYRIGHT:   Copyright 2013 Mislav Blažević
6  *              Copyright 2015-2017 Mark Jansen (mark.jansen@reactos.org)
7  */
8 
9 #ifndef SDBPAPI_H
10 #define SDBPAPI_H
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 void SdbpHeapInit(void);
17 void SdbpHeapDeinit(void);
18 
19 #if SDBAPI_DEBUG_ALLOC
20 
21 LPVOID SdbpAlloc(SIZE_T size, int line, const char* file);
22 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize, int line, const char* file);
23 void SdbpFree(LPVOID mem, int line, const char* file);
24 
25 #define SdbAlloc(size) SdbpAlloc(size, __LINE__, __FILE__)
26 #define SdbReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize, __LINE__, __FILE__)
27 #define SdbFree(mem) SdbpFree(mem, __LINE__, __FILE__)
28 
29 #else
30 
31 LPVOID SdbpAlloc(SIZE_T size);
32 LPVOID SdbpReAlloc(LPVOID mem, SIZE_T size, SIZE_T oldSize);
33 void SdbpFree(LPVOID mem);
34 
35 #define SdbAlloc(size) SdbpAlloc(size)
36 #define SdbReAlloc(mem, size, oldSize) SdbpReAlloc(mem, size, oldSize)
37 #define SdbFree(mem) SdbpFree(mem)
38 
39 #endif
40 
41 #if !defined(SDBWRITE_HOSTTOOL)
42 typedef struct tagMEMMAPPED {
43     HANDLE file;
44     HANDLE section;
45     PBYTE view;
46     SIZE_T size;
47     SIZE_T mapped_size;
48 } MEMMAPPED, *PMEMMAPPED;
49 
50 BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping);
51 void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping);
52 #endif
53 
54 
55 PDB WINAPI SdbpCreate(LPCWSTR path, PATH_TYPE type, BOOL write);
56 void WINAPI SdbpFlush(PDB pdb);
57 DWORD SdbpStrlen(PCWSTR string);
58 DWORD SdbpStrsize(PCWSTR string);
59 
60 BOOL WINAPI SdbpCheckTagType(TAG tag, WORD type);
61 BOOL WINAPI SdbpCheckTagIDType(PDB pdb, TAGID tagid, WORD type);
62 
63 #ifndef WINAPIV
64 #define WINAPIV
65 #endif
66 
67 typedef enum _SHIM_LOG_LEVEL {
68     SHIM_ERR = 1,
69     SHIM_WARN = 2,
70     SHIM_INFO = 3,
71 } SHIM_LOG_LEVEL;
72 
73 BOOL WINAPIV ShimDbgPrint(SHIM_LOG_LEVEL Level, PCSTR FunctionName, PCSTR Format, ...);
74 extern ULONG g_ShimDebugLevel;
75 
76 #define SHIM_ERR(fmt, ...)  do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_ERR, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
77 #define SHIM_WARN(fmt, ...)  do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_WARN, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
78 #define SHIM_INFO(fmt, ...)  do { if (g_ShimDebugLevel) ShimDbgPrint(SHIM_INFO, __FUNCTION__, fmt, ##__VA_ARGS__ ); } while (0)
79 
80 #ifdef __cplusplus
81 } // extern "C"
82 #endif
83 
84 #endif // SDBPAPI_H
85