| OLD | NEW | 
|    1 // Copyright 2015 The Crashpad Authors. All rights reserved. |    1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 
|    2 // |    2 // | 
|    3 // Licensed under the Apache License, Version 2.0 (the "License"); |    3 // Licensed under the Apache License, Version 2.0 (the "License"); | 
|    4 // you may not use this file except in compliance with the License. |    4 // you may not use this file except in compliance with the License. | 
|    5 // You may obtain a copy of the License at |    5 // You may obtain a copy of the License at | 
|    6 // |    6 // | 
|    7 //     http://www.apache.org/licenses/LICENSE-2.0 |    7 //     http://www.apache.org/licenses/LICENSE-2.0 | 
|    8 // |    8 // | 
|    9 // Unless required by applicable law or agreed to in writing, software |    9 // Unless required by applicable law or agreed to in writing, software | 
|   10 // distributed under the License is distributed on an "AS IS" BASIS, |   10 // distributed under the License is distributed on an "AS IS" BASIS, | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   43     //! \brief The base address of the loaded DLL. |   43     //! \brief The base address of the loaded DLL. | 
|   44     WinVMAddress dll_base; |   44     WinVMAddress dll_base; | 
|   45  |   45  | 
|   46     //! \brief The size of the module. |   46     //! \brief The size of the module. | 
|   47     WinVMSize size; |   47     WinVMSize size; | 
|   48  |   48  | 
|   49     //! \brief The module's timestamp. |   49     //! \brief The module's timestamp. | 
|   50     time_t timestamp; |   50     time_t timestamp; | 
|   51   }; |   51   }; | 
|   52  |   52  | 
 |   53   struct Handle { | 
 |   54     Handle(); | 
 |   55     ~Handle(); | 
 |   56  | 
 |   57     //! \brief A string representation of the handle's type. | 
 |   58     std::wstring type_name; | 
 |   59  | 
 |   60     //! \brief The handle's value. | 
 |   61     //! | 
 |   62     //! See https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203 on | 
 |   63     //! 32 bits being the correct size for `HANDLE`s, even on Windows x64. | 
 |   64     uint32_t handle; | 
 |   65  | 
 |   66     //! \brief The attributes for the handle, e.g. `OBJ_INHERIT`, | 
 |   67     //!     `OBJ_CASE_INSENSITIVE`, etc. | 
 |   68     uint32_t attributes; | 
 |   69  | 
 |   70     //! \brief The `ACCESS_MASK` for the handle in this process. | 
 |   71     //! | 
 |   72     //! See | 
 |   73     //! http://blogs.msdn.com/b/openspecification/archive/2010/04/01/about-the-a
     ccess-mask-structure.aspx | 
 |   74     //! for more information. | 
 |   75     uint32_t granted_access; | 
 |   76  | 
 |   77     //! \brief The number of kernel references to the object that this handle | 
 |   78     //!     refers to. | 
 |   79     uint32_t pointer_count; | 
 |   80  | 
 |   81     //! \brief The number of open handles to the object that this handle refers | 
 |   82     //!     to. | 
 |   83     uint32_t handle_count; | 
 |   84   }; | 
 |   85  | 
|   53   ProcessInfo(); |   86   ProcessInfo(); | 
|   54   ~ProcessInfo(); |   87   ~ProcessInfo(); | 
|   55  |   88  | 
|   56   //! \brief Initializes this object with information about the given |   89   //! \brief Initializes this object with information about the given | 
|   57   //!     \a process. |   90   //!     \a process. | 
|   58   //! |   91   //! | 
|   59   //! This method must be called successfully prior to calling any other |   92   //! This method must be called successfully prior to calling any other | 
|   60   //! method in this class. This method may only be called once. |   93   //! method in this class. This method may only be called once. | 
|   61   //! |   94   //! | 
|   62   //! \return `true` on success, `false` on failure with a message logged. |   95   //! \return `true` on success, `false` on failure with a message logged. | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   99   //! \brief Given a range to be read from the target process, returns a vector |  132   //! \brief Given a range to be read from the target process, returns a vector | 
|  100   //!     of ranges, representing the readable portions of the original range. |  133   //!     of ranges, representing the readable portions of the original range. | 
|  101   //! |  134   //! | 
|  102   //! \param[in] range The range being identified. |  135   //! \param[in] range The range being identified. | 
|  103   //! |  136   //! | 
|  104   //! \return A vector of ranges corresponding to the portion of \a range that |  137   //! \return A vector of ranges corresponding to the portion of \a range that | 
|  105   //!     is readable based on the memory map. |  138   //!     is readable based on the memory map. | 
|  106   std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( |  139   std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( | 
|  107       const CheckedRange<WinVMAddress, WinVMSize>& range) const; |  140       const CheckedRange<WinVMAddress, WinVMSize>& range) const; | 
|  108  |  141  | 
 |  142   //! \brief Retrieves information about open handles in the target process. | 
 |  143   const std::vector<Handle>& Handles(); | 
 |  144  | 
|  109  private: |  145  private: | 
|  110   template <class Traits> |  146   template <class Traits> | 
|  111   friend bool GetProcessBasicInformation(HANDLE process, |  147   friend bool GetProcessBasicInformation(HANDLE process, | 
|  112                                          bool is_wow64, |  148                                          bool is_wow64, | 
|  113                                          ProcessInfo* process_info, |  149                                          ProcessInfo* process_info, | 
|  114                                          WinVMAddress* peb_address, |  150                                          WinVMAddress* peb_address, | 
|  115                                          WinVMSize* peb_size); |  151                                          WinVMSize* peb_size); | 
|  116   template <class Traits> |  152   template <class Traits> | 
|  117   friend bool ReadProcessData(HANDLE process, |  153   friend bool ReadProcessData(HANDLE process, | 
|  118                               WinVMAddress peb_address_vmaddr, |  154                               WinVMAddress peb_address_vmaddr, | 
|  119                               ProcessInfo* process_info); |  155                               ProcessInfo* process_info); | 
|  120  |  156  | 
|  121   friend bool ReadMemoryInfo(HANDLE process, |  157   friend bool ReadMemoryInfo(HANDLE process, | 
|  122                              bool is_64_bit, |  158                              bool is_64_bit, | 
|  123                              ProcessInfo* process_info); |  159                              ProcessInfo* process_info); | 
|  124  |  160  | 
 |  161   std::vector<Handle> BuildHandleVector(HANDLE process) const; | 
 |  162  | 
|  125   pid_t process_id_; |  163   pid_t process_id_; | 
|  126   pid_t inherited_from_process_id_; |  164   pid_t inherited_from_process_id_; | 
 |  165   HANDLE process_; | 
|  127   std::wstring command_line_; |  166   std::wstring command_line_; | 
|  128   WinVMAddress peb_address_; |  167   WinVMAddress peb_address_; | 
|  129   WinVMSize peb_size_; |  168   WinVMSize peb_size_; | 
|  130   std::vector<Module> modules_; |  169   std::vector<Module> modules_; | 
|  131   std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; |  170   std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; | 
 |  171   std::vector<Handle> handles_; | 
|  132   bool is_64_bit_; |  172   bool is_64_bit_; | 
|  133   bool is_wow64_; |  173   bool is_wow64_; | 
|  134   InitializationStateDcheck initialized_; |  174   InitializationStateDcheck initialized_; | 
|  135  |  175  | 
|  136   DISALLOW_COPY_AND_ASSIGN(ProcessInfo); |  176   DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | 
|  137 }; |  177 }; | 
|  138  |  178  | 
|  139 //! \brief Given a memory map of a process, and a range to be read from the |  179 //! \brief Given a memory map of a process, and a range to be read from the | 
|  140 //!     target process, returns a vector of ranges, representing the readable |  180 //!     target process, returns a vector of ranges, representing the readable | 
|  141 //!     portions of the original range. |  181 //!     portions of the original range. | 
|  142 //! |  182 //! | 
|  143 //! This is a free function for testing, but prefer |  183 //! This is a free function for testing, but prefer | 
|  144 //! ProcessInfo::GetReadableRanges(). |  184 //! ProcessInfo::GetReadableRanges(). | 
|  145 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( |  185 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( | 
|  146     const CheckedRange<WinVMAddress, WinVMSize>& range, |  186     const CheckedRange<WinVMAddress, WinVMSize>& range, | 
|  147     const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); |  187     const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); | 
|  148  |  188  | 
|  149 }  // namespace crashpad |  189 }  // namespace crashpad | 
|  150  |  190  | 
|  151 #endif  // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ |  191 #endif  // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | 
| OLD | NEW |