Restman
Restman

Reputation: 95

Calling mmap from specific address

How to read mmap function from specific address, if knew it (0x6A6F7444)? I tried:

mmap(0x6A6F7444, 100, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)

But it doen't works. Compile says:

warning: passing argument 1 of ‘munmap’ makes pointer from integer without a cast [-Wint-conversion] 

Upvotes: 0

Views: 1064

Answers (2)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136208

For mmap to use your address it needs MAP_FIXED flag, see man mmap for full details.

Upvotes: 0

David Ranieri
David Ranieri

Reputation: 41017

#include <stdint.h> // for uintptr_t

uintptr_t addr = 0x6A6F7444;

mmap((void *)addr, 100, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);

will disable the warning.

Upvotes: 1

Related Questions