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

Side by Side Diff: sandbox/win/tests/integration_tests/cfi_unittest_exe.cc

Issue 2693193005: [Windows MSVC CFG] Turning on linker CFG for all. Removing CFG compile. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « sandbox/win/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include <windows.h> 4 #include <windows.h>
5 5
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/scoped_native_library.h" 7 #include "base/scoped_native_library.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // CFG exception will be thrown. 213 // CFG exception will be thrown.
214 // 214 //
215 // - The DoPatch() function then overwrites with a small, custom change. This 215 // - The DoPatch() function then overwrites with a small, custom change. This
216 // change will simply add 16 (0x10) to the real function address in EAX/RAX 216 // change will simply add 16 (0x10) to the real function address in EAX/RAX
217 // about to be checked. This will maintain the 16-byte alignment required in 217 // about to be checked. This will maintain the 16-byte alignment required in
218 // a target address by CFG, but also ensure that it fails the check. 218 // a target address by CFG, but also ensure that it fails the check.
219 // 219 //
220 // The whole purpose of this unittest is to ensure that a failed CFG check in 220 // The whole purpose of this unittest is to ensure that a failed CFG check in
221 // a Microsoft binary results in an exception. If CFG is not properly 221 // a Microsoft binary results in an exception. If CFG is not properly
222 // enabled for a process, no exception will be thrown. 222 // enabled for a process, no exception will be thrown.
223 // This test EXE is built with 223 // All Chromium projects should be linked with "common_linker_setup" config
224 // configs += [ "//build/config/win:win_msvc_cfg" ] 224 // (build\config\win\BUILD.gn), which should result in CFG enabled on the
225 // which should result in CFG enabled on the process. 225 // process.
226 // 226 //
227 // - The patches (x86 or x64) were carefully constructed to be valid and not 227 // - The patches (x86 or x64) were carefully constructed to be valid and not
228 // mess up the executing instructions. Need to ensure that the CFG check 228 // mess up the executing instructions. Need to ensure that the CFG check
229 // fully happens, and that nothing else goes wrong before OR AFTER that 229 // fully happens, and that nothing else goes wrong before OR AFTER that
230 // point. The only exception expected is a very intentional one. 230 // point. The only exception expected is a very intentional one.
231 // **The patches also allow the call to GetSystemMetrics to SUCCEED if CFG is 231 // **The patches also allow the call to GetSystemMetrics to SUCCEED if CFG is
232 // NOT enabled for the process! This makes for very clear behaviour. 232 // NOT enabled for the process! This makes for very clear behaviour.
233 void TestMsIndirect() { 233 void TestMsIndirect() {
234 base::ScopedNativeLibrary user32(base::FilePath(L"user32.dll")); 234 base::ScopedNativeLibrary user32(base::FilePath(L"user32.dll"));
235 if (!user32.is_valid()) 235 if (!user32.is_valid())
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 case 1: 286 case 1:
287 TestMsIndirect(); 287 TestMsIndirect();
288 break; 288 break;
289 // Unsupported argument. 289 // Unsupported argument.
290 default: 290 default:
291 _exit(-1); 291 _exit(-1);
292 } 292 }
293 293
294 return 0; 294 return 0;
295 } 295 }
OLDNEW
« no previous file with comments | « sandbox/win/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698