1 #pragma once 2 3 /* 4 When a process is created, DbgInitDebugChannels will locate DEBUGCHANNEL 5 environment variable and extract information about debug channels. 6 This information includes which of the win32k debug channels will be 7 enabled for the current process and which level of a channel will be active. 8 This information will be stored in ppi->DbgChannelLevel. 9 In this way user mode can control how win32k debugging will work when 10 the following macros are used: ERR, FIXME, WARN, TRACE 11 12 By default only the ERR channel will be active. Remember that other 13 debug channels can be activated for applications that are executed with a DEBUGCHANNEL 14 15 Valid syntax for DEBUGCHANNEL is the following: 16 +UserProcess,info+UserWnd,err+UserWndpos,-listview 17 warn+UserMsgQ,-UserMsgGet,+shell 18 19 Note the following: 20 The debug level is not required 21 The operation to enable/disable (+/-) and the name of the channel is required 22 Channels are devided by commas 23 No spaces are allowed 24 The syntax is case sensitive. Levels must be lowercase and 25 the names of the channels must be exactly like they are defined in DBG_DEFAULT_CHANNEL 26 This syntax can be mixed with wine debug channels without problems 27 28 */ 29 30 #if DBG 31 32 #if !defined(__RELFILE__) 33 #define __RELFILE__ __FILE__ 34 #endif 35 36 typedef struct 37 { 38 PWCHAR Name; 39 ULONG Id; 40 } DBG_CHANNEL; 41 42 /* Note: The following values don't need to be sorted */ 43 enum _DEBUGCHANNELS 44 { 45 DbgChEngBlt, 46 DbgChEngBrush, 47 DbgChEngClip, 48 DbgChEngCursor, 49 DbgChEngDev, 50 DbgChEngErr, 51 DbgChEngEvent, 52 DbgChEngGrad, 53 DbgChEngLDev, 54 DbgChEngLine, 55 DbgChEngMapping, 56 DbgChEngPDev, 57 DbgChEngSurface, 58 DbgChEngWnd, 59 DbgChEngXlate, 60 DbgChGdiBitmap, 61 DbgChGdiBlt, 62 DbgChGdiBrush, 63 DbgChGdiClipRgn, 64 DbgChGdiCoord, 65 DbgChGdiDC, 66 DbgChGdiDCAttr, 67 DbgChGdiDCState, 68 DbgChGdiDev, 69 DbgChGdiDib, 70 DbgChGdiFont, 71 DbgChGdiLine, 72 DbgChGdiObj, 73 DbgChGdiPalette, 74 DbgChGdiPath, 75 DbgChGdiPen, 76 DbgChGdiPool, 77 DbgChGdiRgn, 78 DbgChGdiText, 79 DbgChGdiXFormObj, 80 DbgChUserAccel, 81 DbgChUserCallback, 82 DbgChUserCallProc, 83 DbgChUserCaret, 84 DbgChUserClass, 85 DbgChUserClipbrd, 86 DbgChUserCsr, 87 DbgChUserDce, 88 DbgChUserDefwnd, 89 DbgChUserDesktop, 90 DbgChUserDisplay, 91 DbgChUserEvent, 92 DbgChUserFocus, 93 DbgChUserHook, 94 DbgChUserHotkey, 95 DbgChUserIcon, 96 DbgChUserInput, 97 DbgChUserKbd, 98 DbgChUserKbdLayout, 99 DbgChUserMenu, 100 DbgChUserMetric, 101 DbgChUserMisc, 102 DbgChUserMonitor, 103 DbgChUserMsg, 104 DbgChUserMsgQ, 105 DbgChUserObj, 106 DbgChUserPainting, 107 DbgChUserProcess, 108 DbgChUserProp, 109 DbgChUserScrollbar, 110 DbgChUserShutdown, 111 DbgChUserSysparams, 112 DbgChUserThread, 113 DbgChUserTimer, 114 DbgChUserWinsta, 115 DbgChUserWnd, 116 DbgChUserWinpos, 117 DbgChCount 118 }; 119 120 #define DISABLED_LEVEL 0x0 121 #define ERR_LEVEL 0x1 122 #define FIXME_LEVEL 0x2 123 #define WARN_LEVEL 0x4 124 #define TRACE_LEVEL 0x8 125 126 #define MAX_LEVEL ERR_LEVEL | FIXME_LEVEL | WARN_LEVEL | TRACE_LEVEL 127 128 #define DBG_GET_PPI ((PPROCESSINFO)PsGetCurrentProcessWin32Process()) 129 #define DBG_DEFAULT_CHANNEL(x) static int DbgDefaultChannel = DbgCh##x; 130 131 #define DBG_ENABLE_CHANNEL(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] |= level) 132 #define DBG_DISABLE_CHANNEL(ppi,ch,level) ((ppi)->DbgChannelLevel[ch] &= ~level) 133 #define DBG_IS_CHANNEL_ENABLED(ppi,ch,level) (((ppi)->DbgChannelLevel[ch] & level) == level) 134 135 #define DBG_PRINT(ppi,ch,level,fmt, ...) \ 136 do { \ 137 if ((level == ERR_LEVEL) || (ppi && DBG_IS_CHANNEL_ENABLED(ppi,ch,level))) \ 138 DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__); \ 139 } while (0) 140 141 #define ERR(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, ERR_LEVEL,"err: " fmt, ##__VA_ARGS__) 142 #define FIXME(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, FIXME_LEVEL,"fixme: " fmt, ##__VA_ARGS__) 143 #define WARN(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, WARN_LEVEL,"warn: " fmt, ##__VA_ARGS__) 144 #define TRACE(fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgDefaultChannel, TRACE_LEVEL,"trace: " fmt, ##__VA_ARGS__) 145 146 #define ERR_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, ERR_LEVEL, "err: " fmt, ##__VA_ARGS__) 147 #define FIXME_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, FIXME_LEVEL, "fixme: " fmt, ##__VA_ARGS__) 148 #define WARN_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, WARN_LEVEL, "warn: " fmt, ##__VA_ARGS__) 149 #define TRACE_CH(ch,fmt, ...) DBG_PRINT(DBG_GET_PPI, DbgCh##ch, TRACE_LEVEL, "trace: " fmt, ##__VA_ARGS__) 150 151 #define ERR_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, ERR_LEVEL,"err: " fmt, ##__VA_ARGS__) 152 #define FIXME_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, FIXME_LEVEL,"fixme: " fmt, ##__VA_ARGS__) 153 #define WARN_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, WARN_LEVEL,"warn: " fmt, ##__VA_ARGS__) 154 #define TRACE_PPI(ppi,ch,fmt, ...) DBG_PRINT(ppi, DbgCh##ch, TRACE_LEVEL,"trace: " fmt, ##__VA_ARGS__) 155 156 #define STUB DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__RELFILE__,__LINE__); 157 158 #else 159 #define DBG_GET_PPI 160 #define DBG_DEFAULT_CHANNEL(x) 161 162 #define DBG_ENABLE_CHANNEL(ppi,ch,level) 163 #define DBG_DISABLE_CHANNEL(ppi,ch,level) 164 #define DBG_IS_CHANNEL_ENABLED(ppi,ch,level) 165 166 #define DBG_PRINT(ppi,ch,level) 167 168 #define ERR(fmt, ...) 169 #define FIXME(fmt, ...) 170 #define WARN(fmt, ...) 171 #define TRACE(fmt, ...) 172 173 #define ERR_CH(ch,fmt, ...) 174 #define FIXME_CH(ch,fmt, ...) 175 #define WARN_CH(ch,fmt, ...) 176 #define TRACE_CH(ch,fmt, ...) 177 178 #define ERR_PPI(ppi,ch,fmt, ...) 179 #define FIXME_PPI(ppi,ch,fmt, ...) 180 #define WARN_PPI(ppi,ch,fmt, ...) 181 #define TRACE_PPI(ppi,ch,fmt, ...) 182 183 #define STUB 184 185 #endif 186 187 BOOL DbgInitDebugChannels(); 188