squirlhntr How do I cheat?
Reputation: 0
Joined: 05 Dec 2009 Posts: 1
|
Posted: Sat Dec 05, 2009 4:06 pm Post subject: VirtualQueryEx error, general memory access in Win7 |
|
|
Hello all. I am trying to run some code that works in XP but not in Win7, presumably due to security issues. Right now my code is failing with:
| Code: | VirtualQueryEx(handle, etc...)
Error: Access violation reading 0x0000001C |
This is in the process of attempting to read a processes memory. I already sorted out the permissions via OpenProcess so I know I have full access but for some reason there are portions of memory that I cannot read (which is why I am using VirtualQueryEx, in theory to figure out the start address of the memory).
Any suggestions? Have had a hell of a time trying to find out the problem.
Example code (its in python, but you can get the idea... just follow the system calls):
| Code: | window = FindWindow(None, windowName)
threadID, processID = GetWindowThreadProcessId(window.GetSafeHwnd())
# set up security to get full access
process = OpenProcess(0x00040000, 0, processID)
info = GetSecurityInfo(GetCurrentProcess(), SE_KERNEL_OBJECT, 0)
SetSecurityInfo(process, SE_KERNEL_OBJECT, DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, None, None, info.GetSecurityDescriptorDacl(), info.GetSecurityDescriptorGroup())
process.close()
# now that we have same security as this process, re-open with full rights
p = OpenProcess(0x1FFFFF, 0, processID)
meminfo = GetProcessMemoryInfo(p.handle)
bytes_read = c_ulong(0)
size = meminfo['WorkingSetSize']
address = 0x00010000
b = create_string_buffer(size)
windll.kernel32.ReadProcessMemory(p.handle, address, b, size, byref(bytes_read)) # works, but doesn't get all memory as addres is incorrect
print windll.kernel32.GetLastError() # 299
dunno = c_uint(0)
# print windll.kernel32.VirtualProtectEx(p.handle, 0, size, 0x02, byref(dunno))
print windll.kernel32.VirtualQueryEx(p.handle)
|
|
|