System.nsh 14 KB

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