Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EEEX_ALIGN
- ;------------------------------------------------------------------------------
- ; [LUA] EEex_AddressList: Return a table of function and global addresses
- ;
- ; EEex_AddressList()
- ;------------------------------------------------------------------------------
- EEex_AddressList PROC C USES EBX lua_State:DWORD
- LOCAL nPattern:DWORD
- LOCAL ptrCurrentPattern:DWORD
- LOCAL lpszPatternName:DWORD
- LOCAL dwPatternAddress:DWORD
- LOCAL nTotal:DWORD
- LOCAL nCount:DWORD
- LOCAL pT2Array:DWORD
- LOCAL pT2Entry:DWORD
- LOCAL qwAddress:QWORD
- IFDEF EEEX_LOGGING
- IFDEF EEEX_LOGLUACALLS
- .IF gEEexLog >= LOGLEVEL_DEBUG
- Invoke LogMessage, Addr szEEex_AddressList, LOG_STANDARD, 1
- .ENDIF
- ENDIF
- ENDIF
- Invoke F_Lua_createtablex, lua_State
- mov ebx, PatternsDatabase
- mov ptrCurrentPattern, ebx
- mov nPattern, 0
- mov eax, 0
- .WHILE eax < TotalPatterns
- .IF [ebx].PATTERN.bFound == TRUE
- mov eax, [ebx].PATTERN.PatName
- mov lpszPatternName, eax
- .IF [ebx].PATTERN.PatType == 2
- ;--------------------------------------------------------------
- ; Handle type 2 pattern: name=table/array of addresses
- ;--------------------------------------------------------------
- mov eax, [ebx].PATTERN.VerAdj ; used to store count of array entries
- mov nTotal, eax
- mov eax, [ebx].PATTERN.PatAddress ; used to store pointer to array
- .IF eax != NULL && nTotal != 0
- mov pT2Array, eax
- mov pT2Entry, eax
- Invoke F_Lua_pushstring, lua_State, lpszPatternName
- Invoke F_Lua_createtablex, lua_State
- mov nCount, 0
- mov eax, 0
- .WHILE eax < nTotal
- mov ebx, pT2Entry
- mov eax, [ebx]
- mov dwPatternAddress, eax
- fild dwPatternAddress
- fstp qword ptr [qwAddress]
- Invoke F_Lua_pushnumber, lua_State, qwAddress ; dwPatternAddress
- Invoke F_Lua_settable, lua_State, -2
- add pT2Entry, SIZEOF DWORD
- inc nCount
- mov eax, nCount
- .ENDW
- Invoke F_Lua_settable, lua_State, -3
- .ENDIF
- .ELSE
- ;--------------------------------------------------------------
- ; Handle all other pattern types: name=address
- ;--------------------------------------------------------------
- mov eax, [ebx].PATTERN.PatAddress
- mov dwPatternAddress, eax
- Invoke F_Lua_pushstring, lua_State, lpszPatternName
- fild dwPatternAddress
- fstp qword ptr [qwAddress]
- Invoke F_Lua_pushnumber, lua_State, qwAddress ; dwPatternAddress
- Invoke F_Lua_settable, lua_State, -3
- .ENDIF
- .ENDIF
- add ptrCurrentPattern, SIZEOF PATTERN
- mov ebx, ptrCurrentPattern
- inc nPattern
- mov eax, nPattern
- .ENDW
- ; handle special cases, like GetProcAddress, LoadLibrary etc
- Invoke F_Lua_pushstring, lua_State, Addr szGetProcAddress
- fild F_GetProcAddress
- fstp qword ptr [qwAddress]
- Invoke F_Lua_pushnumber, lua_State, qwAddress ; F_GetProcAddress
- Invoke F_Lua_settable, lua_State, -3
- Invoke F_Lua_pushstring, lua_State, Addr szLoadLibrary
- fild F_LoadLibrary
- fstp qword ptr [qwAddress]
- Invoke F_Lua_pushnumber, lua_State, qwAddress ; F_LoadLibrary
- Invoke F_Lua_settable, lua_State, -3
- Invoke F_Lua_pushstring, lua_State, Addr szSDL_Free
- fild F_SDL_free
- fstp qword ptr [qwAddress]
- Invoke F_Lua_pushnumber, lua_State, qwAddress ; F_SDL_free
- Invoke F_Lua_settable, lua_State, -3
- ;Invoke F_Lua_setglobal, lua_State, Addr szEEex_LuaAddressList
- mov eax, 1
- ret
- EEex_AddressList ENDP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement