local libsFinder = embedLibsFinder()
local targetLibName = "libil2cpp.so"
local libStartAddress = libsFinder.getEmbedLibAddress(targetLibName)
if libStartAddress == nil then
print(string.format(""%s" hasn't been found among libraries loaded directly from apk", targetLibName))
else
-- Create a list item to store the address
local listItem = {
address = libStartAddress,
flags = gg.TYPE_DWORD, -- or another appropriate type
name = targetLibName
}
-- Add the list item to GameGuardian's list
gg.addListItems({listItem})
-- Print the address in hexadecimal format
print(string.format("0x%X", libStartAddress))
end
-- Execute the main function
local libsFinder = embedLibsFinder()
local targetLibName = "libil2cpp.so"
local libStartAddress = libsFinder.getEmbedLibAddress(targetLibName)
if libStartAddress == nil then
print(string.format(""%s" hasn't been found among libraries loaded directly from apk", targetLibName))
else
-- Create a list item to store the address
local listItem = {
address = libStartAddress,
flags = gg.TYPE_DWORD, -- or another appropriate type
name = targetLibName
}
-- Add the list item to GameGuardian's list
gg.addListItems({listItem})
-- Print the address in hexadecimal format
print(string.format("0x%X", libStartAddress))
-- Define the offsets you want to add to the base address
--local offsets = {0x2372D10, 0x2372718, 0x236FBE4, 0x236FB28, 0x3B32D40,0x3B32AF4, 0x45CBCF4,0x45C885C,0x45CB918,0x45CBE94,0x45CC944} -- Replace these with your actual offsets
local defaultOffsets = {0x3F671F4}
-- Replace these with your actual offsets
-- Prompt the user to choose whether to enter custom offsets
local offsetChoice = gg.choice({"Enter Custom Offsets", "Use Default Offsets"}, nil, "Choose offset option")
-- Determine the offsets based on user selection
local offsets
if offsetChoice == 1 then
-- Prompt the user to enter custom offsets as a comma-separated string
local userOffsets = gg.prompt({"Enter custom offsets (comma-separated, in hex, non-zero):"}, nil, {"text"})
if userOffsets and userOffsets[1] then
-- Convert the comma-separated string to a table of numbers, ensuring no zero offsets
offsets = {}
for offset in string.gmatch(userOffsets[1], "%s*(%x+)%s*") do
local numericOffset = tonumber(offset, 16)
if numericOffset > 0 then
table.insert(offsets, numericOffset)
else
print("Offset of 0x0 is not allowed to prevent modifying the start address.")
end
end
if #offsets == 0 then
print("No valid offsets entered. Exiting script.")
return
end
else
print("No valid offsets entered. Exiting script.")
return
end
elseif offsetChoice == 2 then
offsets = defaultOffsets
else
print("No valid selection made. Exiting script.")
return
end
-- Prompt the user to select the data type for the value
local dataTypeChoice = gg.choice({"Integer", "Float"}, nil, "Choose the data type for the value")
Assistant
-- Prompt the user to enter the value
local userValue = gg.prompt({"Enter the value:"}, nil, {"number"})
-- Determine the flags based on the user's choice
local dataTypeFlag
if dataTypeChoice == 1 then
dataTypeFlag = gg.TYPE_DWORD -- Integer
elseif dataTypeChoice == 2 then
dataTypeFlag = gg.TYPE_FLOAT -- Float
else
print("No valid selection made. Exiting script.")
return
end
-- Ensure libStartAddress is correctly set to the start of the library
-- Example: local libStartAddress = 0x10000000 -- Replace with the actual start address
for _, offset in ipairs(offsets) do
-- Calculate the target address by adding the offset to the base address
local targetAddress = libStartAddress + offset
code
-- Edit the memory at the target address, target address + 0x4, and target address + 0x8
gg.setValues({
{
address = targetAddress,
flags = gg.TYPE_DWORD,
value = "~A8 LDR X0, [PC,#0x8]" -- Set LDR instruction
},
{
address = targetAddress + 0x4,
flags = gg.TYPE_DWORD,
value = "~A8 RET" -- Set RET instruction
},
{
address = targetAddress + 0x8,
flags = dataTypeFlag, -- Use the selected data type
value = userValue[1] -- Use the user-provided value
}
})
-- Print the modified addresses and values
print(string.format("Modified address 0x%X with value ~A8 LDR X0, [PC,#0x8], 0x%X with value ~A8 RET, and 0x%X with user value %s", targetAddress, targetAddress + 0x4, targetAddress + 0x8, tostring(userValue[1])))
end
end. Modify this script for more advanced arm instructions and hex patching where user can hijack parameters in float and int and bool. Use your best logic
Certainly! Below is an enhanced version of your GameGuardian Lua script that incorporates more advanced ARM instructions, hex patching capabilities, and the ability to hijack parameters for different data types (integer, float, and boolean). The script is organized for better readability and functionality, ensuring users have greater control and flexibility when modifying game memory.
Enhanced GameGuardian Script with Advanced ARM Instructions and Hex Patching
lua
--[[
Enhanced GameGuardian Script
Features:
- Locate target library and base address
- Choose between default and custom offsets
- Select data type (Integer, Float, Boolean)
- Enter value based on selected data type
- Apply advanced ARM instructions or arbitrary hex patches
- Hijack function parameters by modifying memory at specified addresses
--]]
-- Ensure the script is running
if gg.isVisible(true) then
gg.setVisible(false)
end
-- Initialize libraries finder
local libsFinder = embedLibsFinder()
local targetLibName = "libil2cpp.so"
local libStartAddress = libsFinder.getEmbedLibAddress(targetLibName)
-- Function to exit the script gracefully
local function exitScript()
print("Exiting script.")
return
end
-- Check if the target library was found
if libStartAddress == nil then
print(string.format("\"%s\" hasn't been found among libraries loaded directly from apk", targetLibName))
exitScript()
end
-- Create a list item to store the address
local listItem = {
address = libStartAddress,
flags = gg.TYPE_DWORD, -- or another appropriate type
name = targetLibName
}
-- Add the list item to GameGuardian's list
gg.addListItems({listItem})
-- Print the base address in hexadecimal format
print(string.format("Base address of \"%s\": 0x%X", targetLibName, libStartAddress))
-- Define default offsets (add your actual offsets here)
local defaultOffsets = {0x3F671F4} -- Example default offsets
-- Prompt the user to choose whether to enter custom offsets
local offsetChoice = gg.choice({"Enter Custom Offsets", "Use Default Offsets"}, nil, "Choose offset option")
-- Determine the offsets based on user selection
local offsets
if offsetChoice == 1 then
-- Prompt the user to enter custom offsets as a comma-separated string
local userOffsets = gg.prompt({"Enter custom offsets (comma-separated, in hex, non-zero):"}, nil, {"text"})
if userOffsets and userOffsets[1] then
-- Convert the comma-separated string to a table of numbers, ensuring no zero offsets
offsets = {}
for offset in string.gmatch(userOffsets[1], "0x%x+|x%x+") do -- Support hex prefixes
local numericOffset = tonumber(offset, 16)
if numericOffset and numericOffset > 0 then
table.insert(offsets, numericOffset)
else
print("Invalid or zero offset detected and skipped: " .. tostring(offset))
end
end
if #offsets == 0 then
print("No valid offsets entered. Exiting script.")
exitScript()
end
else
print("No offsets entered. Exiting script.")
exitScript()
end
elseif offsetChoice == 2 then
offsets = defaultOffsets
else
print("No valid selection made. Exiting script.")
exitScript()
end
-- Prompt the user to select the data type for the value
local dataTypeChoice = gg.choice({"Integer", "Float", "Boolean", "Hexadecimal Bytes"}, nil, "Choose the data type for the value")
-- Function to validate and retrieve user input based on data type
local function getUserValue(choice)
if choice == 1 then
local input = gg.prompt({"Enter the integer value:"}, nil, {"number"})
if input and input[1] then
return {flag = gg.TYPE_DWORD, value = tonumber(input[1])}
end
elseif choice == 2 then
local input = gg.prompt({"Enter the float value:"}, nil, {"number"})
if input and input[1] then
return {flag = gg.TYPE_FLOAT, value = tonumber(input[1])}
end
elseif choice == 3 then
local input = gg.prompt({"Enter the boolean value (true/false):"}, nil, {"text"})
if input and input[1] then
local boolVal = string.lower(input[1])
if boolVal == "true" then
return {flag = gg.TYPE_BYTE, value = 1}
elseif boolVal == "false" then
return {flag = gg.TYPE_BYTE, value = 0}
else
print("Invalid boolean value. Please enter 'true' or 'false'.")
end
end
elseif choice == 4 then
local input = gg.prompt({"Enter the hex bytes (e.g., DE AD BE EF):"}, nil, {"text"})
if input and input[1] then
-- Convert hex string to number table
local bytes = {}
for byte in string.gmatch(input[1], "%x%x") do
table.insert(bytes, tonumber(byte, 16))
end
if #bytes > 0 then
return {flag = gg.TYPE_BYTE, value = bytes}
end
end
end
return nil
end
-- Retrieve the user value based on selected data type
local userValue = getUserValue(dataTypeChoice)
if not userValue then
print("Invalid or no value entered. Exiting script.")
exitScript()
end
-- Option to apply advanced ARM instructions or hex patch
local patchChoice = gg.choice(
{"Apply Data Patch", "Apply ARM Instruction Patch", "Exit"},
nil,
"Choose patch type"
)
if patchChoice == 1 then
-- Data Patch selected
for _, offset in ipairs(offsets) do
local targetAddress = libStartAddress + offset
-- Prepare the value based on data type
local patchItem = {
address = targetAddress,
flags = userValue.flag,
value = userValue.value
}
gg.setValues({patchItem})
print(string.format("Patched address 0x%X with value %s", targetAddress, tostring(userValue.value)))
end
elseif patchChoice == 2 then
-- ARM Instruction Patch selected
for _, offset in ipairs(offsets) do
local targetAddress = libStartAddress + offset
-- Prompt the user to enter ARM instructions or hex bytes
local armInput = gg.prompt({"Enter ARM instructions or hex bytes (e.g., 'RET' or '1F 20 03 D5'):"}, nil, {"text"})
if armInput and armInput[1] then
local instructions = armInput[1]
local bytes = {}
for byte in string.gmatch(instructions, "%x%x") do
table.insert(bytes, tonumber(byte, 16))
end
if #bytes > 0 then
local instrItem = {
address = targetAddress,
flags = gg.TYPE_BYTE,
value = bytes
}
gg.setValues({instrItem})
print(string.format("Patched address 0x%X with ARM instructions: %s", targetAddress, instructions))
else
-- Handle mnemonic instructions by mapping to hex
local instrMap = {
RET = {0xC0, 0x03, 0x5F, 0xD6}, -- Example encoding for RET (actual encoding may vary)
NOP = {0x00, 0x00, 0x80, 0x52}, -- Example encoding for NOP
-- Add more instruction mappings as needed
}
local mappedInstr = instrMap[string.upper(instructions)]
if mappedInstr then
local instrItem = {
address = targetAddress,
flags = gg.TYPE_BYTE,
value = mappedInstr
}
gg.setValues({instrItem})
print(string.format("Patched address 0x%X with ARM instruction: %s", targetAddress, instructions))
else
print("Unsupported instruction or invalid format.")
end
end
else
print("No ARM instructions entered for address 0x%X. Skipping.", targetAddress)
end
end
elseif patchChoice == 3 then
print("Exiting script.")
exitScript()
else
print("Invalid patch choice. Exiting script.")
exitScript()
end
-- Optional: Function to hijack parameters (example implementation)
local function hijackParameters()
local hijackChoice = gg.choice({"Hijack Function Parameters", "Cancel"}, nil, "Choose an action")
if hijackChoice == 1 then
-- Prompt user to enter the target address and new parameter values
local hijackInputs = gg.prompt({
"Enter target address (hex):",
"Enter new parameter value (integer):",
"Enter new parameter value (float):",
"Enter new parameter value (boolean) (true/false):"
}, nil, {"text", "number", "number", "text"})
if hijackInputs then
local targetAddr = tonumber(hijackInputs[1], 16)
local intVal = tonumber(hijackInputs[2])
local floatVal = tonumber(hijackInputs[3])
local boolVal = string.lower(hijackInputs[4])
-- Prepare the values based on input
local hijackItems = {}
if intVal then
table.insert(hijackItems, {address = targetAddr, flags = gg.TYPE_DWORD, value = intVal})
end
if floatVal then
table.insert(hijackItems, {address = targetAddr + 0x4, flags = gg.TYPE_FLOAT, value = floatVal})
end
if boolVal == "true" then
table.insert(hijackItems, {address = targetAddr + 0x8, flags = gg.TYPE_BYTE, value = 1})
elseif boolVal == "false" then
table.insert(hijackItems, {address = targetAddr + 0x8, flags = gg.TYPE_BYTE, value = 0})
end
if #hijackItems > 0 then
gg.setValues(hijackItems)
print(string.format("Hijacked parameters at address 0x%X.", targetAddr))
else
print("No valid values entered for hijacking.")
end
else
print("No hijack inputs provided.")
end
elseif hijackChoice == 2 then
print("Cancelled hijack operation.")
else
print("Invalid choice. Returning to main script.")
end
end
-- Offer the user to hijack parameters after patching
hijackParameters()
print("Script execution completed.")
Key Enhancements and Features
Single Initialization Block: Removed the duplicated code blocks to streamline the script, ensuring that the library is found and its base address is determined only once.
Expanded Data Type Support:
Boolean: Users can now choose to patch boolean values (true or false), which are represented as bytes (0x01 for true, 0x00 for false).
Hexadecimal Bytes: Users can enter arbitrary hex bytes for more precise hex patching needs.
Advanced ARM Instruction Patching:
Instruction Mapping: The script includes a mapping for common ARM instructions (e.g., RET, NOP). Users can enter mnemonic instructions, and the script will convert them to their corresponding hex byte representations.
Arbitrary Hex Patching: Users can input raw hex bytes if they prefer to manually specify the instructions or data.
Parameter Hijacking Functionality:
Hijack Function Parameters: An optional feature allows users to hijack function parameters by directly modifying memory at specified addresses with new integer, float, or boolean values.
Flexible Input: Users provide the target address and the new values, and the script applies these changes accordingly.
User-Friendly Prompts and Validation:
Input Validation: The script includes checks to ensure that user inputs are valid, preventing errors such as zero offsets or invalid data types.
Graceful Exits: If the user provides invalid inputs or makes an unsupported selection, the script exits gracefully with appropriate messages.
Commenting and Documentation:
Clear comments are added throughout the script to explain each section and its purpose, making it easier for users to understand and modify the script as needed.
Usage Instructions
Run the Script: Execute the script in GameGuardian while the target application is running.
Select Offset Option:
Enter Custom Offsets: Input your desired offsets in hexadecimal format, separated by commas (e.g., 0x1A2B3C, 0x4D5E6F).
Use Default Offsets: Use the predefined default offsets specified in the defaultOffsets table.
Select Data Type:
Choose among Integer, Float, Boolean, or Hexadecimal Bytes based on the value you wish to patch.
Enter Value:
Input the value corresponding to the selected data type.
For Hexadecimal Bytes, enter the bytes separated by spaces (e.g., DE AD BE EF).
Choose Patch Type:
Apply Data Patch: Directly patch the memory with the specified value.
Apply ARM Instruction Patch: Enter ARM instructions by mnemonic or raw hex bytes to replace existing instructions.
Exit: Terminate the script.
Optional Parameter Hijacking:
After patching, you can choose to hijack function parameters by specifying the target address and new values.
Completion: The script will display confirmation messages for each action taken and notify you upon completion.
Notes and Recommendations
Understand the Changes: Ensure you have a good understanding of the memory addresses and the implications of the patches you apply. Incorrect modifications can lead to application instability or crashes.
Backup Original Values: Before applying patches, consider documenting or backing up the original memory values to revert changes if needed.
Expand Instruction Mapping: The provided instruction mappings (RET, NOP) are examples. You can expand the instrMap table with additional ARM instructions as needed.
Security and Compliance: Ensure that modifying game memory complies with the game's terms of service and applicable laws. Unauthorized modifications can result in bans or legal consequences.
By implementing these enhancements, the script becomes a more powerful tool for memory editing, providing users with greater control and flexibility while maintaining safety and usability.