Project1
标题:
有关屏蔽F12重启问题
[打印本页]
作者:
张咚咚
时间:
2017-7-11 22:08
标题:
有关屏蔽F12重启问题
搜了一下论坛,好像没发现有关VX屏蔽F12的资料。。
求屏蔽F12的方法,或者exe、dll
作者:
Password
时间:
2017-7-11 22:43
https://rpg.blue/forum.php?mod=viewthread&tid=393909
——来自水区某触手的黑科技
只弄F12的话这么设置脚本,插入到Main前。
unless defined?(KeyFusion)
#--------------------------------------------------------------------------
# ● 紫苏前辈的获取窗口句柄
# 部分细节已修改
#--------------------------------------------------------------------------
module Kernel
#--------------------------------------------------------------------------
# ● 需要的 Windows API 函数
#--------------------------------------------------------------------------
GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L")
GetWindow = Win32API.new("user32", "GetWindow", "LL", "L")
GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L")
GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L")
GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L")
#--------------------------------------------------------------------------
# ● 获取窗口句柄
#--------------------------------------------------------------------------
def hwnd
# 获取调用线程(RM 的主线程)的进程标识
threadID = GetCurrentThreadId.call
# 获取 Z 次序中最靠前的窗口
hWnd = GetWindow.call(GetForegroundWindow.call, 0)
# 枚举所有窗口
while hWnd != 0
# 如果创建该窗口的线程标识匹配本线程标识
if threadID == GetWindowThreadProcessId.call(hWnd, 0)
# 分配一个 11 个字节的缓冲区
className = " " * 12 # ●
# 获取该窗口的类名
GetClassName.call(hWnd, className, 12) # ●
# 如果匹配 RGSS Player 则跳出循环
break if className[0, 11] == "RGSS Player"
end
# 获取下一个窗口
hWnd = GetWindow.call(hWnd, 2)
end
return hWnd
end
end
#--------------------------------------------------------------------------
# ● KeyFusion主要模块
# 晴兰,保留所有权利
#--------------------------------------------------------------------------
module KeyFusion
module SAFX
extend self
private
def defapi(a, b)
a, b = a.to_s, b.to_s
define_method b do |*args|
Win32API.new(a, b, args.map{"L"}, "L").call(*args.map{|x| ptr(x)})
end
private b
end
def ptr(a)
case a
when Integer then a
when String then [a].pack("p").unpack("L").first
end
end
{
:Kernel32 => %w{RtlMoveMemory LoadLibrary GetProcAddress VirtualProtect GlobalAlloc GlobalFree},
:User32 => %w{SendMessage}
}.each{|k, v|
v.each{|x|
defapi k, x
}
}
def readmem(a, b)
buf = "\0" * b
RtlMoveMemory buf, ptr(a), b
buf
end
def writemem(a, b, c)
RtlMoveMemory ptr(a), c, b
end
def funcaddr(a, b)
GetProcAddress(LoadLibrary(a + "\0"), b + "\0")
end
def malloc(n)
GlobalAlloc 0, n
end
def free(ptr)
GlobalFree ptr
end
def sendMsg(h, m, w, l)
SendMessage h, m, w, l
end
def code(*c)
c.inject([]){|a, b|
b.to_s(16)
if b >= -256 && b <= 256
a + [b % 256]
else
a + [b].pack("L").unpack("C*")
end
}.pack("C*")
end
def getpriv(addr, len)
VirtualProtect addr, len, 0x40, "RGBA"
end
class FuncHook
include SAFX
def initialize(addr)
@codeaddr = malloc 10
@old = addr
@tramp = code 0x55, 0x8b, 0xec, 0xe9, (@old + 5) - (@codeaddr + 8)
writemem @codeaddr, @tramp.length, @tramp
@newcode = yield @codeaddr
@newaddr = ptr(@newcode)
getpriv addr, 5
writemem addr, 5, code(0xe9, (@newaddr - (@old + 5)))
end
end
class MsgHook
include SAFX
extend SAFX
defapi 'user32', 'SetWindowsHookEx'
defapi 'kernel32', 'GetCurrentThreadId'
defapi 'user32', 'GetWindowLong'
defapi 'user32', 'SetWindowLong'
WH_GETMESSAGE = 3
def initialize
thehwnd = hwnd
u = funcaddr 'user32', 'CallWindowProcA'
@old = GetWindowLong thehwnd, -4
[url=home.php?mod=space&uid=10413]@code[/url] = yield @old, u
SetWindowLong thehwnd, -4, @code
end
end
end
extend SAFX
KEY_ENABLE = 0
KEY_DISABLE = 1
KEY_PRESSONCE_ENABLE = 2
KEY_PRESSONCE_DISABLE = 3
KEY_PRESSALWAYS = 4
KeyTable = malloc 256
writemem KeyTable, 256, "\0"*256
GKS = funcaddr('user32', 'GetKeyState')
KeyHook = SAFX::FuncHook.new(GKS) do |origin|
code 0x55, 0x8b, 0xec,
0xba, KeyTable,
0x8b, 0105, 0x8,
0x33, 0311,
0x8a, 0014, 0002,
0x83, 0371, KEY_PRESSALWAYS, 0x75, 9, 0xb8, 0x8000, 0xc9, 0xc2, 0x4, 0x00,
0x83, 0371, KEY_DISABLE, 0x75, 6, 0x31, 0xc0, 0xc9, 0xc2, 0x4, 0x00,
0x83, 0371, KEY_ENABLE, 0x75, 14, 0xff, 0165, 0x8, 0xb8, origin, 0xff, 0320, 0xc9, 0xc2, 0x4, 0x00,
0x83, 0371, KEY_PRESSONCE_ENABLE,
0x75, 16, 0xc7, 0004, 0002, 0,0,0,0, 0xb8, 0x8000, 0xc9,0xc2,0x4, 0x00,
0x83, 0371, KEY_PRESSONCE_DISABLE,
0x75, 16, 0xc7, 0004, 0002, 1,0,0,0, 0xb8, 0x8000, 0xc9,0xc2,0x4, 0x00,
0x33, 0300, 0xc9,0xc2, 0x4, 0x00
end
GAKS = funcaddr('user32', 'GetAsyncKeyState')
AKeyHook = SAFX::FuncHook.new(GAKS) do |origin|
code 0x55, 0x8b, 0xec,
0xba, KeyTable,
0x8b, 0105, 0x8,
0x33, 0311,
0x8a, 0014, 0002,
0x83, 0371, KEY_PRESSALWAYS, 0x75, 9, 0xb8, 0x8000, 0xc9, 0xc2, 0x4, 0x00,
0x83, 0371, KEY_DISABLE, 0x75, 6, 0x31, 0xc0, 0xc9, 0xc2, 0x4, 0x00,
0x83, 0371, KEY_ENABLE, 0x75, 14, 0xff, 0165, 0x8, 0xb8, origin, 0xff, 0320, 0xc9, 0xc2, 0x4, 0x00,
0x83, 0371, KEY_PRESSONCE_ENABLE,
0x75, 16, 0xc7, 0004, 0002, 0,0,0,0, 0xb8, 0x8000, 0xc9,0xc2,0x4, 0x00,
0x83, 0371, KEY_PRESSONCE_DISABLE,
0x75, 16, 0xc7, 0004, 0002, 1,0,0,0, 0xb8, 0x8000, 0xc9,0xc2,0x4, 0x00,
0x33, 0300, 0xc9,0xc2, 0x4, 0x00
end
KEY_LOCKWINDOW_NOLOCK = 0
KEY_LOCKWINDOW_LOCK = 1
LOCKWINDOW = malloc 16
writemem LOCKWINDOW, 16, "\0"*16
ProcHook = SAFX::MsgHook.new do |origin, callproc|
code(0x55, 0x8b, 0xec,
0x8b, 0105, 12,
0xba, LOCKWINDOW,
0x33, 0311,
0x8a, 0012,
0x83, 0371, KEY_LOCKWINDOW_NOLOCK,
0x74, 14,
0x81, 0370, 0x111,
0x75, 6,
0x33, 0300, 0xc9, 0xc2, 0x10, 0x00,
0xff, 0165, 20,
0xff, 0165, 16,
0xff, 0165, 12,
0xff, 0165, 8,
0x68, origin,
0xb8, callproc,
0xff, 0320,
0xc9, 0xc2, 0x10, 0x00)
end
def self.setState(key, state)
writemem KeyTable + key, 1, [state].pack("C")
end
def self.getState(key)
readmem(KeyTable + key, 1).unpack("C").first
end
def self.lockWindow(opt)
if opt
writemem LOCKWINDOW, 1, [KEY_LOCKWINDOW_LOCK].pack("C")
else
writemem LOCKWINDOW, 1, [KEY_LOCKWINDOW_NOLOCK].pack("C")
end
end
VK_F12 = 0x7B
def self.reset
r = getState VK_F12
case r
when KEY_ENABLE
KeyFusion.setState VK_F12, KEY_PRESSONCE_ENABLE
when KEY_DISABLE
KeyFusion.setState VK_F12, KEY_PRESSONCE_DISABLE
end
end
def self.toggleFullScreen
sendMsg hwnd, 0x111, 40002, 1
sendMsg hwnd, 0x111, 0x7d3, 0
end
end
end
VK_F12 = 0x7B
KeyFusion.setState VK_F12, KeyFusion::KEY_DISABLE #禁止对F12的处理
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1