赞 | 40 |
VIP | 0 |
好人卡 | 72 |
积分 | 63 |
经验 | 38967 |
最后登录 | 2024-11-5 |
在线时间 | 1481 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6260
- 在线时间
- 1481 小时
- 注册时间
- 2015-7-25
- 帖子
- 652
|
先用黄鸡的脚本模板然后拿过来改一改
不过注意1点:
选择取消的时候(不退出游戏)你自己写,我这里只是强行来了遍rgss_main { SceneManager.run }而已(对这些不怎么了解所以这是目前想到的唯一方法,所以我只能改到这了)
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
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
|
|