1 : // Copyright 2015 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 : // Process-related convenience utilities for agents.
16 :
17 : #ifndef SYZYGY_COMMON_PROCESS_UTILS_H_
18 : #define SYZYGY_COMMON_PROCESS_UTILS_H_
19 :
20 : #include <windows.h>
21 : #include <vector>
22 :
23 m : namespace common {
24 :
25 m : typedef std::vector<HMODULE> ModuleVector;
26 :
27 : // Retrieves a list of all modules in the current process.
28 : // @param modules returns a vector containing all modules in the process.
29 : // @return true if successful. Otherwise, modules is guaranteed to be empty.
30 : // @note that other threads in the process can be loading or unloading
31 : // libraries concurrently with calling this function and using its results.
32 : // Using the results from this function is therefore inherently racy, unless
33 : // running under the loader's lock, such as e.g. in a DllMain notification
34 : // or e.g. a TLS callback function.
35 m : bool GetCurrentProcessModules(ModuleVector* modules);
36 :
37 : // Retrieves a list of all modules in the specified process.
38 : // @param process the process to query.
39 : // @param modules returns a vector containing all modules in the process.
40 : // @return true if successful. Otherwise, modules is guaranteed to be empty.
41 : // @note that the process can be loading or unloading libraries concurrently
42 : // with this function and the use of its results. Using the results from
43 : // this function is therefore inherently racy.
44 m : bool GetProcessModules(HANDLE process, ModuleVector* modules);
45 :
46 m : } // namespace common
47 :
48 : #endif // SYZYGY_COMMON_PROCESS_UTILS_H_
|