Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Check to see if memory is readable or writeable?

Author
Message
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 23rd Nov 2009 06:27
How do i check to see if a pointer i have is readable or writable?

New Site! Check it out \/
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 23rd Nov 2009 06:40
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 24th Nov 2009 02:59
While this is good programming practice, What i am doing is making a dll to read and write memory, and you have to send a pointer. If the pointer isn't readable or isn't writable then you will end with an error. So all i have is a pointer and no other info on it. Just hoping that the user has sent a valid pointer doesn't seem like a good thing to me.

New Site! Check it out \/
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 24th Nov 2009 03:02
Send a pointer from where? Surely you can see if it's valid or not based on where you retrieve it from. While there is a function to check if a pointer is a valid address, even Microsoft don't recommend you use it, and it won't tell you if it's readable or writeable.

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 24th Nov 2009 05:11
IsBadReadPtr and IsBadWritePtr Yes i know I have read very VERY bad things about them

here is essencially what it does:

you have a Alloc function that will dynamicely create memory of the specified size. then i have reading and writing functions. well if they don't check for errors with the alloc or use the reading functions on a pointer gotten from somewhere else then i need to be able to check if that pointer is readable before trying to read from it as i don't want to crash there program because i am trying to read 'someone else's' memory lol

New Site! Check it out \/
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 24th Nov 2009 09:18 Edited at: 24th Nov 2009 09:19
MSDN seems to indicate that ReadProcessMemory(forum fails at links: http://msdn.microsoft.com/en-us/library/ms680553%28VS.85%29.aspx) will gracefully fail, so you could try that and handle it if it fails. But it's still no indication that what you're reading or writing to is what you in fact think you are.

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 24th Nov 2009 15:44
Ok I will look into that thanks!

New Site! Check it out \/

Login to post a reply

Server time is: 2024-11-24 17:39:36
Your offset time is: 2024-11-24 17:39:36