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.
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) {
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}
#define DTTR_LOG_ERROR(...)
Definition dttr_log.h:31
#define DTTR_PCDOGS_D_AUDIO_OPEN_STREAM_PKG_BASE_PATH_COUNT
DTTR_PCDOGS_API const struct DTTR_PCDOGS_D_Audio_OpenStream_PKGBasePath_type *const DTTR_PCDOGS_D_Audio_OpenStream_PKGBasePath
const DTTR_Core_Context * dttr_sidecar_runtime_context()
Definition entrypoint.c:156
uint32_t dttr_hook_resolve_pcdogs_path_callback()