2
我試圖讀取方法的返回地址,但另一個內存。 所以我得到幀指針,並讀取返回值的值。 據我明白我應該得到的值等於m_stackframe.AddrReturn.Offset,但:callstack和ReadProcessMemory
- 如果我添加了ESP的幀指針地址 - ReadProcessMemory返回false。
- 如果我只是使用地址幀偏移量 - 我得到一個錯誤的值。
//Reading the top method in the stack. bool ok = StackWalk64(IMAGE_FILE_MACHINE_I386,m_processInfo.Handle ,m_threadInfo.Handle, &m_stackframe,&m_threadContext, 0,SymFunctionTableAccess64,SymGetModuleBase64,0); // the Esp register is the base address of the stack, right? DWORD baseAddressOfCallstack = m_threadContext.Esp; // Getting the absolute address by adding the ESP to the stack frame address. DWORD absoluteAddressInCallstack = m_stackframe.AddrFrame.Offset + baseAddressOfCallstack ; // Converting it to a pointer. DWORD* addressInCallStack = (DWORD*)absoluteAddressInCallstack; DWORD val = 0; SIZE_T bytesRead = 0; // and trying to read it from the process... ok = ReadProcessMemory(m_processInfo.Handle, addressInCallStack, (void*)&val, sizeof(DWORD),&bytesRead);
我使用C++的窗口。 有人可以告訴我它有什麼問題嗎? 謝謝:)