tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

extdll.inc (3096B)


      1 ;################################################################
      2 ; ExtDLL header for MASM32
      3 ;
      4 ; Author: Ramon
      5 ;
      6 ; Obs: This header must be included after windows.inc and kernel32.inc
      7 ;      because it need the prototypes for lstrcpy, lstrcpyn, 
      8 ;      GlobalAlloc and GlobalFree
      9 ;
     10 ;################################################################
     11 stack_t struct
     12  next dd ?
     13  text dd ? ; 1 DUP(?) ; this should be the length of string_size
     14 stack_t ends
     15 
     16 .const
     17 ; For page showing plug-ins
     18 WM_NOTIFY_OUTER_NEXT   equ (WM_USER+0x8)
     19 WM_NOTIFY_CUSTOM_READY equ (WM_USER+0xd)
     20 NOTIFY_BYE_BYE         equ 'x'
     21 
     22 INST_0 EQU 0         ; $0
     23 INST_1 EQU 1         ; $1
     24 INST_2 EQU 2         ; $2
     25 INST_3 EQU 3         ; $3
     26 INST_4 EQU 4         ; $4
     27 INST_5 EQU 5         ; $5
     28 INST_6 EQU 6         ; $6
     29 INST_7 EQU 7         ; $7
     30 INST_8 EQU 8         ; $8
     31 INST_9 EQU 9         ; $9
     32 INST_R0 EQU 10        ; $R0
     33 INST_R1 EQU 11        ; $R1
     34 INST_R2 EQU 12        ; $R2
     35 INST_R3 EQU 13        ; $R3
     36 INST_R4 EQU 14        ; $R4
     37 INST_R5 EQU 15        ; $R5
     38 INST_R6 EQU 16        ; $R6
     39 INST_R7 EQU 17        ; $R7
     40 INST_R8 EQU 18        ; $R8
     41 INST_R9 EQU 19        ; $R9
     42 INST_CMDLINE EQU 20   ; $CMDLINE
     43 INST_INSTDIR EQU 21   ; $INSTDIR
     44 INST_OUTDIR EQU 22    ; $OUTDIR
     45 INST_EXEDIR EQU 23    ; $EXEDIR
     46 INST_LANG EQU 24      ; $LANGUAGE
     47 __INST_LAST EQU 25
     48 
     49 .data?
     50 g_stringsize dd ?
     51 g_stacktop dd ?
     52 g_variables dd ?
     53 
     54 m2m MACRO M1, M2
     55      push M2
     56      pop  M1
     57 ENDM
     58 
     59 EXDLL_INIT MACRO
     60      m2m g_stringsize, string_size
     61      m2m g_stacktop, stacktop
     62      m2m g_variables, variables
     63 ENDM
     64 
     65 .code
     66 
     67 ; utility functions (not required but often useful)
     68 popstring proc uses edi pStr:DWORD
     69 
     70  LOCAL th:DWORD
     71 
     72  mov edi, g_stacktop
     73  cmp edi, 0
     74  jz  STACK_ERR
     75  mov edi, [edi]
     76  cmp edi, 0
     77  jz  STACK_ERR
     78 
     79  ASSUME edi:PTR stack_t
     80  invoke lstrcpy, pStr, ADDR [edi].text
     81  mov th , edi
     82  mov edi, [edi].next
     83  mov eax, g_stacktop
     84  mov [eax], edi
     85  invoke GlobalFree, th
     86  ASSUME edi:PTR NOTHING
     87  mov eax, 0
     88  ret
     89  
     90 STACK_ERR:
     91  mov eax, 1
     92  ret
     93 
     94 popstring endp
     95 
     96 pushstring proc uses edi pStr:DWORD
     97 
     98  cmp g_stacktop, 0
     99  jz  STACK_ERR
    100 
    101  mov eax, sizeof stack_t
    102  add eax, g_stringsize
    103  invoke GlobalAlloc, GPTR, eax
    104 
    105  mov edi, eax
    106  assume edi:PTR stack_t
    107 
    108  invoke lstrcpyn, ADDR [edi].text, pStr, g_stringsize
    109  mov eax, g_stacktop
    110  push DWORD PTR[eax]
    111  mov [eax], edi
    112  pop eax
    113  ;lea edi, [edi].next ; Not needed [edi].next == edi
    114  mov DWORD PTR[edi], eax
    115  ASSUME edi:PTR NOTHING
    116 
    117 STACK_ERR:
    118  ret
    119 
    120 pushstring endp
    121 
    122 getuservariable proc varnum:DWORD
    123 
    124  .if varnum < 0 || varnum >= __INST_LAST
    125    xor eax, eax
    126  .else
    127    mov eax, varnum
    128    imul eax, g_stringsize
    129    add eax, g_variables
    130  .endif
    131  ret
    132 
    133 getuservariable endp
    134 
    135 setuservariable proc varnum:DWORD, var:DWORD
    136 
    137  .if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
    138    mov eax, varnum
    139    imul eax, g_stringsize
    140    add eax, g_variables
    141    invoke lstrcpy, eax, var
    142  .endif
    143  ret
    144 
    145 setuservariable endp