Disable Alt+Enter

A Script for disabling Alt+Enter with RPGXP Version 1.02a:
  1. ########################
  2. # Disable Alt+Enter
  3. # Autor Reborn
  4. ########################
  5. module Disable
  6.   PAGE_READWRITE = 0x04
  7.   MoveMemory = Win32API.new('Kernel32.dll', 'RtlMoveMemory', 'ppl', 'v')
  8.   VirtualProtect = Win32API.new('Kernel32.dll', 'VirtualProtect', 'pllp', 'l')
  9.   def self.AltEnter(disable=true)
  10.     if (disable)
  11.       patchAltEnter()
  12.     else
  13.       unpatchAltEnter()
  14.     end
  15.   end
  16.   def self.F1(disable=true)
  17.     if (disable)
  18.       patchF1()
  19.     else
  20.       unpatchF1()
  21.     end
  22.   end
  23.   def self.patchAltEnter()
  24.     # 1 retn and 4 NOPs
  25.     charArr = [0xC3, 0x90, 0x90, 0x90, 0x90].pack('C5')
  26.     # address before full screen call
  27.     address = 0x1008C975
  28.     oldProtection = "xxxx"
  29.     VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
  30.     # place a retn-command before full screen call
  31.     MoveMemory.call(address, charArr, 5)
  32.     VirtualProtect.call(address, 1024, 64, "xxxx")
  33.   end
  34.   def self.unpatchAltEnter()
  35.     # the orginal assemblies
  36.     charArr = [0x66, 0xC7, 0x44, 0x24, 0x3C].pack('C5')
  37.     # address from full screen call
  38.     address = 0x1008C975
  39.     oldProtection = "xxxx"
  40.     VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
  41.     MoveMemory.call(address, charArr, 5)
  42.     VirtualProtect.call(address, 1024, 64, "xxxx")
  43.   end
  44.   def self.patchF1()
  45.     # 6 NOPs
  46.     charArr = [0x90, 0x90, 0x90, 0x90, 0x90, 0x90].pack('C6')
  47.     # address from F1 call
  48.     address = 0x10003A36
  49.     oldProtection = "xxxx"
  50.     VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
  51.     MoveMemory.call(address, charArr, 6)
  52.     VirtualProtect.call(address, 1024, 64, "xxxx")
  53.   end
  54.   def self.unpatchF1()
  55.     # the orginal assemblies
  56.     charArr = [0xFF, 0x15, 0x18, 0x00, 0x0E, 0x10].pack('C6')
  57.     # address from F1 call
  58.     address = 0x10003A36
  59.     oldProtection = "xxxx"
  60.     VirtualProtect.call(address, 1024, PAGE_READWRITE, oldProtection)
  61.     MoveMemory.call(address, charArr, 6)
  62.     VirtualProtect.call(address, 1024, 64, "xxxx")
  63.   end
  64. end
Expand to see the code.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=78588