Reputation: 29693
I want to map some part of process memory as byte array. How to do it?
I have byte array:
byte AmmoBytes[3]
And I want this array to start at address 0xXXXXXXX; How to do it?
Upvotes: 1
Views: 208
Reputation: 57749
I would declare the memory using a constant pointer:
byte * const AmmoBytes = (byte * const) 0xFFFF000;
Declaring the pointer as constant helps the compiler detect errors such as mistakenly changing the pointer value instead of the value pointed to by the pointer.
Upvotes: 0
Reputation: 96291
Generally speaking you can't reliably do this.
If 0xXXXXXXX
represents hardware address(es) then you'll need to write a device driver to gain kernel access to the memory.
If it's a normal memory address then there's no guarantee that it maps to a valid memory location and you're quite likely to crash your program.
What are you really trying to do here?
Upvotes: 0
Reputation: 7779
This is unsafe, but you can say
byte * AmmoBytes = (byte *) 0xXXXXXXXX
Upvotes: 2