Jump to content

CmP

Contributor
  • Posts

    640
  • Joined

  • Last visited

  • Days Won

    43

Posts posted by CmP

  1. local POINTER_TAG = 0xB4 << 56
    
    local function addTag(pointer)
      return pointer | POINTER_TAG
    end
    
    gg.clearResults()
    gg.searchNumber("123456789", gg.TYPE_DWORD)
    local results = gg.getResults(1)
    local address = results[1].address - 0x8 -- applying the offset
    local taggedAddress = addTag(address)
    gg.clearResults()
    gg.searchNumber(taggedAddress, gg.TYPE_QWORD)
  2. No, Google translate works fine, you just haven't specified what you need to implement in script. You just mentioned: 

    6 minutes ago, toanpham6001 said:

    my value is "123" and offset is 0x10

    but you haven't specified what script needs to do. Search for "123"? Then apply offset? How is this related to tagged pointers?

    Again, either describe what script needs to implement with text or show it with video.

  3. 6 minutes ago, toanpham6001 said:

    how would i script it?

    Script what? Where is description of what needs to be implemented? Is it searching, is it editing, is it something else? If describing with text is too hard, at least show what script needs to do with a video.

  4. This is tagged pointer. There is no problem with it. You misunderstood the post from other topic, you shouldn't edit top byte of the pointer. You only need to remove it for navigating to the address in memory editor tab. For example, value of the pointer at address 0x754799F000 from the video is 0xB4000076B220F9F0, remove "B4" from it and leading zeros to get pointed address 0x76B220F9F0, then go to this address in memory editor tab and region label will be shown.

  5. 2 minutes ago, toanpham6001 said:

    my top byte is already 0 what should i do?

    Since you have already created separate topic for your question, provide the details there. Include region log, address of the value and the value itself.

  6. Lua also allows to implement custom iterators to be used with generic "for", so one can implement traversal from 0 that way and use it like ipairs/pairs functions: 

    -- Modified function from http://lua-users.org/wiki/IteratorsTutorial
    function ipairs0(t)
      local function iterator(t, i)
        i = i + 1
        local v = t[i]
        if v ~= nil then
          return i, v
        else
          return nil
        end
      end
      return iterator, t, -1
    end
    
    -- Usage example
    for i, v in ipairs0(t) do
      print(string.format("[%d] = %s", i, v))
    end
  7. 17 minutes ago, nok1a said:

    Could you perhaps provide an example function for print table starting at index zero*?

    It's not more complicated than to print table elements starting from key 1. Looks more like the question is about how to print table elements at all. In the most basic case to print elements with integer keys starting from 0 and without printing contents of any nested tables it's enough to have one loop: 

    local t = {[0] = 0, 1, 2, 3}
    
    print("{")
    local index = 0
    local element = nil
    while true do
      element = t[index]
      if element == nil then
        break
      end
      local representation = string.format("    [%d] = %s", index, element) -- implement custom type-dependent converion of value to string if needed, this one uses default conversion, i.e. string "1" and number 1 will result in the same output
      print(representation)
      index = index + 1
    end
    print("}")
  8. 16 minutes ago, nok1a said:

    It's for readability.

    For readability of the code or the output with table representation? If for the latter, one can simply create custom function to print table contents.

    35 minutes ago, nok1a said:

    It doesn't start with 0 though. Which is rather the result i want to achieve.
      

    image.png

    Must be chronological order.

    There are no regular arrays in Lua, only tables that are associative arrays and can be used to implement many different data structures. Tables in Lua don't have starting element by themselves, but length operator and functions from "table" library operate only on part of table with consecutive integer keys starting from 1. Your interpretation is wrong, because tables don't have defined order of traversal, it's implementation-specific. In fact official Lua doesn't include table contents in it's default procedure to convert table to string. So instead of relying on default table to string conversion in GG implementation of Lua, implement custom function that will perform conversion the way you need.

  9. Note that metatable-based solution suggested above doesn't work as expected in all cases when key used in indexing access or indexing assignment exists in table, because "__index" and "__newindex" events are used only when key is not present in table. Though, XEKEX is right that it's not a good practice to have 0-based arrays in Lua. What is your use case for that and why 1-based arrays don't suffice?

  10. 22 minutes ago, nok1a said:

    Hmm, i don't exactly understand why string.format over string concatenation, could you perhaps explain?

    Because string concatenation produces new string and there are multiple usages of it in the code.

    29 minutes ago, nok1a said:

    I applied it like this to the script, This is ok?

    Mostly yes, but format strings don't need to be passed as parameters in this case and instead of separate call to format address, do it in the same one.

  11. 43 minutes ago, CmP said:

    in which case it may make sense to go with lookup table

    This is misunderstanding from my side. Table-only solution isn't an option for this case, because of requirement to have structure number in name. So solutions can be only function-based (table may be used in the function, but there is no gain from it in this case), but there is indeed some room for performance improvement in my example above - by avoiding string concatenation and using "string.format" instead.

  12. 13 minutes ago, nok1a said:

    Do you mind if i use your example in the script? I would attach link to this threat as i did with the range function.

    Feel free to do that. And there is no need for any credits in this case, but you can do however you prefer.

    16 minutes ago, nok1a said:

    But i do question, if i write it in a separate function the function will be called for each loop. Will this not slow speed down drastically?

    No, it shouldn't, but if you have millions of iterations, then the difference between function and lookup table might become noticeable, in which case it may make sense to go with lookup table.

    18 minutes ago, nok1a said:

    Is it appropriate like that?

    Yes, looks correct.

  13. It looks like you need not a table, but function that returns name for value according to two parameters: structure offset and structure count. Here is an example of such function: 

    function getNameForValue(structOffset, structCount)
      local name = "Structure (" .. structCount .. ")"
      if structOffset == 1 then
        name = name .. " :Unknown: "
      elseif structOffset == 2 then
        name = name .. " :Field offset: "
      elseif structOffset == 3 then
        name = name .. " :Field amount: "
      end
      return name
    end
  14. What's the point of "auto-destruction" of the file that is executed, if it can be simply backed up before executing it?

    There are no ways (without using server) to prevent script from being executed more than one time that couldn't be easily bypassed, but if you still need to have that for some reason, basic approach is to check presence of certain file and only continue execution if the file is not present and to create that file right after the check has been passed.

  15. Sorry, the answers to the questions above are present in your video. In your locale comma is decimal separator and for your values the search range that I suggested above is too narrow.

    Try the following search string: "1,19999~1,20001"

  16. 9 minutes ago, The-Twins said:

    If i search with 1,2 

    ,2 not found must one value 

    Could it be that you use incorrect decimal separator with respect to locale that you have selected in GG?

    There can be 2 options of the decimal separator: dot (.) and comma (,) . Try with dot first, then with comma.

  17. 2 hours ago, Alessa- said:

    Ouw not far from the instruction 

    If very far away cant ?

    This is limitation of particular variant of LDR instruction, it doesn't mean that it's not possible anyhow. But to be able to provide you reasonable answer, one needs to know what you want to achieve, why do you need to use LDR in the first place. So provide the following information (preferably in new topic):
      - what you are working with (function(s) name, description and instructions that it contains);
      - which modification you want to implement (for example, make the function return fixed value).

  18. 1 minute ago, Alessa- said:

    it's true that ldr has a limit, so to overcome it with what?

    Either with 3 instructions as @XEKEX has described in his post or with 1 instruction and 4 bytes for address that need to be not far from the instruction as I have mentioned in this post.

     

  19. 19 minutes ago, Alessa- said:

    Eaxmple ldr addres : B179DE28 

    and i want load addres: AFFDACA4 

    ldr cant doit i dont know why

    As other have mentioned above, such case requires more than one instruction. At least 8 bytes are required: 4 for LDR instruction and 4 for your new address that needs to be placed somewhere not far from LDR instruction. For example: 

    Address  | Instruction/Value
    12345678 | LDR R0, [PC, #-4]
    1234567C | 0xAFFDACA4
  20. And loading saved list with option to set values can't really be faster than setting values directly by definition, since loading list in this case includes setting values. Also what makes loading saved list significantly slower than directly setting values is not setting values part, it's everything that needs to be done before that: reading and parsing saved list file, populating saved list with items.

×
×
  • 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.