merged from work

This commit is contained in:
2019-12-20 20:02:14 +01:00
parent 202608651b
commit 11e3a02511
505 changed files with 65307 additions and 823 deletions

Binary file not shown.

View File

@ -0,0 +1,395 @@
; Some useful functions based on System plugin
;
; (c) brainsucker, 2002
; (r) BSForce
!verbose push 3
!ifndef SysFunc.NSH.Included
!define SysFunc.NSH.Included
!include "System.nsh"
!include "WinMessages.nsh"
; ================= GetInstallerExeName implementation =================
; Adopted Get Parameter function -> now it gets full installer.exe path
; input - nothing, output -> full path at the top of the stack
Function GetInstallerExeName
Push $R0
Push $R1
Push $R2
StrCpy $R0 $CMDLINE 1
StrCpy $R1 '"'
StrCpy $R2 1
StrCmp $R0 '"' loop
StrCpy $R1 ' ' ; we're scanning for a space instead of a quote
loop:
StrCpy $R0 $CMDLINE 1 $R2
StrCmp $R0 $R1 loop2
StrCmp $R0 "" loop2
IntOp $R2 $R2 + 1
Goto loop
loop2:
; Ok, have we found last exename character or string end?
StrCmp $R0 "" "" +2
IntOp $R2 $R2 - 1 ; last exename char
StrCmp $R1 ' ' +3 ; was first character the '"', or something other?
StrCpy $R1 1 ; it was quote
Goto +2
StrCpy $R1 0
IntOp $R2 $R2 - $R1
StrCpy $R0 $CMDLINE $R2 $R1
SearchPath $R0 $R0 ; expand file name to full path
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
; ================= systemGetFileSysTime implementation =================
!macro smGetFileSysTime FILENAME
Push ${FILENAME}
Call systemGetFileSysTime
Pop $R0
!macroend
; -----------------------------------------------------------------
; systemGetFileSysTime (params on stack):
; FILENAME - name of file to get file time
; returns to stack (SYSTEMTIME struct addr)
; -----------------------------------------------------------------
; uses original method from NSIS
Function systemGetFileSysTime
System::Store "s r1"
StrCpy $R0 0
; create WIN32_FIND_DATA struct
System::Call '*${stWIN32_FIND_DATA} .r2'
; Find file info
System::Call '${sysFindFirstFile}(r1, r2) .r3'
; ok?
IntCmp $3 ${INVALID_HANDLE_VALUE} sgfst_exit
; close file search
System::Call '${sysFindClose}(r3)'
; Create systemtime struct for local time
System::Call '*${stSYSTEMTIME} .R0'
; Get File time
System::Call '*$2${stWIN32_FIND_DATA} (,,, .r3)'
; Convert file time (UTC) to local file time
System::Call '${sysFileTimeToLocalFileTime}(r3, .r1)'
; Convert file time to system time
System::Call '${sysFileTimeToSystemTime}(r1, R0)'
sgfst_exit:
; free used memory for WIN32_FIND_DATA struct
System::Free $2
System::Store "P0 l"
FunctionEnd
; ================= systemMessageBox implementation =================
; return to $R0
!macro smMessageBox MODULE MSG CAPTION STYLE ICON
Push "${ICON}"
Push "${STYLE}"
Push "${CAPTION}"
Push "${MSG}"
Push "${MODULE}"
Call systemMessageBox
Pop $R0
!macroend
; -----------------------------------------------------------------
; systemMessageBox (params on stack):
; Module: either handle ("i HANDLE", HANDLE could be 0) or "modulename"
; Msg: text of message
; Caption: caption of message box window
; Style: style, buttons etc
; Icon: either icon handle ("i HANDLE") or resource name
; returns to stack
; -----------------------------------------------------------------
Function systemMessageBox
System::Store "s r2r3r4r5r6"
; may be Module is module handle?
StrCpy $1 $2
IntCmp $1 0 0 smbnext smbnext
; Get module handle
System::Call '${sysGetModuleHandle}($2) .r1'
IntCmp $1 0 loadlib libnotloaded libnotloaded
loadlib:
; Load module and get handle
System::Call '${sysLoadLibrary}($2) .r1'
IntCmp $1 0 0 smbnext smbnext
libnotloaded:
; Indicate that LoadLibrary wasn't used
StrCpy $2 1
smbnext:
; Create MSGBOXPARAMS structure
System::Call '*${stMSGBOXPARAMS}(, $HWNDPARENT, r1, r3, r4, "$5|${MB_USERICON}", $6, _) .r0'
; call MessageBoxIndirect
System::Call '${sysMessageBoxIndirect}(r0) .R0'
; free MSGBOXPARAMS structure
System::Free $0
; have we used load library at start?
IntCmp $2 0 0 smbskipfree smbskipfree
; No, then free the module
System::Call '${sysFreeLibrary}(r1)'
smbskipfree:
System::Store "P0 l"
FunctionEnd
; ================= systemSplash implementation =================
; returns to $R0
!macro smSystemSplash DELAY FILE
Push ${FILE}
Push ${DELAY}
call systemSplash
Pop $R0
!macroend
; -----------------------------------------------------------------
; systemSplash (params on stack):
; Delay - time in ms to show the splash
; File - bitmap (& audio) file name (without extension)
; returns to stack
; -----------------------------------------------------------------
Function _systemSplashWndCB
; Callback receives 4 values
System::Store "s r2r5r7r9"
; Message branching
IntCmp $5 ${WM_CLOSE} m_Close
IntCmp $5 ${WM_TIMER} m_Timer
IntCmp $5 ${WM_LBUTTONDOWN} m_Lbtn
IntCmp $5 ${WM_CREATE} m_Create
IntCmp $5 ${WM_PAINT} m_Paint
goto default
m_Create:
; Create structures
System::Call "*${stRECT} (_) .R8"
System::Call "*${stBITMAP} (_, &l0 .R7) .R9"
; Get bitmap info
System::Call "${sysGetObject} (r6, R7, R9)"
; Get desktop info
System::Call "${sysSystemParametersInfo} (${SPI_GETWORKAREA}, 0, R8, 0)"
; Style (callbacked)
System::Call "${sysSetWindowLong} (r2, ${GWL_STYLE}, 0) .s"
!insertmacro SINGLE_CALLBACK 5 $R7 1 _systemSplashWndCB
; Calculate and set window pos
; Get bmWidth(R2) and bmHeight(R3)
System::Call "*$R9${stBITMAP} (,.R2,.R3)"
; Get left(R4), top(R5), right(R6), bottom(R7)
System::Call "*$R8${stRECT} (.R4,.R5,.R6,.R7)"
; Left pos
IntOp $R0 $R6 - $R4
IntOp $R0 $R0 - $R2
IntOp $R0 $R0 / 2
IntOp $R0 $R0 + $R4
; Top pos
IntOp $R1 $R7 - $R5
IntOp $R1 $R1 - $R3
IntOp $R1 $R1 / 2
IntOp $R1 $R1 + $R5
System::Call "${sysSetWindowPos} (r2, 0, R0, R1, R2, R3, ${SWP_NOZORDER}) .s"
!insertmacro SINGLE_CALLBACK 6 $R7 1 _systemSplashWndCB
; Show window
System::Call "${sysShowWindow} (r2, ${SW_SHOW}) .s"
!insertmacro SINGLE_CALLBACK 7 $R7 1 _systemSplashWndCB
; Set Timer
System::Call "${sysSetTimer} (r2, 1, r8,)"
; Free used memory
System::Free $R8
System::Free $R9
StrCpy $R0 0
goto exit
m_Paint:
; Create structures
System::Call "*${stRECT} (_) .R8"
System::Call "*${stPAINTSTRUCT} (_) .R9"
; Begin Paint
System::Call "${sysBeginPaint} (r2, R9) .R7"
; CreateCompatibleDC
System::Call "${sysCreateCompatibleDC} (R7) .R6"
; GetClientRect
System::Call "${sysGetClientRect} (r2, R8)"
; Select new bitmap
System::Call "${sysSelectObject} (R6, r6) .R5"
; Get left(R0), top(R1), right(R2), bottom(R3)
System::Call "*$R8${stRECT} (.R0,.R1,.R2,.R3)"
; width=right-left
IntOp $R2 $R2 - $R0
; height=bottom-top
IntOp $R3 $R3 - $R1
System::Call "${sysBitBlt} (R7, R0, R1, R2, R3, R6, 0, 0, ${SRCCOPY})"
; Select old bitmap
System::Call "${sysSelectObject} (R6, R5)"
; Delete compatible DC
System::Call "${sysDeleteDC} (R6)"
; End Paint
System::Call "${sysEndPaint} (r2, R9)"
; Free used memory
System::Free $R8
System::Free $R9
StrCpy $R0 0
goto exit
m_Timer:
m_Lbtn:
StrCpy $4 0
IntCmp $5 ${WM_TIMER} destroy
StrCpy $4 1
destroy:
System::Call "${sysDestroyWindow} (r2) .s"
!insertmacro SINGLE_CALLBACK 12 $R4 1 _systemSplashWndCB
default:
; Default
System::Call "${sysDefWindowProc} (r2, r5, r7, r9) .s"
!insertmacro SINGLE_CALLBACK 14 $R0 1 _systemSplashWndCB
goto exit
m_Close:
StrCpy $R0 0
goto exit
exit:
; Restore
System::Store "p4P0 l R0r4"
; Return from callback
System::Call "$3" $R0
FunctionEnd
Function systemSplash
; Save registers and get input
System::Store "s r8r9"
; Get module instance
System::Call "${sysGetModuleHandle} (p) .r7"
; Get arrow cursor
System::Call "${sysLoadCursor} (0, p ${IDC_ARROW}) .R9"
; Get callback
System::Get "${sysWNDPROC}"
Pop $3
; Create window class
System::Call "*${stWNDCLASS} (0,r3,0,0,r7,0,R9,0,p 0,'_sp') .R9"
; Register window class
System::Call "${sysRegisterClass} (R9) .R9"
IntCmp $R9 0 errorexit ; Class registered ok?
; Load Image (LR_CREATEDIBSECTION|LR_LOADFROMFILE = 0x2010)
System::Call '${sysLoadImage} (, s, ${IMAGE_BITMAP}, 0, 0, ${LR_CREATEDIBSECTION}|${LR_LOADFROMFILE}) .r6' "$9.bmp"
IntCmp $6 0 errorexit ; Image loaded ok?
; Start the sound (SND_ASYNC|SND_FILENAME|SND_NODEFAULT = 0x20003)
System::Call "${sysPlaySound} (s,,${SND_ASYNC}|${SND_FILENAME}|${SND_NODEFAULT})" "$9.wav"
; Create window
System::Call "${sysCreateWindowEx} (${WS_EX_TOOLWINDOW}, s, s,,,,,, $HWNDPARENT,,r7,) .s" "_sp" "_sp"
!insertmacro SINGLE_CALLBACK 1 $5 1 _systemSplashWndCB
; Create MSG struct
System::Call "*${stMSG} (_) p.R9"
; -------------------------
repeat:
; Check for window
System::Call "${sysIsWindow} (r5) .s"
!insertmacro SINGLE_CALLBACK 2 $R8 1 _systemSplashWndCB
IntCmp $R8 0 finish
; Get message
System::Call "${sysGetMessage} (R9, r5,_) .s"
!insertmacro SINGLE_CALLBACK 3 $R8 1 _systemSplashWndCB
IntCmp $R8 0 finish
; Dispatch message
System::Call "${sysDispatchMessage} (R9) .s"
!insertmacro SINGLE_CALLBACK 4 $R8 1 _systemSplashWndCB
; Repeat dispatch cycle
goto repeat
; -------------------------
finish:
; Stop the sound
System::Call "${sysPlaySound} (p 0, p 0, i 0)"
; Delete bitmap object
System::Call "${sysDeleteObject} (r6)"
; Delete the callback queue
System::Free $3
; Dialog return
StrCpy $R0 $4
goto exit
; Exit in case of error
errorexit:
StrCpy $R0 -1
goto exit
exit:
; Restore register and put output
System::Store "P0 l"
FunctionEnd
!endif
!verbose pop

View File

@ -0,0 +1,413 @@
; Some useful functions, structures, constants
;
; (c) brainsucker, 2002
; (r) BSForce
!verbose push 3
!ifndef System.NSH.Included
!define System.NSH.Included
!include WinCore.nsh
; ------------- Functions --------------
; LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
!define sysWNDPROC "(p.s, i.s, p.s, p.s) pss"
; LRESULT DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
!define sysDefWindowProc "user32::DefWindowProc(p, i, p, p) p"
!define sysMessageBox "user32::MessageBox(p, t, t, i) i"
!define sysMessageBeep "user32::MessageBeep(i) i"
!define sysMessageBoxIndirect 'user32::MessageBoxIndirect(p) i'
; HMODULE GetModuleHandle(LPCTSTR lpModuleName);
!define sysGetModuleHandle "kernel32::GetModuleHandle(t) i"
; HMODULE LoadLibrary(LPCTSTR lpFileName);
!define sysLoadLibrary "kernel32::LoadLibrary(t) p"
; BOOL FreeLibrary(HMODULE hModule);
!define sysFreeLibrary "kernel32::FreeLibrary(p) i"
; HCURSOR LoadCursor(HINSTANCE hInstance, LPCTSTR lpCursorName);
!define sysLoadCursor "user32::LoadCursor(p, t) p"
; ATOM RegisterClass(CONST WNDCLASS *lpWndClass);
!define sysRegisterClass "user32::RegisterClass(p) i"
; HANDLE LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType,
; int cxDesired, int cyDesired, UINT fuLoad);
!define sysLoadImage "user32::LoadImage(p, t, i, i, i, i) p"
; BOOL PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);
!define sysPlaySound "winmm.dll::PlaySound(t, p, i) i"
; HWND CreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName,
; DWORD dwStyle, int x, int y, int nWidth, int nHeight, HWND hWndParent,
; HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
!define sysCreateWindowEx "user32::CreateWindowEx(i, t, t, i, i, i, i, i, p, p, p, p) p"
; BOOL IsWindow(HWND hWnd);
!define sysIsWindow "user32::IsWindow(p) i"
; LONG SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
!define sysSetWindowLong "user32::SetWindowLong(p, i, p) p"
; BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
!define sysSetWindowPos "user32::SetWindowPos(p, p, i, i, i, i, i) i"
; BOOL ShowWindow(HWND hWnd, int nCmdShow);
!define sysShowWindow "user32::ShowWindow(p, i) i"
; BOOL DestroyWindow(HWND hWnd);
!define sysDestroyWindow "user32::DestroyWindow(p) i"
; BOOL GetClientRect(HWND hWnd, LPRECT lpRect);
!define sysGetClientRect "user32::GetClientRect(p, p) i"
; BOOL GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
!define sysGetMessage "user32::GetMessage(p, p, i, i) i"
; LRESULT DispatchMessage(CONST MSG *lpmsg);
!define sysDispatchMessage "user32::DispatchMessage(p) p"
; BOOL DeleteObject(HGDIOBJ hObject);
!define sysDeleteObject "gdi32::DeleteObject(p) i"
; int GetObject(HGDIOBJ hgdiobj, int cbBuffer, LPVOID lpvObject);
!define sysGetObject "gdi32::GetObject(p, i, p) i"
; HGDIOBJ SelectObject(HDC hdc, HGDIOBJ hgdiobj);
!define sysSelectObject "gdi32::SelectObject(p, p) p"
; HDC CreateCompatibleDC(HDC hdc);
!define sysCreateCompatibleDC "gdi32::CreateCompatibleDC(p) p"
; BOOL DeleteDC(HDC hdc);
!define sysDeleteDC "gdi32::DeleteDC(p) i"
; BOOL BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
; HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop);
!define sysBitBlt "gdi32::BitBlt(p, i, i, i, i, p, i, i, i) i"
; proposed by abgandar
; int AddFontResource(LPCTSTR lpszFilename);
!define sysAddFontResource "gdi32::AddFontResource(t) i"
; HDC BeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint);
!define sysBeginPaint "user32::BeginPaint(p, p) p"
; BOOL EndPaint(HWND hWnd, CONST PAINTSTRUCT *lpPaint);
!define sysEndPaint "user32::EndPaint(p, p) i"
; BOOL SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni);
!define sysSystemParametersInfo "user32::SystemParametersInfo(i, i, p, i) i"
; UINT_PTR SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc);
!define sysSetTimer "user32::SetTimer(p, p, i, k) i"
; DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR LpBuffer);
!define sysGetLogicalDriveStrings 'kernel32::GetLogicalDriveStrings(i, p) i'
!define sysGetDiskFreeSpaceEx 'kernel32::GetDiskFreeSpaceEx(t, *l, *l, *l) i'
; UINT GetDriveType(LPCTSTR lpRootPathName);
!define sysGetDriveType 'kernel32::GetDriveType(t) i'
; HANDLE FindFirstFile(LPCTSTR lpFileName,LPWIN32_FIND_DATA lpFindFileData);
!define sysFindFirstFile 'kernel32::FindFirstFile(t, p) p'
; BOOL FindClose(HANDLE hFindFile);
!define sysFindClose 'kernel32::FindClose(p) i'
; BOOL FileTimeToSystemTime(CONST FILETIME *lpFileTime,
; LPSYSTEMTIME lpSystemTime);
!define sysFileTimeToSystemTime 'kernel32::FileTimeToSystemTime(*l, p) i'
; BOOL FileTimeToLocalFileTime(
; CONST FILETIME *lpFileTime,
; LPFILETIME lpLocalFileTime);
!define sysFileTimeToLocalFileTime 'kernel32::FileTimeToLocalFileTime(*l, *l) i'
; BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION lpTimeZone,
; LPSYSTEMTIME lpUniversalTime, LPSYSTEMTIME lpLocalTime);
!define sysSystemTimeToTzSpecificLocalTime 'kernel32::SystemTimeToTzSpecificLocalTime(p, p, p) i'
!define syslstrlen 'kernel32::lstrlen(t) i'
; int wsprintf(LPTSTR lpOut, LPCTSTR lpFmt, ...);
!define syswsprintf "user32::wsprintf(t, t) i ? c"
; ------------- Structures --------------
; typedef struct _WNDCLASS {
; UINT style;
; WNDPROC lpfnWndProc;
; int cbClsExtra;
; int cbWndExtra;
; HINSTANCE hInstance;
; HICON hIcon;
; HCURSOR hCursor;
; HBRUSH hbrBackground;
; LPCTSTR lpszMenuName;
; LPCTSTR lpszClassName;
; } WNDCLASS, *PWNDCLASS;
!define stWNDCLASS "(i, k, i, i, p, p, p, p, t, t) p"
; typedef struct tagMSG {
; HWND hwnd;
; UINT message;
; WPARAM wParam;
; LPARAM lParam;
; DWORD time;
; POINT pt; -> will be presented as two separate px and py
; } MSG, *PMSG;
!define stMSG "(p, i, p, p, i, i, i) p"
; typedef struct tagBITMAP {
; LONG bmType;
; LONG bmWidth;
; LONG bmHeight;
; LONG bmWidthBytes;
; WORD bmPlanes;
; WORD bmBitsPixel;
; LPVOID bmBits;
; } BITMAP, *PBITMAP;
!define stBITMAP "(i, i, i, i, i, i, p) p"
; typedef struct _RECT {
; LONG left;
; LONG top;
; LONG right;
; LONG bottom;
; } RECT, *PRECT;
!define stRECT "(i, i, i, i) p"
; typedef struct tagPAINTSTRUCT {
; HDC hdc;
; BOOL fErase;
; RECT rcPaint; (rcl, rct, rcr, rcb)
; BOOL fRestore;
; BOOL fIncUpdate;
; BYTE rgbReserved[32];
; } PAINTSTRUCT, *PPAINTSTRUCT;
!define stPAINTSTRUCT "(p, i, i, i, i, i, i, i, &v32) p"
; typedef struct {
; UINT cbSize;
; HWND hwndOwner;
; HINSTANCE hInstance;
; LPCTSTR lpszText;
; LPCTSTR lpszCaption;
; DWORD dwStyle;
; LPCTSTR lpszIcon;
; DWORD_PTR dwContextHelpId;
; MSGBOXCALLBACK lpfnMsgBoxCallback;
; DWORD dwLanguageId;
; } MSGBOXPARAMS, *PMSGBOXPARAMS;
!define stMSGBOXPARAMS '(&l4, p, p, t, t, i, t, p, k, i) p'
; typedef struct _SYSTEMTIME {
; WORD wYear;
; WORD wMonth;
; WORD wDayOfWeek;
; WORD wDay;
; WORD wHour;
; WORD wMinute;
; WORD wSecond;
; WORD wMilliseconds;
; } SYSTEMTIME, *PSYSTEMTIME;
!define stSYSTEMTIME '(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2) p'
; Maximal windows path
!define /ifndef MAX_PATH 260
; typedef struct _WIN32_FIND_DATA {
; DWORD dwFileAttributes;
; FILETIME ftCreationTime;
; FILETIME ftLastAccessTime;
; FILETIME ftLastWriteTime;
; DWORD nFileSizeHigh;
; DWORD nFileSizeLow;
; DWORD dwReserved0;
; DWORD dwReserved1;
; TCHAR cFileName[ MAX_PATH ];
; TCHAR cAlternateFileName[ 14 ];
; } WIN32_FIND_DATA, *PWIN32_FIND_DATA;
!define stWIN32_FIND_DATA '(i, l, l, l, i, i, i, i, &t${MAX_PATH}, &t14) p'
; ------------- Constants --------------
; == Other ==
!define /ifndef INVALID_HANDLE_VALUE -1
; == Sounds ==
!define SND_SYNC 0x0000
!define SND_ASYNC 0x0001
!define SND_NODEFAULT 0x0002
!define SND_MEMORY 0x0004
!define SND_LOOP 0x0008
!define SND_NOSTOP 0x0010
!define SND_NOWAIT 0x00002000
!define SND_ALIAS 0x00010000
!define SND_ALIAS_ID 0x00110000
!define SND_FILENAME 0x00020000
!define SND_RESOURCE 0x00040004
!define SND_PURGE 0x0040
!define SND_APPLICATION 0x0080
; == Windows ==
!define /ifndef WS_OVERLAPPED 0x00000000
!define /ifndef WS_POPUP 0x80000000
!define /ifndef WS_CHILD 0x40000000
!define /ifndef WS_MINIMIZE 0x20000000
!define /ifndef WS_VISIBLE 0x10000000
!define /ifndef WS_DISABLED 0x08000000
!define /ifndef WS_CLIPSIBLINGS 0x04000000
!define /ifndef WS_CLIPCHILDREN 0x02000000
!define /ifndef WS_MAXIMIZE 0x01000000
!define /ifndef WS_CAPTION 0x00C00000
!define /ifndef WS_BORDER 0x00800000
!define /ifndef WS_DLGFRAME 0x00400000
!define /ifndef WS_VSCROLL 0x00200000
!define /ifndef WS_HSCROLL 0x00100000
!define /ifndef WS_SYSMENU 0x00080000
!define /ifndef WS_THICKFRAME 0x00040000
!define /ifndef WS_GROUP 0x00020000
!define /ifndef WS_TABSTOP 0x00010000
!define /ifndef WS_MINIMIZEBOX 0x00020000
!define /ifndef WS_MAXIMIZEBOX 0x00010000
!define /ifndef WS_TILED ${WS_OVERLAPPED}
!define /ifndef WS_ICONIC ${WS_MINIMIZE}
!define /ifndef WS_SIZEBOX ${WS_THICKFRAME}
!define /ifndef WS_OVERLAPPEDWINDOW 0x00CF0000
!define /ifndef WS_TILEDWINDOW ${WS_OVERLAPPEDWINDOW}
!define /ifndef WS_POPUPWINDOW 0x80880000
!define /ifndef WS_CHILDWINDOW ${WS_CHILD}
!define /ifndef WS_EX_DLGMODALFRAME 0x00000001
!define /ifndef WS_EX_NOPARENTNOTIFY 0x00000004
!define /ifndef WS_EX_TOPMOST 0x00000008
!define /ifndef WS_EX_ACCEPTFILES 0x00000010
!define /ifndef WS_EX_TRANSPARENT 0x00000020
!define /ifndef WS_EX_MDICHILD 0x00000040
!define /ifndef WS_EX_TOOLWINDOW 0x00000080
!define /ifndef WS_EX_WINDOWEDGE 0x00000100
!define /ifndef WS_EX_CLIENTEDGE 0x00000200
!define /ifndef WS_EX_CONTEXTHELP 0x00000400
!define /ifndef WS_EX_RIGHT 0x00001000
!define /ifndef WS_EX_LEFT 0x00000000
!define /ifndef WS_EX_RTLREADING 0x00002000
!define /ifndef WS_EX_LTRREADING 0x00000000
!define /ifndef WS_EX_LEFTSCROLLBAR 0x00004000
!define /ifndef WS_EX_RIGHTSCROLLBAR 0x00000000
!define /ifndef WS_EX_CONTROLPARENT 0x00010000
!define /ifndef WS_EX_STATICEDGE 0x00020000
!define /ifndef WS_EX_APPWINDOW 0x00040000
!define /ifndef WS_EX_OVERLAPPEDWINDOW 0x00000300
!define /ifndef WS_EX_PALETTEWINDOW 0x00000188
!define /ifndef WS_EX_LAYERED 0x00080000
!define /ifndef WS_EX_NOINHERITLAYOUT 0x00100000
!define /ifndef WS_EX_LAYOUTRTL 0x00400000
!define /ifndef WS_EX_COMPOSITED 0x02000000
!define /ifndef WS_EX_NOACTIVATE 0x08000000
; == System Parameters Info ==
!define SPI_GETWORKAREA 0x0030
; == Window swap ==
!define SWP_NOSIZE 0x0001
!define SWP_NOMOVE 0x0002
!define SWP_NOZORDER 0x0004
!define SWP_NOREDRAW 0x0008
!define SWP_NOACTIVATE 0x0010
!define SWP_FRAMECHANGED 0x0020
!define SWP_SHOWWINDOW 0x0040
!define SWP_HIDEWINDOW 0x0080
!define SWP_NOCOPYBITS 0x0100
!define SWP_NOOWNERZORDER 0x0200
!define SWP_NOSENDCHANGING 0x0400
!define SWP_DRAWFRAME ${SWP_FRAMECHANGED}
!define SWP_NOREPOSITION ${SWP_NOOWNERZORDER}
!define SWP_DEFERERASE 0x2000
!define SWP_ASYNCWINDOWPOS 0x4000
; == Bit Copy ==
!define SRCCOPY 0x00CC0020
!define SRCPAINT 0x00EE0086
!define SRCAND 0x008800C6
!define SRCINVERT 0x00660046
!define SRCERASE 0x00440328
!define NOTSRCCOPY 0x00330008
!define NOTSRCERASE 0x001100A6
!define MERGECOPY 0x00C000CA
!define MERGEPAINT 0x00BB0226
!define PATCOPY 0x00F00021
!define PATPAINT 0x00FB0A09
!define PATINVERT 0x005A0049
!define DSTINVERT 0x00550009
!define BLACKNESS 0x00000042
!define WHITENESS 0x00FF0062
; == Message Box ==
!define MB_OK 0x00000000
!define MB_OKCANCEL 0x00000001
!define MB_ABORTRETRYIGNORE 0x00000002
!define MB_YESNOCANCEL 0x00000003
!define MB_YESNO 0x00000004
!define MB_RETRYCANCEL 0x00000005
!define MB_CANCELTRYCONTINUE 0x00000006
!define MB_ICONHAND 0x00000010
!define MB_ICONQUESTION 0x00000020
!define MB_ICONEXCLAMATION 0x00000030
!define MB_ICONASTERISK 0x00000040
!define MB_USERICON 0x00000080
!define MB_ICONWARNING ${MB_ICONEXCLAMATION}
!define MB_ICONERROR ${MB_ICONHAND}
!define MB_ICONINFORMATION ${MB_ICONASTERISK}
!define MB_ICONSTOP ${MB_ICONHAND}
!define MB_DEFBUTTON1 0x00000000
!define MB_DEFBUTTON2 0x00000100
!define MB_DEFBUTTON3 0x00000200
!define MB_DEFBUTTON4 0x00000300
!define MB_APPLMODAL 0x00000000
!define MB_SYSTEMMODAL 0x00001000
!define MB_TASKMODAL 0x00002000
!define MB_HELP 0x00004000
!define MB_NOFOCUS 0x00008000
!define MB_SETFOREGROUND 0x00010000
!define MB_DEFAULT_DESKTOP_ONLY 0x00020000
!define MB_TOPMOST 0x00040000
!define MB_RIGHT 0x00080000
!define MB_RTLREADING 0x00100000
; == Callbacks ==
!macro SINGLE_CALLBACK CHKN RES INDEX FUNC
CheckCB_${CHKN}:
Pop ${RES}
StrCmp ${RES} "callback${INDEX}" 0 ExitCB_${CHKN}
Call ${FUNC}
Goto CheckCB_${CHKN}
ExitCB_${CHKN}:
!macroend
!endif
!verbose pop

View File

@ -0,0 +1,137 @@
; This is just an example of System Plugin
;
; (c) brainsucker, 2002
; (r) BSForce
Name "System Plugin Example"
OutFile "System.exe"
!include "SysFunc.nsh"
Section "ThisNameIsIgnoredSoWhyBother?"
SetOutPath $TEMP
; ----- Sample 1 ----- Message box with custom icon -----
; there are no default beeps for custom message boxes, use sysMessageBeep
; in case you need it (see next message box example)
!insertmacro smMessageBox "i 0" "Message box with custom icon!" "System Example 1a" ${MB_OK} "i 103"
; i 0 - installer exe as module
; i 103 - icon ID
; The same example but using icon from resource.dll.
; You could use this dll for storing your resources, just replace FAR icon
; with something you really need.
File "Resource.dll"
System::Call '${sysMessageBeep} (${MB_ICONHAND})' ; custom beep
!insertmacro smMessageBox "`$TEMP\resource.dll`" "Message box with custom icon from resource.dll!" "System Example 1b" ${MB_OKCANCEL} "i 103"
Delete $TEMP\resource.dll
; ----- Sample 2 ----- Fixed disks size/space -----
StrCpy $7 ' Disk, Size, Free, Free for user:$\n$\n'
; Memory for paths
System::StrAlloc 1024
Pop $1
; Get drives
System::Call '${sysGetLogicalDriveStrings}(1024, r1)'
enumok:
; One more drive?
System::Call '${syslstrlen}(i r1) .r2'
IntCmp $2 0 enumex
; Is it DRIVE_FIXED?
System::Call '${sysGetDriveType} (i r1) .r3'
StrCmp $3 ${DRIVE_FIXED} 0 enumnext
; Drive space
System::Call '${sysGetDiskFreeSpaceEx}(i r1, .r3, .r4, .r5)'
; Pretty KBs will be saved on stack
System::Int64Op $3 / 1048576
System::Int64Op $5 / 1048576
System::Int64Op $4 / 1048576
; Get pretty drive path string
System::Call '*$1(&t1024 .r6)'
System::Call '${syswsprintf} (.r7, "%s%20s %20s mb %20s mb %20s mb$\n", tr7, tr6, ts, ts, ts)'
enumnext:
; Next drive path
IntOp $2 $2 * ${NSIS_CHAR_SIZE}
IntOp $1 $1 + $2
IntOp $1 $1 + ${NSIS_CHAR_SIZE}
goto enumok
enumex: ; End of drives or user cancel
; Free memory for paths
System::Free $1
; Message box
System::Call '${sysMessageBox}($HWNDPARENT, s, "System Example 2", ${MB_OKCANCEL})' "$7"
; ----- Sample 3 ----- Direct proc defenition -----
; Direct specification demo
System::Call 'user32::MessageBox(p $HWNDPARENT, t "Just direct MessageBox specification demo ;)", t "System Example 3", i ${MB_OK}) i.s'
Pop $0
; ----- Sample 4 ----- Int64, mixed definition demo -----
; Long int demo
StrCpy $2 "12312312"
StrCpy $3 "12345678903"
System::Int64Op $2 "*" $3
Pop $4
; Cdecl demo (uses 3 defenitions (simple example))
System::Call "${syswsprintf}(.R1, s,,, t, ir0) .R0 (,,tr2,tr3,$4_)" "Int64 ops and strange defenition demo, %s x %s == %s, and previous msgbox result = %d"
MessageBox MB_OKCANCEL "Cool: '$R1'"
; ----- Sample 5 ----- Small structure example -----
; Create & Fill structure
System::Call "*(i 123123123, &t10 'Hello', &i1 0x123dd, &i2 0xffeeddccaa) i.s"
Pop $1
; Read data from structure
System::Call "*$1(i .r2, &t10 .r3, &i1 .r4, &i2 .r5, &l0 .r6)"
; Show data and delete structure
MessageBox MB_OK "Structure example: $\nint == $2 $\nstring == $3 $\nbyte == $4 $\nshort == $5 $\nsize == $6"
System::Free $1
; ----- Sample 6 ----- systemGetFileSysTime demo -----
Call GetInstallerExeName
pop $0
!insertmacro smGetFileSysTime $0
System::Call '*$R0${stSYSTEMTIME}(.r1, .r2, .r3, .r4, .r5, .r6, .r7, .r8)'
MessageBox MB_OK "GetFileSysTime example: file '$0', year $1, month $2, dow $3, day $4, hour $5, min $6, sec $7, ms $8"
; free memory from SYSTEMTIME
System::Free $R0
; ----- Sample 7 ----- systemSplash -> Callbacks demonstration -----
; Logo
File /oname=spltmp.bmp "${NSISDIR}\Contrib\Graphics\Header\orange-nsis.bmp"
; File /oname=spltmp.wav "d:\Windows\Media\tada.wav"
; I. systemSplash variant
!insertmacro smSystemSplash 2000 "$TEMP\spltmp"
; II. Splash Plugin variant
; splash::show 2000 $TEMP\spltmp
; Pop $R0 ; $R0 has '1' if the user closed the splash screen early,
; remove logo
Delete $TEMP\spltmp.bmp
; Delete $TEMP\spltmp.wav
; Display splash result
pop $0
MessageBox MB_OK "Splash (callbacks) demo result $R0"
SectionEnd
; eof