Oct 9, 2011 at 4:34pm UTC
I can only guess what you're trying to do, but:
1 2 3
byte buf[size];
byte* src=reinterpret_cast <byte*>(myAddress);
memcpy(buf,src,size);
If part of the memory you're trying to read is not mapped, you'll get a segmentation fault.
Edit: that's only if you need a copy. Otherwise the middle line will suffice.
Last edited on Oct 9, 2011 at 4:37pm UTC
Oct 9, 2011 at 5:39pm UTC
thanks man, that was a fast reply, I'm not sure if it does what I intend to but I'll try it later, I have to go somewhere now, that was a fast reply o.O
Oct 9, 2011 at 10:02pm UTC
I have this other question:
How come when I try to read the memory from my own process I get
0xC0000005: Access violation
this is starting to piss me off, I mean I already did this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#define NON_WRITE (PAGE_READONLY | PAGE_NOACCESS | PAGE_EXECUTE_READ | PAGE_EXECUTE)
MEMORY_BASIC_INFORMATION mbi;
unsigned long Addr = 0;
while (1)
{
if (VirtualQuery((LPCVOID)Addr,&mbi,sizeof (MEMORY_BASIC_INFORMATION) )== 0) {break ; }
size = mbi.RegionSize;
if ( (mbi.Protect & NON_WRITE) ){ Addr+=mbi.RegionSize;continue ; }
else {
printf("Result: 0x%X-0x%X Protection:%d\n" , Addr,Addr+mbi.RegionSize,mbi.Protect);
for (;Addr < endreg ;Addr++)
{
if (*(DWORD*)Addr == 1234) { printf("Value FOUND" ); }
}
}
}
Why do I always crash at address 0x00030000 I don't get it... it is supposed to "skip" addresses I can't access...
Last edited on Oct 9, 2011 at 10:03pm UTC