OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (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 | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | |
16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | |
17 | |
18 #include <basetsd.h> | |
19 #include <sys/types.h> | |
20 #include <windows.h> | |
21 #include <winternl.h> | |
22 | |
23 #include <string> | |
24 #include <vector> | |
25 | |
26 #include "base/basictypes.h" | |
27 #include "util/misc/initialization_state_dcheck.h" | |
28 | |
29 namespace crashpad { | |
30 | |
31 namespace internal { | |
32 | |
33 //! \brief This structure matches PROCESS_BASIC_INFORMATION in winternl.h but | |
34 //! gives names to the Reserved fields (matching the WDK's ntddk.h). | |
35 struct FULL_PROCESS_BASIC_INFORMATION { | |
36 NTSTATUS ExitStatus; | |
37 PPEB PebBaseAddress; | |
38 KAFFINITY AffinityMask; | |
39 PVOID BasePriority; | |
40 ULONG UniqueProcessId; | |
41 ULONG InheritedFromUniqueProcessId; | |
42 }; | |
43 | |
44 } // namespace internal | |
45 | |
46 //! \brief Gathers about a process given its `HANDLE`. This consists primarily | |
Mark Mentovai
2015/03/06 03:40:23
Missing a word.
scottmg
2015/03/06 06:04:07
Done.
| |
47 //! of information stored in the Process Environment Block. | |
48 class ProcessInfo { | |
49 public: | |
50 ProcessInfo(); | |
51 ~ProcessInfo(); | |
52 | |
53 //! \brief Initializes this object with information about the given | |
54 //! \a process. | |
55 //! | |
56 //! This method must be called successfully prior to calling any other | |
57 //! method in this class. This method may only be called once. | |
58 //! | |
59 //! \return `true` on success, `false` on failure with a message logged. | |
60 bool Initialize(HANDLE process); | |
61 | |
62 //! \return `true` if the target process is a 64-bit process. | |
63 bool Is64Bit() const; | |
64 | |
65 //! \return `true` if the target process is running on the Win32-on-Win64 | |
66 //! subsystem. | |
67 bool IsWow64() const; | |
68 | |
69 //! \return The target process's process ID. | |
70 pid_t ProcessID() const; | |
71 | |
72 //! \return The target process's parent process ID. | |
73 pid_t ParentProcessID() const; | |
74 | |
75 //! \return The command line from the target process's Process Environment | |
76 //! Block. | |
77 bool CommandLine(std::wstring* command_line) const; | |
78 | |
79 //! \brief Retrieves the modules loaded into the target process. | |
80 //! | |
81 //! The modules are enumerated in initialization order as detailed in the | |
82 //! Process Environment Block. The main executable will always be the | |
83 //! first element. | |
84 bool Modules(std::vector<std::wstring>* modules) const; | |
85 | |
86 private: | |
87 internal::FULL_PROCESS_BASIC_INFORMATION process_basic_information_; | |
88 std::wstring command_line_; | |
89 std::vector<std::wstring> modules_; | |
90 bool is_64_bit_; | |
91 bool is_wow64_; | |
92 InitializationStateDcheck initialized_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); | |
95 }; | |
96 | |
97 } // namespace crashpad | |
98 | |
99 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ | |
OLD | NEW |