forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Chrome service for recovery component elevation.
* Service module and COM registration implementation. * Various entry points and build files. Design document: Design document link will be added to the linked bug soon. Bug: 833687 Change-Id: I195a42786e60b2565ba49ba4dd87e5ae4288af7f Reviewed-on: https://chromium-review.googlesource.com/1014723 Commit-Queue: S. Ganesh <ganesh@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Sorin Jianu <sorin@chromium.org> Reviewed-by: Greg Thompson <grt@chromium.org> Cr-Commit-Position: refs/heads/master@{#560923}
- Loading branch information
1 parent
4c41058
commit f173408
Showing
39 changed files
with
2,385 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Copyright 2018 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. | ||
|
||
import("//build/config/chrome_build.gni") | ||
import("//build/toolchain/win/midl.gni") | ||
import("//chrome/process_version_rc_template.gni") | ||
import("//testing/test.gni") | ||
|
||
midl("elevation_service_idl") { | ||
sources = [ | ||
"elevation_service_idl.idl", | ||
] | ||
} | ||
|
||
# Must be in a config because of how GN orders flags (otherwise /W4 will appear | ||
# after this, and turn it back on). | ||
config("no-missing-braces") { | ||
# Macros invoked by WRL CoCreatableClass omit optional braces. | ||
cflags = [ "-Wno-missing-braces" ] | ||
} | ||
|
||
# This service needs to work with Windows 7, so explicitly setting the defines | ||
# to reflect this. Otherwise, WRL uses APIs that are only available in later | ||
# Windows versions. | ||
config("winver") { | ||
defines = [ | ||
"NTDDI_VERSION=NTDDI_WIN7", | ||
"_WIN32_WINNT=_WIN32_WINNT_WIN7", | ||
"WINVER=_WIN32_WINNT_WIN7", | ||
] | ||
} | ||
|
||
executable("elevation_service") { | ||
sources = [ | ||
"elevation_service.cc", | ||
"elevation_service.rc", | ||
] | ||
|
||
configs -= [ "//build/config/win:console" ] | ||
configs += [ "//build/config/win:windowed" ] | ||
configs += [ ":no-missing-braces" ] | ||
configs -= [ "//build/config/win:winver" ] | ||
configs += [ ":winver" ] | ||
|
||
deps = [ | ||
":lib", | ||
":version_resources", | ||
"//base", | ||
"//build/win:default_exe_manifest", | ||
"//chrome/install_static:primary_module", | ||
] | ||
|
||
} | ||
|
||
source_set("lib") { | ||
visibility = [ ":*" ] | ||
|
||
public = [ | ||
"elevator.h", | ||
"service_main.h", | ||
] | ||
|
||
sources = [ | ||
"elevator.cc", | ||
"service_main.cc", | ||
] | ||
|
||
configs += [ ":no-missing-braces" ] | ||
configs -= [ "//build/config/win:winver" ] | ||
configs += [ ":winver" ] | ||
|
||
public_deps = [ | ||
":elevation_service_idl", | ||
"//base", | ||
] | ||
|
||
deps = [ | ||
"//chrome/install_static:install_static_util", | ||
] | ||
} | ||
|
||
process_version_rc_template("version_resources") { | ||
sources = [ | ||
"elevation_service_exe.ver", | ||
] | ||
output = "$target_gen_dir/elevation_service_exe.rc" | ||
} | ||
|
||
test("elevation_service_unittests") { | ||
sources = [ | ||
"run_all_unittests.cc", | ||
"service_main_unittest.cc", | ||
] | ||
|
||
configs -= [ "//build/config/win:winver" ] | ||
configs += [ ":winver" ] | ||
|
||
deps = [ | ||
":lib", | ||
"//base", | ||
"//base/test:test_support", | ||
"//chrome/install_static:install_static_util", | ||
"//chrome/install_static/test:test_support", | ||
"//testing/gtest", | ||
] | ||
|
||
data_deps = [ | ||
":elevation_service", | ||
] | ||
} |
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,4 @@ | ||
include_rules = [ | ||
"+base", | ||
"+chrome/install_static", | ||
] |
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,3 @@ | ||
ganesh@chromium.org | ||
xiaolingbao@chromium.org | ||
sorin@chromium.org |
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,4 @@ | ||
This directory contains the code for a COM server that handles elevation | ||
requests. This code is compiled into an executable named elevation_service.exe. | ||
|
||
This is a standalone executable. |
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,53 @@ | ||
// Copyright 2018 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/at_exit.h" | ||
#include "base/command_line.h" | ||
#include "base/logging.h" | ||
#include "base/process/memory.h" | ||
#include "base/win/process_startup_helper.h" | ||
#include "base/win/scoped_com_initializer.h" | ||
#include "chrome/elevation_service/service_main.h" | ||
#include "chrome/install_static/product_install_details.h" | ||
|
||
extern "C" int WINAPI wWinMain(HINSTANCE instance, | ||
HINSTANCE prev_instance, | ||
base::char16* command_line, | ||
int show_command) { | ||
// Initialize the CommandLine singleton from the environment. | ||
base::CommandLine::Init(0, nullptr); | ||
|
||
logging::LoggingSettings settings; | ||
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | ||
logging::InitLogging(settings); | ||
|
||
// The exit manager is in charge of calling the dtors of singletons. | ||
base::AtExitManager exit_manager; | ||
|
||
install_static::InitializeProductDetailsForPrimaryModule(); | ||
|
||
// Make sure the process exits cleanly on unexpected errors. | ||
base::EnableTerminationOnHeapCorruption(); | ||
base::EnableTerminationOnOutOfMemory(); | ||
base::win::RegisterInvalidParamHandler(); | ||
base::win::SetupCRT(*base::CommandLine::ForCurrentProcess()); | ||
|
||
// Initialize COM for the current thread. | ||
base::win::ScopedCOMInitializer com_initializer( | ||
base::win::ScopedCOMInitializer::kMTA); | ||
if (!com_initializer.Succeeded()) { | ||
PLOG(ERROR) << "Failed to initialize COM"; | ||
return -1; | ||
} | ||
|
||
// Run the COM service. | ||
elevation_service::ServiceMain* service = | ||
elevation_service::ServiceMain::GetInstance(); | ||
if (!service->InitWithCommandLine(base::CommandLine::ForCurrentProcess())) | ||
return -1; | ||
|
||
return service->Start(); | ||
} |
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,37 @@ | ||
// Microsoft Visual C++ generated resource script. | ||
// | ||
|
||
#define APSTUDIO_READONLY_SYMBOLS | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 2 resource. | ||
// | ||
#include "winres.h" | ||
#include "verrsrc.h" | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#undef APSTUDIO_READONLY_SYMBOLS | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// English (United States) resources | ||
|
||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
|
||
#ifdef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// TEXTINCLUDE | ||
// | ||
|
||
1 TEXTINCLUDE | ||
BEGIN | ||
"#include ""winres.h""\r\n" | ||
"#include ""verrsrc.h""\r\n" | ||
"\0" | ||
END | ||
|
||
#endif // APSTUDIO_INVOKED | ||
|
||
#endif // English (United States) resources | ||
///////////////////////////////////////////////////////////////////////////// |
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,2 @@ | ||
INTERNAL_NAME=elevation_service_exe | ||
ORIGINAL_FILENAME=elevation_service.exe |
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,36 @@ | ||
// Copyright 2018 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. | ||
|
||
import "oaidl.idl"; | ||
import "ocidl.idl"; | ||
|
||
[ | ||
object, | ||
oleautomation, | ||
uuid(A949CB4E-C4F9-44C4-B213-6BF8AA9AC69C), | ||
helpstring("IRegisteredCommandElevator Interface"), | ||
pointer_default(unique) | ||
] | ||
interface IRegisteredCommandElevator : IUnknown | ||
{ | ||
// Runs a command elevated. | ||
// | ||
// @param event_id Unique id for the command | ||
// @param caller_proc_id The process id of the calling process | ||
// @param proc_handle The process handle valid in the caller's context | ||
HRESULT LaunchCommand([in, string] const WCHAR* cmd_id, | ||
[in] DWORD caller_proc_id, | ||
[out] ULONG_PTR* proc_handle); | ||
}; | ||
|
||
[ | ||
uuid(0014D784-7012-4A79-8AB6-ADDB8193A06E), | ||
version(1.0), | ||
helpstring("Elevator 1.0 Type Library") | ||
] | ||
library ElevatorLib { | ||
importlib("stdole2.tlb"); | ||
|
||
interface IRegisteredCommandElevator; | ||
}; |
Oops, something went wrong.