A Script for disabling Alt+Enter with RPGXP Version 1.02a:
Code:
########################
# Disable Alt+Enter
# Autor Reborn
########################
module Disable
PAGE_READWRITE = 0x04
MoveMemory = Win32API.new('Kernel32.dll', 'RtlMoveMemory', 'ppl', 'v')
VirtualProtect = Win32API.new('Kernel32.dll', 'VirtualProtect', 'pllp', 'l')
def self.AltEnter(disable=true)
if (disable)
patchAltEnter()
else
unpatchAltEnter()
end
end
def self.F1(disable=true)
if (disable)
patchF1()
else
unpatchF1()
end
end
def self.patchAltEnter()
# 1 retn and 4 NOPs
charArr = [0xC3, 0x90, 0x90, 0x90, 0x90].pack('C5')
# address before full screen call
address = 0x1008C975
oldProtection = "xxxx"
VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
# place a retn-command before full screen call
MoveMemory.call(address, charArr, 5)
VirtualProtect.call(address, 1024, 64, "xxxx")
end
def self.unpatchAltEnter()
# the orginal assemblies
charArr = [0x66, 0xC7, 0x44, 0x24, 0x3C].pack('C5')
# address from full screen call
address = 0x1008C975
oldProtection = "xxxx"
VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
MoveMemory.call(address, charArr, 5)
VirtualProtect.call(address, 1024, 64, "xxxx")
end
def self.patchF1()
# 6 NOPs
charArr = [0x90, 0x90, 0x90, 0x90, 0x90, 0x90].pack('C6')
# address from F1 call
address = 0x10003A36
oldProtection = "xxxx"
VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
MoveMemory.call(address, charArr, 6)
VirtualProtect.call(address, 1024, 64, "xxxx")
end
def self.unpatchF1()
# the orginal assemblies
charArr = [0xFF, 0x15, 0x18, 0x00, 0x0E, 0x10].pack('C6')
# address from F1 call
address = 0x10003A36
oldProtection = "xxxx"
VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
MoveMemory.call(address, charArr, 6)
VirtualProtect.call(address, 1024, 64, "xxxx")
end
end