Subversion Repositories Aucun

Rev

Rev 40 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
38 ixe013 1
#ifdef _DEBUG
28 ixe013 2
#include <windows.h>
91 ixe013 3
#include "trace.h"
28 ixe013 4
#include "debug.h"
5
 
6
typedef struct tagMessageList
7
{
91 ixe013 8
    LPCWSTR pMessageID;     // Text based ID
9
    UINT dMessageNo;        // Numeric ID
10
    BOOL bFilter;           // Filter: 0=Show message, 1=Do not show
11
    LPCWSTR pMessageDesc;       // Text based description
12
    BYTE dWParam;           // wParam Signature
13
    BYTE dLParam;           // lParam Signature
14
    BYTE dLResult;          // lResult Signature
28 ixe013 15
} MessageList;
16
 
91 ixe013 17
static const MessageList g_mlTable[] =
18
{
19
    { L"WM_NULL",           0,      0,  L"No operation", 0, 0, 0 },
20
    { L"WM_CREATE",         1,      0,  L"Window created and about to be displayed", 0, 0, 0 },
21
    { L"WM_DESTROY",            2,      0,  L"Window is being destroy and has been removed from the screen", 0, 0, 0 },
22
    { L"WM_MOVE",           3,      0,  L"Window has been moved", 0, 0, 0 },
23
    { L"WM_SIZE",           5,      0,  L"Window size has been changed", 0, 0, 0 },
24
    { L"WM_ACTIVATE",       6,      0,  L"Window is either being activated for deactivated", 0, 0, 0 },
25
    { L"WM_SETFOCUS",       7,      0,  L"Window has keyboard focus", 0, 0, 0 },
26
    { L"WM_KILLFOCUS",      8,      0,  L"Window is about to lose focus", 0, 0, 0 },
27
    { L"WM_ENABLE",         10,     0,  L"Window enabled state is changing", 0, 0, 0 },
28
    { L"WM_SETREDRAW",      11,     0,  L"Allow or prevent redraws to take place", 0, 0, 0 },
29
    { L"WM_SETTEXT",            12,     0,  L"Set the text of the window", 0, 0, 0 },
30
    { L"WM_GETTEXT",            13,     0,  L"Retrieve corresponding window text", 0, 0, 0 },
31
    { L"WM_GETTEXTLENGTH",  14,     0,  L"Return length, in characters, of associated text", 0, 0, 0 },
32
    { L"WM_PAINT",          15,     0,  L"Paint a portion of the client area", 0, 0, 0 },
33
    { L"WM_CLOSE",          16,     0,  L"Window or application should terminate", 0, 0, 0 },
34
    { L"WM_QUERYENDSESSION",    17,     0,  L"User chose to end current Windows session", 0, 0, 0 },
35
    { L"WM_QUIT",           18,     0,  L"Terminate application request", 0, 0, 0 },
36
    { L"WM_QUERYOPEN",      19,     0,  L"User requested that iconic window be restored", 0, 0, 0 },
37
    { L"WM_ERASEBKGND",     20,     0,  L"Window background must be erased", 0, 0, 0 },
38
    { L"WM_SYSCOLORCHANGE", 21,     0,  L"A change has been made to a system color setting", 0, 0, 0 },
39
    { L"WM_ENDSESSION",     22,     0,  L"Windows session might be ending", 0, 0, 0 },
40
    { L"WM_SHOWWINDOW",     24,     0,  L"Window is about to be hidden or shown", 0, 0, 0 },
41
    { L"WM_SETTINGCHANGE",  26,     0,  L"A system wide setting has changed", 0, 0, 0 },
42
    { L"WM_WININICHANGE",   26,     0,  L"A system wide setting has changed", 0, 0, 0 },
43
    { L"WM_DEVMODECHANGE",  27,     0,  L"User changed device-mode settings", 0, 0, 0 },
44
    { L"WM_ACTIVATEAPP",        28,     0,  L"A window belonging to another application is about to be activated", 0, 0, 0 },
45
    { L"WM_FONTCHANGE",     29,     0,  L"Pool of font resources has changed", 0, 0, 0 },
46
    { L"WM_TIMECHANGE",     30,     0,  L"System time has changed", 0, 0, 0 },
47
    { L"WM_CANCELMODE",     31,     0,  L"Window is to cancel its current mode", 0, 0, 0 },
48
    { L"WM_SETCURSOR",      32,     0,  L"Cursor moved within window and is not captured", 0, 0, 0 },
49
    { L"WM_MOUSEACTIVATE",  33,     0,  L"Window activation via mouse click", 0, 0, 0 },
50
    { L"WM_CHILDACTIVATE",  34,     0,  L"MDI child window has been activated, moved, or sized", 0, 0, 0 },
51
    { L"WM_QUEUESYNC",      35,     0,  L"Separate user-input messages from other journal playback hook messages", 0, 0, 0 },
52
    { L"WM_GETMINMAXINFO",  36,     0,  L"Return minimum or maximum tracking size", 0, 0, 0 },
53
    { L"WM_PAINTICON",      38,     0,  L"Icon is to be painted of minimized window", 0, 0, 0 },
54
    { L"WM_ICONERASEBKGND", 39,     0,  L"Background of the minimized window icon must be painted", 0, 0, 0 },
55
    { L"WM_NEXTDLGCTL",     40,     0,  L"Set the keyboard focus to a different control", 0, 0, 0 },
56
    { L"WM_SPOOLERSTATUS",  42,     0,  L"Job as been added or removed from the Print Manager queue", 0, 0, 0 },
57
    { L"WM_DRAWITEM",       43,     0,  L"Visual aspect of control has changed", 0, 0, 0 },
58
    { L"WM_MEASUREITEM",        44,     0,  L"Provide measurements of owner drawn control", 0, 0, 0 },
59
    { L"WM_DELETEITEM",     45,     0,  L"Items removed from the list/combo box", 0, 0, 0 },
60
    { L"WM_VKEYTOITEM",     46,     0,  L"List box want keyboard input notification", 0, 0, 0 },
61
    { L"WM_CHARTOITEM",     47,     0,  L"List box with keyboard input enabled received a character message", 0, 0, 0 },
62
    { L"WM_SETFONT",            48,     0,  L"Set desired font window is to use while drawing text", 0, 0, 0 },
63
    { L"WM_GETFONT",            49,     0,  L"Return the font with which the window is currently drawing its text", 0, 0, 0 },
64
    { L"WM_SETHOTKEY",      50,     0,  L"Associate hot key", 0, 0, 0 },
65
    { L"WM_GETHOTKEY",      51,     0,  L"Hot key association query", 0, 0, 0 },
66
    { L"WM_QUERYDRAGICON",  55,     0,  L"Minimized iconic window is about to be dragged by user", 0, 0, 0 },
67
    { L"WM_COMPAREITEM",        57,     0,  L"Report the relative item position in a sorted list of an owner-draw combo or list box", 0, 0, 0 },
68
    { L"WM_COMPACTING",     65,     0,  L"System memory is low", 0, 0, 0 },
69
    { L"WM_WINDOWPOSCHANGING",70,   0,  L"Size, position, or Z order is about to change", 0, 0, 0 },
70
    { L"WM_WINDOWPOSCHANGED",71,        0,  L"Size, position, or Z order has changed", 0, 0, 0 },
71
    { L"WM_POWER",          72,     0,  L"System is about to enter suspended mode", 0, 0, 0 },
72
    { L"WM_COPYDATA",       74,     0,  L"Data has be passed to application ", 0, 0, 0 },
73
    { L"WM_CANCELJOURNAL",  75,     0,  L"User cancelled journaling activities", 0, 0, 0 },
74
    { L"WM_NOTIFY",         78,     0,  L"Control event occurred or requires information", 0, 0, 0 },
75
    { L"WM_INPUTLANGCHANGEREQUEST",80,0,    L"User requests to change the current input language", 0, 0, 0 },
76
    { L"WM_INPUTLANGCHANGE",    81,     0,  L"Input language has changed", 0, 0, 0 },
77
    { L"WM_TCARD",          82,     0,  L"User clicked an authorable button on a WinHelp Training Card", 0, 0, 0 },
78
    { L"WM_HELP",           83,     0,  L"User pressed F1", 0, 0, 0 },
79
    { L"WM_USERCHANGED",        84,     0,  L"User has logged on or off", 0, 0, 0 },
80
    { L"WM_NOTIFYFORMAT",   85,     0,  L"Return whether should use ANSI or Unicode structures", 0, 0, 0 },
81
    { L"WM_CONTEXTMENU",        123,    0,  L"User clicked the right mouse button in the window", 0, 0, 0 },
82
    { L"WM_STYLECHANGING",  124,    0,  L"One or more of the window's styles is about to change", 0, 0, 0 },
83
    { L"WM_STYLECHANGED",   125,    0,  L"Window's style has changed", 0, 0, 0 },
84
    { L"WM_DISPLAYCHANGE",  126,    0,  L"Display resolution has changed", 0, 0, 0 },
85
    { L"WM_GETICON",            127,    0,  L"Return the handle of the large or small associated icon", 0, 0, 0 },
86
    { L"WM_SETICON",            128,    0,  L"Set large or small icon", 0, 0, 0 },
87
    { L"WM_NCCREATE",       129,    0,  L"Non-client area created and is about to be displayed", 0, 0, 0 },
88
    { L"WM_NCDESTROY",      130,    0,  L"Non-client area is being destroyed", 0, 0, 0 },
89
    { L"WM_NCCALCSIZE",     131,    0,  L"Size and position of client area must be calculated", 0, 0, 0 },
90
    { L"WM_NCHITTEST",      132,    0,  L"Mouse cursor moved or button was pressed or released", 0, 0, 0 },
91
    { L"WM_NCPAINT",            133,    0,  L"Frame must be painted", 0, 0, 0 },
92
    { L"WM_NCACTIVATE",     134,    0,  L"Nonclient area needs to be changed to reflect active state", 0, 0, 0 },
93
    { L"WM_GETDLGCODE",     135,    0,  L"Chance to override default behavior to dialog box input", 0, 0, 0 },
94
    { L"WM_NCMOUSEMOVE",        160,    0,  L"User moved mouse within non-client area", 0, 0, 0 },
95
    { L"WM_NCLBUTTONDOWN",  161,    0,  L"User pressed left mouse button in non-client area", 0, 0, 0 },
96
    { L"WM_NCLBUTTONUP",        162,    0,  L"User released left mouse button in non-client area", 0, 0, 0 },
97
    { L"WM_NCLBUTTONDBLCLK",    163,    0,  L"User double clicked left mouse button in non-client area", 0, 0, 0 },
98
    { L"WM_NCRBUTTONDOWN",  164,    0,  L"User pressed right mouse button in non-client area", 0, 0, 0 },
99
    { L"WM_NCRBUTTONUP",        165,    0,  L"User released right mouse button in non-client area", 0, 0, 0 },
100
    { L"WM_NCRBUTTONDBLCLK",    166,    0,  L"User double clicked right mouse button in non-client area", 0, 0, 0 },
101
    { L"WM_NCMBUTTONDOWN",  167,    0,  L"User pressed middle mouse button in non-client area", 0, 0, 0 },
102
    { L"WM_NCMBUTTONUP",        168,    0,  L"User released middle mouse button in non-client area", 0, 0, 0 },
103
    { L"WM_NCMBUTTONDBLCLK",    169,    0,  L"User double clicked middle mouse button in non-client area", 0, 0, 0 },
104
    { L"WM_KEYDOWN",            256,    0,  L"Non-system key pressed", 0, 0, 0 },
105
    { L"WM_KEYUP",          257,    0,  L"Non-system key released", 0, 0, 0 },
106
    { L"WM_CHAR",           258,    0,  L"Key down message has been translated", 0, 0, 0 },
107
    { L"WM_DEADCHAR",       259,    0,  L"Dead character code translated", 0, 0, 0 },
108
    { L"WM_SYSKEYDOWN",     260,    0,  L"System key has been pressed (F10 or ALT-key)", 0, 0, 0 },
109
    { L"WM_SYSKEYUP",       261,    0,  L"System key has been released (F10 or ALT-key)", 0, 0, 0 },
110
    { L"WM_SYSCHAR",            262,    0,  L"System ALT key has been translated", 0, 0, 0 },
111
    { L"WM_SYSDEADCHAR",        263,    0,  L"Dead system character code translated", 0, 0, 0 },
112
    { L"WM_IME_STARTCOMPOSITION",269,0, L"IME is about to generate a composition string due to a keystroke", 0, 0, 0 },
113
    { L"WM_IME_ENDCOMPOSITION",270, 0,  L"IME ended composition", 0, 0, 0 },
114
    { L"WM_IME_COMPOSITION",    271,    0,  L"IME changed composition status as a result of a key stroke", 0, 0, 0 },
115
    { L"WM_INITDIALOG",     272,    0,  L"Dialog box is about to be displayed", 0, 0, 0 },
116
    { L"WM_COMMAND",            273,    0,  L"Window received a command notification", 0, 0, 0 },
117
    { L"WM_SYSCOMMAND",     274,    0,  L"User chose a command from the system menu", 0, 0, 0 },
118
    { L"WM_TIMER",          275,    0,  L"Timer expired", 0, 0, 0 },
119
    { L"WM_HSCROLL",            276,    0,  L"Scroll event occurred in the horizontal scroll bar", 0, 0, 0 },
120
    { L"WM_VSCROLL",            277,    0,  L"Scroll event occurred in the vertical scroll bar", 0, 0, 0 },
121
    { L"WM_INITMENU",       278,    0,  L"Menu is about to become active", 0, 0, 0 },
122
    { L"WM_INITMENUPOPUP",  279,    0,  L"Drop-down or sub-menu is about to become active", 0, 0, 0 },
123
    { L"WM_MENUSELECT",     287,    0,  L"Menu item has been selected", 0, 0, 0 },
124
    { L"WM_MENUCHAR",       288,    0,  L"User pressed an unknown menu key", 0, 0, 0 },
125
    { L"WM_ENTERIDLE",      289,    0,  L"Child modal dialog or menu is entering an idle state", 0, 0, 0 },
126
    { L"WM_CTLCOLORMSGBOX", 306,    0,  L"Message box is about to be drawn", 0, 0, 0 },
127
    { L"WM_CTLCOLOREDIT",   307,    0,  L"Edit box is about to be drawn", 0, 0, 0 },
128
    { L"WM_CTLCOLORLISTBOX",    308,    0,  L"List box is about to be drawn", 0, 0, 0 },
129
    { L"WM_CTLCOLORBTN",        309,    0,  L"Button is about to be drawn", 0, 0, 0 },
130
    { L"WM_CTLCOLORDLG",        310,    0,  L"Dialog box is about to be drawn", 0, 0, 0 },
131
    { L"WM_CTLCOLORSCROLLBAR",311,  0,  L"Scroll bar is about to be drawn", 0, 0, 0 },
132
    { L"WM_CTLCOLORSTATIC", 312,    0,  L"Static control is about to be drawn", 0, 0, 0 },
133
    { L"WM_MOUSEMOVE",      512,    0,  L"Mouse cursor moved", 0, 0, 0 },
134
    { L"WM_LBUTTONDOWN",        513,    0,  L"User pressed left mouse button in client area", 0, 0, 0 },
135
    { L"WM_LBUTTONUP",      514,    0,  L"User released left mouse button in client area", 0, 0, 0 },
136
    { L"WM_LBUTTONDBLCLK",  515,    0,  L"User double clicked left mouse button in client area", 0, 0, 0 },
137
    { L"WM_RBUTTONDOWN",        516,    0,  L"User pressed right mouse button in client area", 0, 0, 0 },
138
    { L"WM_RBUTTONUP",      517,    0,  L"User released right mouse button in client area", 0, 0, 0 },
139
    { L"WM_RBUTTONDBLCLK",  518,    0,  L"User double clicked right mouse button in client area", 0, 0, 0 },
140
    { L"WM_MBUTTONDOWN",        519,    0,  L"User pressed middle mouse button in client area", 0, 0, 0 },
141
    { L"WM_MBUTTONUP",      520,    0,  L"User released middle mouse button in client area", 0, 0, 0 },
142
    { L"WM_MBUTTONDBLCLK",  521,    0,  L"User double clicked middle mouse button in client area", 0, 0, 0 },
143
    { L"WM_MOUSEWHEEL",     522,    0,  L"Mouse wheel rotated", 0, 0, 0 },
144
    { L"WM_PARENTNOTIFY",   528,    0,  L"Child window created or destroyed, or mouse click event occurred to child", 0, 0, 0 },
145
    { L"WM_ENTERMENULOOP",  529,    0,  L"Menu modal loop has been entered", 0, 0, 0 },
146
    { L"WM_EXITMENULOOP",   530,    0,  L"Menu modal loop has been exited", 0, 0, 0 },
147
    { L"WM_NEXTMENU",       531,    0,  L"Right or left arrow key was used to switch between menu bar and system menu", 0, 0, 0 },
148
    { L"WM_SIZING",         532,    0,  L"Window is resizing", 0, 0, 0 },
149
    { L"WM_CAPTURECHANGED", 533,    0,  L"Window is losing mouse capture", 0, 0, 0 },
150
    { L"WM_MOVING",         534,    0,  L"Window is moving", 0, 0, 0 },
151
    { L"WM_POWERBROADCAST", 536,    0,  L"Power-management event notification", 0, 0, 0 },
152
    { L"WM_DEVICECHANGE",   537,    0,  L"Hardware configuration has changed", 0, 0, 0 },
153
    { L"WM_MDICREATE",      544,    0,  L"Create a MDI child window", 0, 0, 0 },
154
    { L"WM_MDIDESTROY",     545,    0,  L"Destroy MDI child window", 0, 0, 0 },
155
    { L"WM_MDIACTIVATE",        546,    0,  L"Activate a different MDI child window", 0, 0, 0 },
156
    { L"WM_MDIRESTORE",     547,    0,  L"Restore MDI child window size", 0, 0, 0 },
157
    { L"WM_MDINEXT",            548,    0,  L"Activate the next or previous MDI child window", 0, 0, 0 },
158
    { L"WM_MDIMAXIMIZE",        549,    0,  L"Maximize a MDI child window", 0, 0, 0 },
159
    { L"WM_MDITILE",            550,    0,  L"Arrange all MDI children in a tile format", 0, 0, 0 },
160
    { L"WM_MDICASCADE",     551,    0,  L"Arrange all MDI child windows in cascade format", 0, 0, 0 },
161
    { L"WM_MDIICONARRANGE", 552,    0,  L"Arrange all minimized MDI child windows", 0, 0, 0 },
162
    { L"WM_MDIGETACTIVE",   553,    0,  L"Return handle of active MDI child window", 0, 0, 0 },
163
    { L"WM_MDISETMENU",     560,    0,  L"Replace entire menu of the MDI frame", 0, 0, 0 },
164
    { L"WM_ENTERSIZEMOVE",  561,    0,  L"Entered moving or sizing modal loop", 0, 0, 0 },
165
    { L"WM_EXITSIZEMOVE",   562,    0,  L"Window exited the moving or sizing modal loop", 0, 0, 0 },
166
    { L"WM_DROPFILES",      563,    0,  L"Dropped file notification", 0, 0, 0 },
167
    { L"WM_MDIREFRESHMENU", 564,    0,  L"Refresh the MDI menu of the frame", 0, 0, 0 },
168
    { L"WM_IME_SETCONTEXT", 641,    0,  L"IME window is about to be activated", 0, 0, 0 },
169
    { L"WM_IME_NOTIFY",     642,    0,  L"IME window change notification", 0, 0, 0 },
170
    { L"WM_IME_CONTROL",        643,    0,  L"IME window must carry out requested command", 0, 0, 0 },
171
    { L"WM_IME_COMPOSITIONFULL",644,    0,  L"IME cannot extend the area of the composition window", 0, 0, 0 },
172
    { L"WM_IME_SELECT",     645,    0,  L"System is about to change the current IME", 0, 0, 0 },
173
    { L"WM_IME_CHAR",       646,    0,  L"IME got a character of the conversion result", 0, 0, 0 },
174
    { L"WM_IME_KEYDOWN",        656,    0,  L"IME key press notification", 0, 0, 0 },
175
    { L"WM_IME_KEYUP",      657,    0,  L"IME key release notification", 0, 0, 0 },
176
    { L"WM_MOUSEHOVER",     673,    0,  L"Mouse cursor is hovering", 0, 0, 0 },
177
    { L"WM_MOUSELEAVE",     675,    0,  L"Mouse cursor moved out of window", 0, 0 ,0 },
178
    { L"WM_CUT",                768,    0,  L"Delete current selection", 0, 0, 0 },
179
    { L"WM_COPY",           769,    0,  L"Copy current selection into the clipboard in text format", 0, 0, 0 },
180
    { L"WM_PASTE",          770,    0,  L"Copy current content of the clipboard to control", 0, 0, 0 },
181
    { L"WM_CLEAR",          771,    0,  L"Clear the current selection, if any, from the edit control", 0, 0, 0 },
182
    { L"WM_UNDO",           772,    0,  L"Undo last operation", 0, 0, 0 },
183
    { L"WM_RENDERFORMAT",   773,    0,  L"Render data in the specified clipboard format", 0, 0, 0 },
184
    { L"WM_RENDERALLFORMATS",774,   0,  L"Render data in all clipboard formats", 0, 0, 0 },
185
    { L"WM_DESTROYCLIPBOARD",775,   0,  L"Clipboard has been emptied", 0, 0, 0 },
186
    { L"WM_DRAWCLIPBOARD",  776,    0,  L"Content of the clipboard changed", 0, 0, 0 },
187
    { L"WM_PAINTCLIPBOARD", 777,    0,  L"Clipboard viewer's client area needs repainting", 0, 0, 0 },
188
    { L"WM_VSCROLLCLIPBOARD",778,   0,  L"Event occurred in the clipboard viewer's vertical scroll bar", 0, 0, 0 },
189
    { L"WM_SIZECLIPBOARD",  779,    0,  L"Clipboard viewer's client area has changed size", 0, 0, 0 },
190
    { L"WM_ASKCBFORMATNAME",    780,    0,  L"Request of an owner displayed clipboard format", 0, 0, 0 },
191
    { L"WM_CHANGECBCHAIN",  781,    0,  L"A window is being removed from the clipboard viewer chain", 0, 0, 0 },
192
    { L"WM_HSCROLLCLIPBOARD",782,   0,  L"Event occurred in the clipboard viewer's horizontal scroll bar", 0, 0, 0 },
193
    { L"WM_QUERYNEWPALETTE",    783,    0,  L"Window may realize its logical palette what focus is received", 0, 0, 0 },
194
    { L"WM_PALETTEISCHANGING",784,  0,  L"A window is about to realize its logical palette", 0, 0, 0 },
195
    { L"WM_PALETTECHANGED", 785,    0,  L"A window has realized its logical palette", 0, 0, 0 },
196
    { L"WM_HOTKEY",         786,    0,  L"User pressed registered hotkey", 0, 0, 0 },
197
    { L"WM_PRINT",          791,    0,  L"Render image in current device context request", 0, 0, 0 },
198
    { L"WM_PRINTCLIENT",        792,    0,  L"Render client area in current device context request", 0, 0, 0 },
199
    { L"WM_DDE_INITIATE",   992,    0,  L"Initiate a conversation with a DDE client", 0, 0, 0 },
200
    { L"WM_DDE_TERMINATE",  993,    0,  L"Terminate a DDE conversation", 0, 0, 0 },
201
    { L"WM_DDE_ADVISE",     994,    0,  L"DDE server data item update notification request", 0, 0, 0 },
202
    { L"WM_DDE_UNADVISE",   995,    0,  L"Data or clipboard format client item should no longer be updated", 0, 0, 0 },
203
    { L"WM_DDE_ACK",            996,    0,  L"DDE message has been received and processed", 0, 0, 0 },
204
    { L"WM_DDE_DATA",       997,    0,  L"Data item received or data item available", 0, 0, 0 },
205
    { L"WM_DDE_REQUEST",        998,    0,  L"Client requests the value of a data item", 0, 0, 0 },
206
    { L"WM_DDE_POKE",       999,    0,  L"Client requests unsolicited data be accepted", 0, 0, 0 },
207
    { L"WM_DDE_EXECUTE",        1000,   0,  L"Process a string as a series of commands", 0, 0, 0 },
208
    { L"Unknown",           -1,     0,  L"Unknown message", 0, 0, 0 }
28 ixe013 209
};
210
 
211
static const int nbMessages = sizeof g_mlTable / sizeof *g_mlTable;
212
 
213
LPCWSTR GetWindowsMessageName(UINT msg)
214
{
91 ixe013 215
    LPCWSTR result = g_mlTable[nbMessages-1].pMessageID;
28 ixe013 216
 
91 ixe013 217
    int i;
218
    for (i=0; i<nbMessages; ++i)
219
    {
220
        if (g_mlTable[i].dMessageNo == msg)
221
        {
222
            result = g_mlTable[i].pMessageID;
223
        }
224
    }
28 ixe013 225
 
91 ixe013 226
    return result;
28 ixe013 227
}
228
 
229
 
230
BOOLEAN GetLUIDFromToken(HANDLE token, PLUID session)
231
{
91 ixe013 232
    BOOLEAN result = FALSE;
233
    TOKEN_STATISTICS stats = {0};
234
    DWORD nbstats = sizeof stats;
235
    GetTokenInformation(token, TokenStatistics, &stats, sizeof stats, &nbstats);
28 ixe013 236
 
91 ixe013 237
    *session = stats.AuthenticationId;
28 ixe013 238
 
91 ixe013 239
    return result;
28 ixe013 240
}
241
 
242
void OutputGetSessionUserName(PLUID session)
243
{
91 ixe013 244
    PSECURITY_LOGON_SESSION_DATA sessionData = NULL;
245
    NTSTATUS retval;
28 ixe013 246
 
91 ixe013 247
    // Check for a valid session.
248
    if (!session ) {
249
        OutputDebugString(L"Error - Invalid logon session identifier.\n");
250
        return;
251
    }
252
    // Get the session information.
253
    retval = LsaGetLogonSessionData (session, &sessionData);
254
    if (!retval)
255
    {
256
        // Determine whether there is session data to parse.
257
        if (!sessionData)
258
        { // no data for session
259
            OutputDebugString(L"Invalid logon session data. \n");
260
        }
261
        if (sessionData->UserName.Buffer != NULL)
262
        {
263
            OutputDebugString(L"User from LUID is ");
264
            OutputDebugString((sessionData->UserName).Buffer);
265
            OutputDebugString(L"\n");
266
        }
267
        // Free the memory returned by the LSA.
268
    }
269
    if (sessionData)
270
        LsaFreeReturnBuffer(sessionData);
271
    return;
28 ixe013 272
}
273
 
91 ixe013 274
BOOLEAN ExtractTokenOwner( HANDLE token, wchar_t *csOwner_o, size_t size)
275
{
276
    // First get size needed, TokenUser indicates we want user information from given token
277
    DWORD dwProcessTokenInfoAllocSize = 0;
278
    GetTokenInformation(token, TokenUser, NULL, 0, &dwProcessTokenInfoAllocSize);
279
 
280
    // Call should have failed due to zero-length buffer.
281
    if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER )
282
    {
283
        // Allocate buffer for user information in the token.
284
        PTOKEN_USER pUserToken = (PTOKEN_USER) malloc(dwProcessTokenInfoAllocSize);
285
        if (pUserToken != NULL)
286
        {
287
            // Now get user information in the allocated buffer
288
            if (GetTokenInformation( token, TokenUser, pUserToken, dwProcessTokenInfoAllocSize, &dwProcessTokenInfoAllocSize ))
289
            {
290
                // Some vars that we may need
291
                SID_NAME_USE   snuSIDNameUse;
292
                TCHAR          szUser[MAX_PATH] = { 0 };
293
                DWORD          dwUserNameLength = MAX_PATH;
294
                TCHAR          szDomain[MAX_PATH] = { 0 };
295
                DWORD          dwDomainNameLength = MAX_PATH;
296
 
297
                // Retrieve user name and domain name based on user's SID.
298
                if ( LookupAccountSid( NULL,
299
                                       pUserToken->User.Sid,
300
                                       szUser,
301
                                       &dwUserNameLength,
302
                                       szDomain,
303
                                       &dwDomainNameLength,
304
                                       &snuSIDNameUse ))
305
                {
306
                    // We are done!
307
                    free(pUserToken);
308
 
309
                    // We succeeded
310
                    return TRUE;
311
                }//End if
312
            }// End if
313
 
314
            free(pUserToken);
315
        }// End if
316
    }// End if
317
 
318
 
319
    // Oops trouble
320
    return FALSE;
321
}// End GetProcessOwner
322
 
323
void OutputDebugStringError(DWORD dw)
324
{
325
    TCHAR szBuf[1024];
326
    LPVOID lpMsgBuf;
327
 
328
    FormatMessage(
329
        FORMAT_MESSAGE_ALLOCATE_BUFFER |
330
        FORMAT_MESSAGE_FROM_SYSTEM,
331
        NULL,
332
        dw,
333
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
334
        (LPTSTR) &lpMsgBuf,
335
        0, NULL );
336
 
337
    wsprintf(szBuf,
338
             L"Error %d: %s\n",
339
             dw, lpMsgBuf);
340
 
341
    OutputDebugString(szBuf);
342
 
343
    LocalFree(lpMsgBuf);
344
}
345
 
346
#endif