update_tool/api_link.asm
author David Anderson <dvander@alliedmods.net>
Sat Mar 31 16:23:19 2007 +0000 (2007-03-31)
changeset 300 807620eb4f4e
child 301 659940583dc3
permissions -rw-r--r--
initial import of the updater tool
     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 	%ifdef LINUX
    36 	push	ecx					;push this pointer
    37 	%endif
    38 	push	dword [ebp+12]		;push maxlenth
    39 	push	dword [ebp+8]		;push buffer
    40 	call	dword [edx+216]		;call IVEngineServer::GetGameDir
    41 	%ifdef LINUX
    42 	add		esp, 8				;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 	mov		eax, [ebp+8]
    54 	
    55 	push	dword 0				;NULL
    56 	push	dword VENGINESERVER	;iface name
    57 	call	eax					;call factory
    58 	add		esp, 8				;correct stack
    59 	
    60 	test	eax, eax			;do we have a valid pointer?
    61 	jz		.end				;no, bail out
    62 	
    63 	mov		[engine], eax		;store the engine pointer
    64 	
    65 	call	_LoadFunction
    66 	
    67 .end:
    68 	;We never load, never ever ever!
    69 	xor		eax, eax
    70 	pop		ebp
    71 	%ifdef LINUX
    72 	ret
    73 	%else
    74 	retn	8
    75 	%endif
    76 	
    77 thisUnloadFunction:
    78 	ret
    79 	
    80 section .data
    81 	INTERFACE_NAME		DB		"ISERVERPLUGINCALLBACKS001", 0
    82 	VENGINESERVER		DB		"VEngineServer021", 0
    83 	
    84 	VIRTUAL_TABLE		DD		thisLoadFunction
    85 						DD		thisUnloadFunction
    86 						;We don't need any more of the vtable here
    87 								
    88 	GLOBAL_POINTER		DD		VIRTUAL_TABLE
    89 
    90 	temp_ret			DD		0
    91 	temp_ptr			DD		temp_ret
    92 	engine				DD		0