OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/child/pdf_child_init.h" | 5 #include "chrome/child/pdf_child_init.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 DWORD offset, | 36 DWORD offset, |
37 LPVOID buffer, | 37 LPVOID buffer, |
38 DWORD length); | 38 DWORD length); |
39 GetFontDataPtr g_original_get_font_data = NULL; | 39 GetFontDataPtr g_original_get_font_data = NULL; |
40 static base::win::IATPatchFunction g_iat_patch_get_font_data; | 40 static base::win::IATPatchFunction g_iat_patch_get_font_data; |
41 DWORD WINAPI GetFontDataPatch(HDC hdc, | 41 DWORD WINAPI GetFontDataPatch(HDC hdc, |
42 DWORD table, | 42 DWORD table, |
43 DWORD offset, | 43 DWORD offset, |
44 LPVOID buffer, | 44 LPVOID buffer, |
45 DWORD length) { | 45 DWORD length) { |
46 int rv = g_original_get_font_data(hdc, table, offset, buffer, length); | 46 DWORD rv = g_original_get_font_data(hdc, table, offset, buffer, length); |
47 if (rv == GDI_ERROR && hdc) { | 47 if (rv == GDI_ERROR && hdc) { |
48 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); | 48 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); |
49 | 49 |
50 LOGFONT logfont; | 50 LOGFONT logfont; |
51 if (GetObject(font, sizeof(LOGFONT), &logfont)) { | 51 if (GetObject(font, sizeof(LOGFONT), &logfont)) { |
52 std::vector<char> font_data; | 52 std::vector<char> font_data; |
53 if (content::ChildThread::Get()) | 53 if (content::ChildThread::Get()) |
54 content::ChildThread::Get()->PreCacheFont(logfont); | 54 content::ChildThread::Get()->PreCacheFont(logfont); |
55 rv = g_original_get_font_data(hdc, table, offset, buffer, length); | 55 rv = g_original_get_font_data(hdc, table, offset, buffer, length); |
56 if (content::ChildThread::Get()) | 56 if (content::ChildThread::Get()) |
(...skipping 22 matching lines...) Expand all Loading... |
79 g_iat_patch_createdca.Patch(current_module_name, "gdi32.dll", "CreateDCA", | 79 g_iat_patch_createdca.Patch(current_module_name, "gdi32.dll", "CreateDCA", |
80 CreateDCAPatch); | 80 CreateDCAPatch); |
81 g_iat_patch_get_font_data.Patch(current_module_name, "gdi32.dll", | 81 g_iat_patch_get_font_data.Patch(current_module_name, "gdi32.dll", |
82 "GetFontData", GetFontDataPatch); | 82 "GetFontData", GetFontDataPatch); |
83 g_original_get_font_data = reinterpret_cast<GetFontDataPtr>( | 83 g_original_get_font_data = reinterpret_cast<GetFontDataPtr>( |
84 g_iat_patch_get_font_data.original_function()); | 84 g_iat_patch_get_font_data.original_function()); |
85 #endif // OS_WIN | 85 #endif // OS_WIN |
86 } | 86 } |
87 | 87 |
88 } // namespace chrome | 88 } // namespace chrome |
OLD | NEW |