daily pastebin goal
52%
SHARE
TWEET

EEex_AddressList

fatalexception Feb 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. EEEX_ALIGN
  2. ;------------------------------------------------------------------------------
  3. ; [LUA] EEex_AddressList: Return a table of function and global addresses
  4. ;
  5. ; EEex_AddressList()
  6. ;------------------------------------------------------------------------------
  7. EEex_AddressList PROC C USES EBX lua_State:DWORD
  8.     LOCAL nPattern:DWORD
  9.     LOCAL ptrCurrentPattern:DWORD
  10.     LOCAL lpszPatternName:DWORD
  11.     LOCAL dwPatternAddress:DWORD
  12.     LOCAL nTotal:DWORD
  13.     LOCAL nCount:DWORD
  14.     LOCAL pT2Array:DWORD
  15.     LOCAL pT2Entry:DWORD
  16.     LOCAL qwAddress:QWORD
  17.    
  18.     IFDEF EEEX_LOGGING
  19.     IFDEF EEEX_LOGLUACALLS
  20.     .IF gEEexLog >= LOGLEVEL_DEBUG
  21.         Invoke LogMessage, Addr szEEex_AddressList, LOG_STANDARD, 1
  22.     .ENDIF
  23.     ENDIF
  24.     ENDIF
  25.    
  26.     Invoke F_Lua_createtablex, lua_State
  27.  
  28.     mov ebx, PatternsDatabase
  29.     mov ptrCurrentPattern, ebx
  30.     mov nPattern, 0
  31.     mov eax, 0
  32.     .WHILE eax < TotalPatterns
  33.         .IF [ebx].PATTERN.bFound == TRUE
  34.             mov eax, [ebx].PATTERN.PatName
  35.             mov lpszPatternName, eax
  36.            
  37.             .IF [ebx].PATTERN.PatType == 2
  38.                 ;--------------------------------------------------------------
  39.                 ; Handle type 2 pattern: name=table/array of addresses
  40.                 ;--------------------------------------------------------------
  41.                 mov eax, [ebx].PATTERN.VerAdj ; used to store count of array entries
  42.                 mov nTotal, eax
  43.                 mov eax, [ebx].PATTERN.PatAddress ; used to store pointer to array
  44.                 .IF eax != NULL && nTotal != 0
  45.                     mov pT2Array, eax
  46.                     mov pT2Entry, eax
  47.                    
  48.                     Invoke F_Lua_pushstring, lua_State, lpszPatternName
  49.                    
  50.                     Invoke F_Lua_createtablex, lua_State
  51.                     mov nCount, 0
  52.                     mov eax, 0
  53.                     .WHILE eax < nTotal
  54.                         mov ebx, pT2Entry
  55.                         mov eax, [ebx]
  56.                         mov dwPatternAddress, eax
  57.                        
  58.                         fild dwPatternAddress
  59.                         fstp qword ptr [qwAddress]            
  60.                         Invoke F_Lua_pushnumber, lua_State, qwAddress ; dwPatternAddress
  61.                         Invoke F_Lua_settable, lua_State, -2
  62.                        
  63.                         add pT2Entry, SIZEOF DWORD
  64.                         inc nCount
  65.                         mov eax, nCount
  66.                     .ENDW
  67.                     Invoke F_Lua_settable, lua_State, -3
  68.                    
  69.                 .ENDIF
  70.                
  71.             .ELSE
  72.                 ;--------------------------------------------------------------
  73.                 ; Handle all other pattern types: name=address
  74.                 ;--------------------------------------------------------------
  75.                 mov eax, [ebx].PATTERN.PatAddress
  76.                 mov dwPatternAddress, eax
  77.                 Invoke F_Lua_pushstring, lua_State, lpszPatternName
  78.                 fild dwPatternAddress
  79.                 fstp qword ptr [qwAddress]            
  80.                 Invoke F_Lua_pushnumber, lua_State, qwAddress ; dwPatternAddress
  81.                 Invoke F_Lua_settable, lua_State, -3
  82.             .ENDIF
  83.            
  84.         .ENDIF
  85.         add ptrCurrentPattern, SIZEOF PATTERN
  86.         mov ebx, ptrCurrentPattern
  87.         inc nPattern
  88.         mov eax, nPattern
  89.     .ENDW
  90.    
  91.     ; handle special cases, like GetProcAddress, LoadLibrary etc
  92.     Invoke F_Lua_pushstring, lua_State, Addr szGetProcAddress
  93.     fild F_GetProcAddress
  94.     fstp qword ptr [qwAddress]      
  95.     Invoke F_Lua_pushnumber, lua_State, qwAddress ; F_GetProcAddress
  96.     Invoke F_Lua_settable, lua_State, -3
  97.    
  98.     Invoke F_Lua_pushstring, lua_State, Addr szLoadLibrary
  99.     fild F_LoadLibrary
  100.     fstp qword ptr [qwAddress]    
  101.     Invoke F_Lua_pushnumber, lua_State, qwAddress ; F_LoadLibrary
  102.     Invoke F_Lua_settable, lua_State, -3
  103.    
  104.     Invoke F_Lua_pushstring, lua_State, Addr szSDL_Free
  105.     fild F_SDL_free
  106.     fstp qword ptr [qwAddress]      
  107.     Invoke F_Lua_pushnumber, lua_State, qwAddress ; F_SDL_free
  108.     Invoke F_Lua_settable, lua_State, -3
  109.    
  110.     ;Invoke F_Lua_setglobal, lua_State, Addr szEEex_LuaAddressList
  111.    
  112.     mov eax, 1
  113.     ret
  114. EEex_AddressList ENDP
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top