1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/nsis/Contrib/ExDLL/extdll.inc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,145 @@ 1.4 +;################################################################ 1.5 +; ExtDLL header for MASM32 1.6 +; 1.7 +; Author: Ramon 1.8 +; 1.9 +; Obs: This header must be included after windows.inc and kernel32.inc 1.10 +; because it need the prototypes for lstrcpy, lstrcpyn, 1.11 +; GlobalAlloc and GlobalFree 1.12 +; 1.13 +;################################################################ 1.14 +stack_t struct 1.15 + next dd ? 1.16 + text dd ? ; 1 DUP(?) ; this should be the length of string_size 1.17 +stack_t ends 1.18 + 1.19 +.const 1.20 +; For page showing plug-ins 1.21 +WM_NOTIFY_OUTER_NEXT equ (WM_USER+0x8) 1.22 +WM_NOTIFY_CUSTOM_READY equ (WM_USER+0xd) 1.23 +NOTIFY_BYE_BYE equ 'x' 1.24 + 1.25 +INST_0 EQU 0 ; $0 1.26 +INST_1 EQU 1 ; $1 1.27 +INST_2 EQU 2 ; $2 1.28 +INST_3 EQU 3 ; $3 1.29 +INST_4 EQU 4 ; $4 1.30 +INST_5 EQU 5 ; $5 1.31 +INST_6 EQU 6 ; $6 1.32 +INST_7 EQU 7 ; $7 1.33 +INST_8 EQU 8 ; $8 1.34 +INST_9 EQU 9 ; $9 1.35 +INST_R0 EQU 10 ; $R0 1.36 +INST_R1 EQU 11 ; $R1 1.37 +INST_R2 EQU 12 ; $R2 1.38 +INST_R3 EQU 13 ; $R3 1.39 +INST_R4 EQU 14 ; $R4 1.40 +INST_R5 EQU 15 ; $R5 1.41 +INST_R6 EQU 16 ; $R6 1.42 +INST_R7 EQU 17 ; $R7 1.43 +INST_R8 EQU 18 ; $R8 1.44 +INST_R9 EQU 19 ; $R9 1.45 +INST_CMDLINE EQU 20 ; $CMDLINE 1.46 +INST_INSTDIR EQU 21 ; $INSTDIR 1.47 +INST_OUTDIR EQU 22 ; $OUTDIR 1.48 +INST_EXEDIR EQU 23 ; $EXEDIR 1.49 +INST_LANG EQU 24 ; $LANGUAGE 1.50 +__INST_LAST EQU 25 1.51 + 1.52 +.data? 1.53 +g_stringsize dd ? 1.54 +g_stacktop dd ? 1.55 +g_variables dd ? 1.56 + 1.57 +m2m MACRO M1, M2 1.58 + push M2 1.59 + pop M1 1.60 +ENDM 1.61 + 1.62 +EXDLL_INIT MACRO 1.63 + m2m g_stringsize, string_size 1.64 + m2m g_stacktop, stacktop 1.65 + m2m g_variables, variables 1.66 +ENDM 1.67 + 1.68 +.code 1.69 + 1.70 +; utility functions (not required but often useful) 1.71 +popstring proc uses edi pStr:DWORD 1.72 + 1.73 + LOCAL th:DWORD 1.74 + 1.75 + mov edi, g_stacktop 1.76 + cmp edi, 0 1.77 + jz STACK_ERR 1.78 + mov edi, [edi] 1.79 + cmp edi, 0 1.80 + jz STACK_ERR 1.81 + 1.82 + ASSUME edi:PTR stack_t 1.83 + invoke lstrcpy, pStr, ADDR [edi].text 1.84 + mov th , edi 1.85 + mov edi, [edi].next 1.86 + mov eax, g_stacktop 1.87 + mov [eax], edi 1.88 + invoke GlobalFree, th 1.89 + ASSUME edi:PTR NOTHING 1.90 + mov eax, 0 1.91 + ret 1.92 + 1.93 +STACK_ERR: 1.94 + mov eax, 1 1.95 + ret 1.96 + 1.97 +popstring endp 1.98 + 1.99 +pushstring proc uses edi pStr:DWORD 1.100 + 1.101 + cmp g_stacktop, 0 1.102 + jz STACK_ERR 1.103 + 1.104 + mov eax, sizeof stack_t 1.105 + add eax, g_stringsize 1.106 + invoke GlobalAlloc, GPTR, eax 1.107 + 1.108 + mov edi, eax 1.109 + assume edi:PTR stack_t 1.110 + 1.111 + invoke lstrcpyn, ADDR [edi].text, pStr, g_stringsize 1.112 + mov eax, g_stacktop 1.113 + push DWORD PTR[eax] 1.114 + mov [eax], edi 1.115 + pop eax 1.116 + ;lea edi, [edi].next ; Not needed [edi].next == edi 1.117 + mov DWORD PTR[edi], eax 1.118 + ASSUME edi:PTR NOTHING 1.119 + 1.120 +STACK_ERR: 1.121 + ret 1.122 + 1.123 +pushstring endp 1.124 + 1.125 +getuservariable proc varnum:DWORD 1.126 + 1.127 + .if varnum < 0 || varnum >= __INST_LAST 1.128 + xor eax, eax 1.129 + .else 1.130 + mov eax, varnum 1.131 + imul eax, g_stringsize 1.132 + add eax, g_variables 1.133 + .endif 1.134 + ret 1.135 + 1.136 +getuservariable endp 1.137 + 1.138 +setuservariable proc varnum:DWORD, var:DWORD 1.139 + 1.140 + .if (var != NULL && varnum >= 0 && varnum < __INST_LAST) 1.141 + mov eax, varnum 1.142 + imul eax, g_stringsize 1.143 + add eax, g_variables 1.144 + invoke lstrcpy, eax, var 1.145 + .endif 1.146 + ret 1.147 + 1.148 +setuservariable endp