All pastes #139667 Raw Edit

Mine

public text v1 · immutable
#139667 ·published 2006-08-20 02:23 UTC
rendered paste body
		.586p

GetBase		macro	Reg
		call	$+5
		pop	Reg
		sub	Reg,$-1
		endm

Code		segment	use32
		org	0
		dd	offset	End_of_file
		dw	1		; Version
		dd	End_of_header	; Size of header
		dd	offset	Selections
		dd	offset	Selections_Text
		dd	offset	ID_List
		dd	offset	Entry
		dd	0		; Res1
		dd	0		; Res2
		db	0		; Master Enable

End_of_header	equ	$



storepushret PROC
mov  byte ptr [edi],068h
mov  dword ptr [edi+1], esi
mov byte ptr [edi+5], 0c3h
ret
storepushret ENDP

Entry:

        mov edi, 0124C2Eh
    lea  esi, [igks+ebp] ;ingame keys
        call  storepushret

        mov edi, 012B6AAh
    lea  esi, [gamestate+ebp] ;updates gamestate
        call  storepushret

ret
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;creates a bitmask16 of gamepad presses
;dpad-up= 0001
;dpad-down= 0002
;dpad-left= 0004
;dpad-right= 0008
;start=  0010
;back=  0020
;lthumb= 0040
;rthumb= 0080
;A=  0100
;B=  0200
;X=  0400
;Y=  0800
;black=  1000
;white=  2000

igks:  ;hook @ 0124C2Eh
;00124C2E   lea     ecx,[esp+20h]
;00124C32  push    ecx  
;00124C33   push    eax  
;00124C34   call    00409B6C
        lea  ecx, [esp+20h]
        pushad
        getbase ebp
        lea eax, dword ptr [eax+14h] ;loads XINPUT_GAMEPAD address

        ;-----builds bitmask16 for entire gamepad-----
        xor edx, edx   ;resets edx
        mov cx, 0100h   ;initial bitmask value
        mov bl, byte ptr [eax]  ;copies wButtons
        buildgamepad:
        mov dl, byte ptr [eax+2]  ;loads button
        cmp edx, 03Fh   ;checks for 25% press
        jle notpressed   ;jumps if less than
        add bx, cx    ;enables bitmask
        notpressed:
        shl cx, 1    ;gets next bitmask value
        inc eax    ;gets next button address
        cmp cx, 04000h   ;checks if it assigned all bitmasks (excluding triggers)
        jne buildgamepad   ;jumps if hasnt

        lea eax, [ebp+gamepad]  ;loads gamepad address
        mov word ptr [eax], bx  ;stores new gamepad state
        popad
        push  ecx
        push  eax
        push 00124C34h
        ret
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
framedelay db 0
gamestate: ;hook @ 012B6AAh
;0012B6AA lea     ebx, [ebx]
;0012B6B0 call    sub_12B450
;0012B6B5 mov     al, byte_547F2B
;0012B6BA test    al, al
;0012B6BC jz      short loc_12B6B0
        lea ebx, [ebx]
        loc_12B6B0:
        pushad
        getbase ebp
        xor byte ptr ds:[ebp+framedelay], 1  ;frame limiter (10fps)
        cmp framedelay[ebp], 1   ;checks to make sure everything is updated
        jne limitfps    ;jumps if not

        ;-----checks for gamepad input-----
        call InGameKeys

        ;ADD WHATEVER ELSE YOU WANT HERE, THINK OF IT AS MAIN()

        limitfps:
        popad
        push ebx
        mov ebx, 012B450h
        call ebx   ;updates gamestate
        pop ebx
        mov     al, byte ptr ds:[0547F2Bh]
        test    al, al
        jz  loc_12B6B0
        push    012B6BEh
        ret
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
gamepad  dw 0
InGameKeys PROC
        pushad
        getbase ebp    ;gets base address of trainer
        mov ax, word ptr [ebp+gamepad] ;loads gamepad data
        mov bx, word ptr [ebp+oldpad] ;loads old press
        ;lea ecx, [ebp+config+40h]  ;loads igk config address
        cmp ax, bx    ;compares with new press
        je heldkey    ;jumps if no change

        ;PUT KEYS THAT YOU ONLY WANT EXECUTED ONCE PER PRESS HERE

        wireframe: ;-----toggles wireframe mode-----
cmp  ax, 080h ;rthumb+lthumb
jne testcombo
        pushad
GetBase ebp
        lea ebx, dword ptr ds:[ebp+renderstate] ;loads current renderstate
        xor byte ptr [ebx], 1   ;toggles renderstate (0=wireframe, 1=solid)
        mov cl, byte ptr [ebx]   ;duplicates renderstate
        inc cl     ;adjusts for real enum value
        mov eax, cr0    ;realtime patch routine
        push  eax
        and eax, 0FFFEFFFFh
        mov cr0, eax
        mov byte ptr ds:[0133F6h], cl  ;moves data into address
        pop eax
        mov cr0, eax
        popad

        testcombo:
cmp  ax, 041h ;lthumb+dpad-up
jne nochange

        ;PUT TEST CODE HERE

        jmp nochange
heldkey: ;-----code that is executed multiple times per press-----

        ;PUT KEYS THAT YOU CAN HOLD HERE


nochange:
        ;-----stores old press-----
        lea ebx, [ebp+oldpad]
        mov word ptr [ebx], ax
        popad
        ret
InGameKeys ENDP
oldpad  dw 0
renderstate db 1  ;default solidfill


ID_List		label	dword
		dd	04D530064h
		dd	0


Selections	label	byte

Selections_Text	label	byte

		dd	offset	Text_Menu
		dd	offset	Text_Info
		dd	0

Text_Menu	db	'Halo 2 Test Trainer 3', 0
Text_Info	db	'Made by Jefff', 0
		db	0


End_of_file	equ	$

Code		ends

		end