clang-format

This commit is contained in:
Ben Vanik 2015-05-04 19:03:30 -07:00
parent 0f14575592
commit 442e5f2840
7 changed files with 36 additions and 29 deletions

View File

@ -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("");

View File

@ -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) {

View File

@ -153,8 +153,7 @@ 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;
} }

View File

@ -997,13 +997,21 @@ 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);

View File

@ -253,8 +253,8 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state,
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;