-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test to verify delay load hooks work for chrome.dll.
This test triggers the delay load hooks on child processes by triggering the failed delay load of a DLL from within a sandboxed utility process. The DLL was chosen by examining delay load imports in //build/config/win:delayloads and then picking an imported function that was never called in a sandboxed process. This adds the missing test from crrev.com/c/3626221. BUG=1322217 Change-Id: Ia77521257b364c4a0323f4b20580e5449858eb32 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3633247 Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Will Harris <wfh@chromium.org> Cr-Commit-Position: refs/heads/main@{#1001079}
- Loading branch information
Will Harris
authored and
Chromium LUCI CQ
committed
May 9, 2022
1 parent
bd0488a
commit 80db05b
Showing
9 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <windows.h> | ||
|
||
#include "base/run_loop.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "content/public/browser/browser_child_process_observer.h" | ||
#include "content/public/browser/child_process_data.h" | ||
#include "content/public/browser/child_process_termination_info.h" | ||
#include "content/public/browser/service_process_host.h" | ||
#include "content/public/browser/service_process_info.h" | ||
#include "content/public/test/browser_test.h" | ||
#include "services/test/echo/public/mojom/echo.mojom.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace chrome { | ||
|
||
using ChromeDelayLoadHookTest = InProcessBrowserTest; | ||
|
||
class EchoServiceProcessObserver : public content::ServiceProcessHost::Observer, | ||
public content::BrowserChildProcessObserver { | ||
public: | ||
EchoServiceProcessObserver() { | ||
content::ServiceProcessHost::AddObserver(this); | ||
content::BrowserChildProcessObserver::Add(this); | ||
} | ||
|
||
EchoServiceProcessObserver(const EchoServiceProcessObserver&) = delete; | ||
EchoServiceProcessObserver& operator=(const EchoServiceProcessObserver&) = | ||
delete; | ||
|
||
~EchoServiceProcessObserver() override { | ||
content::BrowserChildProcessObserver::Remove(this); | ||
content::ServiceProcessHost::RemoveObserver(this); | ||
} | ||
|
||
void WaitForLaunch() { launch_loop_.Run(); } | ||
|
||
int WaitForCrash() { | ||
crash_loop_.Run(); | ||
return exit_code_; | ||
} | ||
|
||
private: | ||
// content::ServiceProcessHost::Observer: | ||
void OnServiceProcessLaunched( | ||
const content::ServiceProcessInfo& info) override { | ||
if (info.IsService<echo::mojom::EchoService>()) | ||
launch_loop_.Quit(); | ||
} | ||
|
||
// content::BrowserChildProcessObserver: | ||
void BrowserChildProcessCrashed( | ||
const content::ChildProcessData& data, | ||
const content::ChildProcessTerminationInfo& info) override { | ||
if (data.metrics_name == echo::mojom::EchoService::Name_) { | ||
exit_code_ = info.exit_code; | ||
crash_loop_.Quit(); | ||
} | ||
} | ||
|
||
int exit_code_; | ||
base::RunLoop launch_loop_; | ||
base::RunLoop crash_loop_; | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(ChromeDelayLoadHookTest, ObserveDelayLoadFailure) { | ||
EchoServiceProcessObserver observer; | ||
auto echo_service = | ||
content::ServiceProcessHost::Launch<echo::mojom::EchoService>(); | ||
observer.WaitForLaunch(); | ||
echo_service->DelayLoad(); | ||
int exit_code = observer.WaitForCrash(); | ||
EXPECT_EQ(EXCEPTION_BREAKPOINT, static_cast<DWORD>(exit_code)); | ||
} | ||
|
||
} // namespace chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters