memory reading

This is a discussion on memory reading within the C++ Programming forums, part of the General Programming Boards category; I am trying to write a program that reads the contents in the memory. How can i assign to the ...

  1. #1
    I'm Back
    Join Date
    Dec 2001
    Posts
    556

    Question memory reading

    I am trying to write a program that reads the contents in the memory.

    How can i assign to the pointer the memory addr given by the user as the starting addr and tell it read on till it reaches the ending addr specified by the user?

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    just have the start and stop addresses and increment the address and output the pointers data [upon dereference]. of course, windows would complain. but in real mode you can do it.
    hasafraggin shizigishin oppashigger...

  3. #3
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    This is my program (not complete yet..)

    #include<iostream.h>
    #include<fstream.h>
    #include<conio.h>

    void main()
    {
    char *cp;

    fstream f1;

    clrscr();

    f1.open("DATA.TXT",ios:ut);

    *cp=0x0;

    while(!kbhit())
    {
    f1<<*cp;

    gotoxy(1,1);
    clreol();
    cout<<"ADDRESS : "<<cp<<"\t\t"<<"VALUE : "<<*cp;

    cp=cp+1;
    }

    f1.close();

    getch();
    }


    Is this OK ??

  4. #4
    I'm Back
    Join Date
    Dec 2001
    Posts
    556

    ...
    ...

    ...
    ...

    anybody ??

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    With the additions, it is doing what you want. However, maybe what you want it to do will not be the best way.

    It will crash, because Windows will not let you read some regions of memory. Also, your program gets it's own 2GB adress space. You will not be able to look into others processes' memory this way.

    Try this:

    PHP Code:

    #include <stdlib.h>
    #include <stdio.h>

    int main() 

        const 
    unsigned charcp NULL
        
    unsigned char c 0;

        do
        {
            try
            {
                
    = *cp;
                
    printf("Adress %p contains %x\n"cp);
            }
            catch( ... )
            {
                
    printf("Adress %p is unreadable\n"cp );
            }
     
            
    cp++; 
        }
        while( !
    kbhit() && cp != NULL );

        return 
    0;

    [untested, no compiler at hand]
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  6. #6
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    How can i assign starting addr to the char pointer and compare it with the ending addr.


    DA said
    >>just have the start and stop addresses and increment the address and output the pointers data [upon dereference]<<

    so how to do that?

  7. #7
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    HA, Ive brought this post back from the dead.

    Anybody...Any suggestions...

  8. #8
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> HA, Ive brought this post back from the dead.

    Yes you have, actually for the second time in this thread. Do it again and I'll delete it. Bumping threads is against the rules.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #9
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    adrian i think you might have misunderstood the
    >>Anybody...Any suggestions...<< thing

    i am only asking for programing help.

    by the way should i post a new thread ?

  10. #10
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>>
    adrian i think you might have misunderstood the
    >>Anybody...Any suggestions...<< thing
    <<<

    I don't think so. When you post a message in reply to your own thread to promote your thread back to the top of the list, that is thread bumping, which is against the rules.

    If you check the dates in the thread and the poster, you will see that this thread has been bumped twice.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory usage and memory leaks
    By vsanandan in forum C Programming
    Replies: 1
    Last Post: 05-03-2008, 05:45 AM
  2. reading files into memory
    By bobthebullet990 in forum C Programming
    Replies: 3
    Last Post: 11-30-2005, 02:39 PM
  3. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM
  4. Reading from Low Memory Error...
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 06-13-2002, 10:22 AM
  5. Reading from file into memory
    By GaPe in forum C Programming
    Replies: 15
    Last Post: 12-17-2001, 03:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21