1 //===-- ProcessWindows.cpp --------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "ProcessWindows.h" 11 12 // Other libraries and framework includes 13 #include "lldb/Core/Module.h" 14 #include "lldb/Core/ModuleSpec.h" 15 #include "lldb/Core/PluginManager.h" 16 #include "lldb/Core/Section.h" 17 #include "lldb/Core/State.h" 18 #include "lldb/Host/windows/windows.h" 19 #include "lldb/Target/DynamicLoader.h" 20 #include "lldb/Target/MemoryRegionInfo.h" 21 #include "lldb/Target/Target.h" 22 23 using namespace lldb; 24 using namespace lldb_private; 25 26 namespace lldb_private { 27 28 //------------------------------------------------------------------------------ 29 // Constructors and destructors. 30 31 ProcessWindows::ProcessWindows(lldb::TargetSP target_sp, 32 lldb::ListenerSP listener_sp) 33 : lldb_private::Process(target_sp, listener_sp) {} 34 35 ProcessWindows::~ProcessWindows() {} 36 37 size_t ProcessWindows::GetSTDOUT(char *buf, size_t buf_size, Error &error) { 38 error.SetErrorString("GetSTDOUT unsupported on Windows"); 39 return 0; 40 } 41 42 size_t ProcessWindows::GetSTDERR(char *buf, size_t buf_size, Error &error) { 43 error.SetErrorString("GetSTDERR unsupported on Windows"); 44 return 0; 45 } 46 47 size_t ProcessWindows::PutSTDIN(const char *buf, size_t buf_size, 48 Error &error) { 49 error.SetErrorString("PutSTDIN unsupported on Windows"); 50 return 0; 51 } 52 53 //------------------------------------------------------------------------------ 54 // ProcessInterface protocol. 55 56 lldb::addr_t ProcessWindows::GetImageInfoAddress() { 57 Target &target = GetTarget(); 58 ObjectFile *obj_file = target.GetExecutableModule()->GetObjectFile(); 59 Address addr = obj_file->GetImageInfoAddress(&target); 60 if (addr.IsValid()) 61 return addr.GetLoadAddress(&target); 62 else 63 return LLDB_INVALID_ADDRESS; 64 } 65 66 // The Windows page protection bits are NOT independent masks that can be 67 // bitwise-ORed 68 // together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE | PAGE_READ). 69 // To test for an access type, it's necessary to test for any of the bits that 70 // provide 71 // that access type. 72 bool ProcessWindows::IsPageReadable(uint32_t protect) { 73 return (protect & PAGE_NOACCESS) == 0; 74 } 75 76 bool ProcessWindows::IsPageWritable(uint32_t protect) { 77 return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | 78 PAGE_READWRITE | PAGE_WRITECOPY)) != 0; 79 } 80 81 bool ProcessWindows::IsPageExecutable(uint32_t protect) { 82 return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | 83 PAGE_EXECUTE_WRITECOPY)) != 0; 84 } 85 } 86