Initial Alloy implementation.
This is a regression in functionality and performance, but a much better foundation for the future of the project (I think). It can run basic apps under an SSA interpreter but doesn't support some of the features required to do real 360 apps yet.
This commit is contained in:
@@ -18,11 +18,9 @@ using namespace xe::kernel;
|
||||
|
||||
|
||||
KernelModule::KernelModule(Emulator* emulator) :
|
||||
emulator_(emulator) {
|
||||
memory_ = xe_memory_retain(emulator_->memory());
|
||||
emulator_(emulator), memory_(emulator->memory()) {
|
||||
export_resolver_ = emulator->export_resolver();
|
||||
}
|
||||
|
||||
KernelModule::~KernelModule() {
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ public:
|
||||
virtual ~KernelModule();
|
||||
|
||||
protected:
|
||||
Emulator* emulator_;
|
||||
xe_memory_ref memory_;
|
||||
ExportResolver* export_resolver_;
|
||||
Emulator* emulator_;
|
||||
Memory* memory_;
|
||||
ExportResolver* export_resolver_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/cpu/ppc.h>
|
||||
#include <alloy/frontend/ppc/ppc_context.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using PPCContext = alloy::frontend::ppc::PPCContext;
|
||||
|
||||
|
||||
#define SHIM_CALL void _cdecl
|
||||
#define SHIM_SET_MAPPING(library_name, export_name, shim_data) \
|
||||
@@ -52,7 +54,7 @@ namespace kernel {
|
||||
#define SHIM_SET_RETURN(v) SHIM_SET_GPR_64(3, v)
|
||||
|
||||
|
||||
#define IMPL_MEM_ADDR(a) (a ? xe_memory_addr(state->memory(), a) : NULL)
|
||||
#define IMPL_MEM_ADDR(a) (a ? state->memory()->Translate(a) : NULL)
|
||||
|
||||
#define IMPL_MEM_16(a) (uint16_t)XEGETUINT16BE(IMPL_MEM_ADDR(a))
|
||||
#define IMPL_MEM_32(a) (uint32_t)XEGETUINT32BE(IMPL_MEM_ADDR(a))
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL XamContentGetLicenseMask_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t unk0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL XGetAVPack_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
// DWORD
|
||||
// Not sure what the values are for this, but 6 is VGA.
|
||||
// Other likely values are 3/4/8 for HDMI or something.
|
||||
@@ -37,7 +37,7 @@ SHIM_CALL XGetAVPack_shim(
|
||||
|
||||
|
||||
SHIM_CALL XGetGameRegion_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
XELOGD("XGetGameRegion()");
|
||||
|
||||
SHIM_SET_RETURN(XEX_REGION_ALL);
|
||||
@@ -45,7 +45,7 @@ SHIM_CALL XGetGameRegion_shim(
|
||||
|
||||
|
||||
SHIM_CALL XGetLanguage_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
XELOGD("XGetLanguage()");
|
||||
|
||||
uint32_t desired_language = X_LANGUAGE_ENGLISH;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace xam {
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputgetcapabilities(v=vs.85).aspx
|
||||
SHIM_CALL XamInputGetCapabilities_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t user_index = SHIM_GET_ARG_32(0);
|
||||
uint32_t flags = SHIM_GET_ARG_32(1);
|
||||
uint32_t caps_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -58,7 +58,7 @@ SHIM_CALL XamInputGetCapabilities_shim(
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputgetstate(v=vs.85).aspx
|
||||
SHIM_CALL XamInputGetState_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t user_index = SHIM_GET_ARG_32(0);
|
||||
uint32_t state_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -85,7 +85,7 @@ SHIM_CALL XamInputGetState_shim(
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinputsetstate(v=vs.85).aspx
|
||||
SHIM_CALL XamInputSetState_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t user_index = SHIM_GET_ARG_32(0);
|
||||
uint32_t vibration_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL NetDll_XNetStartup_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t one = SHIM_GET_ARG_32(0);
|
||||
uint32_t params_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -39,7 +39,7 @@ SHIM_CALL NetDll_XNetStartup_shim(
|
||||
|
||||
|
||||
SHIM_CALL NetDll_WSAStartup_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t one = SHIM_GET_ARG_32(0);
|
||||
uint32_t version = SHIM_GET_ARG_16(1);
|
||||
uint32_t data_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
@@ -23,11 +23,9 @@ namespace {
|
||||
|
||||
|
||||
XamState::XamState(Emulator* emulator) :
|
||||
emulator_(emulator) {
|
||||
memory_ = xe_memory_retain(emulator->memory());
|
||||
export_resolver_ = emulator->export_resolver();
|
||||
emulator_(emulator), memory_(emulator->memory()),
|
||||
export_resolver_(emulator->export_resolver()) {
|
||||
}
|
||||
|
||||
XamState::~XamState() {
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ public:
|
||||
~XamState();
|
||||
|
||||
Emulator* emulator() const { return emulator_; }
|
||||
xe_memory_ref memory() const { return memory_; }
|
||||
Memory* memory() const { return memory_; }
|
||||
|
||||
private:
|
||||
Emulator* emulator_;
|
||||
xe_memory_ref memory_;
|
||||
Memory* memory_;
|
||||
ExportResolver* export_resolver_;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL XamUserGetXUID_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t user_index = SHIM_GET_ARG_32(0);
|
||||
uint32_t xuid_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -43,7 +43,7 @@ SHIM_CALL XamUserGetXUID_shim(
|
||||
|
||||
|
||||
SHIM_CALL XamUserGetSigninState_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
uint32_t user_index = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL XGetVideoMode_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
PPCContext* ppc_state, XamState* state) {
|
||||
xe::kernel::xboxkrnl::X_VIDEO_MODE *video_mode = (xe::kernel::xboxkrnl::X_VIDEO_MODE*)SHIM_MEM_ADDR(SHIM_GET_ARG_32(0));
|
||||
xeVdQueryVideoMode(video_mode, true);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,8 @@ using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
KernelState::KernelState(Emulator* emulator) :
|
||||
emulator_(emulator),
|
||||
emulator_(emulator), memory_(emulator->memory()),
|
||||
executable_module_(NULL) {
|
||||
memory_ = xe_memory_retain(emulator->memory());
|
||||
processor_ = emulator->processor();
|
||||
file_system_ = emulator->file_system();
|
||||
|
||||
@@ -38,8 +37,6 @@ KernelState::~KernelState() {
|
||||
// Delete all objects.
|
||||
xe_mutex_free(object_mutex_);
|
||||
delete object_table_;
|
||||
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
|
||||
KernelState* KernelState::shared() {
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
static KernelState* shared();
|
||||
|
||||
Emulator* emulator() const { return emulator_; }
|
||||
xe_memory_ref memory() const { return memory_; }
|
||||
Memory* memory() const { return memory_; }
|
||||
cpu::Processor* processor() const { return processor_; }
|
||||
fs::FileSystem* file_system() const { return file_system_; }
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
private:
|
||||
Emulator* emulator_;
|
||||
xe_memory_ref memory_;
|
||||
Memory* memory_;
|
||||
cpu::Processor* processor_;
|
||||
fs::FileSystem* file_system_;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::cpu;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
@@ -86,6 +87,10 @@ X_STATUS XModule::LoadFromFile(const char* path) {
|
||||
}
|
||||
|
||||
X_STATUS XModule::LoadFromMemory(const void* addr, const size_t length) {
|
||||
Processor* processor = kernel_state()->processor();
|
||||
XenonRuntime* runtime = processor->runtime();
|
||||
XexModule* xex_module = NULL;
|
||||
|
||||
// Load the XEX into memory and decrypt.
|
||||
xe_xex2_options_t xex_options;
|
||||
xe_zero_struct(&xex_options, sizeof(xex_options));
|
||||
@@ -93,11 +98,15 @@ X_STATUS XModule::LoadFromMemory(const void* addr, const size_t length) {
|
||||
XEEXPECTNOTNULL(xex_);
|
||||
|
||||
// Prepare the module for execution.
|
||||
XEEXPECTZERO(kernel_state()->processor()->LoadXexModule(name_, path_, xex_));
|
||||
// Runtime takes ownership.
|
||||
xex_module = new XexModule(runtime);
|
||||
XEEXPECTZERO(xex_module->Load(name_, path_, xex_));
|
||||
XEEXPECTZERO(runtime->AddModule(xex_module));
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
|
||||
XECLEANUP:
|
||||
delete xex_module;
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
|
||||
|
||||
using namespace alloy;
|
||||
using namespace xe;
|
||||
using namespace xe::cpu;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
@@ -61,13 +63,13 @@ XThread::~XThread() {
|
||||
PlatformDestroy();
|
||||
|
||||
if (thread_state_) {
|
||||
kernel_state()->processor()->DeallocThread(thread_state_);
|
||||
delete thread_state_;
|
||||
}
|
||||
if (tls_address_) {
|
||||
xe_memory_heap_free(kernel_state()->memory(), tls_address_, 0);
|
||||
kernel_state()->memory()->HeapFree(tls_address_, 0);
|
||||
}
|
||||
if (thread_state_address_) {
|
||||
xe_memory_heap_free(kernel_state()->memory(), thread_state_address_, 0);
|
||||
kernel_state()->memory()->HeapFree(thread_state_address_, 0);
|
||||
}
|
||||
|
||||
if (thread_handle_) {
|
||||
@@ -111,12 +113,12 @@ uint32_t XThread::thread_id() {
|
||||
}
|
||||
|
||||
uint32_t XThread::last_error() {
|
||||
uint8_t *p = xe_memory_addr(memory(), thread_state_address_);
|
||||
uint8_t *p = memory()->Translate(thread_state_address_);
|
||||
return XEGETUINT32BE(p + 0x160);
|
||||
}
|
||||
|
||||
void XThread::set_last_error(uint32_t error_code) {
|
||||
uint8_t *p = xe_memory_addr(memory(), thread_state_address_);
|
||||
uint8_t *p = memory()->Translate(thread_state_address_);
|
||||
XESETUINT32BE(p + 0x160, error_code);
|
||||
}
|
||||
|
||||
@@ -133,8 +135,8 @@ X_STATUS XThread::Create() {
|
||||
// 0x160: last error
|
||||
// So, at offset 0x100 we have a 4b pointer to offset 200, then have the
|
||||
// structure.
|
||||
thread_state_address_ = xe_memory_heap_alloc(
|
||||
memory(), 0, 2048, XE_MEMORY_FLAG_ZERO);
|
||||
thread_state_address_ = (uint32_t)memory()->HeapAlloc(
|
||||
0, 2048, MEMORY_FLAG_ZERO);
|
||||
if (!thread_state_address_) {
|
||||
XELOGW("Unable to allocate thread state block");
|
||||
return X_STATUS_NO_MEMORY;
|
||||
@@ -148,8 +150,8 @@ X_STATUS XThread::Create() {
|
||||
// Allocate TLS block.
|
||||
const xe_xex2_header_t* header = module->xex_header();
|
||||
uint32_t tls_size = header->tls_info.slot_count * header->tls_info.data_size;
|
||||
tls_address_ = xe_memory_heap_alloc(
|
||||
memory(), 0, tls_size, XE_MEMORY_FLAG_ZERO);
|
||||
tls_address_ = (uint32_t)memory()->HeapAlloc(
|
||||
0, tls_size, MEMORY_FLAG_ZERO);
|
||||
if (!tls_address_) {
|
||||
XELOGW("Unable to allocate thread local storage block");
|
||||
module->Release();
|
||||
@@ -158,11 +160,11 @@ X_STATUS XThread::Create() {
|
||||
|
||||
// Copy in default TLS info.
|
||||
// TODO(benvanik): is this correct?
|
||||
xe_memory_copy(memory(),
|
||||
memory()->Copy(
|
||||
tls_address_, header->tls_info.raw_data_address, tls_size);
|
||||
|
||||
// Setup the thread state block (last error/etc).
|
||||
uint8_t *p = xe_memory_addr(memory(), thread_state_address_);
|
||||
uint8_t *p = memory()->Translate(thread_state_address_);
|
||||
XESETUINT32BE(p + 0x000, tls_address_);
|
||||
XESETUINT32BE(p + 0x100, thread_state_address_);
|
||||
XESETUINT32BE(p + 0x14C, thread_id_);
|
||||
@@ -171,13 +173,9 @@ X_STATUS XThread::Create() {
|
||||
|
||||
// Allocate processor thread state.
|
||||
// This is thread safe.
|
||||
thread_state_ = kernel_state()->processor()->AllocThread(
|
||||
creation_params_.stack_size, thread_state_address_, thread_id_);
|
||||
if (!thread_state_) {
|
||||
XELOGW("Unable to allocate processor thread state");
|
||||
module->Release();
|
||||
return X_STATUS_NO_MEMORY;
|
||||
}
|
||||
thread_state_ = new XenonThreadState(
|
||||
kernel_state()->processor()->runtime(),
|
||||
thread_id_, creation_params_.stack_size, thread_state_address_);
|
||||
|
||||
X_STATUS return_code = PlatformCreate();
|
||||
if (XFAILED(return_code)) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
class ThreadState;
|
||||
class XenonThreadState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
void* thread_handle_;
|
||||
uint32_t tls_address_;
|
||||
uint32_t thread_state_address_;
|
||||
cpu::ThreadState* thread_state_;
|
||||
cpu::XenonThreadState* thread_state_;
|
||||
|
||||
uint32_t irql_;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace xboxkrnl {
|
||||
|
||||
|
||||
SHIM_CALL XMACreateContext_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t context_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -41,7 +41,7 @@ SHIM_CALL XMACreateContext_shim(
|
||||
|
||||
|
||||
SHIM_CALL XMAReleaseContext_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t context_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace xboxkrnl {
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL DbgPrint_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(0);
|
||||
if (format_ptr == 0) {
|
||||
@@ -237,7 +237,7 @@ void xeDbgBreakPoint() {
|
||||
|
||||
|
||||
SHIM_CALL DbgBreakPoint_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD("DbgBreakPoint()");
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ void xeHalReturnToFirmware(uint32_t routine) {
|
||||
|
||||
|
||||
SHIM_CALL HalReturnToFirmware_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t routine = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace xboxkrnl {
|
||||
|
||||
|
||||
SHIM_CALL NtCreateFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t desired_access = SHIM_GET_ARG_32(1);
|
||||
uint32_t object_attributes_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -99,7 +99,7 @@ SHIM_CALL NtCreateFile_shim(
|
||||
}
|
||||
|
||||
SHIM_CALL NtOpenFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_SET_RETURN(X_STATUS_NO_SUCH_FILE);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ void xeNtReadFileCompleted(XAsyncRequest* request, xeNtReadFileState* state) {
|
||||
}
|
||||
|
||||
SHIM_CALL NtReadFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t event_handle = SHIM_GET_ARG_32(1);
|
||||
uint32_t apc_routine_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -219,7 +219,7 @@ SHIM_CALL NtReadFile_shim(
|
||||
}
|
||||
|
||||
SHIM_CALL NtSetInformationFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t io_status_block_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t file_info_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -277,7 +277,7 @@ SHIM_CALL NtSetInformationFile_shim(
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryInformationFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t io_status_block_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t file_info_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -354,7 +354,7 @@ SHIM_CALL NtQueryInformationFile_shim(
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryFullAttributesFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t object_attributes_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t file_info_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -384,7 +384,7 @@ SHIM_CALL NtQueryFullAttributesFile_shim(
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryVolumeInformationFile_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_SET_RETURN(X_STATUS_NO_SUCH_FILE);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
|
||||
|
||||
using namespace alloy;
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
@@ -78,8 +79,8 @@ X_STATUS xeNtAllocateVirtualMemory(
|
||||
|
||||
// Allocate.
|
||||
uint32_t flags = (allocation_type & X_MEM_NOZERO);
|
||||
uint32_t addr = xe_memory_heap_alloc(
|
||||
state->memory(), *base_addr_ptr, adjusted_size, flags);
|
||||
uint32_t addr = (uint32_t)state->memory()->HeapAlloc(
|
||||
*base_addr_ptr, adjusted_size, flags);
|
||||
if (!addr) {
|
||||
// Failed - assume no memory available.
|
||||
return X_STATUS_NO_MEMORY;
|
||||
@@ -94,7 +95,7 @@ X_STATUS xeNtAllocateVirtualMemory(
|
||||
|
||||
|
||||
SHIM_CALL NtAllocateVirtualMemory_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t base_addr_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t base_addr_value = SHIM_MEM_32(base_addr_ptr);
|
||||
uint32_t region_size_ptr = SHIM_GET_ARG_32(1);
|
||||
@@ -147,8 +148,8 @@ X_STATUS xeNtFreeVirtualMemory(
|
||||
|
||||
// Free.
|
||||
uint32_t flags = 0;
|
||||
uint32_t freed_size = xe_memory_heap_free(state->memory(), *base_addr_ptr,
|
||||
flags);
|
||||
uint32_t freed_size = state->memory()->HeapFree(
|
||||
*base_addr_ptr, flags);
|
||||
if (!freed_size) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
@@ -160,7 +161,7 @@ X_STATUS xeNtFreeVirtualMemory(
|
||||
|
||||
|
||||
SHIM_CALL NtFreeVirtualMemory_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t base_addr_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t base_addr_value = SHIM_MEM_32(base_addr_ptr);
|
||||
uint32_t region_size_ptr = SHIM_GET_ARG_32(1);
|
||||
@@ -232,9 +233,9 @@ uint32_t xeMmAllocatePhysicalMemoryEx(
|
||||
XEASSERT(max_addr_range == 0xFFFFFFFF);
|
||||
|
||||
// Allocate.
|
||||
uint32_t flags = XE_MEMORY_FLAG_PHYSICAL;
|
||||
uint32_t base_address = xe_memory_heap_alloc(
|
||||
state->memory(), 0, adjusted_size, flags, adjusted_alignment);
|
||||
uint32_t flags = MEMORY_FLAG_PHYSICAL;
|
||||
uint32_t base_address = (uint32_t)state->memory()->HeapAlloc(
|
||||
0, adjusted_size, flags, adjusted_alignment);
|
||||
if (!base_address) {
|
||||
// Failed - assume no memory available.
|
||||
return 0;
|
||||
@@ -255,7 +256,7 @@ uint32_t xeMmAllocatePhysicalMemoryEx(
|
||||
|
||||
|
||||
SHIM_CALL MmAllocatePhysicalMemoryEx_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t type = SHIM_GET_ARG_32(0);
|
||||
uint32_t region_size = SHIM_GET_ARG_32(1);
|
||||
uint32_t protect_bits = SHIM_GET_ARG_32(2);
|
||||
@@ -294,7 +295,7 @@ void xeMmFreePhysicalMemory(uint32_t type, uint32_t base_address) {
|
||||
|
||||
|
||||
SHIM_CALL MmFreePhysicalMemory_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t type = SHIM_GET_ARG_32(0);
|
||||
uint32_t base_address = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -310,15 +311,14 @@ uint32_t xeMmQueryAddressProtect(uint32_t base_address) {
|
||||
KernelState* state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(state);
|
||||
|
||||
uint32_t access = xe_memory_query_protect(
|
||||
state->memory(), base_address);
|
||||
uint32_t access = state->memory()->QueryProtect(base_address);
|
||||
|
||||
return access;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL MmQueryAddressProtect_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t base_address = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -355,7 +355,7 @@ uint32_t xeMmGetPhysicalAddress(uint32_t base_address) {
|
||||
|
||||
|
||||
SHIM_CALL MmGetPhysicalAddress_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t base_address = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
|
||||
@@ -32,13 +32,13 @@ void xeKeBugCheckEx(uint32_t code, uint32_t param1, uint32_t param2, uint32_t pa
|
||||
}
|
||||
|
||||
SHIM_CALL KeBugCheck_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t code = SHIM_GET_ARG_32(0);
|
||||
xeKeBugCheckEx(code, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
SHIM_CALL KeBugCheckEx_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t code = SHIM_GET_ARG_32(0);
|
||||
uint32_t param1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t param2 = SHIM_GET_ARG_32(2);
|
||||
|
||||
@@ -61,13 +61,13 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
RegisterThreadingExports(export_resolver_, kernel_state_);
|
||||
RegisterVideoExports(export_resolver_, kernel_state_);
|
||||
|
||||
uint8_t* mem = xe_memory_addr(memory_);
|
||||
uint8_t* mem = memory_->membase();
|
||||
|
||||
// KeDebugMonitorData (?*)
|
||||
// Set to a valid value when a remote debugger is attached.
|
||||
// Offset 0x18 is a 4b pointer to a handler function that seems to take two
|
||||
// arguments. If we wanted to see what would happen we could fake that.
|
||||
uint32_t pKeDebugMonitorData = xe_memory_heap_alloc(memory_, 0, 256, 0);
|
||||
uint32_t pKeDebugMonitorData = (uint32_t)memory_->HeapAlloc(0, 256, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeDebugMonitorData,
|
||||
pKeDebugMonitorData);
|
||||
@@ -75,7 +75,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
|
||||
// KeCertMonitorData (?*)
|
||||
// Always set to zero, ignored.
|
||||
uint32_t pKeCertMonitorData = xe_memory_heap_alloc(memory_, 0, 4, 0);
|
||||
uint32_t pKeCertMonitorData = (uint32_t)memory_->HeapAlloc(0, 4, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeCertMonitorData,
|
||||
pKeCertMonitorData);
|
||||
@@ -86,7 +86,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
// 0x00000000, 0x06, 0x00, 0x00, 0x00, 0x00000000, 0x0000, 0x0000
|
||||
// Games seem to check if bit 26 (0x20) is set, which at least for xbox1
|
||||
// was whether an HDD was present. Not sure what the other flags are.
|
||||
uint32_t pXboxHardwareInfo = xe_memory_heap_alloc(memory_, 0, 16, 0);
|
||||
uint32_t pXboxHardwareInfo = (uint32_t)memory_->HeapAlloc(0, 16, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XboxHardwareInfo,
|
||||
pXboxHardwareInfo);
|
||||
@@ -103,13 +103,12 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
// 0x80101000 <- our module structure
|
||||
// 0x80101058 <- pointer to xex header
|
||||
// 0x80101100 <- xex header base
|
||||
uint32_t ppXexExecutableModuleHandle =
|
||||
xe_memory_heap_alloc(memory_, 0, 4, 0);
|
||||
uint32_t ppXexExecutableModuleHandle = (uint32_t)memory_->HeapAlloc(0, 4, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XexExecutableModuleHandle,
|
||||
ppXexExecutableModuleHandle);
|
||||
uint32_t pXexExecutableModuleHandle =
|
||||
xe_memory_heap_alloc(memory_, 0, 256, 0);
|
||||
(uint32_t)memory_->HeapAlloc(0, 256, 0);
|
||||
XESETUINT32BE(mem + ppXexExecutableModuleHandle, pXexExecutableModuleHandle);
|
||||
XESETUINT32BE(mem + pXexExecutableModuleHandle + 0x58, 0x80101100);
|
||||
|
||||
@@ -117,7 +116,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
// The name of the xex. Not sure this is ever really used on real devices.
|
||||
// Perhaps it's how swap disc/etc data is sent?
|
||||
// Always set to "default.xex" (with quotes) for now.
|
||||
uint32_t pExLoadedCommandLine = xe_memory_heap_alloc(memory_, 0, 1024, 0);
|
||||
uint32_t pExLoadedCommandLine = (uint32_t)memory_->HeapAlloc(0, 1024, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::ExLoadedCommandLine,
|
||||
pExLoadedCommandLine);
|
||||
@@ -128,7 +127,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
// XboxKrnlVersion (8b)
|
||||
// Kernel version, looks like 2b.2b.2b.2b.
|
||||
// I've only seen games check >=, so we just fake something here.
|
||||
uint32_t pXboxKrnlVersion = xe_memory_heap_alloc(memory_, 0, 8, 0);
|
||||
uint32_t pXboxKrnlVersion = (uint32_t)memory_->HeapAlloc(0, 8, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XboxKrnlVersion,
|
||||
pXboxKrnlVersion);
|
||||
@@ -138,7 +137,7 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
XESETUINT16BE(mem + pXboxKrnlVersion + 6, 0xFFFF);
|
||||
|
||||
// KeTimeStampBundle (ad)
|
||||
uint32_t pKeTimeStampBundle = xe_memory_heap_alloc(memory_, 0, 24, 0);
|
||||
uint32_t pKeTimeStampBundle = (uint32_t)memory_->HeapAlloc(0, 24, 0);
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeTimeStampBundle,
|
||||
pKeTimeStampBundle);
|
||||
|
||||
@@ -97,7 +97,7 @@ X_STATUS xeExGetXConfigSetting(
|
||||
|
||||
|
||||
SHIM_CALL ExGetXConfigSetting_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint16_t category = SHIM_GET_ARG_16(0);
|
||||
uint16_t setting = SHIM_GET_ARG_16(1);
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -149,7 +149,7 @@ int xeXexCheckExecutablePriviledge(uint32_t privilege) {
|
||||
|
||||
|
||||
SHIM_CALL XexCheckExecutablePrivilege_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t privilege = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -186,7 +186,7 @@ int xeXexGetModuleHandle(const char* module_name,
|
||||
|
||||
|
||||
SHIM_CALL XexGetModuleHandle_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t module_name_ptr = SHIM_GET_ARG_32(0);
|
||||
const char* module_name = (const char*)SHIM_MEM_ADDR(module_name_ptr);
|
||||
uint32_t module_handle_ptr = SHIM_GET_ARG_32(1);
|
||||
@@ -206,12 +206,12 @@ SHIM_CALL XexGetModuleHandle_shim(
|
||||
|
||||
|
||||
// SHIM_CALL XexGetModuleSection_shim(
|
||||
// xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
// PPCContext* ppc_state, KernelState* state) {
|
||||
// }
|
||||
|
||||
|
||||
// SHIM_CALL XexGetProcedureAddress_shim(
|
||||
// xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
// PPCContext* ppc_state, KernelState* state) {
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace xboxkrnl {
|
||||
|
||||
|
||||
SHIM_CALL NtClose_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace xboxkrnl {
|
||||
|
||||
|
||||
SHIM_CALL ObReferenceObjectByHandle_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t object_type_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t out_object_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -66,7 +66,7 @@ SHIM_CALL ObReferenceObjectByHandle_shim(
|
||||
|
||||
|
||||
SHIM_CALL ObDereferenceObject_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t native_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
|
||||
@@ -57,7 +57,7 @@ uint32_t xeRtlCompareMemory(uint32_t source1_ptr, uint32_t source2_ptr,
|
||||
|
||||
|
||||
SHIM_CALL RtlCompareMemory_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t source1 = SHIM_GET_ARG_32(0);
|
||||
uint32_t source2 = SHIM_GET_ARG_32(1);
|
||||
uint32_t length = SHIM_GET_ARG_32(2);
|
||||
@@ -107,7 +107,7 @@ uint32_t xeRtlCompareMemoryUlong(uint32_t source_ptr, uint32_t length,
|
||||
|
||||
|
||||
SHIM_CALL RtlCompareMemoryUlong_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t source = SHIM_GET_ARG_32(0);
|
||||
uint32_t length = SHIM_GET_ARG_32(1);
|
||||
uint32_t pattern = SHIM_GET_ARG_32(2);
|
||||
@@ -150,7 +150,7 @@ void xeRtlFillMemoryUlong(uint32_t destination_ptr, uint32_t length,
|
||||
|
||||
|
||||
SHIM_CALL RtlFillMemoryUlong_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t destination = SHIM_GET_ARG_32(0);
|
||||
uint32_t length = SHIM_GET_ARG_32(1);
|
||||
uint32_t pattern = SHIM_GET_ARG_32(2);
|
||||
@@ -195,7 +195,7 @@ void xeRtlInitAnsiString(uint32_t destination_ptr, uint32_t source_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL RtlInitAnsiString_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t destination_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t source_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -226,7 +226,7 @@ void xeRtlFreeAnsiString(uint32_t string_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL RtlFreeAnsiString_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t string_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD("RtlFreeAnsiString(%.8X)", string_ptr);
|
||||
@@ -268,7 +268,7 @@ void xeRtlInitUnicodeString(uint32_t destination_ptr, uint32_t source_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL RtlInitUnicodeString_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t destination_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t source_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -300,7 +300,7 @@ void xeRtlFreeUnicodeString(uint32_t string_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL RtlFreeUnicodeString_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t string_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD("RtlFreeUnicodeString(%.8X)", string_ptr);
|
||||
@@ -336,7 +336,7 @@ X_STATUS xeRtlUnicodeStringToAnsiString(
|
||||
|
||||
|
||||
SHIM_CALL RtlUnicodeStringToAnsiString_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t destination_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t source_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t alloc_dest = SHIM_GET_ARG_32(2);
|
||||
@@ -352,7 +352,7 @@ SHIM_CALL RtlUnicodeStringToAnsiString_shim(
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL _vsnprintf_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t count = SHIM_GET_ARG_32(1);
|
||||
@@ -569,7 +569,7 @@ uint32_t xeRtlNtStatusToDosError(X_STATUS status) {
|
||||
|
||||
|
||||
SHIM_CALL RtlNtStatusToDosError_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t status = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -618,7 +618,7 @@ uint32_t xeRtlImageXexHeaderField(uint32_t xex_header_base_ptr,
|
||||
|
||||
|
||||
SHIM_CALL RtlImageXexHeaderField_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t xex_header_base = SHIM_GET_ARG_32(0);
|
||||
uint32_t image_field = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -690,7 +690,7 @@ void xeRtlInitializeCriticalSection(uint32_t cs_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL RtlInitializeCriticalSection_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD("RtlInitializeCriticalSection(%.8X)", cs_ptr);
|
||||
@@ -727,7 +727,7 @@ X_STATUS xeRtlInitializeCriticalSectionAndSpinCount(
|
||||
|
||||
|
||||
SHIM_CALL RtlInitializeCriticalSectionAndSpinCount_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t spin_count = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -780,7 +780,7 @@ spin:
|
||||
|
||||
|
||||
SHIM_CALL RtlEnterCriticalSection_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD("RtlEnterCriticalSection(%.8X)", cs_ptr);
|
||||
@@ -818,7 +818,7 @@ uint32_t xeRtlTryEnterCriticalSection(uint32_t cs_ptr, uint32_t thread_id) {
|
||||
|
||||
|
||||
SHIM_CALL RtlTryEnterCriticalSection_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD("RtlTryEnterCriticalSection(%.8X)", cs_ptr);
|
||||
@@ -858,7 +858,7 @@ void xeRtlLeaveCriticalSection(uint32_t cs_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL RtlLeaveCriticalSection_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD("RtlLeaveCriticalSection(%.8X)", cs_ptr);
|
||||
|
||||
@@ -99,7 +99,7 @@ X_STATUS xeExCreateThread(
|
||||
|
||||
|
||||
SHIM_CALL ExCreateThread_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t stack_size = SHIM_GET_ARG_32(1);
|
||||
uint32_t thread_id_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -155,7 +155,7 @@ X_STATUS xeNtResumeThread(uint32_t handle, uint32_t* out_suspend_count) {
|
||||
|
||||
|
||||
SHIM_CALL NtResumeThread_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t suspend_count_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -190,7 +190,7 @@ uint32_t xeKeSetAffinityThread(void* thread_ptr, uint32_t affinity) {
|
||||
|
||||
|
||||
SHIM_CALL KeSetAffinityThread_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t thread = SHIM_GET_ARG_32(0);
|
||||
uint32_t affinity = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -216,7 +216,7 @@ uint32_t xeKeGetCurrentProcessType() {
|
||||
|
||||
|
||||
SHIM_CALL KeGetCurrentProcessType_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"KeGetCurrentProcessType()");
|
||||
|
||||
@@ -236,7 +236,7 @@ uint64_t xeKeQueryPerformanceFrequency() {
|
||||
|
||||
|
||||
SHIM_CALL KeQueryPerformanceFrequency_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"KeQueryPerformanceFrequency()");
|
||||
|
||||
@@ -253,7 +253,7 @@ X_STATUS xeKeDelayExecutionThread(
|
||||
|
||||
|
||||
SHIM_CALL KeDelayExecutionThread_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t processor_mode = SHIM_GET_ARG_32(0);
|
||||
uint32_t alertable = SHIM_GET_ARG_32(1);
|
||||
uint32_t interval_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -278,7 +278,7 @@ void xeKeQuerySystemTime(uint64_t* time_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL KeQuerySystemTime_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t time_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -322,7 +322,7 @@ uint32_t xeKeTlsAlloc() {
|
||||
|
||||
|
||||
SHIM_CALL KeTlsAlloc_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"KeTlsAlloc()");
|
||||
|
||||
@@ -353,7 +353,7 @@ int KeTlsFree(uint32_t tls_index) {
|
||||
|
||||
|
||||
SHIM_CALL KeTlsFree_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t tls_index = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -388,7 +388,7 @@ uint64_t xeKeTlsGetValue(uint32_t tls_index) {
|
||||
|
||||
|
||||
SHIM_CALL KeTlsGetValue_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t tls_index = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -419,7 +419,7 @@ int xeKeTlsSetValue(uint32_t tls_index, uint64_t tls_value) {
|
||||
|
||||
|
||||
SHIM_CALL KeTlsSetValue_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t tls_index = SHIM_GET_ARG_32(0);
|
||||
uint32_t tls_value = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -452,7 +452,7 @@ X_STATUS xeNtCreateEvent(uint32_t* handle_ptr, void* obj_attributes,
|
||||
|
||||
|
||||
SHIM_CALL NtCreateEvent_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t obj_attributes_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t event_type = SHIM_GET_ARG_32(2);
|
||||
@@ -491,7 +491,7 @@ int32_t xeKeSetEvent(void* event_ptr, uint32_t increment, uint32_t wait) {
|
||||
|
||||
|
||||
SHIM_CALL KeSetEvent_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t event_ref = SHIM_GET_ARG_32(0);
|
||||
uint32_t increment = SHIM_GET_ARG_32(1);
|
||||
uint32_t wait = SHIM_GET_ARG_32(2);
|
||||
@@ -508,7 +508,7 @@ SHIM_CALL KeSetEvent_shim(
|
||||
|
||||
|
||||
SHIM_CALL NtSetEvent_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t event_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t previous_state_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -549,7 +549,7 @@ int32_t xeKeResetEvent(void* event_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL KeResetEvent_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t event_ref = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -564,7 +564,7 @@ SHIM_CALL KeResetEvent_shim(
|
||||
|
||||
|
||||
SHIM_CALL NtClearEvent_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t event_handle = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -602,7 +602,7 @@ X_STATUS xeKeWaitForSingleObject(
|
||||
|
||||
|
||||
SHIM_CALL KeWaitForSingleObject_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t object = SHIM_GET_ARG_32(0);
|
||||
uint32_t wait_reason = SHIM_GET_ARG_32(1);
|
||||
uint32_t processor_mode = SHIM_GET_ARG_32(2);
|
||||
@@ -624,7 +624,7 @@ SHIM_CALL KeWaitForSingleObject_shim(
|
||||
|
||||
|
||||
SHIM_CALL NtWaitForSingleObjectEx_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t object_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t timeout = SHIM_GET_ARG_32(1);
|
||||
uint32_t alertable = SHIM_GET_ARG_32(2);
|
||||
@@ -665,7 +665,7 @@ uint32_t xeKfAcquireSpinLock(void* lock_ptr) {
|
||||
|
||||
|
||||
SHIM_CALL KfAcquireSpinLock_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t lock_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -689,7 +689,7 @@ void xeKfReleaseSpinLock(void* lock_ptr, uint32_t old_irql) {
|
||||
|
||||
|
||||
SHIM_CALL KfReleaseSpinLock_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t lock_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t old_irql = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -708,7 +708,7 @@ void xeKeEnterCriticalRegion() {
|
||||
|
||||
|
||||
SHIM_CALL KeEnterCriticalRegion_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"KeEnterCriticalRegion()");
|
||||
xeKeEnterCriticalRegion();
|
||||
@@ -721,7 +721,7 @@ void xeKeLeaveCriticalRegion() {
|
||||
|
||||
|
||||
SHIM_CALL KeLeaveCriticalRegion_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"KeLeaveCriticalRegion()");
|
||||
xeKeLeaveCriticalRegion();
|
||||
|
||||
@@ -49,7 +49,7 @@ void xeVdGetCurrentDisplayGamma(uint32_t* arg0, float* arg1) {
|
||||
|
||||
|
||||
SHIM_CALL VdGetCurrentDisplayGamma_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t arg0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t arg1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -69,7 +69,7 @@ SHIM_CALL VdGetCurrentDisplayGamma_shim(
|
||||
|
||||
|
||||
SHIM_CALL VdGetCurrentDisplayInformation_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -92,7 +92,7 @@ uint32_t xeVdQueryVideoFlags() {
|
||||
|
||||
|
||||
SHIM_CALL VdQueryVideoFlags_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdQueryVideoFlags()");
|
||||
|
||||
@@ -131,7 +131,7 @@ void xeVdQueryVideoMode(X_VIDEO_MODE *video_mode, bool swap) {
|
||||
|
||||
|
||||
SHIM_CALL VdQueryVideoMode_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t video_mode_ptr = SHIM_GET_ARG_32(0);
|
||||
X_VIDEO_MODE *video_mode = (X_VIDEO_MODE*)SHIM_MEM_ADDR(video_mode_ptr);
|
||||
|
||||
@@ -160,7 +160,7 @@ void xeVdInitializeEngines(uint32_t unk0, uint32_t callback, uint32_t unk1,
|
||||
|
||||
|
||||
SHIM_CALL VdInitializeEngines_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t callback = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(2);
|
||||
@@ -192,7 +192,7 @@ void xeVdSetGraphicsInterruptCallback(uint32_t callback, uint32_t user_data) {
|
||||
|
||||
|
||||
SHIM_CALL VdSetGraphicsInterruptCallback_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t callback = SHIM_GET_ARG_32(0);
|
||||
uint32_t user_data = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -224,7 +224,7 @@ void xeVdInitializeRingBuffer(uint32_t ptr, uint32_t page_count) {
|
||||
|
||||
|
||||
SHIM_CALL VdInitializeRingBuffer_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t page_count = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -268,7 +268,7 @@ void xeVdEnableRingBufferRPtrWriteBack(uint32_t ptr, uint32_t block_size) {
|
||||
|
||||
|
||||
SHIM_CALL VdEnableRingBufferRPtrWriteBack_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t block_size = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -287,7 +287,7 @@ void xeVdGetSystemCommandBuffer(uint32_t* p0, uint32_t* p1) {
|
||||
|
||||
|
||||
SHIM_CALL VdGetSystemCommandBuffer_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t p0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t p1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -317,7 +317,7 @@ void xeVdSetSystemCommandBufferGpuIdentifierAddress(uint32_t unk) {
|
||||
|
||||
|
||||
SHIM_CALL VdSetSystemCommandBufferGpuIdentifierAddress_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t unk = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -341,7 +341,7 @@ SHIM_CALL VdSetSystemCommandBufferGpuIdentifierAddress_shim(
|
||||
|
||||
|
||||
SHIM_CALL VdIsHSIOTrainingSucceeded_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdIsHSIOTrainingSucceeded()");
|
||||
|
||||
@@ -352,7 +352,7 @@ SHIM_CALL VdIsHSIOTrainingSucceeded_shim(
|
||||
|
||||
|
||||
SHIM_CALL VdPersistDisplay_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdPersistDisplay(?)");
|
||||
|
||||
@@ -362,7 +362,7 @@ SHIM_CALL VdPersistDisplay_shim(
|
||||
|
||||
|
||||
SHIM_CALL VdRetrainEDRAMWorker_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
@@ -374,7 +374,7 @@ SHIM_CALL VdRetrainEDRAMWorker_shim(
|
||||
|
||||
|
||||
SHIM_CALL VdRetrainEDRAM_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
@@ -391,7 +391,7 @@ SHIM_CALL VdRetrainEDRAM_shim(
|
||||
|
||||
|
||||
SHIM_CALL VdSwap_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0); // ptr into primary ringbuffer
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
@@ -454,13 +454,13 @@ void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdRetrainEDRAM, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdSwap, state);
|
||||
|
||||
xe_memory_ref memory = state->memory();
|
||||
uint8_t* mem = xe_memory_addr(memory);
|
||||
Memory* memory = state->memory();
|
||||
uint8_t* mem = memory->membase();
|
||||
|
||||
// VdGlobalDevice (4b)
|
||||
// Pointer to a global D3D device. Games only seem to set this, so we don't
|
||||
// have to do anything. We may want to read it back later, though.
|
||||
uint32_t pVdGlobalDevice = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
uint32_t pVdGlobalDevice = (uint32_t)memory->HeapAlloc(0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGlobalDevice,
|
||||
pVdGlobalDevice);
|
||||
@@ -468,7 +468,7 @@ void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
|
||||
// VdGlobalXamDevice (4b)
|
||||
// Pointer to the XAM D3D device, which we don't have.
|
||||
uint32_t pVdGlobalXamDevice = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
uint32_t pVdGlobalXamDevice = (uint32_t)memory->HeapAlloc(0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGlobalXamDevice,
|
||||
pVdGlobalXamDevice);
|
||||
@@ -476,7 +476,7 @@ void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
|
||||
// VdGpuClockInMHz (4b)
|
||||
// GPU clock. Xenos is 500MHz. Hope nothing is relying on this timing...
|
||||
uint32_t pVdGpuClockInMHz = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
uint32_t pVdGpuClockInMHz = (uint32_t)memory->HeapAlloc(0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGpuClockInMHz,
|
||||
pVdGpuClockInMHz);
|
||||
@@ -484,7 +484,7 @@ void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
|
||||
// VdHSIOCalibrationLock (28b)
|
||||
// CriticalSection.
|
||||
uint32_t pVdHSIOCalibrationLock = xe_memory_heap_alloc(memory, 0, 28, 0);
|
||||
uint32_t pVdHSIOCalibrationLock = (uint32_t)memory->HeapAlloc(0, 28, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdHSIOCalibrationLock,
|
||||
pVdHSIOCalibrationLock);
|
||||
|
||||
@@ -31,7 +31,7 @@ XObject::~XObject() {
|
||||
XEASSERTZERO(pointer_ref_count_);
|
||||
}
|
||||
|
||||
xe_memory_ref XObject::memory() {
|
||||
Memory* XObject::memory() const {
|
||||
return kernel_state_->memory();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void XObject::SetNativePointer(uint32_t native_ptr) {
|
||||
XObject::LockType();
|
||||
|
||||
DISPATCH_HEADER* header_be =
|
||||
(DISPATCH_HEADER*)xe_memory_addr(kernel_state_->memory(), native_ptr);
|
||||
(DISPATCH_HEADER*)kernel_state_->memory()->Translate(native_ptr);
|
||||
DISPATCH_HEADER header;
|
||||
header.type_flags = XESWAP32(header_be->type_flags);
|
||||
header.signal_state = XESWAP32(header_be->signal_state);
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
static XObject* GetObject(KernelState* kernel_state, void* native_ptr);
|
||||
|
||||
protected:
|
||||
xe_memory_ref memory(); // unretained
|
||||
Memory* memory() const;
|
||||
void SetNativePointer(uint32_t native_ptr);
|
||||
|
||||
KernelState* kernel_state_;
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
#include <third_party/mspack/mspack.h>
|
||||
#include <third_party/pe/pe_image.h>
|
||||
|
||||
using namespace alloy;
|
||||
|
||||
|
||||
typedef struct xe_xex2 {
|
||||
xe_ref_t ref;
|
||||
|
||||
xe_memory_ref memory;
|
||||
Memory* memory;
|
||||
|
||||
xe_xex2_header_t header;
|
||||
|
||||
@@ -35,17 +37,17 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length,
|
||||
int xe_xex2_decrypt_key(xe_xex2_header_t *header);
|
||||
int xe_xex2_read_image(xe_xex2_ref xex,
|
||||
const uint8_t *xex_addr, const size_t xex_length,
|
||||
xe_memory_ref memory);
|
||||
Memory* memory);
|
||||
int xe_xex2_load_pe(xe_xex2_ref xex);
|
||||
|
||||
|
||||
xe_xex2_ref xe_xex2_load(xe_memory_ref memory,
|
||||
xe_xex2_ref xe_xex2_load(Memory* memory,
|
||||
const void* addr, const size_t length,
|
||||
xe_xex2_options_t options) {
|
||||
xe_xex2_ref xex = (xe_xex2_ref)xe_calloc(sizeof(xe_xex2));
|
||||
xe_ref_init((xe_ref)xex);
|
||||
|
||||
xex->memory = xe_memory_retain(memory);
|
||||
xex->memory = memory;
|
||||
xex->sections = new std::vector<PESection*>();
|
||||
|
||||
XEEXPECTZERO(xe_xex2_read_header((const uint8_t*)addr, length, &xex->header));
|
||||
@@ -79,7 +81,7 @@ void xe_xex2_dealloc(xe_xex2_ref xex) {
|
||||
xe_free(library->records);
|
||||
}
|
||||
|
||||
xe_memory_release(xex->memory);
|
||||
xex->memory = NULL;
|
||||
}
|
||||
|
||||
xe_xex2_ref xe_xex2_retain(xe_xex2_ref xex) {
|
||||
@@ -529,19 +531,19 @@ void xe_xex2_decrypt_buffer(const uint8_t *session_key,
|
||||
int xe_xex2_read_image_uncompressed(const xe_xex2_header_t *header,
|
||||
const uint8_t *xex_addr,
|
||||
const size_t xex_length,
|
||||
xe_memory_ref memory) {
|
||||
Memory* memory) {
|
||||
// Allocate in-place the XEX memory.
|
||||
const size_t exe_length = xex_length - header->exe_offset;
|
||||
size_t uncompressed_size = exe_length;
|
||||
uint32_t alloc_result = xe_memory_heap_alloc(
|
||||
memory, header->exe_address, (uint32_t)uncompressed_size,
|
||||
XE_MEMORY_FLAG_ZERO);
|
||||
uint32_t alloc_result = (uint32_t)memory->HeapAlloc(
|
||||
header->exe_address, uncompressed_size,
|
||||
MEMORY_FLAG_ZERO);
|
||||
if (!alloc_result) {
|
||||
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.",
|
||||
header->exe_address, uncompressed_size);
|
||||
return 2;
|
||||
}
|
||||
uint8_t *buffer = (uint8_t*)xe_memory_addr(memory, header->exe_address);
|
||||
uint8_t *buffer = memory->Translate(header->exe_address);
|
||||
|
||||
const uint8_t *p = (const uint8_t*)xex_addr + header->exe_offset;
|
||||
|
||||
@@ -563,7 +565,7 @@ int xe_xex2_read_image_uncompressed(const xe_xex2_header_t *header,
|
||||
int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header,
|
||||
const uint8_t *xex_addr,
|
||||
const size_t xex_length,
|
||||
xe_memory_ref memory) {
|
||||
Memory* memory) {
|
||||
const size_t exe_length = xex_length - header->exe_offset;
|
||||
const uint8_t* source_buffer = (const uint8_t*)xex_addr + header->exe_offset;
|
||||
const uint8_t *p = source_buffer;
|
||||
@@ -579,15 +581,15 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header,
|
||||
}
|
||||
|
||||
// Allocate in-place the XEX memory.
|
||||
uint32_t alloc_result = xe_memory_heap_alloc(
|
||||
memory, header->exe_address, (uint32_t)uncompressed_size,
|
||||
XE_MEMORY_FLAG_ZERO);
|
||||
uint32_t alloc_result = (uint32_t)memory->HeapAlloc(
|
||||
header->exe_address, uncompressed_size,
|
||||
MEMORY_FLAG_ZERO);
|
||||
if (!alloc_result) {
|
||||
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.",
|
||||
header->exe_address, uncompressed_size);
|
||||
XEFAIL();
|
||||
}
|
||||
uint8_t *buffer = (uint8_t*)xe_memory_addr(memory, header->exe_address);
|
||||
uint8_t *buffer = memory->Translate(header->exe_address);
|
||||
uint8_t *d = buffer;
|
||||
|
||||
uint32_t rk[4 * (MAXNR + 1)];
|
||||
@@ -637,7 +639,7 @@ XECLEANUP:
|
||||
int xe_xex2_read_image_compressed(const xe_xex2_header_t *header,
|
||||
const uint8_t *xex_addr,
|
||||
const size_t xex_length,
|
||||
xe_memory_ref memory) {
|
||||
Memory* memory) {
|
||||
const size_t exe_length = xex_length - header->exe_offset;
|
||||
const uint8_t *exe_buffer = (const uint8_t*)xex_addr + header->exe_offset;
|
||||
|
||||
@@ -717,16 +719,16 @@ int xe_xex2_read_image_compressed(const xe_xex2_header_t *header,
|
||||
}
|
||||
|
||||
// Allocate in-place the XEX memory.
|
||||
uint32_t alloc_result = xe_memory_heap_alloc(
|
||||
memory, header->exe_address, (uint32_t)uncompressed_size,
|
||||
XE_MEMORY_FLAG_ZERO);
|
||||
uint32_t alloc_result = (uint32_t)memory->HeapAlloc(
|
||||
header->exe_address, uncompressed_size,
|
||||
MEMORY_FLAG_ZERO);
|
||||
if (!alloc_result) {
|
||||
XELOGE("Unable to allocate XEX memory at %.8X-%.8X.",
|
||||
header->exe_address, uncompressed_size);
|
||||
result_code = 2;
|
||||
XEFAIL();
|
||||
}
|
||||
uint8_t *buffer = (uint8_t*)xe_memory_addr(memory, header->exe_address);
|
||||
uint8_t *buffer = memory->Translate(header->exe_address);
|
||||
|
||||
// Setup decompressor and decompress.
|
||||
sys = mspack_memory_sys_create();
|
||||
@@ -774,7 +776,7 @@ XECLEANUP:
|
||||
}
|
||||
|
||||
int xe_xex2_read_image(xe_xex2_ref xex, const uint8_t *xex_addr,
|
||||
const size_t xex_length, xe_memory_ref memory) {
|
||||
const size_t xex_length, Memory* memory) {
|
||||
const xe_xex2_header_t *header = &xex->header;
|
||||
switch (header->file_format_info.compression_type) {
|
||||
case XEX_COMPRESSION_NONE:
|
||||
@@ -794,7 +796,7 @@ int xe_xex2_read_image(xe_xex2_ref xex, const uint8_t *xex_addr,
|
||||
|
||||
int xe_xex2_load_pe(xe_xex2_ref xex) {
|
||||
const xe_xex2_header_t* header = &xex->header;
|
||||
const uint8_t* p = xe_memory_addr(xex->memory, header->exe_address);
|
||||
const uint8_t* p = xex->memory->Translate(header->exe_address);
|
||||
|
||||
// Verify DOS signature (MZ).
|
||||
const IMAGE_DOS_HEADER* doshdr = (const IMAGE_DOS_HEADER*)p;
|
||||
@@ -891,7 +893,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex,
|
||||
const xe_xex2_import_library_t *library,
|
||||
xe_xex2_import_info_t **out_import_infos,
|
||||
size_t *out_import_info_count) {
|
||||
uint8_t *mem = (uint8_t*)xe_memory_addr(xex->memory, 0);
|
||||
uint8_t *mem = xex->memory->membase();
|
||||
const xe_xex2_header_t *header = xe_xex2_get_header(xex);
|
||||
|
||||
// Find library index for verification.
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#define XENIA_KERNEL_XEX2_H_
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xex2_info.h>
|
||||
|
||||
typedef struct {
|
||||
@@ -46,7 +45,7 @@ public:
|
||||
uint32_t flags; // kXEPESection*
|
||||
};
|
||||
|
||||
xe_xex2_ref xe_xex2_load(xe_memory_ref memory,
|
||||
xe_xex2_ref xe_xex2_load(xe::Memory* memory,
|
||||
const void* addr, const size_t length,
|
||||
xe_xex2_options_t options);
|
||||
xe_xex2_ref xe_xex2_retain(xe_xex2_ref xex);
|
||||
|
||||
Reference in New Issue
Block a user