Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: base/file_util_win.cc

Issue 2805064: Changing the pre-reading of chrome.dll to read it as an image section instead... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util.h ('k') | chrome/app/client_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <propvarutil.h> 8 #include <propvarutil.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 #include <time.h> 12 #include <time.h>
13 #include <string> 13 #include <string>
14 14
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/pe_image.h"
17 #include "base/scoped_comptr_win.h" 18 #include "base/scoped_comptr_win.h"
18 #include "base/scoped_handle.h" 19 #include "base/scoped_handle.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "base/time.h" 21 #include "base/time.h"
21 #include "base/win_util.h" 22 #include "base/win_util.h"
22 23
23 namespace file_util { 24 namespace file_util {
24 25
25 namespace { 26 namespace {
26 27
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 // "\Device\Harddisk...". Helper DevicePathToDriveLetterPath() 1027 // "\Device\Harddisk...". Helper DevicePathToDriveLetterPath()
1027 // will find a drive letter which maps to the path's device, so 1028 // will find a drive letter which maps to the path's device, so
1028 // that we return a path starting with a drive letter. 1029 // that we return a path starting with a drive letter.
1029 FilePath mapped_file(mapped_file_path); 1030 FilePath mapped_file(mapped_file_path);
1030 success = DevicePathToDriveLetterPath(mapped_file, real_path); 1031 success = DevicePathToDriveLetterPath(mapped_file, real_path);
1031 } 1032 }
1032 UnmapViewOfFile(file_view); 1033 UnmapViewOfFile(file_view);
1033 return success; 1034 return success;
1034 } 1035 }
1035 1036
1037 bool PreReadImage(const wchar_t* file_path, size_t size_to_read,
1038 size_t step_size) {
1039 HMODULE dll_module = LoadLibraryExW(
1040 file_path,
1041 NULL,
1042 LOAD_WITH_ALTERED_SEARCH_PATH | DONT_RESOLVE_DLL_REFERENCES);
1043
1044 if (!dll_module)
1045 return false;
1046
1047 PEImage pe_image(dll_module);
1048 PIMAGE_NT_HEADERS nt_headers = pe_image.GetNTHeaders();
1049 size_t actual_size_to_read = size_to_read ? size_to_read :
1050 nt_headers->OptionalHeader.SizeOfImage;
1051 volatile uint8* touch = reinterpret_cast<uint8*>(dll_module);
1052 size_t offset = 0;
1053 while (offset < actual_size_to_read) {
1054 uint8 unused = *(touch + offset);
1055 offset += step_size;
1056 }
1057 FreeLibrary(dll_module);
1058 return true;
1059 }
1060
1036 } // namespace file_util 1061 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | chrome/app/client_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698