1 : // Copyright 2012 Google Inc. 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 : // This file declares the trace::service::ProcessInfo class which
16 : // retrieves and encapsulates the process related information captured
17 : // within a trace file.
18 :
19 : #ifndef SYZYGY_TRACE_SERVICE_PROCESS_INFO_H_
20 : #define SYZYGY_TRACE_SERVICE_PROCESS_INFO_H_
21 :
22 : #include <windows.h>
23 : #include <string>
24 :
25 : #include "base/basictypes.h"
26 : #include "base/files/file_path.h"
27 : #include "base/win/scoped_handle.h"
28 :
29 m : namespace trace {
30 m : namespace service {
31 :
32 : // This class retrieves and encapsulates the process related information
33 : // captured within a trace file. This needs to be a superset of
34 : // sawbuck::sym_util::ModuleInfo, which contains the minimum amount of
35 : // information necessary for uniquely identifying a PE file, and the PDB file
36 : // referring to it. This is necessary to allow us to match events up to modules
37 : // when parsing call trace logs.
38 : //
39 : // Usage:
40 : //
41 : // trace::service::ProcessInfo info;
42 : // if (!info.Initialize(some_pid)) {
43 : // LOG(ERROR) << "Failed to retrieve process info.";
44 : // } else {
45 : // LOG(INF0) << "Process ID = " << info.process_id;
46 : // LOG(INFO) << "Executable = " << info.exectuable_path;
47 : // LOG(INFO) << "Command Line = " << info.command_line;
48 : // LOG(INFO) << "Base Address = " << info.exe_base_address;
49 : // LOG(INFO) << "Image Size = " << info.exe_image_size;
50 : // LOG(INFO) << "Image Checksum = " << info.exe_checksum;
51 : // LOG(INFO) << "Image Time/Date Stamp = " << info.exe_time_date_stamp;
52 : // }
53 m : struct ProcessInfo {
54 m : public:
55 m : ProcessInfo();
56 m : ~ProcessInfo();
57 :
58 : // Retrieves all the relevant process info concerning @p pid, returning
59 : // true on success.
60 m : bool Initialize(uint32 pid);
61 :
62 : // Return this ProcessInfo struct to the state it had just following
63 : // construction.
64 m : void Reset();
65 :
66 : // A handle to the process;
67 m : base::win::ScopedHandle process_handle;
68 :
69 : // The process ID;
70 m : uint32 process_id;
71 :
72 : // The full path to the executable for the process.
73 m : base::FilePath executable_path;
74 :
75 : // The command line for the process.
76 m : std::wstring command_line;
77 :
78 : // The environment block of the process. This is a sequence of wide strings,
79 : // each of which is terminated by a single NULL. The entire sequence is
80 : // terminated by a double NULL.
81 m : std::vector<wchar_t> environment;
82 :
83 : // System information.
84 m : OSVERSIONINFOEX os_version_info;
85 m : SYSTEM_INFO system_info;
86 m : MEMORYSTATUSEX memory_status;
87 :
88 : // The base address at which the executable image is currently loaded.
89 m : uint32 exe_base_address;
90 :
91 : // The size of the executable image loaded at exe_base_address.
92 m : uint32 exe_image_size;
93 :
94 : // The checksum of the executable, taken from the NT headers.
95 m : uint32 exe_checksum;
96 :
97 : // The time/date stamp of the executable, taken from the NT headers.
98 m : uint32 exe_time_date_stamp;
99 :
100 m : private:
101 m : DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
102 m : };
103 :
104 m : } // namespace service
105 m : } // namespace trace
106 :
107 : #endif // SYZYGY_TRACE_SERVICE_PROCESS_INFO_H_
|