Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 85

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Calculating a pointer.
Results 1 to 6 of 6

Thread: Calculating a pointer.

  1. #1

    Calculating a pointer.

    [code=cpp]uint32_t calculate(uint32_t address, vector<uint32_t> offsets) {
    uint32_t nextAddress = address;
    for(vector<uint32_t>::iterator it = offsets.begin(); it != offsets.end(); ++it) {
    nextAddress = readUint(hProc, nextAddress);
    if(nextAddress == 0) break;
    nextAddress = nextAddress + *it;
    }
    return nextAddress;
    }

    // Combined with C++0x:
    auto address = calculate(0x666666, {0x8, 0x2C, 0x34});[/code]

    How easy is that to read a pointer. Share your ways to do it.

  2. #2
    Super Moderator
    Join Date
    May 2007
    Posts
    1,191

    RE: Calculating a pointer.

    Your code ported to C#:
    [code=c#]
    uint Calculate(uint address, uint[] offsets)
    {
    uint addressToReturn = address;
    for (int i = 0; i < offsets.Length; i++)
    {
    addressToReturn = Memory.ReadUInt(addressToReturn);
    addressToReturn += offsets[i];
    }
    return addressToReturn;
    }
    [/code]

  3. #3

    RE: Calculating a pointer.

    Quote Originally Posted by Blaster_89
    Your code ported to C#:
    [code=c#]
    uint Calculate(uint address, uint[] offsets)
    {
    uint addressToReturn = address;
    for (int i = 0; i < offsets.Length; i++)
    {
    addressToReturn = Memory.ReadUInt(addressToReturn);
    addressToReturn += offsets[i];
    }
    return addressToReturn;
    }
    [/code]
    C# is so much easier to write :/
    Better add if(addressToReturn == 0) break; in case we got to a null pointer.

  4. #4

    RE: Calculating a pointer.

    Similar to how I would do it while injected (just modded your code.. Just woke up)

    [code=c++]uint32_t calculate(uint32_t address, vector<uint32_t> offsets)
    {
    uint32_t nextAddress = address;
    for(vector<uint32_t>::iterator it = offsets.begin(); it != offsets.end(); ++it)
    {
    if(nextAddress == *(DWORD*)nextAddress) break;
    nextAddress = *(DWORD*)nextAddress + *it;
    }
    return nextAddress;
    }[/code]

  5. #5
    Senior Member
    Join Date
    Mar 2007
    Posts
    266

    RE: Calculating a pointer.

    I am wondering why then I try to call this function it gives a below error:

    I am not familiar with vectors and iterators :P Solution is probably very easy :P

  6. #6

    RE: Calculating a pointer.

    Uniform initialization and a lot of other C++11 features hasn't been implemented in Visual Studios C++ compiler yet.
    So what you can do is [s]either download Visual C++ Compiler November 2012 CTP or more simple just[/s] change the way you fill the vector with values.

    [code=c++]vector<uint32_t> offsets;
    offsets.push_back(0x8);
    offsets.push_back(0x2C);
    offsets.push_back(0x34);

    uint32_t address = calculate(0x666666, offsets);[/code]

    Also change the calculate function to take the offsets vector as const reference instead so it won't copy the data.
    [code=c++]uint32_t calculate(uint32_t address, const vector<uint32_t> &offsets)[/code]

    EDIT: Change the for loop to use const_iterator instead of iterator.

    EDIT: Just tested and uniform initialization won't work with the november compiler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •