forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_dll_loader_win.h
67 lines (52 loc) · 2.33 KB
/
main_dll_loader_win.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) 2012 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.
// This file defines a class to load the main DLL of a Chrome process.
#ifndef CHROME_APP_MAIN_DLL_LOADER_WIN_H_
#define CHROME_APP_MAIN_DLL_LOADER_WIN_H_
#include <windows.h> // NOLINT
#include <string>
#include "base/strings/string16.h"
namespace base {
class FilePath;
}
// Implements the common aspects of loading the main dll for both chrome and
// chromium scenarios, which are in charge of implementing two abstract
// methods: GetRegistryPath() and OnBeforeLaunch().
class MainDllLoader {
public:
MainDllLoader();
virtual ~MainDllLoader();
// Loads and calls the entry point of chrome.dll. |instance| is the exe
// instance retrieved from wWinMain.
// The return value is what the main entry point of chrome.dll returns
// upon termination.
int Launch(HINSTANCE instance);
// Launches a new instance of the browser if the current instance in
// persistent mode an upgrade is detected.
void RelaunchChromeBrowserWithNewCommandLineIfNeeded();
protected:
// Called after chrome.dll has been loaded but before the entry point
// is invoked. Derived classes can implement custom actions here.
// |process_type| is the argument to the --type command line argument, e.g.
// "renderer", "watcher", etc.
// |dll_path| refers to the path of the Chrome dll being loaded.
virtual void OnBeforeLaunch(const std::string& process_type,
const base::FilePath& dll_path) = 0;
// Called after the chrome.dll entry point returns and before terminating
// this process. The return value will be used as the process return code.
// |dll_path| refers to the path of the Chrome dll being loaded.
virtual int OnBeforeExit(int return_code, const base::FilePath& dll_path) = 0;
private:
// Loads the appropriate DLL for the process type |process_type_|. Populates
// |module| with the path of the loaded DLL. Returns a reference to the
// module, or null on failure.
HMODULE Load(base::FilePath* module);
private:
HMODULE dll_;
std::string process_type_;
};
// Factory for the MainDllLoader. Caller owns the pointer and should call
// delete to free it.
MainDllLoader* MakeMainDllLoader();
#endif // CHROME_APP_MAIN_DLL_LOADER_WIN_H_