OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_SRC_SANDBOX_UTILS_H__ | 5 #ifndef SANDBOX_SRC_SANDBOX_UTILS_H__ |
6 #define SANDBOX_SRC_SANDBOX_UTILS_H__ | 6 #define SANDBOX_SRC_SANDBOX_UTILS_H__ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "sandbox/src/nt_internals.h" | 12 #include "sandbox/win/src/nt_internals.h" |
13 | 13 |
14 namespace sandbox { | 14 namespace sandbox { |
15 | 15 |
16 typedef BOOL (WINAPI* GetModuleHandleExFunction)(DWORD flags, | 16 typedef BOOL (WINAPI* GetModuleHandleExFunction)(DWORD flags, |
17 LPCWSTR module_name, | 17 LPCWSTR module_name, |
18 HMODULE* module); | 18 HMODULE* module); |
19 | 19 |
20 // Windows XP provides a nice function in kernel32.dll called GetModuleHandleEx | 20 // Windows XP provides a nice function in kernel32.dll called GetModuleHandleEx |
21 // This function allows us to verify if a function exported by the module | 21 // This function allows us to verify if a function exported by the module |
22 // lies in the module itself. | 22 // lies in the module itself. |
23 // As we need compatibility with windows 2000, we cannot use this function | 23 // As we need compatibility with windows 2000, we cannot use this function |
24 // by calling it by name. This helper function checks if the GetModuleHandleEx | 24 // by calling it by name. This helper function checks if the GetModuleHandleEx |
25 // function is exported by kernel32 and uses it, otherwise, implemets part of | 25 // function is exported by kernel32 and uses it, otherwise, implemets part of |
26 // the functionality exposed by GetModuleHandleEx. | 26 // the functionality exposed by GetModuleHandleEx. |
27 bool GetModuleHandleHelper(DWORD flags, const wchar_t* module_name, | 27 bool GetModuleHandleHelper(DWORD flags, const wchar_t* module_name, |
28 HMODULE* module); | 28 HMODULE* module); |
29 | 29 |
30 // Returns true if the current OS is Windows XP SP2 or later. | 30 // Returns true if the current OS is Windows XP SP2 or later. |
31 bool IsXPSP2OrLater(); | 31 bool IsXPSP2OrLater(); |
32 | 32 |
33 void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root, | 33 void InitObjectAttribs(const std::wstring& name, ULONG attributes, HANDLE root, |
34 OBJECT_ATTRIBUTES* obj_attr, UNICODE_STRING* uni_name); | 34 OBJECT_ATTRIBUTES* obj_attr, UNICODE_STRING* uni_name); |
35 | 35 |
36 }; // namespace sandbox | 36 }; // namespace sandbox |
37 | 37 |
38 #endif // SANDBOX_SRC_SANDBOX_UTILS_H__ | 38 #endif // SANDBOX_SRC_SANDBOX_UTILS_H__ |
OLD | NEW |