Debian Codegraph @

Contrib/System/System.nsh

raw
1 ; Some useful functions, structures, constants
2 ;
3 ; (c) brainsucker, 2002
4 ; (r) BSForce
5
6 !verbose push 3
7 !ifndef System.NSH.Included
8 !define System.NSH.Included
9
10 !include WinCore.nsh
11
12 ; ------------- Functions --------------
13
14 ; LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
15 !define sysWNDPROC "(p.s, i.s, p.s, p.s) pss"
16
17 ; LRESULT DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
18 !define sysDefWindowProc "user32::DefWindowProc(p, i, p, p) p"
19
20 !define sysMessageBox "user32::MessageBox(p, t, t, i) i"
21
22 !define sysMessageBeep "user32::MessageBeep(i) i"
23
24 !define sysMessageBoxIndirect 'user32::MessageBoxIndirect(p) i'
25
26 ; HMODULE GetModuleHandle(LPCTSTR lpModuleName);
27 !define sysGetModuleHandle "kernel32::GetModuleHandle(t) i"
28
29 ; HMODULE LoadLibrary(LPCTSTR lpFileName);
30 !define sysLoadLibrary "kernel32::LoadLibrary(t) p"
31
32 ; BOOL FreeLibrary(HMODULE hModule);
33 !define sysFreeLibrary "kernel32::FreeLibrary(p) i"
34
35 ; HCURSOR LoadCursor(HINSTANCE hInstance, LPCTSTR lpCursorName);
36 !define sysLoadCursor "user32::LoadCursor(p, t) p"
37
38 ; ATOM RegisterClass(CONST WNDCLASS *lpWndClass);
39 !define sysRegisterClass "user32::RegisterClass(p) i"
40
41 ; HANDLE LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType,
42 ; int cxDesired, int cyDesired, UINT fuLoad);
43 !define sysLoadImage "user32::LoadImage(p, t, i, i, i, i) p"
44
45 ; BOOL PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);
46 !define sysPlaySound "winmm.dll::PlaySound(t, p, i) i"
47
48 ; HWND CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
49 ; DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent,
50 ; HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
51 !define sysCreateWindowEx "user32::CreateWindowEx(i, t, t, i, i, i, i, i, p, p, p, p) p"
52
53 ; BOOL IsWindow(HWND hWnd);
54 !define sysIsWindow "user32::IsWindow(p) i"
55
56 ; LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
57 !define sysSetWindowLong "user32::SetWindowLong(p, i, p) p"
58
59 ; BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
60 !define sysSetWindowPos "user32::SetWindowPos(p, p, i, i, i, i, i) i"
61
62 ; BOOL ShowWindow(HWND hWnd, int nCmdShow);
63 !define sysShowWindow "user32::ShowWindow(p, i) i"
64
65 ; BOOL DestroyWindow(HWND hWnd);
66 !define sysDestroyWindow "user32::DestroyWindow(p) i"
67
68 ; BOOL GetClientRect(HWND hWnd, LPRECT lpRect);
69 !define sysGetClientRect "user32::GetClientRect(p, p) i"
70
71 ; BOOL GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
72 !define sysGetMessage "user32::GetMessage(p, p, i, i) i"
73
74 ; LRESULT DispatchMessage(CONST MSG *lpmsg);
75 !define sysDispatchMessage "user32::DispatchMessage(p) p"
76
77 ; BOOL DeleteObject(HGDIOBJ hObject);
78 !define sysDeleteObject "gdi32::DeleteObject(p) i"
79
80 ; int GetObject(HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject);
81 !define sysGetObject "gdi32::GetObject(p, i, p) i"
82
83 ; HGDIOBJ SelectObject(HDC hdc, HGDIOBJ hgdiobj);
84 !define sysSelectObject "gdi32::SelectObject(p, p) p"
85
86 ; HDC CreateCompatibleDC(HDC hdc);
87 !define sysCreateCompatibleDC "gdi32::CreateCompatibleDC(p) p"
88
89 ; BOOL DeleteDC(HDC hdc);
90 !define sysDeleteDC "gdi32::DeleteDC(p) i"
91
92 ; BOOL BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
93 ; HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop);
94 !define sysBitBlt "gdi32::BitBlt(p, i, i, i, i, p, i, i, i) i"
95
96 ; proposed by abgandar
97 ; int AddFontResource(LPCTSTR lpszFilename);
98 !define sysAddFontResource "gdi32::AddFontResource(t) i"
99
100 ; HDC BeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint);
101 !define sysBeginPaint "user32::BeginPaint(p, p) p"
102
103 ; BOOL EndPaint(HWND hWnd, CONST PAINTSTRUCT *lpPaint);
104 !define sysEndPaint "user32::EndPaint(p, p) i"
105
106 ; BOOL SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni);
107 !define sysSystemParametersInfo "user32::SystemParametersInfo(i, i, p, i) i"
108
109 ; UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);
110 !define sysSetTimer "user32::SetTimer(p, p, i, k) i"
111
112 ; DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR LpBuffer);
113 !define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStrings(i, p) i'
114
115 !define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceEx(t, *l, *l, *l) i'
116
117 ; UINT GetDriveType(LPCTSTR lpRootPathName);
118 !define sysGetDriveType 'kernel32::GetDriveType(t) i'
119
120 ; HANDLE FindFirstFile(LPCTSTR lpFileName,LPWIN32_FIND_DATA lpFindFileData);
121 !define sysFindFirstFile 'kernel32::FindFirstFile(t, p) p'
122
123 ; BOOL FindClose(HANDLE hFindFile);
124 !define sysFindClose 'kernel32::FindClose(p) i'
125
126 ; BOOL FileTimeToSystemTime(CONST FILETIME *lpFileTime,
127 ; LPSYSTEMTIME lpSystemTime);
128 !define sysFileTimeToSystemTime 'kernel32::FileTimeToSystemTime(*l, p) i'
129
130 ; BOOL FileTimeToLocalFileTime(
131 ; CONST FILETIME *lpFileTime,
132 ; LPFILETIME lpLocalFileTime);
133 !define sysFileTimeToLocalFileTime 'kernel32::FileTimeToLocalFileTime(*l, *l) i'
134
135 ; BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION lpTimeZone,
136 ; LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime);
137 !define sysSystemTimeToTzSpecificLocalTime 'kernel32::SystemTimeToTzSpecificLocalTime(p, p, p) i'
138
139 !define syslstrlen 'kernel32::lstrlen(t) i'
140
141 ; int wsprintf(LPTSTR lpOut, LPCTSTR lpFmt, ...);
142 !define syswsprintf "user32::wsprintf(t, t) i ? c"
143
144 ; ------------- Structures --------------
145
146 ; typedef struct _WNDCLASS {
147 ; UINT style;
148 ; WNDPROC lpfnWndProc;
149 ; int cbClsExtra;
150 ; int cbWndExtra;
151 ; HINSTANCE hInstance;
152 ; HICON hIcon;
153 ; HCURSOR hCursor;
154 ; HBRUSH hbrBackground;
155 ; LPCTSTR lpszMenuName;
156 ; LPCTSTR lpszClassName;
157 ; } WNDCLASS, *PWNDCLASS;
158 !define stWNDCLASS "(i, k, i, i, p, p, p, p, t, t) p"
159
160 ; typedef struct tagMSG {
161 ; HWND hwnd;
162 ; UINT message;
163 ; WPARAM wParam;
164 ; LPARAM lParam;
165 ; DWORD time;
166 ; POINT pt; -> will be presented as two separate px and py
167 ; } MSG, *PMSG;
168 !define stMSG "(p, i, p, p, i, i, i) p"
169
170 ; typedef struct tagBITMAP {
171 ; LONG bmType;
172 ; LONG bmWidth;
173 ; LONG bmHeight;
174 ; LONG bmWidthBytes;
175 ; WORD bmPlanes;
176 ; WORD bmBitsPixel;
177 ; LPVOID bmBits;
178 ; } BITMAP, *PBITMAP;
179 !define stBITMAP "(i, i, i, i, i, i, p) p"
180
181 ; typedef struct _RECT {
182 ; LONG left;
183 ; LONG top;
184 ; LONG right;
185 ; LONG bottom;
186 ; } RECT, *PRECT;
187 !define stRECT "(i, i, i, i) p"
188
189 ; typedef struct tagPAINTSTRUCT {
190 ; HDC hdc;
191 ; BOOL fErase;
192 ; RECT rcPaint; (rcl, rct, rcr, rcb)
193 ; BOOL fRestore;
194 ; BOOL fIncUpdate;
195 ; BYTE rgbReserved[32];
196 ; } PAINTSTRUCT, *PPAINTSTRUCT;
197 !define stPAINTSTRUCT "(p, i, i, i, i, i, i, i, &v32) p"
198
199 ; typedef struct {
200 ; UINT cbSize;
201 ; HWND hwndOwner;
202 ; HINSTANCE hInstance;
203 ; LPCTSTR lpszText;
204 ; LPCTSTR lpszCaption;
205 ; DWORD dwStyle;
206 ; LPCTSTR lpszIcon;
207 ; DWORD_PTR dwContextHelpId;
208 ; MSGBOXCALLBACK lpfnMsgBoxCallback;
209 ; DWORD dwLanguageId;
210 ; } MSGBOXPARAMS, *PMSGBOXPARAMS;
211 !define stMSGBOXPARAMS '(&l4, p, p, t, t, i, t, p, k, i) p'
212
213 ; typedef struct _SYSTEMTIME {
214 ; WORD wYear;
215 ; WORD wMonth;
216 ; WORD wDayOfWeek;
217 ; WORD wDay;
218 ; WORD wHour;
219 ; WORD wMinute;
220 ; WORD wSecond;
221 ; WORD wMilliseconds;
222 ; } SYSTEMTIME, *PSYSTEMTIME;
223 !define stSYSTEMTIME '(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) p'
224
225 ; Maximal windows path
226 !define /ifndef MAX_PATH 260
227
228 ; typedef struct _WIN32_FIND_DATA {
229 ; DWORD dwFileAttributes;
230 ; FILETIME ftCreationTime;
231 ; FILETIME ftLastAccessTime;
232 ; FILETIME ftLastWriteTime;
233 ; DWORD nFileSizeHigh;
234 ; DWORD nFileSizeLow;
235 ; DWORD dwReserved0;
236 ; DWORD dwReserved1;
237 ; TCHAR cFileName[ MAX_PATH ];
238 ; TCHAR cAlternateFileName[ 14 ];
239 ; } WIN32_FIND_DATA, *PWIN32_FIND_DATA;
240 !define stWIN32_FIND_DATA '(i, l, l, l, i, i, i, i, &t${MAX_PATH}, &t14) p'
241
242 ; ------------- Constants --------------
243
244 ; == Other ==
245 !define /ifndef INVALID_HANDLE_VALUE -1
246
247 ; == Sounds ==
248
249 !define SND_SYNC 0x0000
250 !define SND_ASYNC 0x0001
251 !define SND_NODEFAULT 0x0002
252 !define SND_MEMORY 0x0004
253 !define SND_LOOP 0x0008
254 !define SND_NOSTOP 0x0010
255
256 !define SND_NOWAIT 0x00002000
257 !define SND_ALIAS 0x00010000
258 !define SND_ALIAS_ID 0x00110000
259 !define SND_FILENAME 0x00020000
260 !define SND_RESOURCE 0x00040004
261 !define SND_PURGE 0x0040
262 !define SND_APPLICATION 0x0080
263
264 ; == Windows ==
265
266 !define /ifndef WS_OVERLAPPED 0x00000000
267 !define /ifndef WS_POPUP 0x80000000
268 !define /ifndef WS_CHILD 0x40000000
269 !define /ifndef WS_MINIMIZE 0x20000000
270 !define /ifndef WS_VISIBLE 0x10000000
271 !define /ifndef WS_DISABLED 0x08000000
272 !define /ifndef WS_CLIPSIBLINGS 0x04000000
273 !define /ifndef WS_CLIPCHILDREN 0x02000000
274 !define /ifndef WS_MAXIMIZE 0x01000000
275 !define /ifndef WS_CAPTION 0x00C00000
276 !define /ifndef WS_BORDER 0x00800000
277 !define /ifndef WS_DLGFRAME 0x00400000
278 !define /ifndef WS_VSCROLL 0x00200000
279 !define /ifndef WS_HSCROLL 0x00100000
280 !define /ifndef WS_SYSMENU 0x00080000
281 !define /ifndef WS_THICKFRAME 0x00040000
282 !define /ifndef WS_GROUP 0x00020000
283 !define /ifndef WS_TABSTOP 0x00010000
284 !define /ifndef WS_MINIMIZEBOX 0x00020000
285 !define /ifndef WS_MAXIMIZEBOX 0x00010000
286 !define /ifndef WS_TILED ${WS_OVERLAPPED}
287 !define /ifndef WS_ICONIC ${WS_MINIMIZE}
288 !define /ifndef WS_SIZEBOX ${WS_THICKFRAME}
289 !define /ifndef WS_OVERLAPPEDWINDOW 0x00CF0000
290 !define /ifndef WS_TILEDWINDOW ${WS_OVERLAPPEDWINDOW}
291 !define /ifndef WS_POPUPWINDOW 0x80880000
292 !define /ifndef WS_CHILDWINDOW ${WS_CHILD}
293 !define /ifndef WS_EX_DLGMODALFRAME 0x00000001
294 !define /ifndef WS_EX_NOPARENTNOTIFY 0x00000004
295 !define /ifndef WS_EX_TOPMOST 0x00000008
296 !define /ifndef WS_EX_ACCEPTFILES 0x00000010
297 !define /ifndef WS_EX_TRANSPARENT 0x00000020
298 !define /ifndef WS_EX_MDICHILD 0x00000040
299 !define /ifndef WS_EX_TOOLWINDOW 0x00000080
300 !define /ifndef WS_EX_WINDOWEDGE 0x00000100
301 !define /ifndef WS_EX_CLIENTEDGE 0x00000200
302 !define /ifndef WS_EX_CONTEXTHELP 0x00000400
303 !define /ifndef WS_EX_RIGHT 0x00001000
304 !define /ifndef WS_EX_LEFT 0x00000000
305 !define /ifndef WS_EX_RTLREADING 0x00002000
306 !define /ifndef WS_EX_LTRREADING 0x00000000
307 !define /ifndef WS_EX_LEFTSCROLLBAR 0x00004000
308 !define /ifndef WS_EX_RIGHTSCROLLBAR 0x00000000
309 !define /ifndef WS_EX_CONTROLPARENT 0x00010000
310 !define /ifndef WS_EX_STATICEDGE 0x00020000
311 !define /ifndef WS_EX_APPWINDOW 0x00040000
312 !define /ifndef WS_EX_OVERLAPPEDWINDOW 0x00000300
313 !define /ifndef WS_EX_PALETTEWINDOW 0x00000188
314 !define /ifndef WS_EX_LAYERED 0x00080000
315 !define /ifndef WS_EX_NOINHERITLAYOUT 0x00100000
316 !define /ifndef WS_EX_LAYOUTRTL 0x00400000
317 !define /ifndef WS_EX_COMPOSITED 0x02000000
318 !define /ifndef WS_EX_NOACTIVATE 0x08000000
319
320
321 ; == System Parameters Info ==
322
323 !define SPI_GETWORKAREA 0x0030
324
325 ; == Window swap ==
326
327 !define SWP_NOSIZE 0x0001
328 !define SWP_NOMOVE 0x0002
329 !define SWP_NOZORDER 0x0004
330 !define SWP_NOREDRAW 0x0008
331 !define SWP_NOACTIVATE 0x0010
332 !define SWP_FRAMECHANGED 0x0020
333 !define SWP_SHOWWINDOW 0x0040
334 !define SWP_HIDEWINDOW 0x0080
335 !define SWP_NOCOPYBITS 0x0100
336 !define SWP_NOOWNERZORDER 0x0200
337 !define SWP_NOSENDCHANGING 0x0400
338
339 !define SWP_DRAWFRAME ${SWP_FRAMECHANGED}
340 !define SWP_NOREPOSITION ${SWP_NOOWNERZORDER}
341 !define SWP_DEFERERASE 0x2000
342 !define SWP_ASYNCWINDOWPOS 0x4000
343
344 ; == Bit Copy ==
345
346 !define SRCCOPY 0x00CC0020
347 !define SRCPAINT 0x00EE0086
348 !define SRCAND 0x008800C6
349 !define SRCINVERT 0x00660046
350 !define SRCERASE 0x00440328
351 !define NOTSRCCOPY 0x00330008
352 !define NOTSRCERASE 0x001100A6
353 !define MERGECOPY 0x00C000CA
354 !define MERGEPAINT 0x00BB0226
355 !define PATCOPY 0x00F00021
356 !define PATPAINT 0x00FB0A09
357 !define PATINVERT 0x005A0049
358 !define DSTINVERT 0x00550009
359 !define BLACKNESS 0x00000042
360 !define WHITENESS 0x00FF0062
361
362 ; == Message Box ==
363
364 !define MB_OK 0x00000000
365 !define MB_OKCANCEL 0x00000001
366 !define MB_ABORTRETRYIGNORE 0x00000002
367 !define MB_YESNOCANCEL 0x00000003
368 !define MB_YESNO 0x00000004
369 !define MB_RETRYCANCEL 0x00000005
370 !define MB_CANCELTRYCONTINUE 0x00000006
371 !define MB_ICONHAND 0x00000010
372 !define MB_ICONQUESTION 0x00000020
373 !define MB_ICONEXCLAMATION 0x00000030
374 !define MB_ICONASTERISK 0x00000040
375 !define MB_USERICON 0x00000080
376 !define MB_ICONWARNING ${MB_ICONEXCLAMATION}
377 !define MB_ICONERROR ${MB_ICONHAND}
378
379 !define MB_ICONINFORMATION ${MB_ICONASTERISK}
380 !define MB_ICONSTOP ${MB_ICONHAND}
381
382 !define MB_DEFBUTTON1 0x00000000
383 !define MB_DEFBUTTON2 0x00000100
384 !define MB_DEFBUTTON3 0x00000200
385 !define MB_DEFBUTTON4 0x00000300
386
387 !define MB_APPLMODAL 0x00000000
388 !define MB_SYSTEMMODAL 0x00001000
389 !define MB_TASKMODAL 0x00002000
390 !define MB_HELP 0x00004000
391
392 !define MB_NOFOCUS 0x00008000
393 !define MB_SETFOREGROUND 0x00010000
394 !define MB_DEFAULT_DESKTOP_ONLY 0x00020000
395
396 !define MB_TOPMOST 0x00040000
397 !define MB_RIGHT 0x00080000
398 !define MB_RTLREADING 0x00100000
399
400
401 ; == Callbacks ==
402
403 !macro SINGLE_CALLBACK CHKN RES INDEX FUNC
404 CheckCB_${CHKN}:
405 Pop ${RES}
406 StrCmp ${RES} "callback${INDEX}" 0 ExitCB_${CHKN}
407 Call ${FUNC}
408 Goto CheckCB_${CHKN}
409 ExitCB_${CHKN}:
410 !macroend
411
412 !endif
413 !verbose pop