update_tool/api_link.asm
branchsourcemm-1.6.0
changeset 428 40a9d2f61121
parent 370 4dc28ab1c722
child 429 cadecde4b802
     1.1 --- a/update_tool/api_link.asm	Thu Oct 04 19:46:28 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,138 +0,0 @@
     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, ServerCommand
    1.23 -global _GetThisPointer, _GetGameDir, _ServerCommand
    1.24 -global _GetICvar, GetICvar
    1.25 -extern _LoadFunction
    1.26 -
    1.27 -GetICvar:
    1.28 -_GetICvar:
    1.29 -	mov 	eax, [icvar]
    1.30 -	ret
    1.31 -
    1.32 -GetThisPointer:
    1.33 -_GetThisPointer:
    1.34 -	mov		eax, GLOBAL_POINTER
    1.35 -	ret
    1.36 -	
    1.37 -GetGameDir:
    1.38 -_GetGameDir:
    1.39 -	push	ebp
    1.40 -	mov		ebp, esp			
    1.41 -	
    1.42 -	mov		ecx, [engine]		;get this pointer
    1.43 -	mov		edx, [ecx]			;get the vtable
    1.44 -	push	dword [ebp+12]		;push maxlenth
    1.45 -	push	dword [ebp+8]		;push buffer
    1.46 -	%ifdef LINUX
    1.47 -	push	ecx					;push this pointer
    1.48 -	%endif
    1.49 -	call	dword [edx+216]		;call IVEngineServer::GetGameDir
    1.50 -	%ifdef LINUX
    1.51 -	add		esp, 12				;correct stack
    1.52 -	%endif
    1.53 -	
    1.54 -	pop 	ebp
    1.55 -	ret
    1.56 -	
    1.57 -ServerCommand
    1.58 -_ServerCommand:
    1.59 -	push	ebp
    1.60 -	mov		ebp, esp
    1.61 -	
    1.62 -	mov		ecx, [engine]		;get this pointer
    1.63 -	mov		edx, [ecx]			;get the vtable
    1.64 -	push	dword [ebp+8]		;push string
    1.65 -	%ifdef LINUX
    1.66 -	push	ecx					;push this pointer
    1.67 -	%endif
    1.68 -	call	dword [edx+144]		;call IVEngineServer::ServerCommand
    1.69 -	%ifdef LINUX
    1.70 -	add		esp, 8				;correct stack
    1.71 -	%endif
    1.72 -	
    1.73 -	pop		ebp
    1.74 -	ret
    1.75 -	
    1.76 -thisLoadFunction:
    1.77 -	push	ebp
    1.78 -	mov		ebp, esp
    1.79 -	
    1.80 -	push	edi
    1.81 -	
    1.82 -	;get factory
    1.83 -	%ifdef LINUX
    1.84 -	mov		edi, [ebp+12]
    1.85 -	%else
    1.86 -	mov		edi, [ebp+8]
    1.87 -	%endif
    1.88 -	
    1.89 -	push	dword 0				;NULL
    1.90 -	push	dword VENGINESERVER	;iface name
    1.91 -	call	edi					;call factory
    1.92 -	add		esp, 8				;correct stack
    1.93 -	
    1.94 -	test	eax, eax			;do we have a valid pointer?
    1.95 -	jz		.end				;no, bail out
    1.96 -	
    1.97 -	mov		[engine], eax		;store the engine pointer
    1.98 -	
    1.99 -	push	dword 0				;NULL
   1.100 -	push	dword VENGINECVAR	;iface name
   1.101 -	call	edi					;call factory
   1.102 -	add		esp, 8				;correct stack
   1.103 -	
   1.104 -	test	eax, eax			;do we have a valid pointer?
   1.105 -	jz		.end				;no, bail out
   1.106 -	
   1.107 -	mov		[icvar], eax		;store the icvar pointer
   1.108 -	
   1.109 -	call	_LoadFunction
   1.110 -	
   1.111 -.end:
   1.112 -	;We never load, never ever ever!
   1.113 -	xor		eax, eax
   1.114 -	
   1.115 -	pop		edi
   1.116 -	
   1.117 -	pop		ebp
   1.118 -	%ifdef LINUX
   1.119 -	ret
   1.120 -	%else
   1.121 -	retn	8
   1.122 -	%endif
   1.123 -	
   1.124 -thisUnloadFunction:
   1.125 -	ret
   1.126 -	
   1.127 -section .data
   1.128 -	INTERFACE_NAME		DB		"ISERVERPLUGINCALLBACKS001", 0
   1.129 -	VENGINESERVER		DB		"VEngineServer021", 0
   1.130 -	VENGINECVAR			DB		"VEngineCvar003", 0
   1.131 -	
   1.132 -	VIRTUAL_TABLE		DD		thisLoadFunction
   1.133 -						DD		thisUnloadFunction
   1.134 -						;We don't need any more of the vtable here
   1.135 -								
   1.136 -	GLOBAL_POINTER		DD		VIRTUAL_TABLE
   1.137 -
   1.138 -	temp_ret			DD		0
   1.139 -	temp_ptr			DD		temp_ret
   1.140 -	engine				DD		0
   1.141 -	icvar				DD		0