Jump to content
  • 0

Peek value (direct address)


BoomEX

Question

Hi,

Really enjoying GameGuardian scripting. I have a question however, consider this excerpt:

gg.searchNumber("0D;1350D::5", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0x7A00000000, 0x8A00000000, 0)
local numres = gg.getResultsCount()
if numres > 0 then
	local res = gg.getResults(99)
  	for i=1,numres,2 do
      gg.setValues({
          {
            address=res[i].address+8,
            flags=4,
            value=9999999
          }
        })
    end
end

I am using setValues to write to address + 8.

ideally what i want to do is only write to address + 8 if the current values is non zero, i'm just not sure how to peek the value of address + 8.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

getValues function can be used to get value(s) at specified address(es). However, in this case an optimization can be applied to get required values as a part of the search. The code may then look, for example, like this: 

gg.searchNumber("0;1350;-1~~1::9", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0x7A00000000, 0x8A00000000, 0)
gg.refineNumber("0;1350::5", gg.TYPE_DWORD, false, gg.SIGN_NOT_EQUAL)
local numres = gg.getResultsCount()
if numres > 0 then
  local res = gg.getResults(99)
  for i, v in ipairs(res) do
    v.value = 9999999
  end
  gg.setValues(res)
end

In the initial search string the part "-1~~1" means any value except 0. It represents the target values that needs to be modified according to your condition.

Refine search on the second line is used to remove first two values of each group of values that were found at the previous step from the results list, so that only target values remain there.

The remaining code simply modifies found results (results list at this point consists only of the target values if any were found) to the desired value.

Link to comment
Share on other sites

1 hour ago, CmP said:

getValues function can be used to get value(s) at specified address(es). However, in this case an optimization can be applied to get required values as a part of the search. The code may then look, for example, like this: 


gg.searchNumber("0;1350;-1~~1::9", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0x7A00000000, 0x8A00000000, 0)
gg.refineNumber("0;1350::5", gg.TYPE_DWORD, false, gg.SIGN_NOT_EQUAL)
local numres = gg.getResultsCount()
if numres > 0 then
  local res = gg.getResults(99)
  for i, v in ipairs(res) do
    v.value = 9999999
  end
  gg.setValues(res)
end

In the initial search string the part "-1~~1" means any value except 0. It represents the target values that needs to be modified according to your condition.

Refine search on the second line is used to remove first two values of each group of values that were found at the previous step from the results list, so that only target values remain there.

The remaining code simply modifies found results (results list at this point consists only of the target values if any were found) to the desired value.

Thank you for this thorough and helpful optimisation. My catch is that I want the value at offset+8, would this still be possible via your optimisation? 

Edit: I just sat a re-read the code and realised it will due to the condition being the third parameter.. very clever!

Link to comment
Share on other sites

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.