OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_ | 5 #ifndef CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_ |
6 #define CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_ | 6 #define CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "chrome_elf/chrome_elf_types.h" | 10 #include "chrome_elf/chrome_elf_types.h" |
11 | 11 |
12 // A CreateFileW replacement that will call NTCreateFile directly when the | 12 // A CreateFileW replacement that will call NTCreateFile directly when the |
13 // criteria defined in ShouldBypass() are satisfied for |lp_file_name|. | 13 // criteria defined in ShouldBypass() are satisfied for |lp_file_name|. |
14 extern "C" HANDLE WINAPI CreateFileWRedirect( | 14 extern "C" HANDLE WINAPI CreateFileWRedirect( |
15 LPCWSTR file_name, | 15 LPCWSTR file_name, |
16 DWORD desired_access, | 16 DWORD desired_access, |
17 DWORD share_mode, | 17 DWORD share_mode, |
18 LPSECURITY_ATTRIBUTES security_attributes, | 18 LPSECURITY_ATTRIBUTES security_attributes, |
19 DWORD creation_disposition, | 19 DWORD creation_disposition, |
20 DWORD flags_and_attributes, | 20 DWORD flags_and_attributes, |
21 HANDLE template_file); | 21 HANDLE template_file); |
22 | 22 |
| 23 // Returns the count of CreateFile calls redirected so far. |
| 24 extern "C" int GetRedirectCount(); |
| 25 |
23 // Partial reimplementation of kernel32!CreateFile (very partial: only handles | 26 // Partial reimplementation of kernel32!CreateFile (very partial: only handles |
24 // reading and writing to files in the User Data directory). | 27 // reading and writing to files in the User Data directory). |
25 HANDLE CreateFileNTDLL( | 28 HANDLE CreateFileNTDLL( |
26 LPCWSTR file_name, | 29 LPCWSTR file_name, |
27 DWORD desired_access, | 30 DWORD desired_access, |
28 DWORD share_mode, | 31 DWORD share_mode, |
29 LPSECURITY_ATTRIBUTES security_attributes, | 32 LPSECURITY_ATTRIBUTES security_attributes, |
30 DWORD creation_disposition, | 33 DWORD creation_disposition, |
31 DWORD flags_and_attributes, | 34 DWORD flags_and_attributes, |
32 HANDLE template_file); | 35 HANDLE template_file); |
33 | 36 |
34 // Determines whether or not we should use our version of CreateFile, or the | 37 // Determines whether or not we should use our version of CreateFile, or the |
35 // system version (only uses ours if we're writing to the user data directory). | 38 // system version (only uses ours if we're writing to the user data directory). |
36 bool ShouldBypass(LPCWSTR file_name); | 39 bool ShouldBypass(LPCWSTR file_name); |
37 | 40 |
38 #endif // CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_ | 41 #endif // CHROME_ELF_CREATE_FILE_CHROME_CREATE_FILE_H_ |
OLD | NEW |