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
  
-- Default offsets
--local defaultOffsets = {0x10, 0x20, 0x30}  -- 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], "%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")

-- 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
    
    -- 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