From 7d51e4125d0104c6d7a220ea5b8d89ce15859e2b Mon Sep 17 00:00:00 2001 From: emoose Date: Thu, 9 Jan 2020 17:25:50 +0000 Subject: [PATCH] [XBDM] Add impl. for DmGetXboxName, stub 5 functions Stubs: DmGetXbeInfo, DmIsDebuggerPresent, DmRegisterCommandProcessor, DmRegisterCommandProcessorEx This helps progress some debug builds of games, DmGetXboxName error codes are based on what some games seem to expect from it. Will probably be a good idea to move most of this to xbdm_info.cc soon. --- src/xenia/kernel/xbdm/xbdm_misc.cc | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/xenia/kernel/xbdm/xbdm_misc.cc b/src/xenia/kernel/xbdm/xbdm_misc.cc index 53f3113d9..d4f155409 100644 --- a/src/xenia/kernel/xbdm/xbdm_misc.cc +++ b/src/xenia/kernel/xbdm/xbdm_misc.cc @@ -14,6 +14,8 @@ #include "xenia/kernel/xthread.h" #include "xenia/xbox.h" +#define XBDM_ERROR(err) (0x82DA0000 | (err & 0xFFFF)) + namespace xe { namespace kernel { namespace xbdm { @@ -42,6 +44,53 @@ dword_result_t DmFindPdbSignature(lpdword_t unk0_ptr, lpdword_t unk1_ptr) { } DECLARE_XBDM_EXPORT1(DmFindPdbSignature, kDebug, kStub); +dword_result_t DmGetXbeInfo(pointer_t path, pointer_t info) { + // TODO: get full path of path parameter, and copy it into info[0:0x100] + memset(info, 0, 0x10C); + return X_ERROR_SUCCESS; +} +DECLARE_XBDM_EXPORT1(DmGetXbeInfo, kDebug, kStub); + +dword_result_t DmGetXboxName(pointer_t name, lpdword_t name_len) { + std::string box_name = "XeniaBox"; + if (!name_len) { + return XBDM_ERROR(0x17); // xbdm invalid arg error code? + } + + auto orig_len = *name_len; + *name_len = (uint32_t)box_name.length() + 1; + + if (orig_len < *name_len) { + return XBDM_ERROR(0x105); // xbdm buffer size error code? + } + + // Limit console name size to 255 chars + auto name_size = std::min((uint32_t)box_name.length(), 255u); + + memcpy(name, box_name.c_str(), name_size); + name[name_size] = 0; + + return X_ERROR_SUCCESS; +} +DECLARE_XBDM_EXPORT1(DmGetXboxName, kDebug, kImplemented); + +dword_result_t DmIsDebuggerPresent() { return 0; } +DECLARE_XBDM_EXPORT1(DmIsDebuggerPresent, kDebug, kStub); + +dword_result_t DmRegisterCommandProcessor(dword_t r3, dword_t r4) { + return X_ERROR_SUCCESS; +} +DECLARE_XBDM_EXPORT1(DmRegisterCommandProcessor, kDebug, kStub); + +dword_result_t DmRegisterCommandProcessorEx(dword_t r3, dword_t r4, + dword_t r5) { + return X_ERROR_SUCCESS; +} +DECLARE_XBDM_EXPORT1(DmRegisterCommandProcessorEx, kDebug, kStub); + +dword_result_t DmSetDumpSettings(dword_t r3) { return X_ERROR_SUCCESS; } +DECLARE_XBDM_EXPORT1(DmSetDumpSettings, kDebug, kStub); + void RegisterMiscExports(xe::cpu::ExportResolver* export_resolver, KernelState* kernel_state) {}