Jump to content
  • 0

How to get data type in script


HorridModz

Question

Posted

Hi, I'm making a useless value remover script for a game. It's working well, but I have two things I want to add but am having troubles with.

Problem 1 (RESOLVED).

The script is designed only for dword values, so I want it to ignore any values that aren't dword. I don't know how to get data type, though. When I use

gg.alert(tostring(gg.getResults(99999)[1]))

it returns what the first picture attached shows - a table with the address, flags, and value. I notice the flags are 4,-gg,TYPE_DWORD - the gg.TYPE_DWORD is what I want.

However, when I try to index the flags, with this code

gg.alert(gg.getResults(99999)[1].flags)

it only returns the 4 (as seen in image 2). And even if it did, I don't just want the 4, I want the data type only.
 

So how do I get the data type? I was thinking that maybe I could use the first piece of code, and do string comparison to see if it contains "gg.TYPE_DWORD". This way seems slow and inefficient and a pain to code, though - is there a better way?

Problem 2.

My script takes all the values from the current search results, and my goal is for it to replace the search results with the new search results. The original search results would look like image 3. My script then takes the results and puts them into an array called "cleansed", and does some searches to see what is useless and what isn't. There are originally about 1300 results, as shown in picture 3, and I want there to about 650 results, consisting of only useful values, as shown in picture 4. My array "cleansed" looks like image 4, with only about 650 results.

But how do I set the search results cleansed? gg.setValues(cleansed) does not work for me as it is only for setting the values of the current results. I want to change the results.

Is there another way to do this? I had the idea of searching the address of each item, but even this would not work. I want all 650 results at once, in the search results tab.

Using "selected as search result" works. Is there a command for this?

 

Thanks for reading!

Screenshot_20220528-171141.png

Screenshot_20220528-171053.png

Screenshot_20220528-172050.png

Screenshot_20220528-172134.png

6 answers to this question

Recommended Posts

Posted

1. to filter all dword value you can do like this 

local results = gg.getResults(gg.getResultsCount()) 
for index, element in ipairs(results) do
  if (element.flags ~= 4) then results[index] = nil end
end 
print (results) -- onlydword values left

 

Posted
1 minute ago, MAARS said:

1. to filter all dword value you can do like this 

local results = gg.getResults(gg.getResultsCount()) 

for _, element in ipairs(result) do 
  if (element.flags ~= 4) element = nil end
end 

print (result) -- Only dword valuesleft in the 

 

Ohhhhh! 4 is the data type index! I thought it meant something else! TY! I just need the second thing now...

Posted

I dont really understand the second issue: you want to bring the filtered values in the search results list ?

Posted
33 minutes ago, MAARS said:

I dont really understand the second issue: you want to bring the filtered values in the search results list ?

Yes!

27 minutes ago, MAARS said:

Another's question: what do you qualify as useless value so they can be removed

My script sees if a value isn't in the range of encrypted values, isn't a dword, or appears a bunch of times. Here is the script - it just needs the second thing.

function checkbad(val,valueflags)
isgood = 0
isbad = 0
if valueflags == "4" then
isbad = 0
i2 = 0
while i2 < #bad and isbad == 0 do
i2 = i2 + 1
if bad[i2] == val then 
isbad = 1
end
end
isgood = 0
i2 = 0
while i2 < #good and isgood == 0 do
i2 = i2 + 1
if good[i2] == val then 
isgood = 1
end
end
else
isbad = 1
isgood = 0
end
end

function checkuseless(value)
useless = 0
if value < 1000000 or value > 200000000 then
useless = 1
end
end 

function checktrap(value)
temp = useless
checkuseless(value)
if useless == 0 then
trap = 0
region = gg.getValuesRange(t[i]).address
if region == 'Jh' then
gg.setRanges(gg.REGION_JAVA_HEAP)
end
if region == 'A' then
gg.setRanges(gg.REGION_ANONYMOUS)
end
if region == 'As' then
gg.setRanges(gg.REGION_ASHMEM)
end
if region == 'B' then
gg.setRanges(gg.REGION_BAD)
end
if region == 'Ca' then
gg.setRanges(gg.REGION_C_ALLOC)
end
if region == 'Cb' then
gg.setRanges(gg.REGION_C_BSS)
end
if region == 'Cd' then
gg.setRanges(gg.REGION_C_DATA)
end
if region == 'Ch' then
gg.setRanges(gg.REGION_C_HEAP)
end
if region == 'Xa' then
gg.setRanges(gg.REGION_CODE_APP)
end
if region == 'Xs' then
gg.setRanges(gg.REGION_CODE_SYS)
end
if region == 'J' then
gg.setRanges(gg.REGION_JAVA)
end
if region == 'O' then
gg.setRanges(gg.REGION_OTHER)
end
if region == 'Ps' then
gg.setRanges(gg.REGION_PPSSPP)
end
if region == 'S' then
gg.setRanges(gg.REGION_STACK)
end
if region == 'V' then
gg.setRanges(gg.REGION_VIDEO)
end
gg.clearResults()
gg.searchNumber(value,gg.TYPE_DWORD)
if gg.getResultsCount() > 8 then
trap = 1
end
end
useless = temp
end

function selectranges()
regions = gg.multiChoice({"IDK what this means (well, it may take a lot longer but rather be safe than sorry!)","Java and java heap","C data, c alloc, c bsss, and c heap","Anonymous","Stack","Ashmen","Other","Bad","Xa code app","Xa code system"},nil,"Select the memory regions your values are in (usually anonymous and sometimes Xa). You can select multiple, but only select the ones your values are in or it will take longer.")
buildranges = ""
if regions[1] then
buildranges = "gg.REGION_ANONYMOUS | gg.REGION_JAVA_HEAP | gg.REGION_C_DATA | gg.REGION_C_BSS |gg.REGION_JAVA |gg.REGION_STACK | gg.REGION_ASHMEM | gg.REGION_OTHER | gg.REGION_BAD | gg.REGION_CODE_APP | gg.REGION_CODE_SYS"
else
if regions [2] then
buildranges = buildranges .. "gg.REGION_JAVA | gg.REGION_JAVA_HEAP |"
end
if regions [3] then
buildranges = buildranges .. "gg.REGION_C_DATA | gg.REGION_C_BSS | gg.REGION_C_HEAP | gg.REGION_C_ALLOC |"
end
if regions [4] then
buildranges = buildranges .. "gg.REGION_ANONYMOUS |"
end
if regions [5] then
buildranges = buildranges .. "gg.REGION_STACK |"
end
if regions [6] then
buildranges = buildranges .. "gg.REGION_ASHMEM |"
end
if regions [7] then
buildranges = buildranges .. "gg.REGION_OTHER |"
end
if regions [8] then
buildranges = buildranges .. "gg.REGION_BAD |"
end
if regions [9] then
buildranges = buildranges .. "gg.REGION_CODE_APP |"
end
if regions [10] then
buildranges = buildranges .. "gg.REGION_CODE_SYS |"
end
end
gg.setRanges(buildranges)
end

gg.setVisible(false)
menu = gg.multiChoice({"What are trap values?","Remove trap values and / or useless values","Q&A / Troubleshooting","About","How script works","Contact Me","Exit"},nil,"Script and method made by HorridModz(User123456789#6424). This script is ONLY for dword values.")
if menu == nil then
os.exit()
end
if menu[7] then
os.exit()
end
if menu[6] then
print("You can contact me on discord at User123456789#6424. To stay updated about all my scripts, you can follow HorridModz on gameguardian.net.")
gg.setVisible(true)
gg.setVisible(true)
os.exit()
end
if menu[5] then
print("This script has two features: Useless value removal and trap value removal.                                                                                                To remove useless values, it removes every dword value that is not in the range of encrypted values. This feature may not always be 100% accurate, but it should work most of the time.                                                                                                                                                                                                To remove trap values, it uses very simple logic which relies on bad game design (which is why almost all pg3d scripts exist xD). I found out through testing that trap values are placed multiple times in memory. However, real values should only appear once, or rarely a couple times. The script simply searches each values and removes any value that a bunch of results come up for. There may be exceptions, so this method isn't 100% accurate.")
gg.setVisible(true)
os.exit()
end
if menu[4] then
print("One day, I was editing a bunch of values I fuzzy searched to try and find the right value, and I hit a trap value and was banned. That gave me the inspiration to make a trap value detector. This script is pretty simple. It uses a method I came up with myself - see 'How script works' for more.                                                                                          The UI  is heavily inspired by DarkOctet#5778")
gg.setVisible(true)
os.exit()
end
if menu[3] then
print("Q: Why are the time left and percent processed counters so inaccurate?                                                                                                                                                                                          A: The script uses multiple optimizations to run faster. It has to do more work on some values than others. The script may progressively get faster, get stuck for a long time on some areas, or go really fast on some areas because of this. The time left counter expects all values to need to be tested, but sometimes the script already knows a value is not a trap value. The 'Remove Useless Values' option will make the script run so much faster that it may halve the time left counter each second, in some cases!                                                                                                                                                                                                          Q: Why are the time left and percent processed counters so inaccurate / unpredictable?                                                                                                                                                                                          A: The script uses multiple optimizations to run faster. It has to do more work on some values than others. The script may progressively get faster, get stuck for a long time on some areas, or go really fast on some areas because of this.                                                                                                                                                                                                          Q: Why are the time left and percent processed counters so inaccurate?                                                                                                                                                                                          A: The script uses multiple optimizations to run faster. It has to do more work on some values than others. The script may progressively get faster, get stuck for a long time on some areas, or go really fast on some areas because of this.                                                                                                                                                                                                          Q: Why are the time left and percent processed counters so inaccurate?                                                                                                                                                                                          A: The script uses multiple optimizations to run faster. It has to do more work on some values than others. The script may progressively get faster, get stuck for a long time on some areas, or go really fast on some areas because of this.                                                                                                                                                                                      Still have questions or problems? Contact User123456789#6424 on discord!")
gg.setVisible(true)
os.exit()
end
if menu[1] then
print("One of the many ways the developers protect their game from gameguardian hacks is having the game automatically generate 'trap values'. Trap values are values that mimic real values that store game data, but actually instantly ban you when you edit them.")
gg.setVisible(true)
os.exit()
end
toremove = gg.multiChoice({"Remove useless values (recommended, also decreases risk of ban or crash and speeds up script a ton)","Remove trap values"},nil,"Script and method made by HorridModz(User123456789#6424). This script may take a while to finish - each value should take around a third of a second to process, depending on device.                                                                                                                                                                                       DISCLAIMER: This script may NOT be 100% accurate! Edit values at your own risk - bans still have the possibility to occur, whether by editing trap values or for other reasons .")
lasttoast = 0
progress =  "Initializing"
gg.toast(progress)
start = os.time()
t = gg.getResults(999999)
cleansed = {}
resultstoremove = {}
bad = {}
good = {}
if toremove == nil then
else
gg.setRanges(gg.REGION_ANONYMOUS | gg.REGION_JAVA_HEAP | gg.REGION_C_DATA | gg.REGION_C_BSS |gg.REGION_JAVA |gg.REGION_STACK | gg.REGION_ASHMEM| gg.REGION_OTHER | gg.REGION_BAD | gg.REGION_CODE_APP | gg.REGION_CODE_SYS)
i = 0
while i < #t do
i = i + 1
useless = 0
trap = 0
isbad = 0
isgood = 0
if isgood == 0 then
checkbad(t[i].value,t[i].flags)
if isbad == 0 and toremove[1] then
checkuseless(t[i].value)
end
if isbad == 0 and useless == 0 and toremove[2] then
checktrap(t[i].value)
end
end
if useless + trap + isbad > 0 then
resultstoremove[#resultstoremove + 1] = t[i]
if isbad == 0 then
bad[#bad + 1] = t[i].value
end
else
t[i].name = "Value from trap value remover script"
cleansed[#cleansed + 1] = t[i]
good[#good + 1] = t[i].value
end
if os.time() - lasttoast > 1 then
timeleft = #t - i
timeleft = timeleft / 5
percentdone = i * 10000
percentdone = percentdone / #t
percentdone = percentdone / 100
progress = tostring(i) .. "/" .. #t .. " Values processed, " .. tostring(percentdone) .. "% done processing                                                                   Estimated time left: " .. tostring(timeleft) .. " seconds."   
gg.toast(progress)
lasttoast = os.time()
end
gg.setVisible(false)
end
end
gg.setVisible(false)
gg.clearResults()
gg.addListItems(cleansed)
time = os.time() - start
progress = "Done!"
gg.toast(progress)
print("Script successfully executed! Values are in the saved list!")
print("                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Summary:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Values processed: " .. tostring(#t) .. ".                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Values saved: " .. tostring(#cleansed).. ".                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Values removed: " .. tostring(#t - #cleansed) .. ".                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Time taken: " .. tostring(time) .. " seconds.                                                                                                                                                                                                                                                                                                                                                                            I hope you enjoyed using my script! You can contact me at User123456789#6424.                                                                                                                                                                                       DISCLAIMER: This script may NOT be 100% accurate! Edit values at your own risk - bans still have the possibility to occur, whether by editing trap values or for other reasons .")
gg.setVisible(true)



 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.