102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
hook_resolve_pcdogs_path.c
Go to the documentation of this file.
1
#include "
hooks_private.h
"
2
#include "
sidecar_private.h
"
3
#include <
dttr_pcdogs.h
>
4
5
#include <
dttr_log.h
>
6
#include <windows.h>
7
8
// Writes the package base path expected by PCDogs from the loaded module path.
9
uint32_t __cdecl
dttr_hook_resolve_pcdogs_path_callback
() {
10
char (*path_buffer)[
DTTR_PCDOGS_D_AUDIO_OPEN_STREAM_PKG_BASE_PATH_COUNT
]
11
=
DTTR_PCDOGS_D_Audio_OpenStream_PKGBasePath
->Ptr();
12
if
(!path_buffer) {
13
DTTR_LOG_ERROR
(
"PCDOGS package base path was unavailable"
);
14
return
0;
15
}
16
17
char
*out_path = *path_buffer;
18
19
DWORD
module_path_length = GetModuleFileNameA(
20
dttr_sidecar_runtime_context
()->game_module,
21
out_path,
22
MAX_PATH
23
);
24
25
if
(module_path_length == 0) {
26
DTTR_LOG_ERROR
(
27
"GetModuleFileNameA failed (error %lu), falling back to current directory"
,
28
GetLastError()
29
);
30
return
GetCurrentDirectoryA(MAX_PATH, out_path);
31
}
32
33
while
(module_path_length > 0 && out_path[module_path_length - 1] !=
'\\'
) {
34
module_path_length--;
35
}
36
37
out_path[module_path_length] =
'\0'
;
38
39
return
module_path_length;
40
}
DWORD
DWORD
Definition
com_direct3ddevice7.c:708
dttr_log.h
DTTR_LOG_ERROR
#define DTTR_LOG_ERROR(...)
Definition
dttr_log.h:31
dttr_pcdogs.h
DTTR_PCDOGS_D_AUDIO_OPEN_STREAM_PKG_BASE_PATH_COUNT
#define DTTR_PCDOGS_D_AUDIO_OPEN_STREAM_PKG_BASE_PATH_COUNT
Definition
dttr_pcdogs.h:60199
DTTR_PCDOGS_D_Audio_OpenStream_PKGBasePath
DTTR_PCDOGS_API const struct DTTR_PCDOGS_D_Audio_OpenStream_PKGBasePath_type *const DTTR_PCDOGS_D_Audio_OpenStream_PKGBasePath
Definition
dttr_pcdogs.h:60226
dttr_sidecar_runtime_context
const DTTR_Core_Context * dttr_sidecar_runtime_context()
Definition
entrypoint.c:156
hooks_private.h
dttr_hook_resolve_pcdogs_path_callback
uint32_t dttr_hook_resolve_pcdogs_path_callback()
Definition
hook_resolve_pcdogs_path.c:9
sidecar_private.h
modules
sidecar
src
game
hook_resolve_pcdogs_path.c
Generated by
1.16.1