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 //------------------------------------------------------------------------------ 30 // Constructors and destructors. 31 32 ProcessWindows::ProcessWindows(lldb::TargetSP target_sp, Listener &listener) 33 : lldb_private::Process(target_sp, listener) 34 { 35 } 36 37 ProcessWindows::~ProcessWindows() 38 { 39 } 40 41 size_t 42 ProcessWindows::GetSTDOUT(char *buf, size_t buf_size, Error &error) 43 { 44 error.SetErrorString("GetSTDOUT unsupported on Windows"); 45 return 0; 46 } 47 48 size_t 49 ProcessWindows::GetSTDERR(char *buf, size_t buf_size, Error &error) 50 { 51 error.SetErrorString("GetSTDERR unsupported on Windows"); 52 return 0; 53 } 54 55 size_t 56 ProcessWindows::PutSTDIN(const char *buf, size_t buf_size, Error &error) 57 { 58 error.SetErrorString("PutSTDIN unsupported on Windows"); 59 return 0; 60 } 61 62 //------------------------------------------------------------------------------ 63 // ProcessInterface protocol. 64 65 66 lldb::addr_t 67 ProcessWindows::GetImageInfoAddress() 68 { 69 Target &target = GetTarget(); 70 ObjectFile *obj_file = target.GetExecutableModule()->GetObjectFile(); 71 Address addr = obj_file->GetImageInfoAddress(&target); 72 if (addr.IsValid()) 73 return addr.GetLoadAddress(&target); 74 else 75 return LLDB_INVALID_ADDRESS; 76 } 77 78 // The Windows page protection bits are NOT independent masks that can be bitwise-ORed 79 // together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE | PAGE_READ). 80 // To test for an access type, it's necessary to test for any of the bits that provide 81 // that access type. 82 bool 83 ProcessWindows::IsPageReadable(uint32_t protect) 84 { 85 return (protect & PAGE_NOACCESS) == 0; 86 } 87 88 bool 89 ProcessWindows::IsPageWritable(uint32_t protect) 90 { 91 return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | PAGE_READWRITE | PAGE_WRITECOPY)) != 0; 92 } 93 94 bool 95 ProcessWindows::IsPageExecutable(uint32_t protect) 96 { 97 return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) != 0; 98 } 99 100 } 101