Implemented this too (XexGetProcedureAddress)

This commit is contained in:
Dr. Chat 2015-05-04 17:40:37 -05:00
parent 49c8efdc6d
commit be3d729831
1 changed files with 24 additions and 4 deletions

View File

@ -246,10 +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);
uint32_t out_function_ptr = SHIM_GET_ARG_32(2);
XELOGD("XexGetProcedureAddress(%.8X, %.8X, %.8X)", module_handle, ordinal,
out_function_ptr);
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);
X_STATUS result = X_STATUS_INVALID_HANDLE;
SHIM_SET_MEM_32(out_function_ptr, 0xDEADF00D);
@ -265,9 +270,24 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state,
if (XSUCCEEDED(result)) {
// TODO(benvanik): implement. May need to create stub functions on the fly.
// module->GetProcAddressByOrdinal(ordinal);
result = X_STATUS_NOT_IMPLEMENTED;
if (ordinal < 0x10000) {
uint64_t ptr = (uint64_t)module->GetProcAddressByOrdinal(ordinal);
SHIM_SET_MEM_32(out_function_ptr, ptr);
result = X_STATUS_NOT_IMPLEMENTED;
} else {
// It's a name pointer instead.
uint64_t ptr = (uint64_t)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;
}
}
}
if (module) {
module->Release();
}