summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2014-11-17 17:46:27 +0000
committerZachary Turner <zturner@google.com>2014-11-17 17:46:27 +0000
commita2fc3a4090bf1f7110712460a8194e169a210e9f (patch)
treebd05cbfa0292baede9dae90e62c8fa8fbcd4417c /lldb/source/Plugins/Process/Windows/ProcessWindows.cpp
parentf70c673db75b71756251e5647e7714ecd345340c (diff)
downloadbcm5719-llvm-a2fc3a4090bf1f7110712460a8194e169a210e9f.tar.gz
bcm5719-llvm-a2fc3a4090bf1f7110712460a8194e169a210e9f.zip
[ProcessWindows] Implement read / write process memory.
llvm-svn: 222147
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/ProcessWindows.cpp')
-rw-r--r--lldb/source/Plugins/Process/Windows/ProcessWindows.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp
index 3c8e4a60010..da61ba9d193 100644
--- a/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/HostNativeProcessBase.h"
#include "lldb/Host/MonitoringProcessLauncher.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/windows/ProcessLauncherWindows.h"
@@ -224,7 +225,7 @@ Error
ProcessWindows::DoDestroy()
{
Error error;
- if (GetPrivateState() != eStateExited && GetPrivateState() != eStateDetached)
+ if (GetPrivateState() != eStateExited && GetPrivateState() != eStateDetached && m_session_data)
{
DebugActiveProcessStop(m_session_data->m_debugger->GetProcess().GetProcessId());
SetPrivateState(eStateExited);
@@ -260,7 +261,32 @@ ProcessWindows::DoReadMemory(lldb::addr_t vm_addr,
size_t size,
Error &error)
{
- return 0;
+ if (!m_session_data)
+ return 0;
+
+ HostProcess process = m_session_data->m_debugger->GetProcess();
+ void *addr = reinterpret_cast<void *>(vm_addr);
+ SIZE_T bytes_read = 0;
+ if (!ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr, buf, size, &bytes_read))
+ error.SetError(GetLastError(), eErrorTypeWin32);
+ return bytes_read;
+}
+
+size_t
+ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Error &error)
+{
+ if (!m_session_data)
+ return 0;
+
+ HostProcess process = m_session_data->m_debugger->GetProcess();
+ void *addr = reinterpret_cast<void *>(vm_addr);
+ SIZE_T bytes_written = 0;
+ lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
+ if (WriteProcessMemory(handle, addr, buf, size, &bytes_written))
+ FlushInstructionCache(handle, addr, bytes_written);
+ else
+ error.SetError(GetLastError(), eErrorTypeWin32);
+ return bytes_written;
}
bool
OpenPOWER on IntegriCloud