michael@0: ;################################################################ michael@0: ; ExtDLL header for MASM32 michael@0: ; michael@0: ; Author: Ramon michael@0: ; michael@0: ; Obs: This header must be included after windows.inc and kernel32.inc michael@0: ; because it need the prototypes for lstrcpy, lstrcpyn, michael@0: ; GlobalAlloc and GlobalFree michael@0: ; michael@0: ;################################################################ michael@0: stack_t struct michael@0: next dd ? michael@0: text dd ? ; 1 DUP(?) ; this should be the length of string_size michael@0: stack_t ends michael@0: michael@0: .const michael@0: ; For page showing plug-ins michael@0: WM_NOTIFY_OUTER_NEXT equ (WM_USER+0x8) michael@0: WM_NOTIFY_CUSTOM_READY equ (WM_USER+0xd) michael@0: NOTIFY_BYE_BYE equ 'x' michael@0: michael@0: INST_0 EQU 0 ; $0 michael@0: INST_1 EQU 1 ; $1 michael@0: INST_2 EQU 2 ; $2 michael@0: INST_3 EQU 3 ; $3 michael@0: INST_4 EQU 4 ; $4 michael@0: INST_5 EQU 5 ; $5 michael@0: INST_6 EQU 6 ; $6 michael@0: INST_7 EQU 7 ; $7 michael@0: INST_8 EQU 8 ; $8 michael@0: INST_9 EQU 9 ; $9 michael@0: INST_R0 EQU 10 ; $R0 michael@0: INST_R1 EQU 11 ; $R1 michael@0: INST_R2 EQU 12 ; $R2 michael@0: INST_R3 EQU 13 ; $R3 michael@0: INST_R4 EQU 14 ; $R4 michael@0: INST_R5 EQU 15 ; $R5 michael@0: INST_R6 EQU 16 ; $R6 michael@0: INST_R7 EQU 17 ; $R7 michael@0: INST_R8 EQU 18 ; $R8 michael@0: INST_R9 EQU 19 ; $R9 michael@0: INST_CMDLINE EQU 20 ; $CMDLINE michael@0: INST_INSTDIR EQU 21 ; $INSTDIR michael@0: INST_OUTDIR EQU 22 ; $OUTDIR michael@0: INST_EXEDIR EQU 23 ; $EXEDIR michael@0: INST_LANG EQU 24 ; $LANGUAGE michael@0: __INST_LAST EQU 25 michael@0: michael@0: .data? michael@0: g_stringsize dd ? michael@0: g_stacktop dd ? michael@0: g_variables dd ? michael@0: michael@0: m2m MACRO M1, M2 michael@0: push M2 michael@0: pop M1 michael@0: ENDM michael@0: michael@0: EXDLL_INIT MACRO michael@0: m2m g_stringsize, string_size michael@0: m2m g_stacktop, stacktop michael@0: m2m g_variables, variables michael@0: ENDM michael@0: michael@0: .code michael@0: michael@0: ; utility functions (not required but often useful) michael@0: popstring proc uses edi pStr:DWORD michael@0: michael@0: LOCAL th:DWORD michael@0: michael@0: mov edi, g_stacktop michael@0: cmp edi, 0 michael@0: jz STACK_ERR michael@0: mov edi, [edi] michael@0: cmp edi, 0 michael@0: jz STACK_ERR michael@0: michael@0: ASSUME edi:PTR stack_t michael@0: invoke lstrcpy, pStr, ADDR [edi].text michael@0: mov th , edi michael@0: mov edi, [edi].next michael@0: mov eax, g_stacktop michael@0: mov [eax], edi michael@0: invoke GlobalFree, th michael@0: ASSUME edi:PTR NOTHING michael@0: mov eax, 0 michael@0: ret michael@0: michael@0: STACK_ERR: michael@0: mov eax, 1 michael@0: ret michael@0: michael@0: popstring endp michael@0: michael@0: pushstring proc uses edi pStr:DWORD michael@0: michael@0: cmp g_stacktop, 0 michael@0: jz STACK_ERR michael@0: michael@0: mov eax, sizeof stack_t michael@0: add eax, g_stringsize michael@0: invoke GlobalAlloc, GPTR, eax michael@0: michael@0: mov edi, eax michael@0: assume edi:PTR stack_t michael@0: michael@0: invoke lstrcpyn, ADDR [edi].text, pStr, g_stringsize michael@0: mov eax, g_stacktop michael@0: push DWORD PTR[eax] michael@0: mov [eax], edi michael@0: pop eax michael@0: ;lea edi, [edi].next ; Not needed [edi].next == edi michael@0: mov DWORD PTR[edi], eax michael@0: ASSUME edi:PTR NOTHING michael@0: michael@0: STACK_ERR: michael@0: ret michael@0: michael@0: pushstring endp michael@0: michael@0: getuservariable proc varnum:DWORD michael@0: michael@0: .if varnum < 0 || varnum >= __INST_LAST michael@0: xor eax, eax michael@0: .else michael@0: mov eax, varnum michael@0: imul eax, g_stringsize michael@0: add eax, g_variables michael@0: .endif michael@0: ret michael@0: michael@0: getuservariable endp michael@0: michael@0: setuservariable proc varnum:DWORD, var:DWORD michael@0: michael@0: .if (var != NULL && varnum >= 0 && varnum < __INST_LAST) michael@0: mov eax, varnum michael@0: imul eax, g_stringsize michael@0: add eax, g_variables michael@0: invoke lstrcpy, eax, var michael@0: .endif michael@0: ret michael@0: michael@0: setuservariable endp