Skip to content

Commit af784ce

Browse files
author
runrevali
committed
[[ SB Inclusions ]] Work around problems linking to MCU_ functions from CEF
1 parent d3c460b commit af784ce

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

revbrowser/src/cefbrowser_w32.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,25 @@ bool MCCefWin32Browser::PlatformGetAuthCredentials(bool p_is_proxy, const CefStr
513513

514514
return t_success;
515515
}
516+
517+
////////////////////////////////////////////////////////////////////////////////
518+
519+
// AL-2015-02-17: [[ SB Inclusions ]] Work around problems linking to MCU_ functions from CEF
520+
#include <stdlib.h>
521+
#include <stdio.h>
522+
#include <cstring>
523+
524+
void *MCU_loadmodule(const char *p_source)
525+
{
526+
return LoadLibraryA(p_source);
527+
}
528+
529+
void MCU_unloadmodule(void *p_module)
530+
{
531+
532+
}
533+
534+
void *MCU_resolvemodulesymbol(void *p_module, const char *p_name)
535+
{
536+
return GetProcAddress(p_module, p_name);
537+
}

revbrowser/src/cefshared.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ const char *MCCefPlatformGetCefLibraryPath(void);
2121
const char *MCCefPlatformGetResourcesDirPath(void);
2222
const char *MCCefPlatformGetLocalePath(void);
2323

24+
// AL-2015-02-17: [[ SB Inclusions ]] Work around problems linking to MCU_ functions from CEF
25+
extern "C" void *MCU_loadmodule(const char *p_source);
26+
extern "C" void MCU_unloadmodule(void *p_module);
27+
extern "C" void *MCU_resolvemodulesymbol(void *p_module, const char *p_symbol);
28+
2429
#endif // __MCCEF_SHARED_H__

revbrowser/src/cefshared_osx.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,60 @@ const char *MCCefPlatformGetResourcesDirPath(void)
4848
{
4949
return nil;
5050
}
51+
52+
////////////////////////////////////////////////////////////////////////////////
53+
54+
// AL-2015-02-17: [[ SB Inclusions ]] Work around problems linking to MCU_ functions from CEF
55+
#include <stdlib.h>
56+
#include <stdio.h>
57+
#include <cstring>
58+
#include <mach-o/dyld.h>
59+
60+
void *MCU_loadmodule(const char *p_source)
61+
{
62+
const struct mach_header *t_module;
63+
t_module = NSAddImage(p_source, NSADDIMAGE_OPTION_RETURN_ON_ERROR | NSADDIMAGE_OPTION_WITH_SEARCHING);
64+
if (t_module == NULL)
65+
{
66+
uint32_t t_buffer_size;
67+
t_buffer_size = 0;
68+
_NSGetExecutablePath(NULL, &t_buffer_size);
69+
char *t_module_path;
70+
t_module_path = (char *) malloc(t_buffer_size + strlen(p_source) + 1);
71+
if (t_module_path != NULL)
72+
{
73+
if (_NSGetExecutablePath(t_module_path, &t_buffer_size) == 0)
74+
{
75+
char *t_last_slash;
76+
t_last_slash = t_module_path + t_buffer_size;
77+
for (uint32_t i = 0; i < t_buffer_size; i++)
78+
{
79+
if (*t_last_slash == '/')
80+
{
81+
*(t_last_slash + 1) = '\0';
82+
break;
83+
}
84+
t_last_slash--;
85+
}
86+
strcat(t_module_path, p_source);
87+
t_module = NSAddImage(t_module_path, NSADDIMAGE_OPTION_RETURN_ON_ERROR | NSADDIMAGE_OPTION_WITH_SEARCHING);
88+
}
89+
free(t_module_path);
90+
}
91+
}
92+
}
93+
94+
void MCU_unloadmodule(void *p_module)
95+
{
96+
97+
}
98+
99+
void *MCU_resolvemodulesymbol(void *p_module, const char *p_name)
100+
{
101+
NSSymbol t_symbol;
102+
t_symbol = NSLookupSymbolInImage((mach_header *)p_module, p_name, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW);
103+
if (t_symbol != NULL)
104+
return NSAddressOfSymbol(t_symbol);
105+
106+
return NULL;
107+
}

0 commit comments

Comments
 (0)