module MFXRB MessageBoxW = Win32API.new('user32', 'MessageBoxW', 'lppl', 'l') def self.callMessageBoxW(hint, title, icon, button,hWnd = 0) MessageBoxW.call(hWnd, hint.u2w, title.u2w, icon | button) end end class String def w2u self.unpack("S*").pack("U*").sub(/\0+$/, '') end def u2w self.unpack("U*").pack("S*") + "\0\0" end def f_e self.force_encoding(__ENCODING__) end def byte_length ret = 0 self.each_byte{ret+=1} ret end def address [self].pack("p").unpack("L")[0] end end module Fux2 module Win32Tools RtlMoveMemoryLP = Win32API.new('kernel32','RtlMoveMemory','lpl','l') RtlMoveMemoryPL = Win32API.new('kernel32','RtlMoveMemory','pll','l') GetModuleHandle = Win32API.new('kernel32','GetModuleHandle','p','l') VirtualProtect = Win32API.new('kernel32','VirtualProtect','lllp','l') def self.readmem(buf,addr,len) RtlMoveMemoryPL.call(buf,addr,len) end def self.writemem(addr,buf,len) RtlMoveMemoryLP.call(addr,buf,len) end def self.unprotect(addr,len) VirtualProtect.call(addr,len,0x40,"\0"*4) end def self.init @@hModule = GetModuleHandle.call("RGSS300.dll") end def self.module_handle @@hModule end init end module Exit_Hook @@hwnd = 0 Addr_Close_Catch = Win32Tools.module_handle+0x17F396 Addr_Eval = Win32Tools.module_handle+0xC580 Addr_Hwnd = Win32Tools.module_handle+0x25EB00 Code_Close_Catch = "\x90"*23 Str_Close_Catch = "Fux2::Exit_Hook.exit_func" def self.unprotectfunc(func) Fux2::Win32Tools.unprotect(func.address,func.byte_length) end def self.unprotect_all unprotectfunc(Code_Close_Catch) end def self.hook_exit cad = Code_Close_Catch.address cal = Code_Close_Catch.byte_length rem = "\0"*5 Fux2::Win32Tools.readmem(rem,Addr_Close_Catch,5) rem = rem.unpack("C*") retn_addr = Addr_Close_Catch+5-cad-cal hook_addr = cad-Addr_Close_Catch-5 Fux2::Win32Tools.writemem(Addr_Close_Catch,[0xE9,hook_addr].pack("CL"),5) eval_addr = Addr_Eval-cad-10 hook_code = [0x68,Str_Close_Catch.address,0xE8,eval_addr,0x83,0xC4,0x4,*rem,0xE9,retn_addr].pack("CLCLCCCCCCCCCL") Fux2::Win32Tools.writemem(cad,hook_code,cal) end def self.get_hwnd rem = "\0"*4 Fux2::Win32Tools.readmem(rem,Addr_Hwnd,4) base_addr = rem.unpack("L")[0] Fux2::Win32Tools.readmem(rem,base_addr+8,4) @@hwnd = rem.unpack("L")[0] end def self.hwnd @@hwnd end def self.exit_func if MFXRB.callMessageBoxW("确定关闭游戏吗?","",32,1) == 1 exit else DataManager.save_game(0) rgss_main { SceneManager.run } end end hook_exit end end
guoxiaomi 发表于 2017-10-25 09:12
alias _old_exit exit
def exit
...
翠靈月 发表于 2017-10-25 19:03
虽然我知道应该还要再加些其他代码,不过能力不足就先直接添加了
添加后达成了不退出并进行游戏的目的
但 ...
Lemax 发表于 2017-10-26 17:34
没事的,怎么样都行,我也可以学习一下。
1.52 MB, 下载次数: 71
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |