FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Client/src/sdllp.cpp at main · ProjectConsolation/Client · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ProjectConsolation
/
Client
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
1
Star
11
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Client
/
src
/
sdllp.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
128 lines (104 loc) · 3.22 KB
Breadcrumbs
Client
/
src
/
sdllp.cpp
Copy path
File metadata and controls
128 lines (104 loc) · 3.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
include
<
std_include.hpp
>
#
include
"
sdllp.hpp
"
#
include
<
utils/flags.hpp
>
#
include
<
utils/string.hpp
>
#
include
<
utils/nt.hpp
>
#
define
EXPORT
(
_export
)
extern
"
C
"
__declspec(naked) __declspec(dllexport)
void
_export
() {
static
FARPROC
function =
0
;
if
(!function) function =
sdllp::get_export
(__FUNCTION__,
LIBRARY
); __asm { jmp function } }
std::map<std::string,
HINSTANCE
> sdllp::libraries;
namespace
{
bool
singleplayer_warning_shown =
false
;
bool
has_multiplayer_module_loaded
()
{
return
GetModuleHandleA
(
"
jb_mp_s.dll
"
) !=
nullptr
;
}
bool
is_multiplayer_host
()
{
const
auto
host_name =
utils::nt::get_host_module
().
get_name
();
return
!
_stricmp
(host_name.
c_str
(),
"
JB_Launcher_s.exe
"
)
|| !
_stricmp
(host_name.
c_str
(),
"
JB_LiveEngine_s.exe
"
)
||
has_multiplayer_module_loaded
()
||
utils::flags::has_flag
(
"
multiplayer
"
);
}
bool
should_load_proxy_library
(
const
char
* library)
{
if
(!
_stricmp
(library,
"
d3d9.dll
"
))
{
return
is_multiplayer_host
();
}
return
true
;
}
void
show_singleplayer_passthrough_warning
(
const
char
* library)
{
if
(singleplayer_warning_shown ||
_stricmp
(library,
"
d3d9.dll
"
) !=
0
)
{
return
;
}
singleplayer_warning_shown =
true
;
MessageBoxA
(
nullptr
,
"
Project: Consolation does not support singleplayer.
\n\n
Launching without modifications using the default system d3d9.dll.
"
,
"
Project: Consolation
"
,
MB_OK
|
MB_ICONWARNING
);
}
}
void
sdllp::load_library
(
const
char
* library)
{
char
mPath
[
MAX_PATH
];
GetSystemDirectoryA
(
mPath
,
MAX_PATH
);
strcat_s
(
mPath
,
"
\\
"
);
strcat_s
(
mPath
, library);
libraries[library] =
LoadLibraryA
(
mPath
);
if
(!
is_loaded
(library))
{
MessageBoxA
(
nullptr
,
utils::string::va
(
"
failed to load '%s'
"
, library),
"
export
"
,
MB_ICONERROR
);
}
else
{
const
auto
host_name =
utils::nt::get_host_module
().
get_name
();
const
auto
multiplayer_flag =
utils::flags::has_flag
(
"
multiplayer
"
) ?
1
:
0
;
const
auto
multiplayer_module =
has_multiplayer_module_loaded
() ?
1
:
0
;
const
auto
multiplayer_host =
should_load_proxy_library
(library) ?
1
:
0
;
printf
(
"
consolation: proxy decision library=%s host=%s flag=%d mp_dll=%d use_custom=%d
\n
"
,
library,
host_name.
c_str
(),
multiplayer_flag,
multiplayer_module,
multiplayer_host
);
if
(!multiplayer_host)
{
show_singleplayer_passthrough_warning
(library);
printf
(
"
export proxy for %s is running in passthrough mode (singleplayer)
\n
"
, library);
}
}
}
bool
sdllp::is_loaded
(
const
char
* library)
{
return
(libraries.
find
(library) != libraries.
end
() && libraries[library]);
}
FARPROC
sdllp::get_export
(
const
char
* function,
const
char
* library)
{
printf
(
"
export '%s' requested from %s.
\n
"
, function, library);
if
(!
is_loaded
(library))
{
load_library
(library);
}
auto
address =
GetProcAddress
(libraries[library], function);
if
(!address)
{
MessageBoxA
(
nullptr
,
utils::string::va
(
"
unable to export function '%s' from '%s'
"
, function, library),
"
export
"
,
MB_ICONERROR
);
return
nullptr
;
}
return
address;
}
#
define
LIBRARY
"
d3d9.dll
"
//
C4740: inline asm in naked functions suppresses global optimization — expected behavior here
#
pragma
warning(push)
#
pragma
warning(disable: 4740)
EXPORT
(D3DPERF_BeginEvent)
EXPORT
(D3DPERF_EndEvent)
EXPORT
(Direct3DCreate9)
#
pragma
warning(pop)
Back
|
FazBrowse Home
|
New Git URL