From b07d5b8ed30ac45702208b5734e6b55c0fdfce77 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Tue, 5 May 2015 18:52:37 -0700 Subject: [PATCH] Fixing compile warnings. --- src/xenia/kernel/objects/xkernel_module.cc | 8 ++++---- src/xenia/kernel/objects/xkernel_module.h | 6 +++--- src/xenia/kernel/objects/xmodule.h | 4 ++-- src/xenia/kernel/objects/xuser_module.cc | 22 ++++++++++++---------- src/xenia/kernel/objects/xuser_module.h | 12 +++++------- src/xenia/kernel/util/xex2.cc | 4 ++-- src/xenia/kernel/xboxkrnl_modules.cc | 4 ++-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/xenia/kernel/objects/xkernel_module.cc b/src/xenia/kernel/objects/xkernel_module.cc index e46e88e16..51b2b130c 100644 --- a/src/xenia/kernel/objects/xkernel_module.cc +++ b/src/xenia/kernel/objects/xkernel_module.cc @@ -28,15 +28,15 @@ XKernelModule::XKernelModule(KernelState* kernel_state, const char* path) XKernelModule::~XKernelModule() {} -void* XKernelModule::GetProcAddressByOrdinal(uint16_t ordinal) { +uint32_t XKernelModule::GetProcAddressByOrdinal(uint16_t ordinal) { // TODO(benvanik): check export tables. XELOGE("GetProcAddressByOrdinal not implemented"); - return NULL; + return 0; } -void* XKernelModule::GetProcAddressByName(const char* name) { +uint32_t XKernelModule::GetProcAddressByName(const char* name) { XELOGE("GetProcAddressByName not implemented"); - return NULL; + return 0; } } // namespace kernel diff --git a/src/xenia/kernel/objects/xkernel_module.h b/src/xenia/kernel/objects/xkernel_module.h index a4117032c..a966117da 100644 --- a/src/xenia/kernel/objects/xkernel_module.h +++ b/src/xenia/kernel/objects/xkernel_module.h @@ -21,10 +21,10 @@ class KernelState; class XKernelModule : public XModule { public: XKernelModule(KernelState* kernel_state, const char* path); - virtual ~XKernelModule(); + ~XKernelModule() override; - virtual void* GetProcAddressByOrdinal(uint16_t ordinal); - virtual void* GetProcAddressByName(const char* name); + uint32_t GetProcAddressByOrdinal(uint16_t ordinal) override; + uint32_t GetProcAddressByName(const char* name) override; protected: Emulator* emulator_; diff --git a/src/xenia/kernel/objects/xmodule.h b/src/xenia/kernel/objects/xmodule.h index 1fd714aa3..51218e8ac 100644 --- a/src/xenia/kernel/objects/xmodule.h +++ b/src/xenia/kernel/objects/xmodule.h @@ -26,8 +26,8 @@ class XModule : public XObject { const std::string& path() const { return path_; } const std::string& name() const { return name_; } - virtual void* GetProcAddressByOrdinal(uint16_t ordinal) = 0; - virtual void* GetProcAddressByName(const char* name) = 0; + virtual uint32_t GetProcAddressByOrdinal(uint16_t ordinal) = 0; + virtual uint32_t GetProcAddressByName(const char* name) = 0; virtual X_STATUS GetSection(const char* name, uint32_t* out_section_data, uint32_t* out_section_size); diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 58f4dd185..ac984d3cf 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -142,23 +142,25 @@ X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) { return X_STATUS_SUCCESS; } -void* XUserModule::GetProcAddressByOrdinal(uint16_t ordinal) { +uint32_t XUserModule::GetProcAddressByOrdinal(uint16_t ordinal) { PEExport export; int ret = xe_xex2_lookup_export(xex_, ordinal, export); + if (ret) { + XELOGE("XUserModule::GetProcAddressByOrdinal(%d) not found", ordinal); + return 0; + } - if (ret) return nullptr; - - return (void*)export.addr; + return uint32_t(export.addr); } -void* XUserModule::GetProcAddressByName(const char* name) { +uint32_t XUserModule::GetProcAddressByName(const char* name) { PEExport export; int ret = xe_xex2_lookup_export(xex_, name, export); - - // Failure. - if (ret) return nullptr; - - return (void*)export.addr; + if (ret) { + XELOGE("XUserModule::GetProcAddressByName(%s) not found", name); + return 0; + } + return uint32_t(export.addr); } X_STATUS XUserModule::GetSection(const char* name, uint32_t* out_section_data, diff --git a/src/xenia/kernel/objects/xuser_module.h b/src/xenia/kernel/objects/xuser_module.h index 19edc0c3b..e97165e49 100644 --- a/src/xenia/kernel/objects/xuser_module.h +++ b/src/xenia/kernel/objects/xuser_module.h @@ -22,7 +22,7 @@ namespace kernel { class XUserModule : public XModule { public: XUserModule(KernelState* kernel_state, const char* path); - virtual ~XUserModule(); + ~XUserModule() override; xe_xex2_ref xex(); const xe_xex2_header_t* xex_header(); @@ -32,18 +32,16 @@ class XUserModule : public XModule { X_STATUS LoadFromFile(const char* path); X_STATUS LoadFromMemory(const void* addr, const size_t length); - virtual void* GetProcAddressByOrdinal(uint16_t ordinal); - virtual void* GetProcAddressByName(const char* name); - virtual X_STATUS GetSection(const char* name, uint32_t* out_section_data, - uint32_t* out_section_size); + uint32_t GetProcAddressByOrdinal(uint16_t ordinal) override; + uint32_t GetProcAddressByName(const char* name) override; + X_STATUS GetSection(const char* name, uint32_t* out_section_data, + uint32_t* out_section_size) override; X_STATUS Launch(uint32_t flags); void Dump(); private: - int LoadPE(); - xe_xex2_ref xex_; uint32_t execution_info_ptr_; }; diff --git a/src/xenia/kernel/util/xex2.cc b/src/xenia/kernel/util/xex2.cc index 9ccf2d2c5..5e1e1ba5f 100644 --- a/src/xenia/kernel/util/xex2.cc +++ b/src/xenia/kernel/util/xex2.cc @@ -1016,7 +1016,7 @@ int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name, const char *mod_name = (const char *)((uint64_t)e + e->Name); - for (int i = 0; i < e->NumberOfNames; i++) { + for (uint32_t i = 0; i < e->NumberOfNames; i++) { const char *fn_name = (const char *)((uint64_t)e + name_table[i]); uint16_t ordinal = ordinal_table[i]; uint64_t addr = (uint64_t)(baseaddr + function_table[ordinal]); @@ -1064,7 +1064,7 @@ int xe_xex2_lookup_export(xe_xex2_ref xex, int ordinal, const char *mod_name = (const char *)((uint64_t)e + e->Name); - if (ordinal < e->NumberOfFunctions) { + if (ordinal < int(e->NumberOfFunctions)) { peexport.name = nullptr; // TODO: Backwards conversion to get this peexport.ordinal = ordinal; peexport.addr = (uint64_t)(baseaddr + function_table[ordinal]); diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index f00dbf5c7..89b6d035c 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -279,14 +279,14 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state, if (XSUCCEEDED(result)) { if (ordinal < 0x10000) { // Ordinal. - uint64_t ptr = (uint64_t)module->GetProcAddressByOrdinal(ordinal); + uint32_t ptr = module->GetProcAddressByOrdinal(ordinal); if (ptr) { SHIM_SET_MEM_32(out_function_ptr, ptr); result = X_STATUS_SUCCESS; } } else { // It's a name pointer instead. - uint64_t ptr = (uint64_t)module->GetProcAddressByName(name); + uint32_t ptr = module->GetProcAddressByName(name); // FYI: We don't need to generate this function now. It'll // be done automatically by xenia when it gets called.