I need to get the value from memory location 0 to 3 bytes assuming int uses 4 bytes of data and if long uses 8 bytes,
I want to read 0 to 7 bytes as long’s data and see what value it gives back.
Can anyone help me with C# code.
Regards,
Vix
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This could be very dangerous, how are getting the address and how are you evaluating that it is valid? Not every address will be valid and trying to read from some of them will result in exceptions.
But you can use the Marshal.Read* methods do to this.
You will need to catch AccessViolationException’s as well.
Also are you trying to read from a virtual address or from physical memory. From C# you will only be reading from the virtual address space of your process. You’d have to use a kernel mode driver to get direct access to the physical memory on your computer.