mirror of
https://github.com/xenia-project/xenia.git
synced 2025-12-06 07:12:03 +01:00
clang-format
This commit is contained in:
parent
0f14575592
commit
442e5f2840
|
|
@ -369,14 +369,16 @@ bool DiscoverTests(std::wstring& test_path,
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
int filter(unsigned int code) {
|
int filter(unsigned int code) {
|
||||||
if (code == EXCEPTION_ILLEGAL_INSTRUCTION)
|
if (code == EXCEPTION_ILLEGAL_INSTRUCTION) {
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
|
}
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ProtectedRunTest(TestSuite &test_suite, TestRunner &runner, TestCase &test_case, int &failed_count, int &passed_count) {
|
void ProtectedRunTest(TestSuite& test_suite, TestRunner& runner,
|
||||||
|
TestCase& test_case, int& failed_count,
|
||||||
|
int& passed_count) {
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
__try {
|
__try {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -393,7 +395,8 @@ void ProtectedRunTest(TestSuite &test_suite, TestRunner &runner, TestCase &test_
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
} __except (filter(GetExceptionCode())) {
|
}
|
||||||
|
__except(filter(GetExceptionCode())) {
|
||||||
XELOGE(" TEST FAILED (UNSUPPORTED INSTRUCTION)");
|
XELOGE(" TEST FAILED (UNSUPPORTED INSTRUCTION)");
|
||||||
++failed_count;
|
++failed_count;
|
||||||
}
|
}
|
||||||
|
|
@ -442,7 +445,8 @@ bool RunTests(const std::wstring& test_name) {
|
||||||
for (auto& test_case : test_suite.test_cases) {
|
for (auto& test_case : test_suite.test_cases) {
|
||||||
XELOGI(" - %s", test_case.name.c_str());
|
XELOGI(" - %s", test_case.name.c_str());
|
||||||
TestRunner runner;
|
TestRunner runner;
|
||||||
ProtectedRunTest(test_suite, runner, test_case, failed_count, passed_count);
|
ProtectedRunTest(test_suite, runner, test_case, failed_count,
|
||||||
|
passed_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
XELOGI("");
|
XELOGI("");
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,9 @@ XModule::XModule(KernelState* kernel_state, const std::string& path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XModule::~XModule() {
|
XModule::~XModule() { kernel_state_->UnregisterModule(this); }
|
||||||
kernel_state_->UnregisterModule(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XModule::OnLoad() {
|
void XModule::OnLoad() { kernel_state_->RegisterModule(this); }
|
||||||
kernel_state_->RegisterModule(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
X_STATUS XModule::GetSection(const char* name, uint32_t* out_section_data,
|
X_STATUS XModule::GetSection(const char* name, uint32_t* out_section_data,
|
||||||
uint32_t* out_section_size) {
|
uint32_t* out_section_size) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class XModule : public XObject {
|
||||||
const std::string& name() const { return name_; }
|
const std::string& name() const { return name_; }
|
||||||
|
|
||||||
virtual void* GetProcAddressByOrdinal(uint16_t ordinal) = 0;
|
virtual void* GetProcAddressByOrdinal(uint16_t ordinal) = 0;
|
||||||
virtual void* GetProcAddressByName(const char *name) = 0;
|
virtual void* GetProcAddressByName(const char* name) = 0;
|
||||||
virtual X_STATUS GetSection(const char* name, uint32_t* out_section_data,
|
virtual X_STATUS GetSection(const char* name, uint32_t* out_section_data,
|
||||||
uint32_t* out_section_size);
|
uint32_t* out_section_size);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,9 @@ void* XUserModule::GetProcAddressByName(const char* name) {
|
||||||
int ret = xe_xex2_lookup_export(xex_, name, export);
|
int ret = xe_xex2_lookup_export(xex_, name, export);
|
||||||
|
|
||||||
// Failure.
|
// Failure.
|
||||||
if (ret)
|
if (ret) return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (void *)export.addr;
|
return (void*)export.addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS XUserModule::GetSection(const char* name, uint32_t* out_section_data,
|
X_STATUS XUserModule::GetSection(const char* name, uint32_t* out_section_data,
|
||||||
|
|
|
||||||
|
|
@ -989,7 +989,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex,
|
||||||
}
|
}
|
||||||
|
|
||||||
int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name,
|
int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name,
|
||||||
PEExport &peexport) {
|
PEExport &peexport) {
|
||||||
auto header = xe_xex2_get_header(xex);
|
auto header = xe_xex2_get_header(xex);
|
||||||
|
|
||||||
// no exports :(
|
// no exports :(
|
||||||
|
|
@ -997,15 +997,23 @@ int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t baseaddr = (uint64_t)xex->memory->TranslateVirtual(header->exe_address);
|
uint64_t baseaddr =
|
||||||
IMAGE_EXPORT_DIRECTORY *e = (PIMAGE_EXPORT_DIRECTORY)(baseaddr + header->export_table_offset);
|
(uint64_t)xex->memory->TranslateVirtual(header->exe_address);
|
||||||
|
IMAGE_EXPORT_DIRECTORY *e =
|
||||||
|
(PIMAGE_EXPORT_DIRECTORY)(baseaddr + header->export_table_offset);
|
||||||
|
|
||||||
// e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY!
|
// e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY!
|
||||||
uint32_t* function_table = (uint32_t*)((uint64_t)e + e->AddressOfFunctions); // Functions relative to base
|
uint32_t *function_table =
|
||||||
uint32_t* name_table = (uint32_t*)((uint64_t)e + e->AddressOfNames); // Names relative to directory
|
(uint32_t *)((uint64_t)e +
|
||||||
uint16_t* ordinal_table = (uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals); // Table of ordinals
|
e->AddressOfFunctions); // Functions relative to base
|
||||||
|
uint32_t *name_table =
|
||||||
|
(uint32_t *)((uint64_t)e +
|
||||||
|
e->AddressOfNames); // Names relative to directory
|
||||||
|
uint16_t *ordinal_table =
|
||||||
|
(uint16_t *)((uint64_t)e +
|
||||||
|
e->AddressOfNameOrdinals); // Table of ordinals
|
||||||
|
|
||||||
const char* mod_name = (const char*)((uint64_t)e + e->Name);
|
const char *mod_name = (const char *)((uint64_t)e + e->Name);
|
||||||
|
|
||||||
for (int i = 0; i < e->NumberOfNames; i++) {
|
for (int i = 0; i < e->NumberOfNames; i++) {
|
||||||
const char *fn_name = (const char *)((uint64_t)e + name_table[i]);
|
const char *fn_name = (const char *)((uint64_t)e + name_table[i]);
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ class PESection {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PEExport {
|
struct PEExport {
|
||||||
const char *name;
|
const char* name;
|
||||||
uint32_t ordinal;
|
uint32_t ordinal;
|
||||||
|
|
||||||
uint64_t addr; // Function address
|
uint64_t addr; // Function address
|
||||||
};
|
};
|
||||||
|
|
||||||
xe_xex2_ref xe_xex2_load(xe::Memory* memory, const void* addr,
|
xe_xex2_ref xe_xex2_load(xe::Memory* memory, const void* addr,
|
||||||
|
|
@ -62,7 +62,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex,
|
||||||
xe_xex2_import_info_t** out_import_infos,
|
xe_xex2_import_info_t** out_import_infos,
|
||||||
size_t* out_import_info_count);
|
size_t* out_import_info_count);
|
||||||
|
|
||||||
int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name,
|
int xe_xex2_lookup_export(xe_xex2_ref xex, const char* name,
|
||||||
PEExport &peexport);
|
PEExport& peexport);
|
||||||
|
|
||||||
#endif // XENIA_KERNEL_UTIL_XEX2_H_
|
#endif // XENIA_KERNEL_UTIL_XEX2_H_
|
||||||
|
|
|
||||||
|
|
@ -246,15 +246,15 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state,
|
||||||
KernelState* state) {
|
KernelState* state) {
|
||||||
uint32_t module_handle = SHIM_GET_ARG_32(0);
|
uint32_t module_handle = SHIM_GET_ARG_32(0);
|
||||||
uint32_t ordinal = SHIM_GET_ARG_32(1);
|
uint32_t ordinal = SHIM_GET_ARG_32(1);
|
||||||
const char *name = (const char *)SHIM_MEM_ADDR(ordinal);
|
const char* name = (const char*)SHIM_MEM_ADDR(ordinal);
|
||||||
uint32_t out_function_ptr = SHIM_GET_ARG_32(2);
|
uint32_t out_function_ptr = SHIM_GET_ARG_32(2);
|
||||||
|
|
||||||
if (ordinal < 0x10000) {
|
if (ordinal < 0x10000) {
|
||||||
XELOGD("XexGetProcedureAddress(%.8X, %.8X, %.8X)", module_handle, ordinal,
|
XELOGD("XexGetProcedureAddress(%.8X, %.8X, %.8X)", module_handle, ordinal,
|
||||||
out_function_ptr);
|
out_function_ptr);
|
||||||
} else {
|
} else {
|
||||||
XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle, ordinal,
|
XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle,
|
||||||
name, out_function_ptr);
|
ordinal, name, out_function_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue