[Kernel] Suffix export functions with _entry.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -19,14 +19,14 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
dword_result_t XAudioGetSpeakerConfig(lpdword_t config_ptr) {
|
||||
dword_result_t XAudioGetSpeakerConfig_entry(lpdword_t config_ptr) {
|
||||
*config_ptr = 0x00010001;
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XAudioGetSpeakerConfig, kAudio, kImplemented);
|
||||
|
||||
dword_result_t XAudioGetVoiceCategoryVolumeChangeMask(lpunknown_t driver_ptr,
|
||||
lpdword_t out_ptr) {
|
||||
dword_result_t XAudioGetVoiceCategoryVolumeChangeMask_entry(
|
||||
lpunknown_t driver_ptr, lpdword_t out_ptr) {
|
||||
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
|
||||
|
||||
xe::threading::MaybeYield();
|
||||
@@ -39,7 +39,8 @@ dword_result_t XAudioGetVoiceCategoryVolumeChangeMask(lpunknown_t driver_ptr,
|
||||
DECLARE_XBOXKRNL_EXPORT2(XAudioGetVoiceCategoryVolumeChangeMask, kAudio, kStub,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XAudioGetVoiceCategoryVolume(dword_t unk, lpfloat_t out_ptr) {
|
||||
dword_result_t XAudioGetVoiceCategoryVolume_entry(dword_t unk,
|
||||
lpfloat_t out_ptr) {
|
||||
// Expects a floating point single. Volume %?
|
||||
*out_ptr = 1.0f;
|
||||
|
||||
@@ -48,11 +49,11 @@ dword_result_t XAudioGetVoiceCategoryVolume(dword_t unk, lpfloat_t out_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(XAudioGetVoiceCategoryVolume, kAudio, kStub,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XAudioEnableDucker(dword_t unk) { return X_ERROR_SUCCESS; }
|
||||
dword_result_t XAudioEnableDucker_entry(dword_t unk) { return X_ERROR_SUCCESS; }
|
||||
DECLARE_XBOXKRNL_EXPORT1(XAudioEnableDucker, kAudio, kStub);
|
||||
|
||||
dword_result_t XAudioRegisterRenderDriverClient(lpdword_t callback_ptr,
|
||||
lpdword_t driver_ptr) {
|
||||
dword_result_t XAudioRegisterRenderDriverClient_entry(lpdword_t callback_ptr,
|
||||
lpdword_t driver_ptr) {
|
||||
uint32_t callback = callback_ptr[0];
|
||||
uint32_t callback_arg = callback_ptr[1];
|
||||
|
||||
@@ -71,7 +72,8 @@ dword_result_t XAudioRegisterRenderDriverClient(lpdword_t callback_ptr,
|
||||
DECLARE_XBOXKRNL_EXPORT1(XAudioRegisterRenderDriverClient, kAudio,
|
||||
kImplemented);
|
||||
|
||||
dword_result_t XAudioUnregisterRenderDriverClient(lpunknown_t driver_ptr) {
|
||||
dword_result_t XAudioUnregisterRenderDriverClient_entry(
|
||||
lpunknown_t driver_ptr) {
|
||||
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
|
||||
|
||||
auto audio_system = kernel_state()->emulator()->audio_system();
|
||||
@@ -81,8 +83,8 @@ dword_result_t XAudioUnregisterRenderDriverClient(lpunknown_t driver_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(XAudioUnregisterRenderDriverClient, kAudio,
|
||||
kImplemented);
|
||||
|
||||
dword_result_t XAudioSubmitRenderDriverFrame(lpunknown_t driver_ptr,
|
||||
lpunknown_t samples_ptr) {
|
||||
dword_result_t XAudioSubmitRenderDriverFrame_entry(lpunknown_t driver_ptr,
|
||||
lpunknown_t samples_ptr) {
|
||||
assert_true((driver_ptr.guest_address() & 0xFFFF0000) == 0x41550000);
|
||||
|
||||
auto audio_system = kernel_state()->emulator()->audio_system();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ using xe::apu::XMA_CONTEXT_DATA;
|
||||
// restrictions of frame/subframe/etc:
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.xaudio2.xaudio2_buffer(v=vs.85).aspx
|
||||
|
||||
dword_result_t XMACreateContext(lpdword_t context_out_ptr) {
|
||||
dword_result_t XMACreateContext_entry(lpdword_t context_out_ptr) {
|
||||
auto xma_decoder = kernel_state()->emulator()->audio_system()->xma_decoder();
|
||||
uint32_t context_ptr = xma_decoder->AllocateContext();
|
||||
*context_out_ptr = context_ptr;
|
||||
@@ -70,7 +70,7 @@ dword_result_t XMACreateContext(lpdword_t context_out_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMACreateContext, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAReleaseContext(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAReleaseContext_entry(lpvoid_t context_ptr) {
|
||||
auto xma_decoder = kernel_state()->emulator()->audio_system()->xma_decoder();
|
||||
xma_decoder->ReleaseContext(context_ptr);
|
||||
return 0;
|
||||
@@ -117,8 +117,8 @@ struct XMA_CONTEXT_INIT {
|
||||
};
|
||||
static_assert_size(XMA_CONTEXT_INIT, 56);
|
||||
|
||||
dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
|
||||
pointer_t<XMA_CONTEXT_INIT> context_init) {
|
||||
dword_result_t XMAInitializeContext_entry(
|
||||
lpvoid_t context_ptr, pointer_t<XMA_CONTEXT_INIT> context_init) {
|
||||
// Input buffers may be null (buffer 1 in 415607D4).
|
||||
// Convert to host endianness.
|
||||
uint32_t input_buffer_0_guest_ptr = context_init->input_buffer_0_ptr;
|
||||
@@ -193,8 +193,8 @@ dword_result_t XMAInitializeContext(lpvoid_t context_ptr,
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAInitializeContext, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetLoopData(lpvoid_t context_ptr,
|
||||
pointer_t<XMA_CONTEXT_DATA> loop_data) {
|
||||
dword_result_t XMASetLoopData_entry(lpvoid_t context_ptr,
|
||||
pointer_t<XMA_CONTEXT_DATA> loop_data) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
|
||||
context.loop_start = loop_data->loop_start;
|
||||
@@ -209,15 +209,15 @@ dword_result_t XMASetLoopData(lpvoid_t context_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetLoopData, kAudio, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t XMAGetInputBufferReadOffset(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAGetInputBufferReadOffset_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.input_buffer_read_offset;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAGetInputBufferReadOffset, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetInputBufferReadOffset(lpvoid_t context_ptr,
|
||||
dword_t value) {
|
||||
dword_result_t XMASetInputBufferReadOffset_entry(lpvoid_t context_ptr,
|
||||
dword_t value) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
context.input_buffer_read_offset = value;
|
||||
context.Store(context_ptr);
|
||||
@@ -227,8 +227,8 @@ dword_result_t XMASetInputBufferReadOffset(lpvoid_t context_ptr,
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBufferReadOffset, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetInputBuffer0(lpvoid_t context_ptr, lpvoid_t buffer,
|
||||
dword_t packet_count) {
|
||||
dword_result_t XMASetInputBuffer0_entry(lpvoid_t context_ptr, lpvoid_t buffer,
|
||||
dword_t packet_count) {
|
||||
uint32_t buffer_physical_address =
|
||||
kernel_memory()->GetPhysicalAddress(buffer.guest_address());
|
||||
assert_true(buffer_physical_address != UINT32_MAX);
|
||||
@@ -251,14 +251,14 @@ dword_result_t XMASetInputBuffer0(lpvoid_t context_ptr, lpvoid_t buffer,
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer0, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAIsInputBuffer0Valid(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAIsInputBuffer0Valid_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.input_buffer_0_valid;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAIsInputBuffer0Valid, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetInputBuffer0Valid(lpvoid_t context_ptr) {
|
||||
dword_result_t XMASetInputBuffer0Valid_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
context.input_buffer_0_valid = 1;
|
||||
context.Store(context_ptr);
|
||||
@@ -268,8 +268,8 @@ dword_result_t XMASetInputBuffer0Valid(lpvoid_t context_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer0Valid, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetInputBuffer1(lpvoid_t context_ptr, lpvoid_t buffer,
|
||||
dword_t packet_count) {
|
||||
dword_result_t XMASetInputBuffer1_entry(lpvoid_t context_ptr, lpvoid_t buffer,
|
||||
dword_t packet_count) {
|
||||
uint32_t buffer_physical_address =
|
||||
kernel_memory()->GetPhysicalAddress(buffer.guest_address());
|
||||
assert_true(buffer_physical_address != UINT32_MAX);
|
||||
@@ -292,14 +292,14 @@ dword_result_t XMASetInputBuffer1(lpvoid_t context_ptr, lpvoid_t buffer,
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer1, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAIsInputBuffer1Valid(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAIsInputBuffer1Valid_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.input_buffer_1_valid;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAIsInputBuffer1Valid, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetInputBuffer1Valid(lpvoid_t context_ptr) {
|
||||
dword_result_t XMASetInputBuffer1Valid_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
context.input_buffer_1_valid = 1;
|
||||
context.Store(context_ptr);
|
||||
@@ -309,14 +309,14 @@ dword_result_t XMASetInputBuffer1Valid(lpvoid_t context_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetInputBuffer1Valid, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAIsOutputBufferValid(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAIsOutputBufferValid_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.output_buffer_valid;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAIsOutputBufferValid, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetOutputBufferValid(lpvoid_t context_ptr) {
|
||||
dword_result_t XMASetOutputBufferValid_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
context.output_buffer_valid = 1;
|
||||
context.Store(context_ptr);
|
||||
@@ -326,15 +326,15 @@ dword_result_t XMASetOutputBufferValid(lpvoid_t context_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetOutputBufferValid, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAGetOutputBufferReadOffset(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAGetOutputBufferReadOffset_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.output_buffer_read_offset;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAGetOutputBufferReadOffset, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMASetOutputBufferReadOffset(lpvoid_t context_ptr,
|
||||
dword_t value) {
|
||||
dword_result_t XMASetOutputBufferReadOffset_entry(lpvoid_t context_ptr,
|
||||
dword_t value) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
context.output_buffer_read_offset = value;
|
||||
context.Store(context_ptr);
|
||||
@@ -344,27 +344,27 @@ dword_result_t XMASetOutputBufferReadOffset(lpvoid_t context_ptr,
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMASetOutputBufferReadOffset, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAGetOutputBufferWriteOffset(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAGetOutputBufferWriteOffset_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.output_buffer_write_offset;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAGetOutputBufferWriteOffset, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMAGetPacketMetadata(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAGetPacketMetadata_entry(lpvoid_t context_ptr) {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
return context.packet_metadata;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XMAGetPacketMetadata, kAudio, kImplemented);
|
||||
|
||||
dword_result_t XMAEnableContext(lpvoid_t context_ptr) {
|
||||
dword_result_t XMAEnableContext_entry(lpvoid_t context_ptr) {
|
||||
StoreXmaContextIndexedRegister(kernel_state(), 0x1940, context_ptr);
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMAEnableContext, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMADisableContext(lpvoid_t context_ptr, dword_t wait) {
|
||||
dword_result_t XMADisableContext_entry(lpvoid_t context_ptr, dword_t wait) {
|
||||
X_HRESULT result = X_E_SUCCESS;
|
||||
StoreXmaContextIndexedRegister(kernel_state(), 0x1A40, context_ptr);
|
||||
if (!kernel_state()
|
||||
@@ -379,7 +379,7 @@ dword_result_t XMADisableContext(lpvoid_t context_ptr, dword_t wait) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(XMADisableContext, kAudio, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t XMABlockWhileInUse(lpvoid_t context_ptr) {
|
||||
dword_result_t XMABlockWhileInUse_entry(lpvoid_t context_ptr) {
|
||||
do {
|
||||
XMA_CONTEXT_DATA context(context_ptr);
|
||||
if (!context.input_buffer_0_valid && !context.input_buffer_1_valid) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -43,8 +43,8 @@ typedef struct {
|
||||
} XECRYPT_RC4_STATE;
|
||||
static_assert_size(XECRYPT_RC4_STATE, 0x102);
|
||||
|
||||
void XeCryptRc4Key(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t key,
|
||||
dword_t key_size) {
|
||||
void XeCryptRc4Key_entry(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t key,
|
||||
dword_t key_size) {
|
||||
// Setup RC4 state
|
||||
rc4_ctx->i = rc4_ctx->j = 0;
|
||||
for (uint32_t x = 0; x < 0x100; x++) {
|
||||
@@ -61,8 +61,8 @@ void XeCryptRc4Key(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t key,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptRc4Key, kNone, kImplemented);
|
||||
|
||||
void XeCryptRc4Ecb(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t data,
|
||||
dword_t size) {
|
||||
void XeCryptRc4Ecb_entry(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t data,
|
||||
dword_t size) {
|
||||
// Crypt data
|
||||
for (uint32_t idx = 0; idx < size; idx++) {
|
||||
rc4_ctx->i = (rc4_ctx->i + 1) % 0x100;
|
||||
@@ -79,10 +79,11 @@ void XeCryptRc4Ecb(pointer_t<XECRYPT_RC4_STATE> rc4_ctx, lpvoid_t data,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptRc4Ecb, kNone, kImplemented);
|
||||
|
||||
void XeCryptRc4(lpvoid_t key, dword_t key_size, lpvoid_t data, dword_t size) {
|
||||
void XeCryptRc4_entry(lpvoid_t key, dword_t key_size, lpvoid_t data,
|
||||
dword_t size) {
|
||||
XECRYPT_RC4_STATE rc4_ctx;
|
||||
XeCryptRc4Key(&rc4_ctx, key, key_size);
|
||||
XeCryptRc4Ecb(&rc4_ctx, data, size);
|
||||
XeCryptRc4Key_entry(&rc4_ctx, key, key_size);
|
||||
XeCryptRc4Ecb_entry(&rc4_ctx, data, size);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptRc4, kNone, kImplemented);
|
||||
|
||||
@@ -107,7 +108,7 @@ void StoreSha1(const sha1::SHA1* sha, XECRYPT_SHA_STATE* state) {
|
||||
std::copy_n(sha->getBlock(), sha->getBlockByteIndex(), state->buffer);
|
||||
}
|
||||
|
||||
void XeCryptShaInit(pointer_t<XECRYPT_SHA_STATE> sha_state) {
|
||||
void XeCryptShaInit_entry(pointer_t<XECRYPT_SHA_STATE> sha_state) {
|
||||
sha_state.Zero();
|
||||
|
||||
sha_state->state[0] = 0x67452301;
|
||||
@@ -118,8 +119,8 @@ void XeCryptShaInit(pointer_t<XECRYPT_SHA_STATE> sha_state) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptShaInit, kNone, kImplemented);
|
||||
|
||||
void XeCryptShaUpdate(pointer_t<XECRYPT_SHA_STATE> sha_state, lpvoid_t input,
|
||||
dword_t input_size) {
|
||||
void XeCryptShaUpdate_entry(pointer_t<XECRYPT_SHA_STATE> sha_state,
|
||||
lpvoid_t input, dword_t input_size) {
|
||||
sha1::SHA1 sha;
|
||||
InitSha1(&sha, sha_state);
|
||||
|
||||
@@ -129,8 +130,8 @@ void XeCryptShaUpdate(pointer_t<XECRYPT_SHA_STATE> sha_state, lpvoid_t input,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptShaUpdate, kNone, kImplemented);
|
||||
|
||||
void XeCryptShaFinal(pointer_t<XECRYPT_SHA_STATE> sha_state,
|
||||
pointer_t<uint8_t> out, dword_t out_size) {
|
||||
void XeCryptShaFinal_entry(pointer_t<XECRYPT_SHA_STATE> sha_state,
|
||||
pointer_t<uint8_t> out, dword_t out_size) {
|
||||
sha1::SHA1 sha;
|
||||
InitSha1(&sha, sha_state);
|
||||
|
||||
@@ -143,9 +144,10 @@ void XeCryptShaFinal(pointer_t<XECRYPT_SHA_STATE> sha_state,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptShaFinal, kNone, kImplemented);
|
||||
|
||||
void XeCryptSha(lpvoid_t input_1, dword_t input_1_size, lpvoid_t input_2,
|
||||
dword_t input_2_size, lpvoid_t input_3, dword_t input_3_size,
|
||||
lpvoid_t output, dword_t output_size) {
|
||||
void XeCryptSha_entry(lpvoid_t input_1, dword_t input_1_size, lpvoid_t input_2,
|
||||
dword_t input_2_size, lpvoid_t input_3,
|
||||
dword_t input_3_size, lpvoid_t output,
|
||||
dword_t output_size) {
|
||||
sha1::SHA1 sha;
|
||||
|
||||
if (input_1 && input_1_size) {
|
||||
@@ -172,7 +174,7 @@ typedef struct {
|
||||
uint8_t buffer[64]; // 0x24
|
||||
} XECRYPT_SHA256_STATE;
|
||||
|
||||
void XeCryptSha256Init(pointer_t<XECRYPT_SHA256_STATE> sha_state) {
|
||||
void XeCryptSha256Init_entry(pointer_t<XECRYPT_SHA256_STATE> sha_state) {
|
||||
sha_state.Zero();
|
||||
|
||||
sha_state->state[0] = 0x6a09e667;
|
||||
@@ -186,8 +188,8 @@ void XeCryptSha256Init(pointer_t<XECRYPT_SHA256_STATE> sha_state) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptSha256Init, kNone, kImplemented);
|
||||
|
||||
void XeCryptSha256Update(pointer_t<XECRYPT_SHA256_STATE> sha_state,
|
||||
lpvoid_t input, dword_t input_size) {
|
||||
void XeCryptSha256Update_entry(pointer_t<XECRYPT_SHA256_STATE> sha_state,
|
||||
lpvoid_t input, dword_t input_size) {
|
||||
sha256::SHA256 sha;
|
||||
std::copy(std::begin(sha_state->state), std::end(sha_state->state),
|
||||
sha.getHashValues());
|
||||
@@ -205,8 +207,8 @@ void XeCryptSha256Update(pointer_t<XECRYPT_SHA256_STATE> sha_state,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptSha256Update, kNone, kImplemented);
|
||||
|
||||
void XeCryptSha256Final(pointer_t<XECRYPT_SHA256_STATE> sha_state,
|
||||
pointer_t<uint8_t> out, dword_t out_size) {
|
||||
void XeCryptSha256Final_entry(pointer_t<XECRYPT_SHA256_STATE> sha_state,
|
||||
pointer_t<uint8_t> out, dword_t out_size) {
|
||||
sha256::SHA256 sha;
|
||||
std::copy(std::begin(sha_state->state), std::end(sha_state->state),
|
||||
sha.getHashValues());
|
||||
@@ -224,8 +226,8 @@ void XeCryptSha256Final(pointer_t<XECRYPT_SHA256_STATE> sha_state,
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptSha256Final, kNone, kImplemented);
|
||||
|
||||
// Byteswaps each 8 bytes
|
||||
void XeCryptBnQw_SwapDwQwLeBe(pointer_t<uint64_t> qw_inp,
|
||||
pointer_t<uint64_t> qw_out, dword_t size) {
|
||||
void XeCryptBnQw_SwapDwQwLeBe_entry(pointer_t<uint64_t> qw_inp,
|
||||
pointer_t<uint64_t> qw_out, dword_t size) {
|
||||
xe::copy_and_swap<uint64_t>(qw_out, qw_inp, size);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptBnQw_SwapDwQwLeBe, kNone, kImplemented);
|
||||
@@ -239,9 +241,9 @@ typedef struct {
|
||||
} XECRYPT_RSA;
|
||||
static_assert_size(XECRYPT_RSA, 0x10);
|
||||
|
||||
dword_result_t XeCryptBnQwNeRsaPubCrypt(pointer_t<uint64_t> qw_a,
|
||||
pointer_t<uint64_t> qw_b,
|
||||
pointer_t<XECRYPT_RSA> rsa) {
|
||||
dword_result_t XeCryptBnQwNeRsaPubCrypt_entry(pointer_t<uint64_t> qw_a,
|
||||
pointer_t<uint64_t> qw_b,
|
||||
pointer_t<XECRYPT_RSA> rsa) {
|
||||
// 0 indicates failure (but not a BOOL return value)
|
||||
#ifndef XE_PLATFORM_WIN32
|
||||
XELOGE(
|
||||
@@ -342,14 +344,14 @@ DECLARE_XBOXKRNL_EXPORT1(XeCryptBnQwNeRsaPubCrypt, kNone, kImplemented);
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptBnQwNeRsaPubCrypt, kNone, kStub);
|
||||
#endif
|
||||
|
||||
dword_result_t XeCryptBnDwLePkcs1Verify(lpvoid_t hash, lpvoid_t sig,
|
||||
dword_t size) {
|
||||
dword_result_t XeCryptBnDwLePkcs1Verify_entry(lpvoid_t hash, lpvoid_t sig,
|
||||
dword_t size) {
|
||||
// BOOL return value
|
||||
return 1;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptBnDwLePkcs1Verify, kNone, kStub);
|
||||
|
||||
void XeCryptRandom(lpvoid_t buf, dword_t buf_size) {
|
||||
void XeCryptRandom_entry(lpvoid_t buf, dword_t buf_size) {
|
||||
std::memset(buf, 0xFD, buf_size);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptRandom, kNone, kStub);
|
||||
@@ -359,7 +361,7 @@ struct XECRYPT_DES_STATE {
|
||||
};
|
||||
|
||||
// Sets bit 0 to make the parity odd
|
||||
void XeCryptDesParity(lpvoid_t inp, dword_t inp_size, lpvoid_t out_ptr) {
|
||||
void XeCryptDesParity_entry(lpvoid_t inp, dword_t inp_size, lpvoid_t out_ptr) {
|
||||
DES::set_parity(inp, inp_size, out_ptr);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptDesParity, kNone, kImplemented);
|
||||
@@ -368,7 +370,8 @@ struct XECRYPT_DES3_STATE {
|
||||
XECRYPT_DES_STATE des_state[3];
|
||||
};
|
||||
|
||||
void XeCryptDes3Key(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t key) {
|
||||
void XeCryptDes3Key_entry(pointer_t<XECRYPT_DES3_STATE> state_ptr,
|
||||
lpqword_t key) {
|
||||
DES3 des3(key[0], key[1], key[2]);
|
||||
DES* des = des3.getDES();
|
||||
|
||||
@@ -379,8 +382,8 @@ void XeCryptDes3Key(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t key) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptDes3Key, kNone, kImplemented);
|
||||
|
||||
void XeCryptDes3Ecb(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t inp,
|
||||
lpqword_t out, dword_t encrypt) {
|
||||
void XeCryptDes3Ecb_entry(pointer_t<XECRYPT_DES3_STATE> state_ptr,
|
||||
lpqword_t inp, lpqword_t out, dword_t encrypt) {
|
||||
DES3 des3((ui64*)state_ptr->des_state[0].keytab,
|
||||
(ui64*)state_ptr->des_state[1].keytab,
|
||||
(ui64*)state_ptr->des_state[2].keytab);
|
||||
@@ -393,9 +396,9 @@ void XeCryptDes3Ecb(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t inp,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptDes3Ecb, kNone, kImplemented);
|
||||
|
||||
void XeCryptDes3Cbc(pointer_t<XECRYPT_DES3_STATE> state_ptr, lpqword_t inp,
|
||||
dword_t inp_size, lpqword_t out, lpqword_t feed,
|
||||
dword_t encrypt) {
|
||||
void XeCryptDes3Cbc_entry(pointer_t<XECRYPT_DES3_STATE> state_ptr,
|
||||
lpqword_t inp, dword_t inp_size, lpqword_t out,
|
||||
lpqword_t feed, dword_t encrypt) {
|
||||
DES3 des3((ui64*)state_ptr->des_state[0].keytab,
|
||||
(ui64*)state_ptr->des_state[1].keytab,
|
||||
(ui64*)state_ptr->des_state[2].keytab);
|
||||
@@ -429,7 +432,7 @@ static inline uint8_t xeXeCryptAesMul2(uint8_t a) {
|
||||
return (a & 0x80) ? ((a << 1) ^ 0x1B) : (a << 1);
|
||||
}
|
||||
|
||||
void XeCryptAesKey(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t key) {
|
||||
void XeCryptAesKey_entry(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t key) {
|
||||
aes_key_schedule_128(key, reinterpret_cast<uint8_t*>(state_ptr->keytabenc));
|
||||
// Decryption key schedule not needed by openluopworld/aes_128, but generated
|
||||
// to fill the context structure properly.
|
||||
@@ -494,8 +497,8 @@ void XeCryptAesKey(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t key) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptAesKey, kNone, kImplemented);
|
||||
|
||||
void XeCryptAesEcb(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
|
||||
lpvoid_t out_ptr, dword_t encrypt) {
|
||||
void XeCryptAesEcb_entry(pointer_t<XECRYPT_AES_STATE> state_ptr,
|
||||
lpvoid_t inp_ptr, lpvoid_t out_ptr, dword_t encrypt) {
|
||||
const uint8_t* keytab =
|
||||
reinterpret_cast<const uint8_t*>(state_ptr->keytabenc);
|
||||
if (encrypt) {
|
||||
@@ -506,9 +509,9 @@ void XeCryptAesEcb(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptAesEcb, kNone, kImplemented);
|
||||
|
||||
void XeCryptAesCbc(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
|
||||
dword_t inp_size, lpvoid_t out_ptr, lpvoid_t feed_ptr,
|
||||
dword_t encrypt) {
|
||||
void XeCryptAesCbc_entry(pointer_t<XECRYPT_AES_STATE> state_ptr,
|
||||
lpvoid_t inp_ptr, dword_t inp_size, lpvoid_t out_ptr,
|
||||
lpvoid_t feed_ptr, dword_t encrypt) {
|
||||
const uint8_t* keytab =
|
||||
reinterpret_cast<const uint8_t*>(state_ptr->keytabenc);
|
||||
const uint8_t* inp = inp_ptr.as<const uint8_t*>();
|
||||
@@ -541,10 +544,10 @@ void XeCryptAesCbc(pointer_t<XECRYPT_AES_STATE> state_ptr, lpvoid_t inp_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeCryptAesCbc, kNone, kImplemented);
|
||||
|
||||
void XeCryptHmacSha(lpvoid_t key, dword_t key_size_in, lpvoid_t inp_1,
|
||||
dword_t inp_1_size, lpvoid_t inp_2, dword_t inp_2_size,
|
||||
lpvoid_t inp_3, dword_t inp_3_size, lpvoid_t out,
|
||||
dword_t out_size) {
|
||||
void XeCryptHmacSha_entry(lpvoid_t key, dword_t key_size_in, lpvoid_t inp_1,
|
||||
dword_t inp_1_size, lpvoid_t inp_2,
|
||||
dword_t inp_2_size, lpvoid_t inp_3,
|
||||
dword_t inp_3_size, lpvoid_t out, dword_t out_size) {
|
||||
uint32_t key_size = key_size_in;
|
||||
sha1::SHA1 sha;
|
||||
uint8_t kpad_i[0x40];
|
||||
@@ -605,19 +608,19 @@ DECLARE_XBOXKRNL_EXPORT1(XeCryptHmacSha, kNone, kImplemented);
|
||||
static const uint8_t key19[] = {0xE1, 0xBC, 0x15, 0x9C, 0x73, 0xB1, 0xEA, 0xE9,
|
||||
0xAB, 0x31, 0x70, 0xF3, 0xAD, 0x47, 0xEB, 0xF3};
|
||||
|
||||
dword_result_t XeKeysHmacSha(dword_t key_num, lpvoid_t inp_1,
|
||||
dword_t inp_1_size, lpvoid_t inp_2,
|
||||
dword_t inp_2_size, lpvoid_t inp_3,
|
||||
dword_t inp_3_size, lpvoid_t out,
|
||||
dword_t out_size) {
|
||||
dword_result_t XeKeysHmacSha_entry(dword_t key_num, lpvoid_t inp_1,
|
||||
dword_t inp_1_size, lpvoid_t inp_2,
|
||||
dword_t inp_2_size, lpvoid_t inp_3,
|
||||
dword_t inp_3_size, lpvoid_t out,
|
||||
dword_t out_size) {
|
||||
const uint8_t* key = nullptr;
|
||||
if (key_num == 0x19) {
|
||||
key = key19;
|
||||
}
|
||||
|
||||
if (key) {
|
||||
XeCryptHmacSha((void*)key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size,
|
||||
inp_3, inp_3_size, out, out_size);
|
||||
XeCryptHmacSha_entry((void*)key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size,
|
||||
inp_3, inp_3_size, out, out_size);
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -630,41 +633,42 @@ static const uint8_t xe_key_obfuscation_key[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
dword_result_t XeKeysAesCbcUsingKey(lpvoid_t obscured_key, lpvoid_t inp_ptr,
|
||||
dword_t inp_size, lpvoid_t out_ptr,
|
||||
lpvoid_t feed_ptr, dword_t encrypt) {
|
||||
dword_result_t XeKeysAesCbcUsingKey_entry(lpvoid_t obscured_key,
|
||||
lpvoid_t inp_ptr, dword_t inp_size,
|
||||
lpvoid_t out_ptr, lpvoid_t feed_ptr,
|
||||
dword_t encrypt) {
|
||||
uint8_t key[16];
|
||||
|
||||
// Deobscure key
|
||||
XECRYPT_AES_STATE aes;
|
||||
XeCryptAesKey(&aes, (uint8_t*)xe_key_obfuscation_key);
|
||||
XeCryptAesEcb(&aes, obscured_key, key, 0);
|
||||
XeCryptAesKey_entry(&aes, (uint8_t*)xe_key_obfuscation_key);
|
||||
XeCryptAesEcb_entry(&aes, obscured_key, key, 0);
|
||||
|
||||
// Run CBC using deobscured key
|
||||
XeCryptAesKey(&aes, key);
|
||||
XeCryptAesCbc(&aes, inp_ptr, inp_size, out_ptr, feed_ptr, encrypt);
|
||||
XeCryptAesKey_entry(&aes, key);
|
||||
XeCryptAesCbc_entry(&aes, inp_ptr, inp_size, out_ptr, feed_ptr, encrypt);
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeKeysAesCbcUsingKey, kNone, kImplemented);
|
||||
|
||||
dword_result_t XeKeysObscureKey(lpvoid_t input, lpvoid_t output) {
|
||||
dword_result_t XeKeysObscureKey_entry(lpvoid_t input, lpvoid_t output) {
|
||||
// Based on HvxKeysObscureKey
|
||||
// Seems to encrypt input with per-console KEY_OBFUSCATION_KEY (key 0x18)
|
||||
|
||||
XECRYPT_AES_STATE aes;
|
||||
XeCryptAesKey(&aes, (uint8_t*)xe_key_obfuscation_key);
|
||||
XeCryptAesEcb(&aes, input, output, 1);
|
||||
XeCryptAesKey_entry(&aes, (uint8_t*)xe_key_obfuscation_key);
|
||||
XeCryptAesEcb_entry(&aes, input, output, 1);
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeKeysObscureKey, kNone, kImplemented);
|
||||
|
||||
dword_result_t XeKeysHmacShaUsingKey(lpvoid_t obscured_key, lpvoid_t inp_1,
|
||||
dword_t inp_1_size, lpvoid_t inp_2,
|
||||
dword_t inp_2_size, lpvoid_t inp_3,
|
||||
dword_t inp_3_size, lpvoid_t out,
|
||||
dword_t out_size) {
|
||||
dword_result_t XeKeysHmacShaUsingKey_entry(lpvoid_t obscured_key,
|
||||
lpvoid_t inp_1, dword_t inp_1_size,
|
||||
lpvoid_t inp_2, dword_t inp_2_size,
|
||||
lpvoid_t inp_3, dword_t inp_3_size,
|
||||
lpvoid_t out, dword_t out_size) {
|
||||
if (!obscured_key) {
|
||||
return X_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
@@ -673,11 +677,11 @@ dword_result_t XeKeysHmacShaUsingKey(lpvoid_t obscured_key, lpvoid_t inp_1,
|
||||
|
||||
// Deobscure key
|
||||
XECRYPT_AES_STATE aes;
|
||||
XeCryptAesKey(&aes, (uint8_t*)xe_key_obfuscation_key);
|
||||
XeCryptAesEcb(&aes, obscured_key, key, 0);
|
||||
XeCryptAesKey_entry(&aes, (uint8_t*)xe_key_obfuscation_key);
|
||||
XeCryptAesEcb_entry(&aes, obscured_key, key, 0);
|
||||
|
||||
XeCryptHmacSha(key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size, inp_3,
|
||||
inp_3_size, out, out_size);
|
||||
XeCryptHmacSha_entry(key, 0x10, inp_1, inp_1_size, inp_2, inp_2_size, inp_3,
|
||||
inp_3_size, out, out_size);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XeKeysHmacShaUsingKey, kNone, kImplemented);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
void DbgBreakPoint() { xe::debugging::Break(); }
|
||||
void DbgBreakPoint_entry() { xe::debugging::Break(); }
|
||||
DECLARE_XBOXKRNL_EXPORT2(DbgBreakPoint, kDebug, kStub, kImportant);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
|
||||
@@ -123,7 +123,7 @@ void HandleCppException(pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
xe::debugging::Break();
|
||||
}
|
||||
|
||||
void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
void RtlRaiseException_entry(pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
switch (record->exception_code) {
|
||||
case 0x406D1388: {
|
||||
HandleSetThreadName(record);
|
||||
@@ -141,8 +141,8 @@ void RtlRaiseException(pointer_t<X_EXCEPTION_RECORD> record) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(RtlRaiseException, kDebug, kStub, kImportant);
|
||||
|
||||
void KeBugCheckEx(dword_t code, dword_t param1, dword_t param2, dword_t param3,
|
||||
dword_t param4) {
|
||||
void KeBugCheckEx_entry(dword_t code, dword_t param1, dword_t param2,
|
||||
dword_t param3, dword_t param4) {
|
||||
XELOGD("*** STOP: 0x{:08X} (0x{:08X}, 0x{:08X}, 0x{:08X}, 0x{:08X})", code,
|
||||
param1, param2, param3, param4);
|
||||
fflush(stdout);
|
||||
@@ -151,7 +151,7 @@ void KeBugCheckEx(dword_t code, dword_t param1, dword_t param2, dword_t param3,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeBugCheckEx, kDebug, kStub, kImportant);
|
||||
|
||||
void KeBugCheck(dword_t code) { KeBugCheckEx(code, 0, 0, 0, 0); }
|
||||
void KeBugCheck_entry(dword_t code) { KeBugCheckEx_entry(code, 0, 0, 0, 0); }
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeBugCheck, kDebug, kImplemented, kImportant);
|
||||
|
||||
void RegisterDebugExports(xe::cpu::ExportResolver* export_resolver,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -1011,7 +1011,7 @@ uint32_t xeRtlNtStatusToDosError(uint32_t source_status) {
|
||||
return 317; // ERROR_MR_MID_NOT_FOUND
|
||||
}
|
||||
|
||||
dword_result_t RtlNtStatusToDosError(dword_t source_status) {
|
||||
dword_result_t RtlNtStatusToDosError_entry(dword_t source_status) {
|
||||
return xeRtlNtStatusToDosError(source_status);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT3(RtlNtStatusToDosError, kNone, kImportant,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -17,7 +17,7 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
void HalReturnToFirmware(dword_t routine) {
|
||||
void HalReturnToFirmware_entry(dword_t routine) {
|
||||
// void
|
||||
// IN FIRMWARE_REENTRY Routine
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -17,7 +17,7 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
dword_result_t HidReadKeys(dword_t unk1, unknown_t unk2, unknown_t unk3) {
|
||||
dword_result_t HidReadKeys_entry(dword_t unk1, unknown_t unk2, unknown_t unk3) {
|
||||
/* TODO(gibbed):
|
||||
* Games check for the following errors:
|
||||
* 0xC000009D - translated to 0x48F - ERROR_DEVICE_NOT_CONNECTED
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -95,13 +95,13 @@ static bool IsValidPath(const std::string_view s, bool is_pattern) {
|
||||
return true;
|
||||
}
|
||||
|
||||
dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> object_attrs,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpqword_t allocation_size_ptr,
|
||||
dword_t file_attributes, dword_t share_access,
|
||||
dword_t creation_disposition,
|
||||
dword_t create_options) {
|
||||
dword_result_t NtCreateFile_entry(lpdword_t handle_out, dword_t desired_access,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> object_attrs,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpqword_t allocation_size_ptr,
|
||||
dword_t file_attributes, dword_t share_access,
|
||||
dword_t creation_disposition,
|
||||
dword_t create_options) {
|
||||
uint64_t allocation_size = 0; // is this correct???
|
||||
if (allocation_size_ptr) {
|
||||
allocation_size = *allocation_size_ptr;
|
||||
@@ -170,22 +170,22 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateFile, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtOpenFile(lpdword_t handle_out, dword_t desired_access,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> object_attributes,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
dword_t open_options) {
|
||||
return NtCreateFile(handle_out, desired_access, object_attributes,
|
||||
io_status_block, nullptr, 0, 0,
|
||||
static_cast<uint32_t>(xe::vfs::FileDisposition::kOpen),
|
||||
open_options);
|
||||
dword_result_t NtOpenFile_entry(
|
||||
lpdword_t handle_out, dword_t desired_access,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> object_attributes,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block, dword_t open_options) {
|
||||
return NtCreateFile_entry(
|
||||
handle_out, desired_access, object_attributes, io_status_block, nullptr,
|
||||
0, 0, static_cast<uint32_t>(xe::vfs::FileDisposition::kOpen),
|
||||
open_options);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtOpenFile, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
|
||||
lpvoid_t apc_routine_ptr, lpvoid_t apc_context,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpvoid_t buffer, dword_t buffer_length,
|
||||
lpqword_t byte_offset_ptr) {
|
||||
dword_result_t NtReadFile_entry(dword_t file_handle, dword_t event_handle,
|
||||
lpvoid_t apc_routine_ptr, lpvoid_t apc_context,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpvoid_t buffer, dword_t buffer_length,
|
||||
lpqword_t byte_offset_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
bool signal_event = false;
|
||||
@@ -265,11 +265,10 @@ dword_result_t NtReadFile(dword_t file_handle, dword_t event_handle,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtReadFile, kFileSystem, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t NtReadFileScatter(dword_t file_handle, dword_t event_handle,
|
||||
lpvoid_t apc_routine_ptr, lpvoid_t apc_context,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpdword_t segment_array, dword_t length,
|
||||
lpqword_t byte_offset_ptr) {
|
||||
dword_result_t NtReadFileScatter_entry(
|
||||
dword_t file_handle, dword_t event_handle, lpvoid_t apc_routine_ptr,
|
||||
lpvoid_t apc_context, pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpdword_t segment_array, dword_t length, lpqword_t byte_offset_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
bool signal_event = false;
|
||||
@@ -352,11 +351,11 @@ dword_result_t NtReadFileScatter(dword_t file_handle, dword_t event_handle,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtReadFileScatter, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtWriteFile(dword_t file_handle, dword_t event_handle,
|
||||
function_t apc_routine, lpvoid_t apc_context,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpvoid_t buffer, dword_t buffer_length,
|
||||
lpqword_t byte_offset_ptr) {
|
||||
dword_result_t NtWriteFile_entry(dword_t file_handle, dword_t event_handle,
|
||||
function_t apc_routine, lpvoid_t apc_context,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpvoid_t buffer, dword_t buffer_length,
|
||||
lpqword_t byte_offset_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
// Grab event to signal.
|
||||
@@ -430,10 +429,10 @@ dword_result_t NtWriteFile(dword_t file_handle, dword_t event_handle,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtWriteFile, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtCreateIoCompletion(lpdword_t out_handle,
|
||||
dword_t desired_access,
|
||||
lpvoid_t object_attribs,
|
||||
dword_t num_concurrent_threads) {
|
||||
dword_result_t NtCreateIoCompletion_entry(lpdword_t out_handle,
|
||||
dword_t desired_access,
|
||||
lpvoid_t object_attribs,
|
||||
dword_t num_concurrent_threads) {
|
||||
auto completion = new XIOCompletion(kernel_state());
|
||||
if (out_handle) {
|
||||
*out_handle = completion->handle();
|
||||
@@ -443,9 +442,10 @@ dword_result_t NtCreateIoCompletion(lpdword_t out_handle,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateIoCompletion, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtSetIoCompletion(dword_t handle, dword_t key_context,
|
||||
dword_t apc_context, dword_t completion_status,
|
||||
dword_t num_bytes) {
|
||||
dword_result_t NtSetIoCompletion_entry(dword_t handle, dword_t key_context,
|
||||
dword_t apc_context,
|
||||
dword_t completion_status,
|
||||
dword_t num_bytes) {
|
||||
auto port =
|
||||
kernel_state()->object_table()->LookupObject<XIOCompletion>(handle);
|
||||
if (!port) {
|
||||
@@ -465,7 +465,7 @@ DECLARE_XBOXKRNL_EXPORT2(NtSetIoCompletion, kFileSystem, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
// Dequeues a packet from the completion port.
|
||||
dword_result_t NtRemoveIoCompletion(
|
||||
dword_result_t NtRemoveIoCompletion_entry(
|
||||
dword_t handle, lpdword_t key_context, lpdword_t apc_context,
|
||||
pointer_t<X_IO_STATUS_BLOCK> io_status_block, lpqword_t timeout) {
|
||||
X_STATUS status = X_STATUS_SUCCESS;
|
||||
@@ -502,7 +502,7 @@ dword_result_t NtRemoveIoCompletion(
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtRemoveIoCompletion, kFileSystem, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t NtQueryFullAttributesFile(
|
||||
dword_result_t NtQueryFullAttributesFile_entry(
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> obj_attribs,
|
||||
pointer_t<X_FILE_NETWORK_OPEN_INFORMATION> file_info) {
|
||||
auto object_name =
|
||||
@@ -544,7 +544,7 @@ dword_result_t NtQueryFullAttributesFile(
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtQueryFullAttributesFile, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtQueryDirectoryFile(
|
||||
dword_result_t NtQueryDirectoryFile_entry(
|
||||
dword_t file_handle, dword_t event_handle, function_t apc_routine,
|
||||
lpvoid_t apc_context, pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
pointer_t<X_FILE_DIRECTORY_INFORMATION> file_info_ptr, dword_t length,
|
||||
@@ -588,7 +588,7 @@ dword_result_t NtQueryDirectoryFile(
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtQueryDirectoryFile, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t NtFlushBuffersFile(
|
||||
dword_result_t NtFlushBuffersFile_entry(
|
||||
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block_ptr) {
|
||||
auto result = X_STATUS_SUCCESS;
|
||||
|
||||
@@ -602,7 +602,7 @@ dword_result_t NtFlushBuffersFile(
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtFlushBuffersFile, kFileSystem, kStub);
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/devnotes/ntopensymboliclinkobject
|
||||
dword_result_t NtOpenSymbolicLinkObject(
|
||||
dword_result_t NtOpenSymbolicLinkObject_entry(
|
||||
lpdword_t handle_out, pointer_t<X_OBJECT_ATTRIBUTES> object_attrs) {
|
||||
if (!object_attrs) {
|
||||
return X_STATUS_INVALID_PARAMETER;
|
||||
@@ -646,8 +646,8 @@ dword_result_t NtOpenSymbolicLinkObject(
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtOpenSymbolicLinkObject, kFileSystem, kImplemented);
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/devnotes/ntquerysymboliclinkobject
|
||||
dword_result_t NtQuerySymbolicLinkObject(dword_t handle,
|
||||
pointer_t<X_ANSI_STRING> target) {
|
||||
dword_result_t NtQuerySymbolicLinkObject_entry(
|
||||
dword_t handle, pointer_t<X_ANSI_STRING> target) {
|
||||
auto symlink =
|
||||
kernel_state()->object_table()->LookupObject<XSymbolicLink>(handle);
|
||||
if (!symlink) {
|
||||
@@ -664,17 +664,17 @@ dword_result_t NtQuerySymbolicLinkObject(dword_t handle,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtQuerySymbolicLinkObject, kFileSystem, kImplemented);
|
||||
|
||||
dword_result_t FscGetCacheElementCount(dword_t r3) { return 0; }
|
||||
dword_result_t FscGetCacheElementCount_entry(dword_t r3) { return 0; }
|
||||
DECLARE_XBOXKRNL_EXPORT1(FscGetCacheElementCount, kFileSystem, kStub);
|
||||
|
||||
dword_result_t FscSetCacheElementCount(dword_t unk_0, dword_t unk_1) {
|
||||
dword_result_t FscSetCacheElementCount_entry(dword_t unk_0, dword_t unk_1) {
|
||||
// unk_0 = 0
|
||||
// unk_1 looks like a count? in what units? 256 is a common value
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(FscSetCacheElementCount, kFileSystem, kStub);
|
||||
|
||||
dword_result_t NtDeviceIoControlFile(
|
||||
dword_result_t NtDeviceIoControlFile_entry(
|
||||
dword_t handle, dword_t event_handle, dword_t apc_routine,
|
||||
dword_t apc_context, dword_t io_status_block, dword_t io_control_code,
|
||||
lpvoid_t input_buffer, dword_t input_buffer_len, lpvoid_t output_buffer,
|
||||
@@ -712,8 +712,9 @@ dword_result_t NtDeviceIoControlFile(
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtDeviceIoControlFile, kFileSystem, kStub);
|
||||
|
||||
dword_result_t IoCreateDevice(dword_t device_struct, dword_t r4, dword_t r5,
|
||||
dword_t r6, dword_t r7, lpdword_t out_struct) {
|
||||
dword_result_t IoCreateDevice_entry(dword_t device_struct, dword_t r4,
|
||||
dword_t r5, dword_t r6, dword_t r7,
|
||||
lpdword_t out_struct) {
|
||||
// Called from XMountUtilityDrive XAM-task code
|
||||
// That code tries writing things to a pointer at out_struct+0x18
|
||||
// We'll alloc some scratch space for it so it doesn't cause any exceptions
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -54,7 +54,7 @@ uint32_t GetQueryFileInfoMinimumLength(uint32_t info_class) {
|
||||
}
|
||||
}
|
||||
|
||||
dword_result_t NtQueryInformationFile(
|
||||
dword_result_t NtQueryInformationFile_entry(
|
||||
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block_ptr,
|
||||
lpvoid_t info_ptr, dword_t info_length, dword_t info_class) {
|
||||
uint32_t minimum_length = GetQueryFileInfoMinimumLength(info_class);
|
||||
@@ -179,7 +179,7 @@ uint32_t GetSetFileInfoMinimumLength(uint32_t info_class) {
|
||||
}
|
||||
}
|
||||
|
||||
dword_result_t NtSetInformationFile(
|
||||
dword_result_t NtSetInformationFile_entry(
|
||||
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block,
|
||||
lpvoid_t info_ptr, dword_t info_length, dword_t info_class) {
|
||||
uint32_t minimum_length = GetSetFileInfoMinimumLength(info_class);
|
||||
@@ -277,7 +277,7 @@ uint32_t GetQueryVolumeInfoMinimumLength(uint32_t info_class) {
|
||||
}
|
||||
}
|
||||
|
||||
dword_result_t NtQueryVolumeInformationFile(
|
||||
dword_result_t NtQueryVolumeInformationFile_entry(
|
||||
dword_t file_handle, pointer_t<X_IO_STATUS_BLOCK> io_status_block_ptr,
|
||||
lpvoid_t info_ptr, dword_t info_length, dword_t info_class) {
|
||||
uint32_t minimum_length = GetQueryVolumeInfoMinimumLength(info_class);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -57,10 +57,11 @@ uint32_t FromXdkProtectFlags(uint32_t protect) {
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
|
||||
lpdword_t region_size_ptr,
|
||||
dword_t alloc_type, dword_t protect_bits,
|
||||
dword_t debug_memory) {
|
||||
dword_result_t NtAllocateVirtualMemory_entry(lpdword_t base_addr_ptr,
|
||||
lpdword_t region_size_ptr,
|
||||
dword_t alloc_type,
|
||||
dword_t protect_bits,
|
||||
dword_t debug_memory) {
|
||||
// NTSTATUS
|
||||
// _Inout_ PVOID *BaseAddress,
|
||||
// _Inout_ PSIZE_T RegionSize,
|
||||
@@ -189,11 +190,11 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtAllocateVirtualMemory, kMemory, kImplemented);
|
||||
|
||||
dword_result_t NtProtectVirtualMemory(lpdword_t base_addr_ptr,
|
||||
lpdword_t region_size_ptr,
|
||||
dword_t protect_bits,
|
||||
lpdword_t old_protect,
|
||||
dword_t debug_memory) {
|
||||
dword_result_t NtProtectVirtualMemory_entry(lpdword_t base_addr_ptr,
|
||||
lpdword_t region_size_ptr,
|
||||
dword_t protect_bits,
|
||||
lpdword_t old_protect,
|
||||
dword_t debug_memory) {
|
||||
// Set to TRUE when this memory refers to devkit memory area.
|
||||
assert_true(debug_memory == 0);
|
||||
|
||||
@@ -239,9 +240,10 @@ dword_result_t NtProtectVirtualMemory(lpdword_t base_addr_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtProtectVirtualMemory, kMemory, kImplemented);
|
||||
|
||||
dword_result_t NtFreeVirtualMemory(lpdword_t base_addr_ptr,
|
||||
lpdword_t region_size_ptr, dword_t free_type,
|
||||
dword_t debug_memory) {
|
||||
dword_result_t NtFreeVirtualMemory_entry(lpdword_t base_addr_ptr,
|
||||
lpdword_t region_size_ptr,
|
||||
dword_t free_type,
|
||||
dword_t debug_memory) {
|
||||
uint32_t base_addr_value = *base_addr_ptr;
|
||||
uint32_t region_size_value = *region_size_ptr;
|
||||
// X_MEM_DECOMMIT | X_MEM_RELEASE
|
||||
@@ -293,7 +295,7 @@ struct X_MEMORY_BASIC_INFORMATION {
|
||||
be<uint32_t> type;
|
||||
};
|
||||
|
||||
dword_result_t NtQueryVirtualMemory(
|
||||
dword_result_t NtQueryVirtualMemory_entry(
|
||||
dword_t base_address,
|
||||
pointer_t<X_MEMORY_BASIC_INFORMATION> memory_basic_information_ptr) {
|
||||
auto heap = kernel_state()->memory()->LookupHeap(base_address);
|
||||
@@ -328,11 +330,9 @@ dword_result_t NtQueryVirtualMemory(
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtQueryVirtualMemory, kMemory, kImplemented);
|
||||
|
||||
dword_result_t MmAllocatePhysicalMemoryEx(dword_t flags, dword_t region_size,
|
||||
dword_t protect_bits,
|
||||
dword_t min_addr_range,
|
||||
dword_t max_addr_range,
|
||||
dword_t alignment) {
|
||||
dword_result_t MmAllocatePhysicalMemoryEx_entry(
|
||||
dword_t flags, dword_t region_size, dword_t protect_bits,
|
||||
dword_t min_addr_range, dword_t max_addr_range, dword_t alignment) {
|
||||
// Type will usually be 0 (user request?), where 1 and 2 are sometimes made
|
||||
// by D3D/etc.
|
||||
|
||||
@@ -392,14 +392,15 @@ dword_result_t MmAllocatePhysicalMemoryEx(dword_t flags, dword_t region_size,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmAllocatePhysicalMemoryEx, kMemory, kImplemented);
|
||||
|
||||
dword_result_t MmAllocatePhysicalMemory(dword_t flags, dword_t region_size,
|
||||
dword_t protect_bits) {
|
||||
return MmAllocatePhysicalMemoryEx(flags, region_size, protect_bits, 0,
|
||||
0xFFFFFFFFu, 0);
|
||||
dword_result_t MmAllocatePhysicalMemory_entry(dword_t flags,
|
||||
dword_t region_size,
|
||||
dword_t protect_bits) {
|
||||
return MmAllocatePhysicalMemoryEx_entry(flags, region_size, protect_bits, 0,
|
||||
0xFFFFFFFFu, 0);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmAllocatePhysicalMemory, kMemory, kImplemented);
|
||||
|
||||
void MmFreePhysicalMemory(dword_t type, dword_t base_address) {
|
||||
void MmFreePhysicalMemory_entry(dword_t type, dword_t base_address) {
|
||||
// base_address = result of MmAllocatePhysicalMemory.
|
||||
|
||||
assert_true((base_address & 0x1F) == 0);
|
||||
@@ -409,7 +410,7 @@ void MmFreePhysicalMemory(dword_t type, dword_t base_address) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmFreePhysicalMemory, kMemory, kImplemented);
|
||||
|
||||
dword_result_t MmQueryAddressProtect(dword_t base_address) {
|
||||
dword_result_t MmQueryAddressProtect_entry(dword_t base_address) {
|
||||
auto heap = kernel_state()->memory()->LookupHeap(base_address);
|
||||
uint32_t access;
|
||||
if (!heap->QueryProtect(base_address, &access)) {
|
||||
@@ -422,8 +423,8 @@ dword_result_t MmQueryAddressProtect(dword_t base_address) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(MmQueryAddressProtect, kMemory, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void MmSetAddressProtect(lpvoid_t base_address, dword_t region_size,
|
||||
dword_t protect_bits) {
|
||||
void MmSetAddressProtect_entry(lpvoid_t base_address, dword_t region_size,
|
||||
dword_t protect_bits) {
|
||||
if (!protect_bits) {
|
||||
XELOGE("MmSetAddressProtect: Failed due to incorrect protect_bits");
|
||||
return;
|
||||
@@ -435,7 +436,7 @@ void MmSetAddressProtect(lpvoid_t base_address, dword_t region_size,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmSetAddressProtect, kMemory, kImplemented);
|
||||
|
||||
dword_result_t MmQueryAllocationSize(lpvoid_t base_address) {
|
||||
dword_result_t MmQueryAllocationSize_entry(lpvoid_t base_address) {
|
||||
auto heap = kernel_state()->memory()->LookupHeap(base_address);
|
||||
uint32_t size;
|
||||
if (!heap->QuerySize(base_address, &size)) {
|
||||
@@ -471,7 +472,7 @@ struct X_MM_QUERY_STATISTICS_RESULT {
|
||||
};
|
||||
static_assert_size(X_MM_QUERY_STATISTICS_RESULT, 104);
|
||||
|
||||
dword_result_t MmQueryStatistics(
|
||||
dword_result_t MmQueryStatistics_entry(
|
||||
pointer_t<X_MM_QUERY_STATISTICS_RESULT> stats_ptr) {
|
||||
if (!stats_ptr) {
|
||||
return X_STATUS_INVALID_PARAMETER;
|
||||
@@ -550,7 +551,7 @@ dword_result_t MmQueryStatistics(
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmQueryStatistics, kMemory, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff554547(v=vs.85).aspx
|
||||
dword_result_t MmGetPhysicalAddress(dword_t base_address) {
|
||||
dword_result_t MmGetPhysicalAddress_entry(dword_t base_address) {
|
||||
// PHYSICAL_ADDRESS MmGetPhysicalAddress(
|
||||
// _In_ PVOID BaseAddress
|
||||
// );
|
||||
@@ -564,8 +565,8 @@ dword_result_t MmGetPhysicalAddress(dword_t base_address) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmGetPhysicalAddress, kMemory, kImplemented);
|
||||
|
||||
dword_result_t MmMapIoSpace(dword_t unk0, lpvoid_t src_address, dword_t size,
|
||||
dword_t flags) {
|
||||
dword_result_t MmMapIoSpace_entry(dword_t unk0, lpvoid_t src_address,
|
||||
dword_t size, dword_t flags) {
|
||||
// I've only seen this used to map XMA audio contexts.
|
||||
// The code seems fine with taking the src address, so this just returns that.
|
||||
// If others start using it there could be problems.
|
||||
@@ -577,8 +578,8 @@ dword_result_t MmMapIoSpace(dword_t unk0, lpvoid_t src_address, dword_t size,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmMapIoSpace, kMemory, kImplemented);
|
||||
|
||||
dword_result_t ExAllocatePoolTypeWithTag(dword_t size, dword_t tag,
|
||||
dword_t zero) {
|
||||
dword_result_t ExAllocatePoolTypeWithTag_entry(dword_t size, dword_t tag,
|
||||
dword_t zero) {
|
||||
uint32_t alignment = 8;
|
||||
uint32_t adjusted_size = size;
|
||||
if (adjusted_size < 4 * 1024) {
|
||||
@@ -594,33 +595,33 @@ dword_result_t ExAllocatePoolTypeWithTag(dword_t size, dword_t tag,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExAllocatePoolTypeWithTag, kMemory, kImplemented);
|
||||
|
||||
dword_result_t ExAllocatePool(dword_t size) {
|
||||
dword_result_t ExAllocatePool_entry(dword_t size) {
|
||||
const uint32_t none = 0x656E6F4E; // 'None'
|
||||
return ExAllocatePoolTypeWithTag(size, none, 0);
|
||||
return ExAllocatePoolTypeWithTag_entry(size, none, 0);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExAllocatePool, kMemory, kImplemented);
|
||||
|
||||
void ExFreePool(lpvoid_t base_address) {
|
||||
void ExFreePool_entry(lpvoid_t base_address) {
|
||||
kernel_state()->memory()->SystemHeapFree(base_address);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExFreePool, kMemory, kImplemented);
|
||||
|
||||
dword_result_t KeGetImagePageTableEntry(lpvoid_t address) {
|
||||
dword_result_t KeGetImagePageTableEntry_entry(lpvoid_t address) {
|
||||
// Unknown
|
||||
return 1;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeGetImagePageTableEntry, kMemory, kStub);
|
||||
|
||||
dword_result_t KeLockL2() {
|
||||
dword_result_t KeLockL2_entry() {
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeLockL2, kMemory, kStub);
|
||||
|
||||
void KeUnlockL2() {}
|
||||
void KeUnlockL2_entry() {}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeUnlockL2, kMemory, kStub);
|
||||
|
||||
dword_result_t MmCreateKernelStack(dword_t stack_size, dword_t r4) {
|
||||
dword_result_t MmCreateKernelStack_entry(dword_t stack_size, dword_t r4) {
|
||||
assert_zero(r4); // Unknown argument.
|
||||
|
||||
auto stack_size_aligned = (stack_size + 0xFFF) & 0xFFFFF000;
|
||||
@@ -637,7 +638,8 @@ dword_result_t MmCreateKernelStack(dword_t stack_size, dword_t r4) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(MmCreateKernelStack, kMemory, kImplemented);
|
||||
|
||||
dword_result_t MmDeleteKernelStack(lpvoid_t stack_base, lpvoid_t stack_end) {
|
||||
dword_result_t MmDeleteKernelStack_entry(lpvoid_t stack_base,
|
||||
lpvoid_t stack_end) {
|
||||
// Release the stack (where stack_end is the low address)
|
||||
if (kernel_memory()->LookupHeap(0x70000000)->Release(stack_end)) {
|
||||
return X_STATUS_SUCCESS;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -18,7 +18,7 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
void KeEnableFpuExceptions(dword_t enabled) {
|
||||
void KeEnableFpuExceptions_entry(dword_t enabled) {
|
||||
// TODO(benvanik): can we do anything about exceptions?
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeEnableFpuExceptions, kNone, kStub);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
dword_result_t XexCheckExecutablePrivilege(dword_t privilege) {
|
||||
dword_result_t XexCheckExecutablePrivilege_entry(dword_t privilege) {
|
||||
// BOOL
|
||||
// DWORD Privilege
|
||||
|
||||
@@ -39,8 +39,8 @@ dword_result_t XexCheckExecutablePrivilege(dword_t privilege) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XexCheckExecutablePrivilege, kModules, kImplemented);
|
||||
|
||||
dword_result_t XexGetModuleHandle(lpstring_t module_name,
|
||||
lpdword_t hmodule_ptr) {
|
||||
dword_result_t XexGetModuleHandle_entry(lpstring_t module_name,
|
||||
lpdword_t hmodule_ptr) {
|
||||
object_ref<XModule> module;
|
||||
|
||||
if (!module_name) {
|
||||
@@ -61,8 +61,9 @@ dword_result_t XexGetModuleHandle(lpstring_t module_name,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XexGetModuleHandle, kModules, kImplemented);
|
||||
|
||||
dword_result_t XexGetModuleSection(lpvoid_t hmodule, lpstring_t name,
|
||||
lpdword_t data_ptr, lpdword_t size_ptr) {
|
||||
dword_result_t XexGetModuleSection_entry(lpvoid_t hmodule, lpstring_t name,
|
||||
lpdword_t data_ptr,
|
||||
lpdword_t size_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto module = XModule::GetFromHModule(kernel_state(), hmodule);
|
||||
@@ -82,8 +83,8 @@ dword_result_t XexGetModuleSection(lpvoid_t hmodule, lpstring_t name,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XexGetModuleSection, kModules, kImplemented);
|
||||
|
||||
dword_result_t XexLoadImage(lpstring_t module_name, dword_t module_flags,
|
||||
dword_t min_version, lpdword_t hmodule_ptr) {
|
||||
dword_result_t XexLoadImage_entry(lpstring_t module_name, dword_t module_flags,
|
||||
dword_t min_version, lpdword_t hmodule_ptr) {
|
||||
X_STATUS result = X_STATUS_NO_SUCH_FILE;
|
||||
|
||||
uint32_t hmodule = 0;
|
||||
@@ -117,7 +118,7 @@ dword_result_t XexLoadImage(lpstring_t module_name, dword_t module_flags,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XexLoadImage, kModules, kImplemented);
|
||||
|
||||
dword_result_t XexUnloadImage(lpvoid_t hmodule) {
|
||||
dword_result_t XexUnloadImage_entry(lpvoid_t hmodule) {
|
||||
auto module = XModule::GetFromHModule(kernel_state(), hmodule);
|
||||
if (!module) {
|
||||
return X_STATUS_INVALID_HANDLE;
|
||||
@@ -138,8 +139,8 @@ dword_result_t XexUnloadImage(lpvoid_t hmodule) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XexUnloadImage, kModules, kImplemented);
|
||||
|
||||
dword_result_t XexGetProcedureAddress(lpvoid_t hmodule, dword_t ordinal,
|
||||
lpdword_t out_function_ptr) {
|
||||
dword_result_t XexGetProcedureAddress_entry(lpvoid_t hmodule, dword_t ordinal,
|
||||
lpdword_t out_function_ptr) {
|
||||
// May be entry point?
|
||||
assert_not_zero(ordinal);
|
||||
|
||||
@@ -184,7 +185,7 @@ dword_result_t XexGetProcedureAddress(lpvoid_t hmodule, dword_t ordinal,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XexGetProcedureAddress, kModules, kImplemented);
|
||||
|
||||
void ExRegisterTitleTerminateNotification(
|
||||
void ExRegisterTitleTerminateNotification_entry(
|
||||
pointer_t<X_EX_TITLE_TERMINATE_REGISTRATION> reg, dword_t create) {
|
||||
if (create) {
|
||||
// Adding.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -20,9 +20,9 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
dword_result_t ObOpenObjectByName(lpunknown_t obj_attributes_ptr,
|
||||
lpunknown_t object_type_ptr, dword_t unk,
|
||||
lpdword_t handle_ptr) {
|
||||
dword_result_t ObOpenObjectByName_entry(lpunknown_t obj_attributes_ptr,
|
||||
lpunknown_t object_type_ptr,
|
||||
dword_t unk, lpdword_t handle_ptr) {
|
||||
// r3 = ptr to info?
|
||||
// +0 = -4
|
||||
// +4 = name ptr
|
||||
@@ -47,8 +47,8 @@ dword_result_t ObOpenObjectByName(lpunknown_t obj_attributes_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObOpenObjectByName, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObOpenObjectByPointer(lpvoid_t object_ptr,
|
||||
lpdword_t out_handle_ptr) {
|
||||
dword_result_t ObOpenObjectByPointer_entry(lpvoid_t object_ptr,
|
||||
lpdword_t out_handle_ptr) {
|
||||
auto object = XObject::GetNativeObject<XObject>(kernel_state(), object_ptr);
|
||||
if (!object) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
@@ -61,8 +61,8 @@ dword_result_t ObOpenObjectByPointer(lpvoid_t object_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObOpenObjectByPointer, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObLookupThreadByThreadId(dword_t thread_id,
|
||||
lpdword_t out_object_ptr) {
|
||||
dword_result_t ObLookupThreadByThreadId_entry(dword_t thread_id,
|
||||
lpdword_t out_object_ptr) {
|
||||
auto thread = kernel_state()->GetThreadByID(thread_id);
|
||||
if (!thread) {
|
||||
return X_STATUS_NOT_FOUND;
|
||||
@@ -75,9 +75,9 @@ dword_result_t ObLookupThreadByThreadId(dword_t thread_id,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObLookupThreadByThreadId, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObReferenceObjectByHandle(dword_t handle,
|
||||
dword_t object_type_ptr,
|
||||
lpdword_t out_object_ptr) {
|
||||
dword_result_t ObReferenceObjectByHandle_entry(dword_t handle,
|
||||
dword_t object_type_ptr,
|
||||
lpdword_t out_object_ptr) {
|
||||
// These values come from how Xenia handles uninitialized kernel data exports.
|
||||
// D###BEEF where ### is the ordinal.
|
||||
const static std::unordered_map<XObject::Type, uint32_t> object_types = {
|
||||
@@ -109,22 +109,24 @@ dword_result_t ObReferenceObjectByHandle(dword_t handle,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObReferenceObjectByHandle, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObReferenceObjectByName(lpstring_t name, dword_t attributes,
|
||||
dword_t object_type_ptr,
|
||||
lpvoid_t parse_context,
|
||||
lpdword_t out_object_ptr) {
|
||||
dword_result_t ObReferenceObjectByName_entry(lpstring_t name,
|
||||
dword_t attributes,
|
||||
dword_t object_type_ptr,
|
||||
lpvoid_t parse_context,
|
||||
lpdword_t out_object_ptr) {
|
||||
X_HANDLE handle = X_INVALID_HANDLE_VALUE;
|
||||
X_STATUS result =
|
||||
kernel_state()->object_table()->GetObjectByName(name.value(), &handle);
|
||||
if (XSUCCEEDED(result)) {
|
||||
return ObReferenceObjectByHandle(handle, object_type_ptr, out_object_ptr);
|
||||
return ObReferenceObjectByHandle_entry(handle, object_type_ptr,
|
||||
out_object_ptr);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObReferenceObjectByName, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObDereferenceObject(dword_t native_ptr) {
|
||||
dword_result_t ObDereferenceObject_entry(dword_t native_ptr) {
|
||||
// Check if a dummy value from ObReferenceObjectByHandle.
|
||||
if (native_ptr == 0xDEADF00D) {
|
||||
return 0;
|
||||
@@ -140,8 +142,8 @@ dword_result_t ObDereferenceObject(dword_t native_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObDereferenceObject, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObCreateSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr,
|
||||
pointer_t<X_ANSI_STRING> target_ptr) {
|
||||
dword_result_t ObCreateSymbolicLink_entry(pointer_t<X_ANSI_STRING> path_ptr,
|
||||
pointer_t<X_ANSI_STRING> target_ptr) {
|
||||
auto path = util::TranslateAnsiString(kernel_memory(), path_ptr);
|
||||
auto target = util::TranslateAnsiString(kernel_memory(), target_ptr);
|
||||
path = xe::utf8::canonicalize_guest_path(path);
|
||||
@@ -159,7 +161,7 @@ dword_result_t ObCreateSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObCreateSymbolicLink, kNone, kImplemented);
|
||||
|
||||
dword_result_t ObDeleteSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr) {
|
||||
dword_result_t ObDeleteSymbolicLink_entry(pointer_t<X_ANSI_STRING> path_ptr) {
|
||||
auto path = util::TranslateAnsiString(kernel_memory(), path_ptr);
|
||||
if (!kernel_state()->file_system()->UnregisterSymbolicLink(path)) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
@@ -169,8 +171,8 @@ dword_result_t ObDeleteSymbolicLink(pointer_t<X_ANSI_STRING> path_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ObDeleteSymbolicLink, kNone, kImplemented);
|
||||
|
||||
dword_result_t NtDuplicateObject(dword_t handle, lpdword_t new_handle_ptr,
|
||||
dword_t options) {
|
||||
dword_result_t NtDuplicateObject_entry(dword_t handle, lpdword_t new_handle_ptr,
|
||||
dword_t options) {
|
||||
// NOTE: new_handle_ptr can be zero to just close a handle.
|
||||
// NOTE: this function seems to be used to get the current thread handle
|
||||
// (passed handle=-2).
|
||||
@@ -194,7 +196,7 @@ dword_result_t NtDuplicateObject(dword_t handle, lpdword_t new_handle_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtDuplicateObject, kNone, kImplemented);
|
||||
|
||||
dword_result_t NtClose(dword_t handle) {
|
||||
dword_result_t NtClose_entry(dword_t handle) {
|
||||
return kernel_state()->object_table()->ReleaseHandle(handle);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtClose, kNone, kImplemented);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -30,8 +30,8 @@ namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff561778
|
||||
dword_result_t RtlCompareMemory(lpvoid_t source1, lpvoid_t source2,
|
||||
dword_t length) {
|
||||
dword_result_t RtlCompareMemory_entry(lpvoid_t source1, lpvoid_t source2,
|
||||
dword_t length) {
|
||||
uint8_t* p1 = source1;
|
||||
uint8_t* p2 = source2;
|
||||
|
||||
@@ -51,8 +51,8 @@ dword_result_t RtlCompareMemory(lpvoid_t source1, lpvoid_t source2,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlCompareMemory, kMemory, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff552123
|
||||
dword_result_t RtlCompareMemoryUlong(lpvoid_t source, dword_t length,
|
||||
dword_t pattern) {
|
||||
dword_result_t RtlCompareMemoryUlong_entry(lpvoid_t source, dword_t length,
|
||||
dword_t pattern) {
|
||||
// Return 0 if source/length not aligned
|
||||
if (source.guest_address() % 4 || length % 4) {
|
||||
return 0;
|
||||
@@ -72,7 +72,8 @@ dword_result_t RtlCompareMemoryUlong(lpvoid_t source, dword_t length,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlCompareMemoryUlong, kMemory, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff552263
|
||||
void RtlFillMemoryUlong(lpvoid_t destination, dword_t length, dword_t pattern) {
|
||||
void RtlFillMemoryUlong_entry(lpvoid_t destination, dword_t length,
|
||||
dword_t pattern) {
|
||||
// NOTE: length must be % 4, so we can work on uint32s.
|
||||
uint32_t count = length >> 2;
|
||||
|
||||
@@ -84,7 +85,7 @@ void RtlFillMemoryUlong(lpvoid_t destination, dword_t length, dword_t pattern) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlFillMemoryUlong, kMemory, kImplemented);
|
||||
|
||||
dword_result_t RtlUpperChar(dword_t in) {
|
||||
dword_result_t RtlUpperChar_entry(dword_t in) {
|
||||
char c = in & 0xFF;
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
return c ^ 0x20;
|
||||
@@ -94,7 +95,7 @@ dword_result_t RtlUpperChar(dword_t in) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlUpperChar, kNone, kImplemented);
|
||||
|
||||
dword_result_t RtlLowerChar(dword_t in) {
|
||||
dword_result_t RtlLowerChar_entry(dword_t in) {
|
||||
char c = in & 0xFF;
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
return c ^ 0x20;
|
||||
@@ -104,8 +105,8 @@ dword_result_t RtlLowerChar(dword_t in) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlLowerChar, kNone, kImplemented);
|
||||
|
||||
dword_result_t RtlCompareString(lpstring_t string_1, lpstring_t string_2,
|
||||
dword_t case_insensitive) {
|
||||
dword_result_t RtlCompareString_entry(lpstring_t string_1, lpstring_t string_2,
|
||||
dword_t case_insensitive) {
|
||||
int ret = case_insensitive ? strcasecmp(string_1, string_2)
|
||||
: std::strcmp(string_1, string_2);
|
||||
|
||||
@@ -113,9 +114,11 @@ dword_result_t RtlCompareString(lpstring_t string_1, lpstring_t string_2,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlCompareString, kNone, kImplemented);
|
||||
|
||||
dword_result_t RtlCompareStringN(lpstring_t string_1, dword_t string_1_len,
|
||||
lpstring_t string_2, dword_t string_2_len,
|
||||
dword_t case_insensitive) {
|
||||
dword_result_t RtlCompareStringN_entry(lpstring_t string_1,
|
||||
dword_t string_1_len,
|
||||
lpstring_t string_2,
|
||||
dword_t string_2_len,
|
||||
dword_t case_insensitive) {
|
||||
uint32_t len1 = string_1_len;
|
||||
uint32_t len2 = string_2_len;
|
||||
|
||||
@@ -135,8 +138,8 @@ dword_result_t RtlCompareStringN(lpstring_t string_1, dword_t string_1_len,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlCompareStringN, kNone, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff561918
|
||||
void RtlInitAnsiString(pointer_t<X_ANSI_STRING> destination,
|
||||
lpstring_t source) {
|
||||
void RtlInitAnsiString_entry(pointer_t<X_ANSI_STRING> destination,
|
||||
lpstring_t source) {
|
||||
if (source) {
|
||||
uint16_t length = (uint16_t)strlen(source);
|
||||
destination->length = length;
|
||||
@@ -150,7 +153,7 @@ void RtlInitAnsiString(pointer_t<X_ANSI_STRING> destination,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlInitAnsiString, kNone, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff561899
|
||||
void RtlFreeAnsiString(pointer_t<X_ANSI_STRING> string) {
|
||||
void RtlFreeAnsiString_entry(pointer_t<X_ANSI_STRING> string) {
|
||||
if (string->pointer) {
|
||||
kernel_memory()->SystemHeapFree(string->pointer);
|
||||
}
|
||||
@@ -160,8 +163,8 @@ void RtlFreeAnsiString(pointer_t<X_ANSI_STRING> string) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlFreeAnsiString, kNone, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff561934
|
||||
void RtlInitUnicodeString(pointer_t<X_UNICODE_STRING> destination,
|
||||
lpu16string_t source) {
|
||||
void RtlInitUnicodeString_entry(pointer_t<X_UNICODE_STRING> destination,
|
||||
lpu16string_t source) {
|
||||
if (source) {
|
||||
destination->length = (uint16_t)source.value().size() * 2;
|
||||
destination->maximum_length = (uint16_t)(source.value().size() + 1) * 2;
|
||||
@@ -173,7 +176,7 @@ void RtlInitUnicodeString(pointer_t<X_UNICODE_STRING> destination,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlInitUnicodeString, kNone, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff561903
|
||||
void RtlFreeUnicodeString(pointer_t<X_UNICODE_STRING> string) {
|
||||
void RtlFreeUnicodeString_entry(pointer_t<X_UNICODE_STRING> string) {
|
||||
if (string->pointer) {
|
||||
kernel_memory()->SystemHeapFree(string->pointer);
|
||||
}
|
||||
@@ -182,8 +185,8 @@ void RtlFreeUnicodeString(pointer_t<X_UNICODE_STRING> string) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlFreeUnicodeString, kNone, kImplemented);
|
||||
|
||||
void RtlCopyString(pointer_t<X_ANSI_STRING> destination,
|
||||
pointer_t<X_ANSI_STRING> source) {
|
||||
void RtlCopyString_entry(pointer_t<X_ANSI_STRING> destination,
|
||||
pointer_t<X_ANSI_STRING> source) {
|
||||
if (!source) {
|
||||
destination->length = 0;
|
||||
return;
|
||||
@@ -199,8 +202,8 @@ void RtlCopyString(pointer_t<X_ANSI_STRING> destination,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlCopyString, kNone, kImplemented);
|
||||
|
||||
void RtlCopyUnicodeString(pointer_t<X_UNICODE_STRING> destination,
|
||||
pointer_t<X_UNICODE_STRING> source) {
|
||||
void RtlCopyUnicodeString_entry(pointer_t<X_UNICODE_STRING> destination,
|
||||
pointer_t<X_UNICODE_STRING> source) {
|
||||
if (!source) {
|
||||
destination->length = 0;
|
||||
return;
|
||||
@@ -217,7 +220,7 @@ void RtlCopyUnicodeString(pointer_t<X_UNICODE_STRING> destination,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlCopyUnicodeString, kNone, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff562969
|
||||
dword_result_t RtlUnicodeStringToAnsiString(
|
||||
dword_result_t RtlUnicodeStringToAnsiString_entry(
|
||||
pointer_t<X_ANSI_STRING> destination_ptr,
|
||||
pointer_t<X_UNICODE_STRING> source_ptr, dword_t alloc_dest) {
|
||||
// NTSTATUS
|
||||
@@ -261,11 +264,11 @@ dword_result_t RtlUnicodeStringToAnsiString(
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlUnicodeStringToAnsiString, kNone, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff553113
|
||||
dword_result_t RtlMultiByteToUnicodeN(lpword_t destination_ptr,
|
||||
dword_t destination_len,
|
||||
lpdword_t written_ptr,
|
||||
pointer_t<uint8_t> source_ptr,
|
||||
dword_t source_len) {
|
||||
dword_result_t RtlMultiByteToUnicodeN_entry(lpword_t destination_ptr,
|
||||
dword_t destination_len,
|
||||
lpdword_t written_ptr,
|
||||
pointer_t<uint8_t> source_ptr,
|
||||
dword_t source_len) {
|
||||
uint32_t copy_len = destination_len >> 1;
|
||||
copy_len = copy_len < source_len ? copy_len : source_len.value();
|
||||
|
||||
@@ -286,10 +289,11 @@ DECLARE_XBOXKRNL_EXPORT3(RtlMultiByteToUnicodeN, kNone, kImplemented,
|
||||
kHighFrequency, kSketchy);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ff553261
|
||||
dword_result_t RtlUnicodeToMultiByteN(pointer_t<uint8_t> destination_ptr,
|
||||
dword_t destination_len,
|
||||
lpdword_t written_ptr,
|
||||
lpword_t source_ptr, dword_t source_len) {
|
||||
dword_result_t RtlUnicodeToMultiByteN_entry(pointer_t<uint8_t> destination_ptr,
|
||||
dword_t destination_len,
|
||||
lpdword_t written_ptr,
|
||||
lpword_t source_ptr,
|
||||
dword_t source_len) {
|
||||
uint32_t copy_len = source_len >> 1;
|
||||
copy_len = copy_len < destination_len ? copy_len : destination_len.value();
|
||||
|
||||
@@ -302,14 +306,13 @@ dword_result_t RtlUnicodeToMultiByteN(pointer_t<uint8_t> destination_ptr,
|
||||
if (written_ptr.guest_address() != 0) {
|
||||
*written_ptr = copy_len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT3(RtlUnicodeToMultiByteN, kNone, kImplemented,
|
||||
kHighFrequency, kSketchy);
|
||||
|
||||
// https://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/Executable%20Images/RtlImageNtHeader.html
|
||||
pointer_result_t RtlImageNtHeader(lpvoid_t module) {
|
||||
pointer_result_t RtlImageNtHeader_entry(lpvoid_t module) {
|
||||
if (!module) {
|
||||
return 0;
|
||||
}
|
||||
@@ -332,8 +335,8 @@ pointer_result_t RtlImageNtHeader(lpvoid_t module) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlImageNtHeader, kNone, kImplemented);
|
||||
|
||||
pointer_result_t RtlImageXexHeaderField(pointer_t<xex2_header> xex_header,
|
||||
dword_t field_dword) {
|
||||
pointer_result_t RtlImageXexHeaderField_entry(pointer_t<xex2_header> xex_header,
|
||||
dword_t field_dword) {
|
||||
uint32_t field_value = 0;
|
||||
uint32_t field = field_dword; // VS acts weird going from dword_t -> enum
|
||||
|
||||
@@ -382,7 +385,7 @@ void xeRtlInitializeCriticalSection(X_RTL_CRITICAL_SECTION* cs,
|
||||
cs->owning_thread = 0;
|
||||
}
|
||||
|
||||
void RtlInitializeCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
void RtlInitializeCriticalSection_entry(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
xeRtlInitializeCriticalSection(cs, cs.guest_address());
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlInitializeCriticalSection, kNone, kImplemented);
|
||||
@@ -407,7 +410,7 @@ X_STATUS xeRtlInitializeCriticalSectionAndSpinCount(X_RTL_CRITICAL_SECTION* cs,
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dword_result_t RtlInitializeCriticalSectionAndSpinCount(
|
||||
dword_result_t RtlInitializeCriticalSectionAndSpinCount_entry(
|
||||
pointer_t<X_RTL_CRITICAL_SECTION> cs, dword_t spin_count) {
|
||||
return xeRtlInitializeCriticalSectionAndSpinCount(cs, cs.guest_address(),
|
||||
spin_count);
|
||||
@@ -415,7 +418,7 @@ dword_result_t RtlInitializeCriticalSectionAndSpinCount(
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlInitializeCriticalSectionAndSpinCount, kNone,
|
||||
kImplemented);
|
||||
|
||||
void RtlEnterCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
void RtlEnterCriticalSection_entry(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
uint32_t cur_thread = XThread::GetCurrentThread()->guest_object();
|
||||
uint32_t spin_count = cs->header.absolute * 256;
|
||||
|
||||
@@ -449,7 +452,7 @@ void RtlEnterCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(RtlEnterCriticalSection, kNone, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t RtlTryEnterCriticalSection(
|
||||
dword_result_t RtlTryEnterCriticalSection_entry(
|
||||
pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
uint32_t thread = XThread::GetCurrentThread()->guest_object();
|
||||
|
||||
@@ -471,7 +474,7 @@ dword_result_t RtlTryEnterCriticalSection(
|
||||
DECLARE_XBOXKRNL_EXPORT2(RtlTryEnterCriticalSection, kNone, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void RtlLeaveCriticalSection(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
void RtlLeaveCriticalSection_entry(pointer_t<X_RTL_CRITICAL_SECTION> cs) {
|
||||
assert_true(cs->owning_thread == XThread::GetCurrentThread()->guest_object());
|
||||
|
||||
// Drop recursion count - if it isn't zero we still have the lock.
|
||||
@@ -506,8 +509,8 @@ struct X_TIME_FIELDS {
|
||||
static_assert_size(X_TIME_FIELDS, 16);
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtltimetotimefields
|
||||
void RtlTimeToTimeFields(lpqword_t time_ptr,
|
||||
pointer_t<X_TIME_FIELDS> time_fields_ptr) {
|
||||
void RtlTimeToTimeFields_entry(lpqword_t time_ptr,
|
||||
pointer_t<X_TIME_FIELDS> time_fields_ptr) {
|
||||
auto tp = XClock::to_sys(XClock::from_file_time(time_ptr.value()));
|
||||
auto dp = date::floor<date::days>(tp);
|
||||
auto year_month_day = date::year_month_day{dp};
|
||||
@@ -526,8 +529,8 @@ void RtlTimeToTimeFields(lpqword_t time_ptr,
|
||||
DECLARE_XBOXKRNL_EXPORT1(RtlTimeToTimeFields, kNone, kImplemented);
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtltimefieldstotime
|
||||
dword_result_t RtlTimeFieldsToTime(pointer_t<X_TIME_FIELDS> time_fields_ptr,
|
||||
lpqword_t time_ptr) {
|
||||
dword_result_t RtlTimeFieldsToTime_entry(
|
||||
pointer_t<X_TIME_FIELDS> time_fields_ptr, lpqword_t time_ptr) {
|
||||
if (time_fields_ptr->year < 1601 || time_fields_ptr->month < 1 ||
|
||||
time_fields_ptr->month > 12 || time_fields_ptr->day < 1 ||
|
||||
time_fields_ptr->day > 31 || time_fields_ptr->hour > 23 ||
|
||||
@@ -608,7 +611,8 @@ static uint32_t crc32_table[256] = {
|
||||
0x2D02EF8Du,
|
||||
};
|
||||
|
||||
dword_result_t RtlComputeCrc32(dword_t seed, lpvoid_t buffer, dword_t length) {
|
||||
dword_result_t RtlComputeCrc32_entry(dword_t seed, lpvoid_t buffer,
|
||||
dword_t length) {
|
||||
if (!length) {
|
||||
return seed.value();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2020 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -824,7 +824,7 @@ class WideCountFormatData : public FormatData {
|
||||
int32_t count_;
|
||||
};
|
||||
|
||||
SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL DbgPrint_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(0);
|
||||
if (!format_ptr) {
|
||||
SHIM_SET_RETURN_32(X_STATUS_INVALID_PARAMETER);
|
||||
@@ -854,7 +854,7 @@ SHIM_CALL DbgPrint_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx
|
||||
SHIM_CALL _snprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL _snprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
int32_t buffer_count = SHIM_GET_ARG_32(1);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -894,7 +894,7 @@ SHIM_CALL _snprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
|
||||
SHIM_CALL sprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL sprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -925,7 +925,7 @@ SHIM_CALL sprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx
|
||||
SHIM_CALL _snwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL _snwprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
int32_t buffer_count = SHIM_GET_ARG_32(1);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -966,7 +966,7 @@ SHIM_CALL _snwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
|
||||
SHIM_CALL swprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL swprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -998,7 +998,7 @@ SHIM_CALL swprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/1kt27hek.aspx
|
||||
SHIM_CALL _vsnprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL _vsnprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
int32_t buffer_count = SHIM_GET_ARG_32(1);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -1041,7 +1041,8 @@ SHIM_CALL _vsnprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/1kt27hek.aspx
|
||||
SHIM_CALL _vsnwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL _vsnwprintf_entry(PPCContext* ppc_context,
|
||||
KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
int32_t buffer_count = SHIM_GET_ARG_32(1);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -1086,7 +1087,7 @@ SHIM_CALL _vsnwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
|
||||
SHIM_CALL vsprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL vsprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -1118,7 +1119,8 @@ SHIM_CALL vsprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/w05tbk72.aspx
|
||||
SHIM_CALL _vscwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL _vscwprintf_entry(PPCContext* ppc_context,
|
||||
KernelState* kernel_state) {
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t arg_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -1145,7 +1147,7 @@ SHIM_CALL _vscwprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/28d5ce15.aspx
|
||||
SHIM_CALL vswprintf_shim(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
SHIM_CALL vswprintf_entry(PPCContext* ppc_context, KernelState* kernel_state) {
|
||||
uint32_t buffer_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t arg_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -95,11 +95,12 @@ object_ref<T> LookupNamedObject(KernelState* kernel_state,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dword_result_t ExCreateThread(lpdword_t handle_ptr, dword_t stack_size,
|
||||
lpdword_t thread_id_ptr,
|
||||
dword_t xapi_thread_startup,
|
||||
lpvoid_t start_address, lpvoid_t start_context,
|
||||
dword_t creation_flags) {
|
||||
dword_result_t ExCreateThread_entry(lpdword_t handle_ptr, dword_t stack_size,
|
||||
lpdword_t thread_id_ptr,
|
||||
dword_t xapi_thread_startup,
|
||||
lpvoid_t start_address,
|
||||
lpvoid_t start_context,
|
||||
dword_t creation_flags) {
|
||||
// http://jafile.com/uploads/scoop/main.cpp.txt
|
||||
// DWORD
|
||||
// LPHANDLE Handle,
|
||||
@@ -149,7 +150,7 @@ dword_result_t ExCreateThread(lpdword_t handle_ptr, dword_t stack_size,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExCreateThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t ExTerminateThread(dword_t exit_code) {
|
||||
dword_result_t ExTerminateThread_entry(dword_t exit_code) {
|
||||
XThread* thread = XThread::GetCurrentThread();
|
||||
|
||||
// NOTE: this kills us right now. We won't return from it.
|
||||
@@ -157,7 +158,8 @@ dword_result_t ExTerminateThread(dword_t exit_code) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExTerminateThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtResumeThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
dword_result_t NtResumeThread_entry(dword_t handle,
|
||||
lpdword_t suspend_count_ptr) {
|
||||
X_RESULT result = X_STATUS_INVALID_HANDLE;
|
||||
uint32_t suspend_count = 0;
|
||||
|
||||
@@ -173,7 +175,7 @@ dword_result_t NtResumeThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtResumeThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeResumeThread(lpvoid_t thread_ptr) {
|
||||
dword_result_t KeResumeThread_entry(lpvoid_t thread_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
if (thread) {
|
||||
@@ -186,7 +188,8 @@ dword_result_t KeResumeThread(lpvoid_t thread_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeResumeThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtSuspendThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
dword_result_t NtSuspendThread_entry(dword_t handle,
|
||||
lpdword_t suspend_count_ptr) {
|
||||
X_RESULT result = X_STATUS_SUCCESS;
|
||||
uint32_t suspend_count = 0;
|
||||
|
||||
@@ -205,9 +208,11 @@ dword_result_t NtSuspendThread(dword_t handle, lpdword_t suspend_count_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtSuspendThread, kThreading, kImplemented);
|
||||
|
||||
void KeSetCurrentStackPointers(lpvoid_t stack_ptr, pointer_t<X_KTHREAD> thread,
|
||||
lpvoid_t stack_alloc_base, lpvoid_t stack_base,
|
||||
lpvoid_t stack_limit) {
|
||||
void KeSetCurrentStackPointers_entry(lpvoid_t stack_ptr,
|
||||
pointer_t<X_KTHREAD> thread,
|
||||
lpvoid_t stack_alloc_base,
|
||||
lpvoid_t stack_base,
|
||||
lpvoid_t stack_limit) {
|
||||
auto current_thread = XThread::GetCurrentThread();
|
||||
auto context = current_thread->thread_state()->context();
|
||||
auto pcr = kernel_memory()->TranslateVirtual<X_KPCR*>(
|
||||
@@ -230,8 +235,8 @@ void KeSetCurrentStackPointers(lpvoid_t stack_ptr, pointer_t<X_KTHREAD> thread,
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeSetCurrentStackPointers, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeSetAffinityThread(lpvoid_t thread_ptr, dword_t affinity,
|
||||
lpdword_t previous_affinity_ptr) {
|
||||
dword_result_t KeSetAffinityThread_entry(lpvoid_t thread_ptr, dword_t affinity,
|
||||
lpdword_t previous_affinity_ptr) {
|
||||
// The Xbox 360, according to disassembly of KeSetAffinityThread, unlike
|
||||
// Windows NT, stores the previous affinity via the pointer provided as an
|
||||
// argument, not in the return value - the return value is used for the
|
||||
@@ -250,7 +255,7 @@ dword_result_t KeSetAffinityThread(lpvoid_t thread_ptr, dword_t affinity,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetAffinityThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeQueryBasePriorityThread(lpvoid_t thread_ptr) {
|
||||
dword_result_t KeQueryBasePriorityThread_entry(lpvoid_t thread_ptr) {
|
||||
int32_t priority = 0;
|
||||
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
@@ -262,7 +267,8 @@ dword_result_t KeQueryBasePriorityThread(lpvoid_t thread_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeQueryBasePriorityThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeSetBasePriorityThread(lpvoid_t thread_ptr, dword_t increment) {
|
||||
dword_result_t KeSetBasePriorityThread_entry(lpvoid_t thread_ptr,
|
||||
dword_t increment) {
|
||||
int32_t prev_priority = 0;
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
|
||||
@@ -275,7 +281,8 @@ dword_result_t KeSetBasePriorityThread(lpvoid_t thread_ptr, dword_t increment) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetBasePriorityThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeSetDisableBoostThread(lpvoid_t thread_ptr, dword_t disabled) {
|
||||
dword_result_t KeSetDisableBoostThread_entry(lpvoid_t thread_ptr,
|
||||
dword_t disabled) {
|
||||
auto thread = XObject::GetNativeObject<XThread>(kernel_state(), thread_ptr);
|
||||
if (thread) {
|
||||
// Uhm?
|
||||
@@ -285,13 +292,13 @@ dword_result_t KeSetDisableBoostThread(lpvoid_t thread_ptr, dword_t disabled) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetDisableBoostThread, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeGetCurrentProcessType() {
|
||||
dword_result_t KeGetCurrentProcessType_entry() {
|
||||
return kernel_state()->process_type();
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeGetCurrentProcessType, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeSetCurrentProcessType(dword_t type) {
|
||||
void KeSetCurrentProcessType_entry(dword_t type) {
|
||||
// One of X_PROCTYPE_?
|
||||
|
||||
assert_true(type <= 2);
|
||||
@@ -300,15 +307,16 @@ void KeSetCurrentProcessType(dword_t type) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeSetCurrentProcessType, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeQueryPerformanceFrequency() {
|
||||
dword_result_t KeQueryPerformanceFrequency_entry() {
|
||||
uint64_t result = Clock::guest_tick_frequency();
|
||||
return static_cast<uint32_t>(result);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeQueryPerformanceFrequency, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeDelayExecutionThread(dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t interval_ptr) {
|
||||
dword_result_t KeDelayExecutionThread_entry(dword_t processor_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t interval_ptr) {
|
||||
XThread* thread = XThread::GetCurrentThread();
|
||||
X_STATUS result = thread->Delay(processor_mode, alertable, *interval_ptr);
|
||||
|
||||
@@ -317,7 +325,7 @@ dword_result_t KeDelayExecutionThread(dword_t processor_mode, dword_t alertable,
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeDelayExecutionThread, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtYieldExecution() {
|
||||
dword_result_t NtYieldExecution_entry() {
|
||||
auto thread = XThread::GetCurrentThread();
|
||||
thread->Delay(0, 0, 0);
|
||||
return 0;
|
||||
@@ -325,7 +333,7 @@ dword_result_t NtYieldExecution() {
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtYieldExecution, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeQuerySystemTime(lpqword_t time_ptr) {
|
||||
void KeQuerySystemTime_entry(lpqword_t time_ptr) {
|
||||
uint64_t time = Clock::QueryGuestSystemTime();
|
||||
if (time_ptr) {
|
||||
*time_ptr = time;
|
||||
@@ -334,7 +342,7 @@ void KeQuerySystemTime(lpqword_t time_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeQuerySystemTime, kThreading, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686801
|
||||
dword_result_t KeTlsAlloc() {
|
||||
dword_result_t KeTlsAlloc_entry() {
|
||||
uint32_t slot = kernel_state()->AllocateTLS();
|
||||
XThread::GetCurrentThread()->SetTLSValue(slot, 0);
|
||||
|
||||
@@ -343,7 +351,7 @@ dword_result_t KeTlsAlloc() {
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeTlsAlloc, kThreading, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686804
|
||||
dword_result_t KeTlsFree(dword_t tls_index) {
|
||||
dword_result_t KeTlsFree_entry(dword_t tls_index) {
|
||||
if (tls_index == X_TLS_OUT_OF_INDEXES) {
|
||||
return 0;
|
||||
}
|
||||
@@ -354,7 +362,7 @@ dword_result_t KeTlsFree(dword_t tls_index) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeTlsFree, kThreading, kImplemented);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686812
|
||||
dword_result_t KeTlsGetValue(dword_t tls_index) {
|
||||
dword_result_t KeTlsGetValue_entry(dword_t tls_index) {
|
||||
// xboxkrnl doesn't actually have an error branch - it always succeeds, even
|
||||
// if it overflows the TLS.
|
||||
uint32_t value = 0;
|
||||
@@ -368,7 +376,7 @@ DECLARE_XBOXKRNL_EXPORT2(KeTlsGetValue, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms686818
|
||||
dword_result_t KeTlsSetValue(dword_t tls_index, dword_t tls_value) {
|
||||
dword_result_t KeTlsSetValue_entry(dword_t tls_index, dword_t tls_value) {
|
||||
// xboxkrnl doesn't actually have an error branch - it always succeeds, even
|
||||
// if it overflows the TLS.
|
||||
if (XThread::GetCurrentThread()->SetTLSValue(tls_index, tls_value)) {
|
||||
@@ -379,8 +387,8 @@ dword_result_t KeTlsSetValue(dword_t tls_index, dword_t tls_value) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeTlsSetValue, kThreading, kImplemented);
|
||||
|
||||
void KeInitializeEvent(pointer_t<X_KEVENT> event_ptr, dword_t event_type,
|
||||
dword_t initial_state) {
|
||||
void KeInitializeEvent_entry(pointer_t<X_KEVENT> event_ptr, dword_t event_type,
|
||||
dword_t initial_state) {
|
||||
event_ptr.Zero();
|
||||
event_ptr->header.type = event_type;
|
||||
event_ptr->header.signal_state = (uint32_t)initial_state;
|
||||
@@ -403,14 +411,14 @@ uint32_t xeKeSetEvent(X_KEVENT* event_ptr, uint32_t increment, uint32_t wait) {
|
||||
return ev->Set(increment, !!wait);
|
||||
}
|
||||
|
||||
dword_result_t KeSetEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait) {
|
||||
dword_result_t KeSetEvent_entry(pointer_t<X_KEVENT> event_ptr,
|
||||
dword_t increment, dword_t wait) {
|
||||
return xeKeSetEvent(event_ptr, increment, wait);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeSetEvent, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t KePulseEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
dword_t wait) {
|
||||
dword_result_t KePulseEvent_entry(pointer_t<X_KEVENT> event_ptr,
|
||||
dword_t increment, dword_t wait) {
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
assert_always();
|
||||
@@ -422,7 +430,7 @@ dword_result_t KePulseEvent(pointer_t<X_KEVENT> event_ptr, dword_t increment,
|
||||
DECLARE_XBOXKRNL_EXPORT2(KePulseEvent, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeResetEvent(pointer_t<X_KEVENT> event_ptr) {
|
||||
dword_result_t KeResetEvent_entry(pointer_t<X_KEVENT> event_ptr) {
|
||||
auto ev = XObject::GetNativeObject<XEvent>(kernel_state(), event_ptr);
|
||||
if (!ev) {
|
||||
assert_always();
|
||||
@@ -433,9 +441,9 @@ dword_result_t KeResetEvent(pointer_t<X_KEVENT> event_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeResetEvent, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCreateEvent(lpdword_t handle_ptr,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes_ptr,
|
||||
dword_t event_type, dword_t initial_state) {
|
||||
dword_result_t NtCreateEvent_entry(
|
||||
lpdword_t handle_ptr, pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes_ptr,
|
||||
dword_t event_type, dword_t initial_state) {
|
||||
// Check for an existing timer with the same name.
|
||||
auto existing_object =
|
||||
LookupNamedObject<XEvent>(kernel_state(), obj_attributes_ptr);
|
||||
@@ -482,12 +490,13 @@ uint32_t xeNtSetEvent(uint32_t handle, xe::be<uint32_t>* previous_state_ptr) {
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtSetEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
dword_result_t NtSetEvent_entry(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
return xeNtSetEvent(handle, previous_state_ptr);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtSetEvent, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
dword_result_t NtPulseEvent(dword_t handle, lpdword_t previous_state_ptr) {
|
||||
dword_result_t NtPulseEvent_entry(dword_t handle,
|
||||
lpdword_t previous_state_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto ev = kernel_state()->object_table()->LookupObject<XEvent>(handle);
|
||||
@@ -518,13 +527,15 @@ uint32_t xeNtClearEvent(uint32_t handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t NtClearEvent(dword_t handle) { return xeNtClearEvent(handle); }
|
||||
dword_result_t NtClearEvent_entry(dword_t handle) {
|
||||
return xeNtClearEvent(handle);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtClearEvent, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff552150(v=vs.85).aspx
|
||||
void KeInitializeSemaphore(pointer_t<X_KSEMAPHORE> semaphore_ptr, dword_t count,
|
||||
dword_t limit) {
|
||||
void KeInitializeSemaphore_entry(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t count, dword_t limit) {
|
||||
semaphore_ptr->header.type = 5; // SemaphoreObject
|
||||
semaphore_ptr->header.signal_state = (uint32_t)count;
|
||||
semaphore_ptr->limit = (uint32_t)limit;
|
||||
@@ -553,16 +564,16 @@ uint32_t xeKeReleaseSemaphore(X_KSEMAPHORE* semaphore_ptr, uint32_t increment,
|
||||
return sem->ReleaseSemaphore(adjustment);
|
||||
}
|
||||
|
||||
dword_result_t KeReleaseSemaphore(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t increment, dword_t adjustment,
|
||||
dword_t wait) {
|
||||
dword_result_t KeReleaseSemaphore_entry(pointer_t<X_KSEMAPHORE> semaphore_ptr,
|
||||
dword_t increment, dword_t adjustment,
|
||||
dword_t wait) {
|
||||
return xeKeReleaseSemaphore(semaphore_ptr, increment, adjustment, wait);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeReleaseSemaphore, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCreateSemaphore(lpdword_t handle_ptr,
|
||||
lpvoid_t obj_attributes_ptr, dword_t count,
|
||||
dword_t limit) {
|
||||
dword_result_t NtCreateSemaphore_entry(lpdword_t handle_ptr,
|
||||
lpvoid_t obj_attributes_ptr,
|
||||
dword_t count, dword_t limit) {
|
||||
// Check for an existing timer with the same name.
|
||||
auto existing_object =
|
||||
LookupNamedObject<XSemaphore>(kernel_state(), obj_attributes_ptr);
|
||||
@@ -594,8 +605,9 @@ dword_result_t NtCreateSemaphore(lpdword_t handle_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateSemaphore, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtReleaseSemaphore(dword_t sem_handle, dword_t release_count,
|
||||
lpdword_t previous_count_ptr) {
|
||||
dword_result_t NtReleaseSemaphore_entry(dword_t sem_handle,
|
||||
dword_t release_count,
|
||||
lpdword_t previous_count_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
int32_t previous_count = 0;
|
||||
|
||||
@@ -612,11 +624,12 @@ dword_result_t NtReleaseSemaphore(dword_t sem_handle, dword_t release_count,
|
||||
|
||||
return result;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtReleaseSemaphore, kThreading, kImplemented);
|
||||
DECLARE_XBOXKRNL_EXPORT2(NtReleaseSemaphore, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t NtCreateMutant(lpdword_t handle_out,
|
||||
pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes,
|
||||
dword_t initial_owner) {
|
||||
dword_result_t NtCreateMutant_entry(
|
||||
lpdword_t handle_out, pointer_t<X_OBJECT_ATTRIBUTES> obj_attributes,
|
||||
dword_t initial_owner) {
|
||||
// Check for an existing timer with the same name.
|
||||
auto existing_object = LookupNamedObject<XMutant>(
|
||||
kernel_state(), obj_attributes.guest_address());
|
||||
@@ -648,7 +661,7 @@ dword_result_t NtCreateMutant(lpdword_t handle_out,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateMutant, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtReleaseMutant(dword_t mutant_handle, dword_t unknown) {
|
||||
dword_result_t NtReleaseMutant_entry(dword_t mutant_handle, dword_t unknown) {
|
||||
// This doesn't seem to be supported.
|
||||
// int32_t previous_count_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
@@ -674,8 +687,9 @@ dword_result_t NtReleaseMutant(dword_t mutant_handle, dword_t unknown) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtReleaseMutant, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCreateTimer(lpdword_t handle_ptr, lpvoid_t obj_attributes_ptr,
|
||||
dword_t timer_type) {
|
||||
dword_result_t NtCreateTimer_entry(lpdword_t handle_ptr,
|
||||
lpvoid_t obj_attributes_ptr,
|
||||
dword_t timer_type) {
|
||||
// timer_type = NotificationTimer (0) or SynchronizationTimer (1)
|
||||
|
||||
// Check for an existing timer with the same name.
|
||||
@@ -709,11 +723,11 @@ dword_result_t NtCreateTimer(lpdword_t handle_ptr, lpvoid_t obj_attributes_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtCreateTimer, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtSetTimerEx(dword_t timer_handle, lpqword_t due_time_ptr,
|
||||
lpvoid_t routine_ptr /*PTIMERAPCROUTINE*/,
|
||||
dword_t unk_one, lpvoid_t routine_arg,
|
||||
dword_t resume, dword_t period_ms,
|
||||
dword_t unk_zero) {
|
||||
dword_result_t NtSetTimerEx_entry(dword_t timer_handle, lpqword_t due_time_ptr,
|
||||
lpvoid_t routine_ptr /*PTIMERAPCROUTINE*/,
|
||||
dword_t unk_one, lpvoid_t routine_arg,
|
||||
dword_t resume, dword_t period_ms,
|
||||
dword_t unk_zero) {
|
||||
assert_true(unk_one == 1);
|
||||
assert_true(unk_zero == 0);
|
||||
|
||||
@@ -735,8 +749,8 @@ dword_result_t NtSetTimerEx(dword_t timer_handle, lpqword_t due_time_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtSetTimerEx, kThreading, kImplemented);
|
||||
|
||||
dword_result_t NtCancelTimer(dword_t timer_handle,
|
||||
lpdword_t current_state_ptr) {
|
||||
dword_result_t NtCancelTimer_entry(dword_t timer_handle,
|
||||
lpdword_t current_state_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto timer =
|
||||
@@ -771,9 +785,11 @@ uint32_t xeKeWaitForSingleObject(void* object_ptr, uint32_t wait_reason,
|
||||
return result;
|
||||
}
|
||||
|
||||
dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
||||
dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t KeWaitForSingleObject_entry(lpvoid_t object_ptr,
|
||||
dword_t wait_reason,
|
||||
dword_t processor_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
return xeKeWaitForSingleObject(object_ptr, wait_reason, processor_mode,
|
||||
alertable, timeout_ptr ? &timeout : nullptr);
|
||||
@@ -781,9 +797,10 @@ dword_result_t KeWaitForSingleObject(lpvoid_t object_ptr, dword_t wait_reason,
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeWaitForSingleObject, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtWaitForSingleObjectEx(dword_t object_handle, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t NtWaitForSingleObjectEx_entry(dword_t object_handle,
|
||||
dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto object =
|
||||
@@ -801,12 +818,10 @@ dword_result_t NtWaitForSingleObjectEx(dword_t object_handle, dword_t wait_mode,
|
||||
DECLARE_XBOXKRNL_EXPORT3(NtWaitForSingleObjectEx, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t KeWaitForMultipleObjects(dword_t count, lpdword_t objects_ptr,
|
||||
dword_t wait_type, dword_t wait_reason,
|
||||
dword_t processor_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr,
|
||||
lpvoid_t wait_block_array_ptr) {
|
||||
dword_result_t KeWaitForMultipleObjects_entry(
|
||||
dword_t count, lpdword_t objects_ptr, dword_t wait_type,
|
||||
dword_t wait_reason, dword_t processor_mode, dword_t alertable,
|
||||
lpqword_t timeout_ptr, lpvoid_t wait_block_array_ptr) {
|
||||
assert_true(wait_type <= 1);
|
||||
|
||||
std::vector<object_ref<XObject>> objects;
|
||||
@@ -852,10 +867,9 @@ uint32_t xeNtWaitForMultipleObjectsEx(uint32_t count, xe::be<uint32_t>* handles,
|
||||
wait_type, 6, wait_mode, alertable, timeout_ptr);
|
||||
}
|
||||
|
||||
dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t NtWaitForMultipleObjectsEx_entry(
|
||||
dword_t count, lpdword_t handles, dword_t wait_type, dword_t wait_mode,
|
||||
dword_t alertable, lpqword_t timeout_ptr) {
|
||||
uint64_t timeout = timeout_ptr ? static_cast<uint64_t>(*timeout_ptr) : 0u;
|
||||
return xeNtWaitForMultipleObjectsEx(count, handles, wait_type, wait_mode,
|
||||
alertable,
|
||||
@@ -864,10 +878,11 @@ dword_result_t NtWaitForMultipleObjectsEx(dword_t count, lpdword_t handles,
|
||||
DECLARE_XBOXKRNL_EXPORT3(NtWaitForMultipleObjectsEx, kThreading, kImplemented,
|
||||
kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t NtSignalAndWaitForSingleObjectEx(dword_t signal_handle,
|
||||
dword_t wait_handle,
|
||||
dword_t alertable, dword_t r6,
|
||||
lpqword_t timeout_ptr) {
|
||||
dword_result_t NtSignalAndWaitForSingleObjectEx_entry(dword_t signal_handle,
|
||||
dword_t wait_handle,
|
||||
dword_t alertable,
|
||||
dword_t r6,
|
||||
lpqword_t timeout_ptr) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
auto signal_object =
|
||||
@@ -907,7 +922,7 @@ uint32_t xeKeKfAcquireSpinLock(uint32_t* lock) {
|
||||
return old_irql;
|
||||
}
|
||||
|
||||
dword_result_t KfAcquireSpinLock(lpdword_t lock_ptr) {
|
||||
dword_result_t KfAcquireSpinLock_entry(lpdword_t lock_ptr) {
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
return xeKeKfAcquireSpinLock(lock);
|
||||
}
|
||||
@@ -923,14 +938,14 @@ void xeKeKfReleaseSpinLock(uint32_t* lock, dword_t old_irql) {
|
||||
xe::atomic_dec(lock);
|
||||
}
|
||||
|
||||
void KfReleaseSpinLock(lpdword_t lock_ptr, dword_t old_irql) {
|
||||
void KfReleaseSpinLock_entry(lpdword_t lock_ptr, dword_t old_irql) {
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
xeKeKfReleaseSpinLock(lock, old_irql);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KfReleaseSpinLock, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
void KeAcquireSpinLockAtRaisedIrql_entry(lpdword_t lock_ptr) {
|
||||
// Lock.
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
while (!xe::atomic_cas(0, 1, lock)) {
|
||||
@@ -941,7 +956,7 @@ void KeAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT3(KeAcquireSpinLockAtRaisedIrql, kThreading,
|
||||
kImplemented, kBlocking, kHighFrequency);
|
||||
|
||||
dword_result_t KeTryToAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
dword_result_t KeTryToAcquireSpinLockAtRaisedIrql_entry(lpdword_t lock_ptr) {
|
||||
// Lock.
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
if (!xe::atomic_cas(0, 1, lock)) {
|
||||
@@ -952,7 +967,7 @@ dword_result_t KeTryToAcquireSpinLockAtRaisedIrql(lpdword_t lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT4(KeTryToAcquireSpinLockAtRaisedIrql, kThreading,
|
||||
kImplemented, kBlocking, kHighFrequency, kSketchy);
|
||||
|
||||
void KeReleaseSpinLockFromRaisedIrql(lpdword_t lock_ptr) {
|
||||
void KeReleaseSpinLockFromRaisedIrql_entry(lpdword_t lock_ptr) {
|
||||
// Unlock.
|
||||
auto lock = reinterpret_cast<uint32_t*>(lock_ptr.host_address());
|
||||
xe::atomic_dec(lock);
|
||||
@@ -960,26 +975,26 @@ void KeReleaseSpinLockFromRaisedIrql(lpdword_t lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeReleaseSpinLockFromRaisedIrql, kThreading,
|
||||
kImplemented, kHighFrequency);
|
||||
|
||||
void KeEnterCriticalRegion() {
|
||||
void KeEnterCriticalRegion_entry() {
|
||||
XThread::GetCurrentThread()->EnterCriticalRegion();
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeEnterCriticalRegion, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KeLeaveCriticalRegion() {
|
||||
void KeLeaveCriticalRegion_entry() {
|
||||
XThread::GetCurrentThread()->LeaveCriticalRegion();
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeLeaveCriticalRegion, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
dword_result_t KeRaiseIrqlToDpcLevel() {
|
||||
dword_result_t KeRaiseIrqlToDpcLevel_entry() {
|
||||
auto old_value = kernel_state()->processor()->RaiseIrql(cpu::Irql::DPC);
|
||||
return (uint32_t)old_value;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeRaiseIrqlToDpcLevel, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
void KfLowerIrql(dword_t old_value) {
|
||||
void KfLowerIrql_entry(dword_t old_value) {
|
||||
kernel_state()->processor()->LowerIrql(
|
||||
static_cast<cpu::Irql>((uint32_t)old_value));
|
||||
|
||||
@@ -987,9 +1002,9 @@ void KfLowerIrql(dword_t old_value) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KfLowerIrql, kThreading, kImplemented, kHighFrequency);
|
||||
|
||||
void NtQueueApcThread(dword_t thread_handle, lpvoid_t apc_routine,
|
||||
lpvoid_t apc_routine_context, lpvoid_t arg1,
|
||||
lpvoid_t arg2) {
|
||||
void NtQueueApcThread_entry(dword_t thread_handle, lpvoid_t apc_routine,
|
||||
lpvoid_t apc_routine_context, lpvoid_t arg1,
|
||||
lpvoid_t arg2) {
|
||||
auto thread =
|
||||
kernel_state()->object_table()->LookupObject<XThread>(thread_handle);
|
||||
|
||||
@@ -1007,10 +1022,10 @@ void NtQueueApcThread(dword_t thread_handle, lpvoid_t apc_routine,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(NtQueueApcThread, kThreading, kImplemented);
|
||||
|
||||
void KeInitializeApc(pointer_t<XAPC> apc, lpvoid_t thread_ptr,
|
||||
lpvoid_t kernel_routine, lpvoid_t rundown_routine,
|
||||
lpvoid_t normal_routine, dword_t processor_mode,
|
||||
lpvoid_t normal_context) {
|
||||
void KeInitializeApc_entry(pointer_t<XAPC> apc, lpvoid_t thread_ptr,
|
||||
lpvoid_t kernel_routine, lpvoid_t rundown_routine,
|
||||
lpvoid_t normal_routine, dword_t processor_mode,
|
||||
lpvoid_t normal_context) {
|
||||
apc->Initialize();
|
||||
apc->processor_mode = processor_mode;
|
||||
apc->thread_ptr = thread_ptr.guest_address();
|
||||
@@ -1022,8 +1037,9 @@ void KeInitializeApc(pointer_t<XAPC> apc, lpvoid_t thread_ptr,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeInitializeApc, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeInsertQueueApc(pointer_t<XAPC> apc, lpvoid_t arg1,
|
||||
lpvoid_t arg2, dword_t priority_increment) {
|
||||
dword_result_t KeInsertQueueApc_entry(pointer_t<XAPC> apc, lpvoid_t arg1,
|
||||
lpvoid_t arg2,
|
||||
dword_t priority_increment) {
|
||||
auto thread = XObject::GetNativeObject<XThread>(
|
||||
kernel_state(),
|
||||
kernel_state()->memory()->TranslateVirtual(apc->thread_ptr));
|
||||
@@ -1057,7 +1073,7 @@ dword_result_t KeInsertQueueApc(pointer_t<XAPC> apc, lpvoid_t arg1,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeInsertQueueApc, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KeRemoveQueueApc(pointer_t<XAPC> apc) {
|
||||
dword_result_t KeRemoveQueueApc_entry(pointer_t<XAPC> apc) {
|
||||
bool result = false;
|
||||
|
||||
auto thread = XObject::GetNativeObject<XThread>(
|
||||
@@ -1087,8 +1103,8 @@ dword_result_t KeRemoveQueueApc(pointer_t<XAPC> apc) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KeRemoveQueueApc, kThreading, kImplemented);
|
||||
|
||||
dword_result_t KiApcNormalRoutineNop(dword_t unk0 /* output? */,
|
||||
dword_t unk1 /* 0x13 */) {
|
||||
dword_result_t KiApcNormalRoutineNop_entry(dword_t unk0 /* output? */,
|
||||
dword_t unk1 /* 0x13 */) {
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(KiApcNormalRoutineNop, kThreading, kStub);
|
||||
@@ -1103,7 +1119,8 @@ typedef struct {
|
||||
xe::be<uint32_t> arg2;
|
||||
} XDPC;
|
||||
|
||||
void KeInitializeDpc(pointer_t<XDPC> dpc, lpvoid_t routine, lpvoid_t context) {
|
||||
void KeInitializeDpc_entry(pointer_t<XDPC> dpc, lpvoid_t routine,
|
||||
lpvoid_t context) {
|
||||
// KDPC (maybe) 0x18 bytes?
|
||||
uint32_t type = 19; // DpcObject
|
||||
uint32_t importance = 0;
|
||||
@@ -1118,8 +1135,8 @@ void KeInitializeDpc(pointer_t<XDPC> dpc, lpvoid_t routine, lpvoid_t context) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeInitializeDpc, kThreading, kImplemented, kSketchy);
|
||||
|
||||
dword_result_t KeInsertQueueDpc(pointer_t<XDPC> dpc, dword_t arg1,
|
||||
dword_t arg2) {
|
||||
dword_result_t KeInsertQueueDpc_entry(pointer_t<XDPC> dpc, dword_t arg1,
|
||||
dword_t arg2) {
|
||||
assert_always("DPC does not dispatch yet; going to hang!");
|
||||
|
||||
uint32_t list_entry_ptr = dpc.guest_address() + 4;
|
||||
@@ -1143,7 +1160,7 @@ dword_result_t KeInsertQueueDpc(pointer_t<XDPC> dpc, dword_t arg1,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(KeInsertQueueDpc, kThreading, kStub, kSketchy);
|
||||
|
||||
dword_result_t KeRemoveQueueDpc(pointer_t<XDPC> dpc) {
|
||||
dword_result_t KeRemoveQueueDpc_entry(pointer_t<XDPC> dpc) {
|
||||
bool result = false;
|
||||
|
||||
uint32_t list_entry_ptr = dpc.guest_address() + 4;
|
||||
@@ -1171,18 +1188,18 @@ struct X_ERWLOCK {
|
||||
};
|
||||
static_assert_size(X_ERWLOCK, 0x38);
|
||||
|
||||
void ExInitializeReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExInitializeReadWriteLock_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
lock_ptr->lock_count = -1;
|
||||
lock_ptr->writers_waiting_count = 0;
|
||||
lock_ptr->readers_waiting_count = 0;
|
||||
lock_ptr->readers_entry_count = 0;
|
||||
KeInitializeEvent(&lock_ptr->writer_event, 1, 0);
|
||||
KeInitializeSemaphore(&lock_ptr->reader_semaphore, 0, 0x7FFFFFFF);
|
||||
KeInitializeEvent_entry(&lock_ptr->writer_event, 1, 0);
|
||||
KeInitializeSemaphore_entry(&lock_ptr->reader_semaphore, 0, 0x7FFFFFFF);
|
||||
lock_ptr->spin_lock = 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExInitializeReadWriteLock, kThreading, kImplemented);
|
||||
|
||||
void ExAcquireReadWriteLockExclusive(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExAcquireReadWriteLockExclusive_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
int32_t lock_count = ++lock_ptr->lock_count;
|
||||
@@ -1199,7 +1216,7 @@ void ExAcquireReadWriteLockExclusive(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(ExAcquireReadWriteLockExclusive, kThreading,
|
||||
kImplemented, kBlocking);
|
||||
|
||||
dword_result_t ExTryToAcquireReadWriteLockExclusive(
|
||||
dword_result_t ExTryToAcquireReadWriteLockExclusive_entry(
|
||||
pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
@@ -1217,7 +1234,7 @@ dword_result_t ExTryToAcquireReadWriteLockExclusive(
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExTryToAcquireReadWriteLockExclusive, kThreading,
|
||||
kImplemented);
|
||||
|
||||
void ExAcquireReadWriteLockShared(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExAcquireReadWriteLockShared_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
int32_t lock_count = ++lock_ptr->lock_count;
|
||||
@@ -1236,7 +1253,7 @@ void ExAcquireReadWriteLockShared(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(ExAcquireReadWriteLockShared, kThreading, kImplemented,
|
||||
kBlocking);
|
||||
|
||||
dword_result_t ExTryToAcquireReadWriteLockShared(
|
||||
dword_result_t ExTryToAcquireReadWriteLockShared_entry(
|
||||
pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
@@ -1256,7 +1273,7 @@ dword_result_t ExTryToAcquireReadWriteLockShared(
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExTryToAcquireReadWriteLockShared, kThreading,
|
||||
kImplemented);
|
||||
|
||||
void ExReleaseReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
void ExReleaseReadWriteLock_entry(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
auto old_irql = xeKeKfAcquireSpinLock(&lock_ptr->spin_lock);
|
||||
|
||||
int32_t lock_count = --lock_ptr->lock_count;
|
||||
@@ -1292,7 +1309,7 @@ void ExReleaseReadWriteLock(pointer_t<X_ERWLOCK> lock_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT1(ExReleaseReadWriteLock, kThreading, kImplemented);
|
||||
|
||||
// NOTE: This function is very commonly inlined, and probably won't be called!
|
||||
pointer_result_t InterlockedPushEntrySList(
|
||||
pointer_result_t InterlockedPushEntrySList_entry(
|
||||
pointer_t<X_SLIST_HEADER> plist_ptr, pointer_t<X_SINGLE_LIST_ENTRY> entry) {
|
||||
assert_not_null(plist_ptr);
|
||||
assert_not_null(entry);
|
||||
@@ -1317,7 +1334,8 @@ pointer_result_t InterlockedPushEntrySList(
|
||||
DECLARE_XBOXKRNL_EXPORT2(InterlockedPushEntrySList, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
pointer_result_t InterlockedPopEntrySList(pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
pointer_result_t InterlockedPopEntrySList_entry(
|
||||
pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
assert_not_null(plist_ptr);
|
||||
|
||||
uint32_t popped = 0;
|
||||
@@ -1344,7 +1362,8 @@ pointer_result_t InterlockedPopEntrySList(pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
DECLARE_XBOXKRNL_EXPORT2(InterlockedPopEntrySList, kThreading, kImplemented,
|
||||
kHighFrequency);
|
||||
|
||||
pointer_result_t InterlockedFlushSList(pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
pointer_result_t InterlockedFlushSList_entry(
|
||||
pointer_t<X_SLIST_HEADER> plist_ptr) {
|
||||
assert_not_null(plist_ptr);
|
||||
|
||||
alignas(8) X_SLIST_HEADER old_hdr = *plist_ptr;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -17,9 +17,9 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
dword_result_t XUsbcamCreate(dword_t buffer,
|
||||
dword_t buffer_size, // 0x4B000 640x480?
|
||||
lpunknown_t unk3_ptr) {
|
||||
dword_result_t XUsbcamCreate_entry(dword_t buffer,
|
||||
dword_t buffer_size, // 0x4B000 640x480?
|
||||
lpunknown_t unk3_ptr) {
|
||||
// This function should return success.
|
||||
// It looks like it only allocates space for usbcam support.
|
||||
// returning error code might cause games to initialize incorrectly.
|
||||
@@ -31,7 +31,7 @@ dword_result_t XUsbcamCreate(dword_t buffer,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(XUsbcamCreate, kNone, kStub);
|
||||
|
||||
dword_result_t XUsbcamGetState() {
|
||||
dword_result_t XUsbcamGetState_entry() {
|
||||
// 0 = not connected.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ namespace xboxkrnl {
|
||||
// https://www.microsoft.com/en-za/download/details.aspx?id=5313 -- "Stripped
|
||||
// Down Direct3D: Xbox 360 Command Buffer and Resource Management"
|
||||
|
||||
void VdGetCurrentDisplayGamma(lpdword_t type_ptr, lpfloat_t power_ptr) {
|
||||
void VdGetCurrentDisplayGamma_entry(lpdword_t type_ptr, lpfloat_t power_ptr) {
|
||||
// 1 - sRGB.
|
||||
// 2 - TV (BT.709).
|
||||
// 3 - use the power written to *power_ptr.
|
||||
@@ -104,9 +104,8 @@ struct X_DISPLAY_INFO {
|
||||
};
|
||||
static_assert_size(X_DISPLAY_INFO, 0x58);
|
||||
|
||||
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode);
|
||||
|
||||
void VdGetCurrentDisplayInformation(pointer_t<X_DISPLAY_INFO> display_info) {
|
||||
void VdGetCurrentDisplayInformation_entry(
|
||||
pointer_t<X_DISPLAY_INFO> display_info) {
|
||||
X_VIDEO_MODE mode;
|
||||
VdQueryVideoMode(&mode);
|
||||
|
||||
@@ -132,9 +131,9 @@ void VdGetCurrentDisplayInformation(pointer_t<X_DISPLAY_INFO> display_info) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdGetCurrentDisplayInformation, kVideo, kStub);
|
||||
|
||||
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
|
||||
void VdQueryVideoMode(X_VIDEO_MODE* video_mode) {
|
||||
// TODO(benvanik): get info from actual display.
|
||||
video_mode.Zero();
|
||||
std::memset(video_mode, 0, sizeof(X_VIDEO_MODE));
|
||||
video_mode->display_width = 1280;
|
||||
video_mode->display_height = 720;
|
||||
video_mode->is_interlaced = 0;
|
||||
@@ -145,9 +144,13 @@ void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode) {
|
||||
video_mode->unknown_0x8a = 0x4A;
|
||||
video_mode->unknown_0x01 = 0x01;
|
||||
}
|
||||
|
||||
void VdQueryVideoMode_entry(pointer_t<X_VIDEO_MODE> video_mode) {
|
||||
VdQueryVideoMode(video_mode);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdQueryVideoMode, kVideo, kStub);
|
||||
|
||||
dword_result_t VdQueryVideoFlags() {
|
||||
dword_result_t VdQueryVideoFlags_entry() {
|
||||
X_VIDEO_MODE mode;
|
||||
VdQueryVideoMode(&mode);
|
||||
|
||||
@@ -160,7 +163,7 @@ dword_result_t VdQueryVideoFlags() {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdQueryVideoFlags, kVideo, kStub);
|
||||
|
||||
dword_result_t VdSetDisplayMode(dword_t flags) {
|
||||
dword_result_t VdSetDisplayMode_entry(dword_t flags) {
|
||||
// Often 0x40000000.
|
||||
|
||||
// 0?ccf000 00000000 00000000 000000r0
|
||||
@@ -179,17 +182,17 @@ dword_result_t VdSetDisplayMode(dword_t flags) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdSetDisplayMode, kVideo, kStub);
|
||||
|
||||
dword_result_t VdSetDisplayModeOverride(unknown_t unk0, unknown_t unk1,
|
||||
double_t refresh_rate, unknown_t unk3,
|
||||
unknown_t unk4) {
|
||||
dword_result_t VdSetDisplayModeOverride_entry(unknown_t unk0, unknown_t unk1,
|
||||
double_t refresh_rate,
|
||||
unknown_t unk3, unknown_t unk4) {
|
||||
// refresh_rate = 0, 50, 59.9, etc.
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdSetDisplayModeOverride, kVideo, kStub);
|
||||
|
||||
dword_result_t VdInitializeEngines(unknown_t unk0, function_t callback,
|
||||
lpvoid_t arg, lpdword_t pfp_ptr,
|
||||
lpdword_t me_ptr) {
|
||||
dword_result_t VdInitializeEngines_entry(unknown_t unk0, function_t callback,
|
||||
lpvoid_t arg, lpdword_t pfp_ptr,
|
||||
lpdword_t me_ptr) {
|
||||
// r3 = 0x4F810000
|
||||
// r4 = function ptr (cleanup callback?)
|
||||
// r5 = function arg
|
||||
@@ -199,27 +202,28 @@ dword_result_t VdInitializeEngines(unknown_t unk0, function_t callback,
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdInitializeEngines, kVideo, kStub);
|
||||
|
||||
void VdShutdownEngines() {
|
||||
void VdShutdownEngines_entry() {
|
||||
// Ignored for now.
|
||||
// Games seem to call an Initialize/Shutdown pair to query info, then
|
||||
// re-initialize.
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdShutdownEngines, kVideo, kStub);
|
||||
|
||||
dword_result_t VdGetGraphicsAsicID() {
|
||||
dword_result_t VdGetGraphicsAsicID_entry() {
|
||||
// Games compare for < 0x10 and do VdInitializeEDRAM, else other
|
||||
// (retrain/etc).
|
||||
return 0x11;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdGetGraphicsAsicID, kVideo, kStub);
|
||||
|
||||
dword_result_t VdEnableDisableClockGating(dword_t enabled) {
|
||||
dword_result_t VdEnableDisableClockGating_entry(dword_t enabled) {
|
||||
// Ignored, as it really doesn't matter.
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdEnableDisableClockGating, kVideo, kStub);
|
||||
|
||||
void VdSetGraphicsInterruptCallback(function_t callback, lpvoid_t user_data) {
|
||||
void VdSetGraphicsInterruptCallback_entry(function_t callback,
|
||||
lpvoid_t user_data) {
|
||||
// callback takes 2 params
|
||||
// r3 = bool 0/1 - 0 is normal interrupt, 1 is some acquire/lock mumble
|
||||
// r4 = user_data (r4 of VdSetGraphicsInterruptCallback)
|
||||
@@ -228,7 +232,7 @@ void VdSetGraphicsInterruptCallback(function_t callback, lpvoid_t user_data) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdSetGraphicsInterruptCallback, kVideo, kImplemented);
|
||||
|
||||
void VdInitializeRingBuffer(lpvoid_t ptr, int_t size_log2) {
|
||||
void VdInitializeRingBuffer_entry(lpvoid_t ptr, int_t size_log2) {
|
||||
// r3 = result of MmGetPhysicalAddress
|
||||
// r4 = log2(size)
|
||||
// Buffer pointers are from MmAllocatePhysicalMemory with WRITE_COMBINE.
|
||||
@@ -237,21 +241,22 @@ void VdInitializeRingBuffer(lpvoid_t ptr, int_t size_log2) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdInitializeRingBuffer, kVideo, kImplemented);
|
||||
|
||||
void VdEnableRingBufferRPtrWriteBack(lpvoid_t ptr, int_t block_size_log2) {
|
||||
void VdEnableRingBufferRPtrWriteBack_entry(lpvoid_t ptr,
|
||||
int_t block_size_log2) {
|
||||
// r4 = log2(block size), 6, usually --- <=19
|
||||
auto graphics_system = kernel_state()->emulator()->graphics_system();
|
||||
graphics_system->EnableReadPointerWriteBack(ptr, block_size_log2);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdEnableRingBufferRPtrWriteBack, kVideo, kImplemented);
|
||||
|
||||
void VdGetSystemCommandBuffer(lpunknown_t p0_ptr, lpunknown_t p1_ptr) {
|
||||
void VdGetSystemCommandBuffer_entry(lpunknown_t p0_ptr, lpunknown_t p1_ptr) {
|
||||
p0_ptr.Zero(0x94);
|
||||
xe::store_and_swap<uint32_t>(p0_ptr, 0xBEEF0000);
|
||||
xe::store_and_swap<uint32_t>(p1_ptr, 0xBEEF0001);
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdGetSystemCommandBuffer, kVideo, kStub);
|
||||
|
||||
void VdSetSystemCommandBufferGpuIdentifierAddress(lpunknown_t unk) {
|
||||
void VdSetSystemCommandBufferGpuIdentifierAddress_entry(lpunknown_t unk) {
|
||||
// r3 = 0x2B10(d3d?) + 8
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdSetSystemCommandBufferGpuIdentifierAddress, kVideo,
|
||||
@@ -262,7 +267,7 @@ DECLARE_XBOXKRNL_EXPORT1(VdSetSystemCommandBufferGpuIdentifierAddress, kVideo,
|
||||
// r4 = 19
|
||||
// no op?
|
||||
|
||||
dword_result_t VdInitializeScalerCommandBuffer(
|
||||
dword_result_t VdInitializeScalerCommandBuffer_entry(
|
||||
dword_t scaler_source_xy, // ((uint16_t)y << 16) | (uint16_t)x
|
||||
dword_t scaler_source_wh, // ((uint16_t)h << 16) | (uint16_t)w
|
||||
dword_t scaled_output_xy, // ((uint16_t)y << 16) | (uint16_t)x
|
||||
@@ -302,7 +307,7 @@ void AppendParam(StringBuffer* string_buffer, pointer_t<BufferScaling> param) {
|
||||
uint16_t(param->fb_width), uint16_t(param->fb_height));
|
||||
}
|
||||
|
||||
dword_result_t VdCallGraphicsNotificationRoutines(
|
||||
dword_result_t VdCallGraphicsNotificationRoutines_entry(
|
||||
unknown_t unk0, pointer_t<BufferScaling> args_ptr) {
|
||||
assert_true(unk0 == 1);
|
||||
|
||||
@@ -313,13 +318,13 @@ dword_result_t VdCallGraphicsNotificationRoutines(
|
||||
DECLARE_XBOXKRNL_EXPORT2(VdCallGraphicsNotificationRoutines, kVideo,
|
||||
kImplemented, kSketchy);
|
||||
|
||||
dword_result_t VdIsHSIOTrainingSucceeded() {
|
||||
dword_result_t VdIsHSIOTrainingSucceeded_entry() {
|
||||
// BOOL return value
|
||||
return 1;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdIsHSIOTrainingSucceeded, kVideo, kStub);
|
||||
|
||||
dword_result_t VdPersistDisplay(unknown_t unk0, lpdword_t unk1_ptr) {
|
||||
dword_result_t VdPersistDisplay_entry(unknown_t unk0, lpdword_t unk1_ptr) {
|
||||
// unk1_ptr needs to be populated with a pointer passed to
|
||||
// MmFreePhysicalMemory(1, *unk1_ptr).
|
||||
if (unk1_ptr) {
|
||||
@@ -334,23 +339,25 @@ dword_result_t VdPersistDisplay(unknown_t unk0, lpdword_t unk1_ptr) {
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT2(VdPersistDisplay, kVideo, kImplemented, kSketchy);
|
||||
|
||||
dword_result_t VdRetrainEDRAMWorker(unknown_t unk0) { return 0; }
|
||||
dword_result_t VdRetrainEDRAMWorker_entry(unknown_t unk0) { return 0; }
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdRetrainEDRAMWorker, kVideo, kStub);
|
||||
|
||||
dword_result_t VdRetrainEDRAM(unknown_t unk0, unknown_t unk1, unknown_t unk2,
|
||||
unknown_t unk3, unknown_t unk4, unknown_t unk5) {
|
||||
dword_result_t VdRetrainEDRAM_entry(unknown_t unk0, unknown_t unk1,
|
||||
unknown_t unk2, unknown_t unk3,
|
||||
unknown_t unk4, unknown_t unk5) {
|
||||
return 0;
|
||||
}
|
||||
DECLARE_XBOXKRNL_EXPORT1(VdRetrainEDRAM, kVideo, kStub);
|
||||
|
||||
void VdSwap(lpvoid_t buffer_ptr, // ptr into primary ringbuffer
|
||||
lpvoid_t fetch_ptr, // frontbuffer Direct3D 9 texture header fetch
|
||||
lpunknown_t unk2, // system writeback ptr
|
||||
lpunknown_t unk3, // buffer from VdGetSystemCommandBuffer
|
||||
lpunknown_t unk4, // from VdGetSystemCommandBuffer (0xBEEF0001)
|
||||
lpdword_t frontbuffer_ptr, // ptr to frontbuffer address
|
||||
lpdword_t texture_format_ptr, lpdword_t color_space_ptr,
|
||||
lpdword_t width, lpdword_t height) {
|
||||
void VdSwap_entry(
|
||||
lpvoid_t buffer_ptr, // ptr into primary ringbuffer
|
||||
lpvoid_t fetch_ptr, // frontbuffer Direct3D 9 texture header fetch
|
||||
lpunknown_t unk2, // system writeback ptr
|
||||
lpunknown_t unk3, // buffer from VdGetSystemCommandBuffer
|
||||
lpunknown_t unk4, // from VdGetSystemCommandBuffer (0xBEEF0001)
|
||||
lpdword_t frontbuffer_ptr, // ptr to frontbuffer address
|
||||
lpdword_t texture_format_ptr, lpdword_t color_space_ptr, lpdword_t width,
|
||||
lpdword_t height) {
|
||||
// All of these parameters are REQUIRED.
|
||||
assert(buffer_ptr);
|
||||
assert(fetch_ptr);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2015 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -17,7 +17,7 @@ namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
void VdQueryVideoMode(pointer_t<X_VIDEO_MODE> video_mode);
|
||||
void VdQueryVideoMode(X_VIDEO_MODE* video_mode);
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2019 Ben Vanik. All rights reserved. *
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -122,9 +122,10 @@ X_STATUS xeExGetXConfigSetting(uint16_t category, uint16_t setting,
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
dword_result_t ExGetXConfigSetting(word_t category, word_t setting,
|
||||
lpdword_t buffer_ptr, word_t buffer_size,
|
||||
lpword_t required_size_ptr) {
|
||||
dword_result_t ExGetXConfigSetting_entry(word_t category, word_t setting,
|
||||
lpvoid_t buffer_ptr,
|
||||
word_t buffer_size,
|
||||
lpword_t required_size_ptr) {
|
||||
uint16_t required_size = 0;
|
||||
X_STATUS result = xeExGetXConfigSetting(category, setting, buffer_ptr,
|
||||
buffer_size, &required_size);
|
||||
|
||||
Reference in New Issue
Block a user