Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I sm trying to scan a system's memory.

My plan : Create pointers to point to memory, And move this pointer up one byte each loop.

So this is what i came up with :

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

const char *MemAdressPointer(int n);

int main(void) {

    int i = 0;
    for(i = 0; i<100; i++)
    {
        const char* pAddr = MemAdressPointer(i+5000);
        printf("%c hexadecimal value of : 0x%p with i at : %i
", *pAddr, pAddr, i);
    }
    getchar();
    return 0;
}

const char *MemAdressPointer(int n)
{
    void *p1 = (void*) n;

    const char* p2;
    p2 = p1;

    return p2;
}

Everything, at least that i know of, works.

It prints the good memory address.

But when i print the character (%c) it just stops responding

It is weird, the pointer, being a character,

shouldn't it point to one byte and get this byte's binary value

and get the corresponding character out of it.

Thanks for any help you can give me.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
251 views
Welcome To Ask or Share your Answers For Others

1 Answer

That is not how modern operating systems work. You cannot simply read out the systems ram, because applications memory is virtualized and also the OS prohibits direct access due to security policies.

The OS may offer some API to access other processes memory (assumed you have the rights to do). On Win32Api this is ReadProcessMemory.

May be some other OS API allows the direct read out of the systems address space. You may dig into How do you read directly from physical memory?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...