Switching shim mapping macro to use ordinal constants.

This commit is contained in:
Ben Vanik 2013-05-26 20:10:10 -07:00
parent a332faf419
commit 25d8b5f8d8
14 changed files with 53 additions and 71 deletions

View File

@ -70,13 +70,7 @@ SHIM_CALL XGetLanguage_shim(
void xe::kernel::xam::RegisterInfoExports(
ExportResolver* export_resolver, XamState* state) {
#define SHIM_SET_MAPPING(ordinal, shim, impl) \
export_resolver->SetFunctionMapping("xam.xex", ordinal, \
state, (xe_kernel_export_shim_fn)shim, (xe_kernel_export_impl_fn)impl)
SHIM_SET_MAPPING(0x000003CB, XGetAVPack_shim, NULL);
SHIM_SET_MAPPING(0x000003CC, XGetGameRegion_shim, NULL);
SHIM_SET_MAPPING(0x000003CD, XGetLanguage_shim, NULL);
#undef SET_MAPPING
SHIM_SET_MAPPING("xam.xex", XGetAVPack, state);
SHIM_SET_MAPPING("xam.xex", XGetGameRegion, state);
SHIM_SET_MAPPING("xam.xex", XGetLanguage, state);
}

View File

@ -11,6 +11,7 @@
#define XENIA_KERNEL_MODULES_XAM_INFO_H_
#include <xenia/kernel/modules/xam/xam_state.h>
#include <xenia/kernel/modules/xam/xam_ordinals.h>
namespace xe {

View File

@ -65,7 +65,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
// 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.
resolver->SetVariableMapping(
"xboxkrnl.exe", 0x00000059,
"xboxkrnl.exe", ordinals::KeDebugMonitorData,
0x80102100);
XESETUINT32BE(mem + 0x80102100, 0);
@ -75,7 +75,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
// 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.
resolver->SetVariableMapping(
"xboxkrnl.exe", 0x00000156,
"xboxkrnl.exe", ordinals::XboxHardwareInfo,
0x80100FED);
XESETUINT32BE(mem + 0x80100FED, 0x00000000); // flags
XESETUINT8BE(mem + 0x80100FEE, 0x06); // cpu count
@ -91,7 +91,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
// 0x80101058 <- pointer to xex header
// 0x80101100 <- xex header base
resolver->SetVariableMapping(
"xboxkrnl.exe", 0x00000193,
"xboxkrnl.exe", ordinals::XexExecutableModuleHandle,
0x80100FFC);
XESETUINT32BE(mem + 0x80100FFC, 0x80101000);
XESETUINT32BE(mem + 0x80101058, 0x80101100);
@ -101,7 +101,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
// Perhaps it's how swap disc/etc data is sent?
// Always set to "default.xex" (with quotes) for now.
resolver->SetVariableMapping(
"xboxkrnl.exe", 0x000001AE,
"xboxkrnl.exe", ordinals::ExLoadedCommandLine,
0x80102000);
char command_line[] = "\"default.xex\"";
xe_copy_memory(mem + 0x80102000, 1024,

View File

@ -49,11 +49,5 @@ SHIM_CALL HalReturnToFirmware_shim(
void xe::kernel::xboxkrnl::RegisterHalExports(
ExportResolver* export_resolver, KernelState* state) {
#define SHIM_SET_MAPPING(ordinal, shim, impl) \
export_resolver->SetFunctionMapping("xboxkrnl.exe", ordinal, \
state, (xe_kernel_export_shim_fn)shim, (xe_kernel_export_impl_fn)impl)
SHIM_SET_MAPPING(0x00000028, HalReturnToFirmware_shim, NULL);
#undef SET_MAPPING
SHIM_SET_MAPPING("xboxkrnl.exe", HalReturnToFirmware, state);
}

View File

@ -11,6 +11,7 @@
#define XENIA_KERNEL_MODULES_XBOXKRNL_HAL_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
namespace xe {

View File

@ -151,12 +151,6 @@ SHIM_CALL NtFreeVirtualMemory_shim(
void xe::kernel::xboxkrnl::RegisterMemoryExports(
ExportResolver* export_resolver, KernelState* state) {
#define SHIM_SET_MAPPING(ordinal, shim, impl) \
export_resolver->SetFunctionMapping("xboxkrnl.exe", ordinal, \
state, (xe_kernel_export_shim_fn)shim, (xe_kernel_export_impl_fn)impl)
SHIM_SET_MAPPING(0x000000CC, NtAllocateVirtualMemory_shim, NULL);
SHIM_SET_MAPPING(0x000000DC, NtFreeVirtualMemory_shim, NULL);
#undef SET_MAPPING
SHIM_SET_MAPPING("xboxkrnl.exe", NtAllocateVirtualMemory, state);
SHIM_SET_MAPPING("xboxkrnl.exe", NtFreeVirtualMemory, state);
}

View File

@ -11,6 +11,7 @@
#define XENIA_KERNEL_MODULES_XBOXKRNL_MEMORY_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
namespace xe {

View File

@ -109,17 +109,11 @@ SHIM_CALL XexGetModuleHandle_shim(
void xe::kernel::xboxkrnl::RegisterModuleExports(
ExportResolver* export_resolver, KernelState* state) {
#define SHIM_SET_MAPPING(ordinal, shim, impl) \
export_resolver->SetFunctionMapping("xboxkrnl.exe", ordinal, \
state, (xe_kernel_export_shim_fn)shim, (xe_kernel_export_impl_fn)impl)
// SHIM_SET_MAPPING("xboxkrnl.exe", ExGetXConfigSetting, state);
//SHIM_SET_MAPPING(0x00000010, ExGetXConfigSetting_shim, NULL);
SHIM_SET_MAPPING("xboxkrnl.exe", XexCheckExecutablePrivilege, state);
SHIM_SET_MAPPING(0x00000194, XexCheckExecutablePrivilege_shim, NULL);
SHIM_SET_MAPPING(0x00000195, XexGetModuleHandle_shim, NULL);
// SHIM_SET_MAPPING(0x00000196, XexGetModuleSection_shim, NULL);
// SHIM_SET_MAPPING(0x00000197, XexGetProcedureAddress_shim, NULL);
#undef SET_MAPPING
SHIM_SET_MAPPING("xboxkrnl.exe", XexGetModuleHandle, state);
// SHIM_SET_MAPPING("xboxkrnl.exe", XexGetModuleSection, state);
// SHIM_SET_MAPPING("xboxkrnl.exe", XexGetProcedureAddress, state);
}

View File

@ -11,6 +11,7 @@
#define XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_IMPL_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
namespace xe {

View File

@ -489,27 +489,21 @@ SHIM_CALL RtlLeaveCriticalSection_shim(
void xe::kernel::xboxkrnl::RegisterRtlExports(
ExportResolver* export_resolver, KernelState* state) {
#define SHIM_SET_MAPPING(ordinal, shim, impl) \
export_resolver->SetFunctionMapping("xboxkrnl.exe", ordinal, \
state, (xe_kernel_export_shim_fn)shim, (xe_kernel_export_impl_fn)impl)
SHIM_SET_MAPPING("xboxkrnl.exe", RtlCompareMemory, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlCompareMemoryUlong, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlFillMemoryUlong, state);
SHIM_SET_MAPPING(0x0000011A, RtlCompareMemory_shim, NULL);
SHIM_SET_MAPPING(0x0000011B, RtlCompareMemoryUlong_shim, NULL);
SHIM_SET_MAPPING(0x00000126, RtlFillMemoryUlong_shim, NULL);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitAnsiString, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlFreeAnsiString, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitUnicodeString, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlFreeUnicodeString, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlUnicodeStringToAnsiString, state);
SHIM_SET_MAPPING(0x0000012C, RtlInitAnsiString_shim, NULL);
SHIM_SET_MAPPING(0x00000127, RtlFreeAnsiString_shim, NULL);
SHIM_SET_MAPPING(0x0000012D, RtlInitUnicodeString_shim, NULL);
SHIM_SET_MAPPING(0x00000128, RtlFreeUnicodeString_shim, NULL);
SHIM_SET_MAPPING(0x00000142, RtlUnicodeStringToAnsiString_shim, NULL);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlImageXexHeaderField, state);
SHIM_SET_MAPPING(0x0000012B, RtlImageXexHeaderField_shim, NULL);
SHIM_SET_MAPPING(0x0000012E, RtlInitializeCriticalSection_shim, NULL);
SHIM_SET_MAPPING(0x0000012F, RtlInitializeCriticalSectionAndSpinCount_shim, NULL);
SHIM_SET_MAPPING(0x00000125, RtlEnterCriticalSection_shim, NULL);
SHIM_SET_MAPPING(0x00000141, RtlTryEnterCriticalSection_shim, NULL);
SHIM_SET_MAPPING(0x00000130, RtlLeaveCriticalSection_shim, NULL);
#undef SET_MAPPING
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSection, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlInitializeCriticalSectionAndSpinCount, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlEnterCriticalSection, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlTryEnterCriticalSection, state);
SHIM_SET_MAPPING("xboxkrnl.exe", RtlLeaveCriticalSection, state);
}

View File

@ -11,6 +11,7 @@
#define XENIA_KERNEL_MODULES_XBOXKRNL_RTL_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
namespace xe {

View File

@ -242,18 +242,12 @@ SHIM_CALL KeTlsSetValue_shim(
void xe::kernel::xboxkrnl::RegisterThreadingExports(
ExportResolver* export_resolver, KernelState* state) {
#define SHIM_SET_MAPPING(ordinal, shim, impl) \
export_resolver->SetFunctionMapping("xboxkrnl.exe", ordinal, \
state, (xe_kernel_export_shim_fn)shim, (xe_kernel_export_impl_fn)impl)
SHIM_SET_MAPPING("xboxkrnl.exe", ExCreateThread, state);
SHIM_SET_MAPPING(0x0000000D, ExCreateThread_shim, NULL);
SHIM_SET_MAPPING("xboxkrnl.exe", KeGetCurrentProcessType, state);
SHIM_SET_MAPPING(0x00000066, KeGetCurrentProcessType_shim, NULL);
SHIM_SET_MAPPING(0x00000152, KeTlsAlloc_shim, NULL);
SHIM_SET_MAPPING(0x00000153, KeTlsFree_shim, NULL);
SHIM_SET_MAPPING(0x00000154, KeTlsGetValue_shim, NULL);
SHIM_SET_MAPPING(0x00000155, KeTlsSetValue_shim, NULL);
#undef SET_MAPPING
SHIM_SET_MAPPING("xboxkrnl.exe", KeTlsAlloc, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeTlsFree, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeTlsGetValue, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeTlsSetValue, state);
}

View File

@ -11,6 +11,7 @@
#define XENIA_KERNEL_MODULES_XBOXKRNL_THREADING_H_
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
namespace xe {

View File

@ -23,6 +23,18 @@ namespace kernel {
#define SHIM_CALL void _cdecl
#define SHIM_SET_MAPPING(library_name, export_name, shim_data) \
export_resolver->SetFunctionMapping( \
library_name, ordinals::##export_name, \
shim_data, \
(xe_kernel_export_shim_fn)export_name##_shim, \
NULL);
#define SHIM_SET_MAPPING_WITH_IMPL(library_name, export_name, shim_data) \
export_resolver->SetFunctionMapping( \
library_name, ordinals::##export_name, \
shim_data, \
(xe_kernel_export_shim_fn)export_name##_shim, \
(xe_kernel_export_impl_fn)export_name##_impl);
#define SHIM_MEM_ADDR(a) (ppc_state->membase + a)