update_tool/api_link.asm
author David Anderson <dvander@alliedmods.net>
Sat Mar 31 17:51:08 2007 +0000 (2007-03-31)
changeset 301 659940583dc3
parent 300 807620eb4f4e
child 305 539f25c00858
permissions -rw-r--r--
fixed linux issues
     1 ;;;;
     2 ;; (C)2005-2007 AlliedModders LLC
     3 ;; By the Metamod:Source Development Team
     4 ;; This software is licensed under the zlib/libpng free software license.
     5 ;;
     6 ;; This assembly file is a short thunk wrapper to let us load as a VSP and exit quietly,
     7 ;; without any overhead of the rest of the interface, and also to prevent linking against
     8 ;; tierX or vstdlib
     9 ;;;;
    10 
    11 ;;Exports:
    12 ;; void GetBaseDir(char *buffer, maxlength);
    13 ;; void *GetThisPointer();
    14 ;;Imports:
    15 ;; void LoadFunction();
    16 
    17 section .text
    18 
    19 global GetThisPointer, GetGameDir
    20 global _GetThisPointer, _GetGameDir
    21 extern _LoadFunction
    22 
    23 GetThisPointer:
    24 _GetThisPointer:
    25 	mov		eax, GLOBAL_POINTER
    26 	ret
    27 	
    28 GetGameDir:
    29 _GetGameDir:
    30 	push	ebp
    31 	mov		ebp, esp			
    32 	
    33 	mov		ecx, [engine]		;get this pointer
    34 	mov		edx, [ecx]			;get the vtable
    35 	push	dword [ebp+12]		;push maxlenth
    36 	push	dword [ebp+8]		;push buffer
    37 	%ifdef LINUX
    38 	push	ecx					;push this pointer
    39 	%endif
    40 	call	dword [edx+216]		;call IVEngineServer::GetGameDir
    41 	%ifdef LINUX
    42 	add		esp, 12				;correct stack
    43 	%endif
    44 	
    45 	pop 	ebp
    46 	ret
    47 
    48 thisLoadFunction:
    49 	push	ebp
    50 	mov		ebp, esp
    51 	
    52 	;get factory
    53 	%ifdef LINUX
    54 	mov		eax, [ebp+12]
    55 	%else
    56 	mov		eax, [ebp+8]
    57 	%endif
    58 	
    59 	push	dword 0				;NULL
    60 	push	dword VENGINESERVER	;iface name
    61 	call	eax					;call factory
    62 	add		esp, 8				;correct stack
    63 	
    64 	test	eax, eax			;do we have a valid pointer?
    65 	jz		.end				;no, bail out
    66 	
    67 	mov		[engine], eax		;store the engine pointer
    68 	
    69 	call	_LoadFunction
    70 	
    71 .end:
    72 	;We never load, never ever ever!
    73 	xor		eax, eax
    74 	pop		ebp
    75 	%ifdef LINUX
    76 	ret
    77 	%else
    78 	retn	8
    79 	%endif
    80 	
    81 thisUnloadFunction:
    82 	ret
    83 	
    84 section .data
    85 	INTERFACE_NAME		DB		"ISERVERPLUGINCALLBACKS001", 0
    86 	VENGINESERVER		DB		"VEngineServer021", 0
    87 	
    88 	VIRTUAL_TABLE		DD		thisLoadFunction
    89 						DD		thisUnloadFunction
    90 						;We don't need any more of the vtable here
    91 								
    92 	GLOBAL_POINTER		DD		VIRTUAL_TABLE
    93 
    94 	temp_ret			DD		0
    95 	temp_ptr			DD		temp_ret
    96 	engine				DD		0