blob: ae1bce6ed74f83172684a76673063ba6535ceb39 [file] [log] [blame]
// Copyright 2008-2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================
//
// Contains ProcessLauncher class to launch a process using a COM interface. The
// COM object is typically created by the caller as a medium integrity object
// impersonating the identity of the active user. This is to allow for launching
// a medium-integrity process from a high-integrity process.
// TODO(omaha): consider renaming of the source files to match their purpose.
#ifndef OMAHA_GOOPDATE_BROWSER_LAUNCHER_H__
#define OMAHA_GOOPDATE_BROWSER_LAUNCHER_H__
#include <windows.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlstr.h>
#include "omaha/common/atlregmapex.h"
#include "omaha/common/const_cmd_line.h"
#include "omaha/goopdate/const_goopdate.h"
#include "omaha/goopdate/goopdate_utils.h"
#include "omaha/goopdate/resource.h"
// Generated by MIDL in the "BUILD_MODE.OBJ_ROOT + SETTINGS.SUBDIR".
#include "goopdate/google_update_idl.h"
namespace omaha {
const TCHAR* const kThreadingBoth = _T("Both");
const TCHAR* const kTlbVersion = _T("1.0");
const TCHAR* const kProcessWorkerProgId =
_T("GoogleUpdateProcessLauncher");
const TCHAR* const kProcessWorkerDescription =
_T("Google Update Process Launcher Class");
class ATL_NO_VTABLE ProcessLauncher
: public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<ProcessLauncher, &__uuidof(ProcessLauncherClass)>,
public IProcessLauncher {
public:
ProcessLauncher();
virtual ~ProcessLauncher();
DECLARE_NOT_AGGREGATABLE(ProcessLauncher)
DECLARE_PROTECT_FINAL_CONSTRUCT()
DECLARE_REGISTRY_RESOURCEID_EX(IDR_GOOGLE_UPDATE_WORKER_CLASS)
#pragma warning(push)
// C4640: construction of local static object is not thread-safe
#pragma warning(disable : 4640)
BEGIN_REGISTRY_MAP()
REGMAP_ENTRY(_T("HKROOT"), goopdate_utils::GetHKRoot())
REGMAP_ENTRY(_T("THREADING"), kThreadingBoth)
REGMAP_EXE_MODULE(_T("MODULE"))
REGMAP_ENTRY(_T("VERSION"), kTlbVersion)
REGMAP_ENTRY(_T("PROGID"), kProcessWorkerProgId)
REGMAP_ENTRY(_T("DESCRIPTION"), kProcessWorkerDescription)
REGMAP_UUID(_T("CLSID"), __uuidof(ProcessLauncherClass))
REGMAP_UUID(_T("LIBID"), LIBID_GoogleUpdateLib)
END_REGISTRY_MAP()
#pragma warning(pop)
// C4505: unreferenced IUnknown local functions have been removed
#pragma warning(disable : 4505)
BEGIN_COM_MAP(ProcessLauncher)
COM_INTERFACE_ENTRY(IProcessLauncher)
END_COM_MAP()
// Launches a command line at medium integrity.
STDMETHOD(LaunchCmdLine)(const TCHAR* cmd_line);
// Launches the appropriate browser.
STDMETHOD(LaunchBrowser)(DWORD type, const TCHAR* url);
// Launches a command line elevated.
STDMETHOD(LaunchCmdElevated)(const WCHAR* app_guid,
const WCHAR* cmd_id,
DWORD caller_proc_id,
ULONG_PTR* proc_handle);
private:
DISALLOW_EVIL_CONSTRUCTORS(ProcessLauncher);
};
} // namespace omaha
#endif // OMAHA_GOOPDATE_BROWSER_LAUNCHER_H__