Advertisement
John

x86 Menu Base

Oct 3rd, 2015
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386
  2. .model flat, stdcall
  3. option casemap :none
  4.  
  5. include \masm32\include\msvcrt.inc
  6. include \masm32\include\kernel32.inc
  7. include \masm32\include\user32.inc
  8. include \masm32\include\masm32.inc
  9. includelib \masm32\lib\msvcrt.lib
  10. includelib \masm32\lib\masm32.lib
  11. includelib \masm32\lib\kernel32.lib
  12. includelib \masm32\lib\user32.lib
  13. include PS3.inc
  14.  
  15. system equ <_imp__system>
  16.  
  17. .data
  18.     str_connecting db "Connecting to PS3...", 0Ah, 0
  19.     str_con_s db "Successfully connected", 0Ah, 0
  20.     str_con_f db "Failed to connect", 0Ah, 0
  21.     str_atc_s db "Successfully attached", 0Ah, 0
  22.     str_atc_f db "Failed to attach", 0Ah, 0
  23.  
  24.     game_target dd 0FFFFFFFEh
  25.     game_proc_id dd 0
  26.     game_pucount dd 0
  27.  
  28.     buttons_addr dd 1FC7C90h
  29.     textstate_addr dd 2057217h
  30.     textstr_addr dd 2056B04h
  31.  
  32.     mem_input dd ?
  33.     mem_output dd ?
  34.    
  35.     og_menu_text db "~g~Menu Title!", 0Ah, 0Ah, "~w~God Mode |~w~Super Jump |~w~Unlimited Ammo |~w~Option 4 |~w~Option 5", 0
  36.     menu_text db "~g~Menu Title!", 0Ah, 0Ah, "~w~God Mode |~w~Super Jump |~w~Unlimited Ammo |~w~Option 4 |~w~Option 5", 0
  37.    
  38.     menu_option dd 0
  39.     menu_option_count dd 0
  40.     menu_isopen db 0
  41.    
  42.     str_button_x db "Pressed Square", 0Ah, 0
  43.     str_button_up db "Pressed Up", 0Ah, 0
  44.     str_button_down db "Pressed Down", 0Ah, 0
  45.     str_button_a db "Pressed Cross", 0Ah, 0
  46.    
  47.     str_opened_menu db "Opened menu", 0Ah, 0
  48.     str_closed_menu db "Closed menu", 0Ah, 0
  49.    
  50.     godmode_bytes db 038h, 060h, 07Fh, 0FFh, 0B0h, 07Fh, 0h, 0B4h
  51.     nop_bytes db 060h, 0, 0, 0
  52.     ammo1_bytes db 03Bh, 0A0h, 003h, 0E7h
  53.     ammo2_bytes db 038h, 0E0h, 000h, 063h
  54.    
  55. .code
  56. Main:
  57. _ConnectPS3:
  58.     push offset str_connecting
  59.     call StdOut
  60.  
  61.     call SNPS3InitTargetComms
  62.     push 0
  63.     push game_target
  64.     call SNPS3Connect
  65.     cmp eax, 0
  66.     je _con_success
  67.     cmp eax, 6
  68.     je _con_success
  69.     push offset str_con_f
  70.     call StdOut
  71.     jmp _Exit
  72.  
  73. _con_success:
  74.     push offset str_con_s
  75.     call StdOut
  76.  
  77.     push offset game_proc_id
  78.     push offset game_pucount
  79.     push game_target
  80.     call SNPS3ProcessList
  81.  
  82.     push offset game_proc_id
  83.     push offset game_pucount
  84.     push game_target
  85.     call SNPS3ProcessList
  86.  
  87.     push game_proc_id
  88.     push 0
  89.     push game_target
  90.     call SNPS3ProcessAttach
  91.     cmp eax, 0
  92.     je _atc_success
  93.     push offset str_atc_f
  94.     call StdOut
  95.     jmp _Exit
  96.  
  97. _atc_success:
  98.     push offset str_atc_s
  99.     call StdOut
  100.     push game_proc_id
  101.     push game_target
  102.     call SNPS3ProcessContinue
  103.  
  104.     _looop:
  105.     call MenuMonitor
  106.     push 100
  107.     call Sleep
  108.     jmp _looop
  109.    
  110. _Exit:
  111.     push 0
  112.     call ExitProcess
  113.  
  114. DrawMenu proc _input
  115.     mov eax, -1
  116.     mov ebx, lengthof menu_text
  117.     mov ecx, 0
  118.    
  119.     _loop:
  120.     inc eax
  121.     cmp eax, ebx
  122.     je _end
  123.     cmp byte ptr [og_menu_text+eax], '~'
  124.     jne _next
  125.     cmp byte ptr [og_menu_text+eax+1], 'w'
  126.     jne _next
  127.     cmp byte ptr [og_menu_text+eax+2], '~'
  128.     jne _next
  129.     cmp ecx, _input
  130.     jne _next
  131.     mov byte ptr [menu_text+eax+1], 'r'
  132.     _next:
  133.     cmp byte ptr [og_menu_text+eax], '|'
  134.     jne _next2
  135.     mov byte ptr [menu_text+eax], 0Ah
  136.     inc ecx
  137.     _next2:
  138.     cmp ebx, eax
  139.     jne _loop
  140.     _end:
  141.     mov menu_option_count, ecx
  142.     push offset menu_text
  143.     push lengthof menu_text
  144.     push textstr_addr
  145.     call SetMemory
  146.    
  147.     cld
  148.     mov esi, offset og_menu_text
  149.     mov edi, offset menu_text
  150.     mov ecx, lengthof og_menu_text
  151.     rep movsb
  152.    
  153.     ret
  154. DrawMenu endp
  155.  
  156. ToggleText proc _state
  157.     mov byte ptr mem_input, 3h
  158.     cmp _state, 0
  159.     jne _end
  160.     mov byte ptr mem_input, 2h
  161.     _end:
  162.     push offset mem_input
  163.     push 1
  164.     push textstate_addr
  165.     call SetMemory
  166.     ret
  167. ToggleText endp
  168.  
  169. GetButton proc
  170.     push 4
  171.     push buttons_addr
  172.     call GetMemory
  173.     ret
  174. GetButton endp
  175.  
  176. ExecuteOption proc _input
  177.     cmp _input, 0
  178.     je _option0
  179.     cmp _input, 1
  180.     je _option1
  181.     cmp _input, 2
  182.     je _option2
  183.     cmp _input, 3
  184.     je _option3
  185.    
  186.     _option0:
  187.     push offset godmode_bytes
  188.     push lengthof godmode_bytes
  189.     push 1185D08h
  190.     call SetMemory
  191.     ret
  192.    
  193.     _option1:
  194.     push offset nop_bytes
  195.     push lengthof nop_bytes
  196.     push 5EE6A0h
  197.     call SetMemory
  198.     ret
  199.    
  200.     _option2:
  201.     push offset ammo1_bytes
  202.     push lengthof ammo1_bytes
  203.     push 0FBF0A4h
  204.     call SetMemory
  205.    
  206.     push offset ammo2_bytes
  207.     push lengthof ammo2_bytes
  208.     push 0FDA420h
  209.     call SetMemory
  210.     ret
  211.    
  212.     _option3:
  213.     ret
  214.    
  215.     ret
  216. ExecuteOption endp
  217.  
  218. MenuMonitor proc
  219.     call GetButton
  220.     cmp byte ptr [eax+1], 10h
  221.     je PressedUp
  222.     cmp byte ptr [eax+1], 40h
  223.     je PressedDown
  224.     cmp byte ptr [eax+3], 80h
  225.     je PressedSquare
  226.     cmp byte ptr [eax+3], 40h
  227.     je PressedCross
  228.     jmp _end2
  229.    
  230.     PressedUp:
  231.     cmp menu_isopen, 0
  232.     je _end
  233.     cmp menu_option, 0
  234.     je _end
  235.     dec menu_option
  236.     push offset str_button_up
  237.     call StdOut
  238.     jmp _end
  239.    
  240.     PressedDown:
  241.     cmp menu_isopen, 0
  242.     je _end2
  243.     mov ebx, menu_option_count
  244.     cmp menu_option, ebx
  245.     je _end
  246.     inc menu_option
  247.     push offset str_button_down
  248.     call StdOut
  249.     jmp _end
  250.    
  251.     PressedSquare:
  252.     cmp menu_isopen, 0
  253.     je _end2
  254.     cmp menu_isopen, 1
  255.     jne _end2
  256.     jmp _close
  257.     push offset str_button_x
  258.     call StdOut
  259.     jmp _end
  260.    
  261.     PressedCross:
  262.     cmp menu_isopen, 0
  263.     je _end2
  264.     push menu_option
  265.     call ExecuteOption
  266.     push offset str_button_a
  267.     call StdOut
  268.     jmp _end
  269.    
  270.     _close:
  271.     push offset str_closed_menu
  272.     call StdOut
  273.     mov menu_isopen, 0
  274.     push 0
  275.     call ToggleText
  276.     jmp _end2
  277.    
  278.     _end:
  279.     cmp menu_isopen, 0
  280.     jne _end3
  281.     push offset str_opened_menu
  282.     call StdOut
  283.     _end3:
  284.     mov menu_isopen, 1
  285.     push menu_option
  286.     call DrawMenu
  287.     push 1
  288.     call ToggleText
  289.    
  290.     _end2:
  291.     ret
  292. MenuMonitor endp
  293.  
  294. SetMemory proc _address, _length, _input
  295.     push _input
  296.     push _length
  297.     push 0
  298.     push _address
  299.     push 0
  300.     push 0
  301.     push dword ptr game_proc_id
  302.     push 0
  303.     push dword ptr game_target
  304.     call SNPS3ProcessSetMemory
  305.     mov eax, 0
  306.     ret
  307. SetMemory endp
  308.  
  309. GetMemory proc _address, _length
  310.     push offset mem_output
  311.     push _length
  312.     push 0
  313.     push _address
  314.     push 0
  315.     push 0
  316.     push dword ptr game_proc_id
  317.     push 0
  318.     push dword ptr game_target
  319.     call SNPS3ProcessGetMemory
  320.     mov eax, offset mem_output
  321.     ret
  322. GetMemory endp
  323.  
  324. end Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement