Results 1 to 3 of 3
  1. #1
    I.P's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    10
    Reputation
    11
    Thanks
    0

    I'm new to c++ and have a question about pointers

    So I have a quick question about pointers..

    So far I have learned that the & sign tells the compiler where about's in the computers memory the value you wan't is stored.

    and that you can use a pointer to access the value stored in that memory address.


    But all the examples are like:

    Code:
    int fingers = 10;
    int *Pointer = &finger;
    cout << *pointer;
    So as far as I understand, my program is accessing the memory address where int fingers is stored, and is pointing to the value that is stored within that memory address.

    But what if I wan't the pointer to access a memory address that is not created within my program, if you understand what I am saying.

    is it possible for me to put in a hexidecimal memory address before the & sign
    like the following code?

    Code:
    int *Pointer = &0x93jfm
    would that return the value that is stored in that memory address without declaring it or do I have to declare it or something, Sorry if I confused you,Iv'e only been learning c++ 1 day,and I wen't from finishing page 8 with switch statements and page 9 were pointers which is when my mind started racing with questions.

    Thanks for your help

    __________________________________________________ _________________

    Okay, now I understand what I'm actually trying to say a little more.

    Say the value you wanted to retrieve out of a memory address was not within your program, you wanted to retrieve the value of a diffrent memory address outside your program,

    So far I have only learnt how to access the memory address of int's I have made, and then get the value of that.
    but since I'm the one that made that int, and made it equal that value, It's not very usefull, atleast not for making hacks ect,it would be useful for transfering lots of data though ;P

    so what If you didn't make the int,how would you point to it then?

    Heres a little example to show you guys what I'm trying to do

    Say I used olly dbg/cheat engine to find the memory address of what stores how many points you have in a card game of Solitaire,

    so now I need to make a pointer to that memory address,How would I go about doing that? Can someone please also try explain the code, I'm trying to learn from this not just leech code examples,Thanks
    Last edited by I.P; 05-26-2011 at 09:33 PM.

  2. #2
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Yes, except you need to actually have hexadecimal, and not some random string ('j', 'f' and 'm' are not valid hexadecimal characters).

    To get the value of some arbitrary address in memory, you can use some code that looks a little like the following:

    Code:
    int i = *(int*)0xFFFFFF
    In order (from right to left), address 0xFFFFFF is cast into a pointer to an integer, and is dereferenced to its value, which is the copied to 'i'. Note that its copied in this case, since we're dereferencing it. If you would like a reference, then use the below code:

    Code:
    int* i = (int*)0xFFFFFF

  3. The Following User Says Thank You to freedompeace For This Useful Post:

    258456 (05-27-2011)

  4. #3
    I.P's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    10
    Reputation
    11
    Thanks
    0
    Thanks so much for this.