clang-format
This commit is contained in:
parent
0f14575592
commit
442e5f2840
|
@ -369,14 +369,16 @@ bool DiscoverTests(std::wstring& test_path,
|
|||
|
||||
#ifdef _MSC_VER
|
||||
int filter(unsigned int code) {
|
||||
if (code == EXCEPTION_ILLEGAL_INSTRUCTION)
|
||||
if (code == EXCEPTION_ILLEGAL_INSTRUCTION) {
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
|
||||
}
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
#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
|
||||
__try {
|
||||
#endif
|
||||
|
@ -393,7 +395,8 @@ void ProtectedRunTest(TestSuite &test_suite, TestRunner &runner, TestCase &test_
|
|||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
} __except (filter(GetExceptionCode())) {
|
||||
}
|
||||
__except(filter(GetExceptionCode())) {
|
||||
XELOGE(" TEST FAILED (UNSUPPORTED INSTRUCTION)");
|
||||
++failed_count;
|
||||
}
|
||||
|
@ -442,7 +445,8 @@ bool RunTests(const std::wstring& test_name) {
|
|||
for (auto& test_case : test_suite.test_cases) {
|
||||
XELOGI(" - %s", test_case.name.c_str());
|
||||
TestRunner runner;
|
||||
ProtectedRunTest(test_suite, runner, test_case, failed_count, passed_count);
|
||||
ProtectedRunTest(test_suite, runner, test_case, failed_count,
|
||||
passed_count);
|
||||
}
|
||||
|
||||
XELOGI("");
|
||||
|
|
|
@ -29,13 +29,9 @@ XModule::XModule(KernelState* kernel_state, const std::string& path)
|
|||
}
|
||||
}
|
||||
|
||||
XModule::~XModule() {
|
||||
kernel_state_->UnregisterModule(this);
|
||||
}
|
||||
XModule::~XModule() { kernel_state_->UnregisterModule(this); }
|
||||
|
||||
void XModule::OnLoad() {
|
||||
kernel_state_->RegisterModule(this);
|
||||
}
|
||||
void XModule::OnLoad() { kernel_state_->RegisterModule(this); }
|
||||
|
||||
X_STATUS XModule::GetSection(const char* name, uint32_t* out_section_data,
|
||||
uint32_t* out_section_size) {
|
||||
|
|
|
@ -27,7 +27,7 @@ class XModule : public XObject {
|
|||
const std::string& name() const { return name_; }
|
||||
|
||||
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,
|
||||
uint32_t* out_section_size);
|
||||
|
||||
|
|
|
@ -153,10 +153,9 @@ void* XUserModule::GetProcAddressByName(const char* name) {
|
|||
int ret = xe_xex2_lookup_export(xex_, name, export);
|
||||
|
||||
// Failure.
|
||||
if (ret)
|
||||
return NULL;
|
||||
if (ret) return NULL;
|
||||
|
||||
return (void *)export.addr;
|
||||
return (void*)export.addr;
|
||||
}
|
||||
|
||||
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,
|
||||
PEExport &peexport) {
|
||||
PEExport &peexport) {
|
||||
auto header = xe_xex2_get_header(xex);
|
||||
|
||||
// no exports :(
|
||||
|
@ -997,15 +997,23 @@ int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name,
|
|||
return 1;
|
||||
}
|
||||
|
||||
uint64_t baseaddr = (uint64_t)xex->memory->TranslateVirtual(header->exe_address);
|
||||
IMAGE_EXPORT_DIRECTORY *e = (PIMAGE_EXPORT_DIRECTORY)(baseaddr + header->export_table_offset);
|
||||
uint64_t baseaddr =
|
||||
(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!
|
||||
uint32_t* function_table = (uint32_t*)((uint64_t)e + 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
|
||||
uint32_t *function_table =
|
||||
(uint32_t *)((uint64_t)e +
|
||||
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++) {
|
||||
const char *fn_name = (const char *)((uint64_t)e + name_table[i]);
|
||||
|
|
|
@ -44,10 +44,10 @@ class PESection {
|
|||
};
|
||||
|
||||
struct PEExport {
|
||||
const char *name;
|
||||
const char* name;
|
||||
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,
|
||||
|
@ -62,7 +62,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex,
|
|||
xe_xex2_import_info_t** out_import_infos,
|
||||
size_t* out_import_info_count);
|
||||
|
||||
int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name,
|
||||
PEExport &peexport);
|
||||
int xe_xex2_lookup_export(xe_xex2_ref xex, const char* name,
|
||||
PEExport& peexport);
|
||||
|
||||
#endif // XENIA_KERNEL_UTIL_XEX2_H_
|
||||
|
|
|
@ -246,15 +246,15 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state,
|
|||
KernelState* state) {
|
||||
uint32_t module_handle = SHIM_GET_ARG_32(0);
|
||||
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);
|
||||
|
||||
if (ordinal < 0x10000) {
|
||||
XELOGD("XexGetProcedureAddress(%.8X, %.8X, %.8X)", module_handle, ordinal,
|
||||
out_function_ptr);
|
||||
} else {
|
||||
XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle, ordinal,
|
||||
name, out_function_ptr);
|
||||
XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle,
|
||||
ordinal, name, out_function_ptr);
|
||||
}
|
||||
|
||||
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
||||
|
|
Loading…
Reference in New Issue