Results 1 to 1 of 1

Thread: C++ Pointers

  1. #1
    Vitrix Maggot
    Vitrix Maggot is offline
    Member-in-training Vitrix Maggot's Avatar
    Join Date
    2013 Apr
    Thanked 43 Times in 24 Posts
    Rep Power

    C++ Pointers

    I'm doing this tutorial so that it is better to understand how it behaves the Pointers in C ++ and so we can discuss and ask questions about it, try to make the tutorial as clear as possible.

    Pointers are the foundation of any hack games, since the hacks consist of memory changes, which are made through pointers.
    Thus making important learning of it in this forum

    Pointers in C + +


    int * Ptri;
    float * ptrf;
    Thus we declare two pointers, Ptri which is a pointer to an integer and ptrf that points to a float.
    NOTE: As Ptri is not an integer, not a ptrf tbm number of type float, ie, their values ​​are in memory address and the value of these addresses is that they are an integer and a float, respectively.

    Using pointers:

    int var = 5;
    int * = VarPtr &var;
    Thus the pointer is pointing to VarPtr the value of the variable var.
    So if we do,
    * VarPtr = 7;
    We will be changing the value of var to 7.

    It is worth mentioning some incorrect syntax and explains them, lest we confuse:
    1) int * = VarPtr var;
    2) int * VarPtr = 5;
    3) int * = 0x0005 VARPTR;
    4) int * = VarPtr &5;

    In 1 is flawed because var is of type integer and VarPtr is type pointer to integer.
    2 because in 5 is an integer constant, thereby generating the error of the first and second error per 5 can not be assigned to another value.
    3 is the same in the case of 2, since it is also an integer 0x0005 (hexadecimal).
    In 4 there is an error because 5 is a contact and does not occupy a place in physical memory or a variable

    Now we are a few examples:

    Example 1:

    int a, b = 5;
    int result = * &a;
    a = 10;
    cout << * result + b;

    15 / / (10 + 5)
    Example 2:

    int a, b, * ptr1, ptr2 * / / declaration
    a = 10 / / initializing "a"
    b = 7 / / initializing "b"
    ptr1 = &a; / / "ptr1" receives the address of "a"
    ptr2 = ptr1; / / "ptr2" gets the value of "ptr1" which is the address of "a" (note that it is allowed to assign a pointer to another, they are of the same type)
    ptr1 = &b; / / "ptr1" points to "b" note "ptr2" keeps pointing to "a"
    * Ptr2 = 18 / / address value of "ptr2" ("a") receives 18. (A = 18)
    b = 15 / / b gets 15;
    cout << a << "," << b << "," << * ptr1 << "," << * ptr2;

    18, 15, 15, 18

    With pointers you can access and manipulate memory regions values, and it is also possible that a single pointer you manipulate multiple variables.
    It is a type of data most useful for various applications.

    Using pointers - Theory of hacks:

    Using the game pinbal example,

    Suppose we have the adress (address) that corresponds to the number of balls pinbal.

    Well, we know that the number of balls is an integer, then we conclude that the pointer value that interests us is the integer type.

    Then we'll make a type cast to make this hexadecimal (which is the adress) in whose region of memory pointer to which it points is the hexadecimal: (int *) 0x010101
    Note that if we did int * 0x010101 would be wrong, would the error 3) tutorial.

    To access the pointer value we create enough just by the "*": D
    Then when we do * (int *) 0x010101 will be accessing the value of the number of balls remaining in pinbal (adopting the example).

    Thus we could do the following:
    int value = * (int *) 0x010101 / / recording the current value of the number of balls in the variable value.
    Or change the value as follows:
    * (Int *) 0x010101 = 30 / / Changing the current value of the number of balls to 30
    Thus we would have 30 balls, following the example of pinball.
    I admire most other programmers not paid any dick!!

    Admiro outros Programadores mais nao pago pau pra nenhum !!

    Skype: Vitor Monteiro

  2. The Following User Says Thank You to Vitrix Maggot For This Useful Post:

Similar Threads

  1. [C#]I have a problem with pointers(VIDEO)
    By P.o.X in forum Programming Tutorials
    Replies: 7
    Last Post: 2013-02-15, 01:28 PM
  2. [Useful] Pointers
    By Dwar in forum Battle of the Immortals
    Replies: 2
    Last Post: 2011-02-08, 05:49 PM
  3. [Help] Pointers for CE
    By SternKraft in forum Requiem Online
    Replies: 0
    Last Post: 2011-01-30, 03:44 PM
  4. [C++] Example of patching pointers
    By Dwar in forum C/C++
    Replies: 0
    Last Post: 2010-11-29, 04:14 PM
  5. Pointers
    By Surubre in forum General Game Research
    Replies: 4
    Last Post: 2010-11-29, 04:02 PM
Visitors found this page by searching for:
Nobody landed on this page from a search engine, yet!

Posting Permissions

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