| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "sandbox/win/sandbox_poc/main_ui_window.h" | 5 #include "sandbox/win/sandbox_poc/main_ui_window.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <CommCtrl.h> | 8 #include <CommCtrl.h> |
| 9 #include <commdlg.h> | 9 #include <commdlg.h> |
| 10 #include <stdarg.h> | 10 #include <stdarg.h> |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 return false; | 493 return false; |
| 494 } | 494 } |
| 495 | 495 |
| 496 wchar_t * arguments = new wchar_t[size_call]; | 496 wchar_t * arguments = new wchar_t[size_call]; |
| 497 wnsprintf(arguments, static_cast<int>(size_call), L"%ls %ls \"%ls\" %ls", | 497 wnsprintf(arguments, static_cast<int>(size_call), L"%ls %ls \"%ls\" %ls", |
| 498 spawn_target_.c_str(), entry_point_.c_str(), | 498 spawn_target_.c_str(), entry_point_.c_str(), |
| 499 dll_path_.c_str(), log_pipe); | 499 dll_path_.c_str(), log_pipe); |
| 500 | 500 |
| 501 arguments[size_call - 1] = L'\0'; | 501 arguments[size_call - 1] = L'\0'; |
| 502 | 502 |
| 503 sandbox::TargetPolicy* policy = broker_->CreatePolicy(); | 503 scoped_refptr<sandbox::TargetPolicy> policy = broker_->CreatePolicy(); |
| 504 policy->SetJobLevel(sandbox::JOB_LOCKDOWN, 0); | 504 policy->SetJobLevel(sandbox::JOB_LOCKDOWN, 0); |
| 505 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, | 505 policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, |
| 506 sandbox::USER_LOCKDOWN); | 506 sandbox::USER_LOCKDOWN); |
| 507 policy->SetAlternateDesktop(true); | 507 policy->SetAlternateDesktop(true); |
| 508 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); | 508 policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); |
| 509 | 509 |
| 510 // Set the rule to allow the POC dll to be loaded by the target. Note that | 510 // Set the rule to allow the POC dll to be loaded by the target. Note that |
| 511 // the rule allows 'all access' to the DLL, which could mean that the target | 511 // the rule allows 'all access' to the DLL, which could mean that the target |
| 512 // could modify the DLL on disk. | 512 // could modify the DLL on disk. |
| 513 policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, | 513 policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, |
| 514 sandbox::TargetPolicy::FILES_ALLOW_ANY, dll_path_.c_str()); | 514 sandbox::TargetPolicy::FILES_ALLOW_ANY, dll_path_.c_str()); |
| 515 | 515 |
| 516 sandbox::ResultCode warning_result = sandbox::SBOX_ALL_OK; | 516 sandbox::ResultCode warning_result = sandbox::SBOX_ALL_OK; |
| 517 DWORD last_error = ERROR_SUCCESS; | 517 DWORD last_error = ERROR_SUCCESS; |
| 518 sandbox::ResultCode result = | 518 sandbox::ResultCode result = |
| 519 broker_->SpawnTarget(spawn_target_.c_str(), arguments, policy, | 519 broker_->SpawnTarget(spawn_target_.c_str(), arguments, policy, |
| 520 &warning_result, &last_error, &target_); | 520 &warning_result, &last_error, &target_); |
| 521 | 521 |
| 522 policy->Release(); | |
| 523 policy = NULL; | 522 policy = NULL; |
| 524 | 523 |
| 525 bool return_value = false; | 524 bool return_value = false; |
| 526 if (sandbox::SBOX_ALL_OK != result) { | 525 if (sandbox::SBOX_ALL_OK != result) { |
| 527 AddDebugMessage( | 526 AddDebugMessage( |
| 528 L"Failed to spawn target %ls w/args (%ls), sandbox error code: %d", | 527 L"Failed to spawn target %ls w/args (%ls), sandbox error code: %d", |
| 529 spawn_target_.c_str(), arguments, result); | 528 spawn_target_.c_str(), arguments, result); |
| 530 return_value = false; | 529 return_value = false; |
| 531 } else { | 530 } else { |
| 532 DWORD thread_id; | 531 DWORD thread_id; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 item.iItem = ListView_GetItemCount(list_view_); | 655 item.iItem = ListView_GetItemCount(list_view_); |
| 657 item.iSubItem = 0; | 656 item.iSubItem = 0; |
| 658 item.mask = LVIF_TEXT | LVIF_PARAM; | 657 item.mask = LVIF_TEXT | LVIF_PARAM; |
| 659 item.pszText = message_time; | 658 item.pszText = message_time; |
| 660 item.lParam = 0; | 659 item.lParam = 0; |
| 661 | 660 |
| 662 ListView_InsertItem(list_view_, &item); | 661 ListView_InsertItem(list_view_, &item); |
| 663 | 662 |
| 664 delete[] message_time; | 663 delete[] message_time; |
| 665 } | 664 } |
| OLD | NEW |