1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/update_tool/api_link.asm Sat Mar 31 16:23:19 2007 +0000
1.3 @@ -0,0 +1,92 @@
1.4 +;;;;
1.5 +;; (C)2005-2007 AlliedModders LLC
1.6 +;; By the Metamod:Source Development Team
1.7 +;; This software is licensed under the zlib/libpng free software license.
1.8 +;;
1.9 +;; This assembly file is a short thunk wrapper to let us load as a VSP and exit quietly,
1.10 +;; without any overhead of the rest of the interface, and also to prevent linking against
1.11 +;; tierX or vstdlib
1.12 +;;;;
1.13 +
1.14 +;;Exports:
1.15 +;; void GetBaseDir(char *buffer, maxlength);
1.16 +;; void *GetThisPointer();
1.17 +;;Imports:
1.18 +;; void LoadFunction();
1.19 +
1.20 +section .text
1.21 +
1.22 +global GetThisPointer, GetGameDir
1.23 +global _GetThisPointer, _GetGameDir
1.24 +extern _LoadFunction
1.25 +
1.26 +GetThisPointer:
1.27 +_GetThisPointer:
1.28 + mov eax, GLOBAL_POINTER
1.29 + ret
1.30 +
1.31 +GetGameDir:
1.32 +_GetGameDir:
1.33 + push ebp
1.34 + mov ebp, esp
1.35 +
1.36 + mov ecx, [engine] ;get this pointer
1.37 + mov edx, [ecx] ;get the vtable
1.38 + %ifdef LINUX
1.39 + push ecx ;push this pointer
1.40 + %endif
1.41 + push dword [ebp+12] ;push maxlenth
1.42 + push dword [ebp+8] ;push buffer
1.43 + call dword [edx+216] ;call IVEngineServer::GetGameDir
1.44 + %ifdef LINUX
1.45 + add esp, 8 ;correct stack
1.46 + %endif
1.47 +
1.48 + pop ebp
1.49 + ret
1.50 +
1.51 +thisLoadFunction:
1.52 + push ebp
1.53 + mov ebp, esp
1.54 +
1.55 + ;get factory
1.56 + mov eax, [ebp+8]
1.57 +
1.58 + push dword 0 ;NULL
1.59 + push dword VENGINESERVER ;iface name
1.60 + call eax ;call factory
1.61 + add esp, 8 ;correct stack
1.62 +
1.63 + test eax, eax ;do we have a valid pointer?
1.64 + jz .end ;no, bail out
1.65 +
1.66 + mov [engine], eax ;store the engine pointer
1.67 +
1.68 + call _LoadFunction
1.69 +
1.70 +.end:
1.71 + ;We never load, never ever ever!
1.72 + xor eax, eax
1.73 + pop ebp
1.74 + %ifdef LINUX
1.75 + ret
1.76 + %else
1.77 + retn 8
1.78 + %endif
1.79 +
1.80 +thisUnloadFunction:
1.81 + ret
1.82 +
1.83 +section .data
1.84 + INTERFACE_NAME DB "ISERVERPLUGINCALLBACKS001", 0
1.85 + VENGINESERVER DB "VEngineServer021", 0
1.86 +
1.87 + VIRTUAL_TABLE DD thisLoadFunction
1.88 + DD thisUnloadFunction
1.89 + ;We don't need any more of the vtable here
1.90 +
1.91 + GLOBAL_POINTER DD VIRTUAL_TABLE
1.92 +
1.93 + temp_ret DD 0
1.94 + temp_ptr DD temp_ret
1.95 + engine DD 0