System.nsh 15 KB

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