XEX-style exports, dumping exports, and prepping kernel export lookup.
This commit is contained in:
@@ -252,22 +252,25 @@ 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);
|
||||
uint32_t out_function_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
if (ordinal < 0x10000) {
|
||||
// May be entry point?
|
||||
assert_not_zero(ordinal);
|
||||
|
||||
bool is_string_name = (ordinal & 0xFFFF0000) != 0;
|
||||
auto string_name = reinterpret_cast<const char*>(SHIM_MEM_ADDR(ordinal));
|
||||
|
||||
if (is_string_name) {
|
||||
XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle,
|
||||
ordinal, string_name, out_function_ptr);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
||||
SHIM_SET_MEM_32(out_function_ptr, 0xDEADF00D);
|
||||
|
||||
XModule* module = NULL;
|
||||
|
||||
if (!module_handle) {
|
||||
module = state->GetExecutableModule();
|
||||
} else {
|
||||
@@ -276,23 +279,19 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state,
|
||||
}
|
||||
|
||||
if (XSUCCEEDED(result)) {
|
||||
if (ordinal < 0x10000) {
|
||||
// Ordinal.
|
||||
uint32_t ptr = module->GetProcAddressByOrdinal(ordinal);
|
||||
if (ptr) {
|
||||
SHIM_SET_MEM_32(out_function_ptr, ptr);
|
||||
result = X_STATUS_SUCCESS;
|
||||
}
|
||||
uint32_t ptr;
|
||||
if (is_string_name) {
|
||||
ptr = module->GetProcAddressByName(string_name);
|
||||
} else {
|
||||
// It's a name pointer instead.
|
||||
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.
|
||||
if (ptr) {
|
||||
SHIM_SET_MEM_32(out_function_ptr, ptr);
|
||||
result = X_STATUS_SUCCESS;
|
||||
}
|
||||
ptr = module->GetProcAddressByOrdinal(ordinal);
|
||||
}
|
||||
if (ptr) {
|
||||
SHIM_SET_MEM_32(out_function_ptr, ptr);
|
||||
result = X_STATUS_SUCCESS;
|
||||
} else {
|
||||
XELOGW("ERROR: XexGetProcedureAddress ordinal not found!");
|
||||
SHIM_SET_MEM_32(out_function_ptr, 0);
|
||||
result = X_STATUS_DRIVER_ORDINAL_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user