-
Notifications
You must be signed in to change notification settings - Fork 0
/
pepper_proxy.c
69 lines (58 loc) · 1.83 KB
/
pepper_proxy.c
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
68
69
#include "cpp-compat.h"
#include <dlfcn.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "ppapi/c/ppp.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/pp_errors.h"
#include "all_includes.h"
#define PPFP_PATH "/opt/google/chrome/PepperFlash/libpepflashplayer.so"
static int32_t (*orig_PPP_InitializeModule)(PP_Module module, PPB_GetInterface get_browser_interface);
static const void * (*orig_PPP_GetInterface)(const char* interface_name);
static int32_t (*orig_PPP_InitializeBroker)(PP_ConnectInstance_Func* connect_instance_func);
static void (*orig_PPP_ShutdownBroker)(void);
static void *h = NULL;
static PPB_GetInterface orig_get_browser_interface;
static
void
ensure_original_loaded(void)
{
if (!h) {
h = dlopen(PPFP_PATH, RTLD_LAZY);
orig_PPP_InitializeModule = dlsym(h, "PPP_InitializeModule");
orig_PPP_GetInterface = dlsym(h, "PPP_GetInterface");
orig_PPP_InitializeBroker = dlsym(h, "PPP_InitializeBroker");
orig_PPP_ShutdownBroker = dlsym(h, "PPP_ShutdownBroker");
}
}
#include "trace-wrappers.c"
const void *
PPP_GetInterface(const char *interface_name)
{
ensure_original_loaded();
return my_PPP_GetInterface(interface_name);
}
int32_t
PPP_InitializeBroker(PP_ConnectInstance_Func *connect_instance_func)
{
printf("PPP_InitializeBroker\n");
if (orig_PPP_InitializeBroker)
return orig_PPP_InitializeBroker(connect_instance_func);
else
return PP_ERROR_FAILED;
}
void
PPP_ShutdownBroker()
{
printf("PPP_ShutdownBroker\n");
if (orig_PPP_ShutdownBroker)
orig_PPP_ShutdownBroker();
}
int32_t
PPP_InitializeModule(PP_Module module, PPB_GetInterface get_browser_interface)
{
ensure_original_loaded();
orig_get_browser_interface = get_browser_interface;
return orig_PPP_InitializeModule(module, my_PPB_GetInterface);
}