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