Converting logging to ASCII and other Windows fixes.

This commit is contained in:
Ben Vanik
2013-02-09 08:05:39 -08:00
parent fa16593ab6
commit 3cae7ed714
37 changed files with 213 additions and 192 deletions

View File

@@ -35,7 +35,7 @@ void XGetAVPack_shim(
void XGetGameRegion_shim(
xe_ppc_state_t* ppc_state, XamState* state) {
XELOGD(XT("XGetGameRegion()"));
XELOGD("XGetGameRegion()");
SHIM_SET_RETURN(XEX_REGION_ALL);
}
@@ -43,7 +43,7 @@ void XGetGameRegion_shim(
void XGetLanguage_shim(
xe_ppc_state_t* ppc_state, XamState* state) {
XELOGD(XT("XGetLanguage()"));
XELOGD("XGetLanguage()");
uint32_t desired_language = X_LANGUAGE_ENGLISH;

View File

@@ -117,13 +117,13 @@ int XboxkrnlModule::LaunchModule(const char* path) {
// Load the module into memory from the filesystem.
X_STATUS result_code = module->LoadFromFile(path);
if (XFAILED(result_code)) {
XELOGE(XT("Failed to load module %s: %.8X"), path, result_code);
XELOGE("Failed to load module %s: %.8X", path, result_code);
module->Release();
return 1;
}
if (FLAGS_abort_before_entry) {
XELOGI(XT("--abort_before_entry causing an early exit"));
XELOGI("--abort_before_entry causing an early exit");
module->Release();
return 0;
}
@@ -132,7 +132,7 @@ int XboxkrnlModule::LaunchModule(const char* path) {
// NOTE: this won't return until the module exits.
result_code = module->Launch(0);
if (XFAILED(result_code)) {
XELOGE(XT("Failed to launch module %s: %.8X"), path, result_code);
XELOGE("Failed to launch module %s: %.8X", path, result_code);
module->Release();
return 2;
}

View File

@@ -59,11 +59,11 @@ X_STATUS XModule::LoadFromFile(const char* path) {
// TODO(benvanik): make this code shared?
fs::Entry* fs_entry = kernel_state()->filesystem()->ResolvePath(path);
if (!fs_entry) {
XELOGE(XT("File not found: %s"), path);
XELOGE("File not found: %s", path);
return X_STATUS_NO_SUCH_FILE;
}
if (fs_entry->type() != fs::Entry::kTypeFile) {
XELOGE(XT("Invalid file type: %s"), path);
XELOGE("Invalid file type: %s", path);
return X_STATUS_NO_SUCH_FILE;
}
fs::FileEntry* fs_file = static_cast<fs::FileEntry*>(fs_entry);
@@ -114,14 +114,14 @@ X_STATUS XModule::GetSection(const char* name,
void* XModule::GetProcAddressByOrdinal(uint16_t ordinal) {
// TODO(benvanik): check export tables.
XELOGE(XT("GetProcAddressByOrdinal not implemented"));
XELOGE("GetProcAddressByOrdinal not implemented");
return NULL;
}
X_STATUS XModule::Launch(uint32_t flags) {
const xe_xex2_header_t* header = xex_header();
XELOGI(XT("Launching module..."));
XELOGI("Launching module...");
// Set as the main module, while running.
kernel_state()->SetExecutableModule(this);
@@ -137,7 +137,7 @@ X_STATUS XModule::Launch(uint32_t flags) {
X_STATUS result = thread->Create();
if (XFAILED(result)) {
XELOGE(XT("Could not create launch thread: %.8X"), result);
XELOGE("Could not create launch thread: %.8X", result);
return result;
}

View File

@@ -54,7 +54,7 @@ XThread::~XThread() {
if (thread_handle_) {
// TODO(benvanik): platform kill
XELOGE(XT("Thread disposed without exiting"));
XELOGE("Thread disposed without exiting");
}
}
@@ -84,7 +84,7 @@ X_STATUS XThread::Create() {
// consistent.
thread_state_address_ = xe_memory_heap_alloc(memory(), 0, 2048, 0);
if (!thread_state_address_) {
XELOGW(XT("Unable to allocate thread state block"));
XELOGW("Unable to allocate thread state block");
return X_STATUS_NO_MEMORY;
}
@@ -106,13 +106,13 @@ X_STATUS XThread::Create() {
processor_state_ = kernel_state()->processor()->AllocThread(
creation_params_.stack_size, thread_state_address_);
if (!processor_state_) {
XELOGW(XT("Unable to allocate processor thread state"));
XELOGW("Unable to allocate processor thread state");
return X_STATUS_NO_MEMORY;
}
X_STATUS return_code = PlatformCreate();
if (XFAILED(return_code)) {
XELOGW(XT("Unable to create platform thread (%.8X)"), return_code);
XELOGW("Unable to create platform thread (%.8X)", return_code);
return return_code;
}
@@ -151,7 +151,7 @@ X_STATUS XThread::PlatformCreate() {
if (!thread_handle_) {
uint32_t last_error = GetLastError();
// TODO(benvanik): translate?
XELOGE(XT("CreateThread failed with %d"), last_error);
XELOGE("CreateThread failed with %d", last_error);
return last_error;
}
@@ -229,7 +229,7 @@ X_STATUS XThread::PlatformExit(int exit_code) {
void XThread::Execute() {
// Run XapiThreadStartup first, if present.
if (creation_params_.xapi_thread_startup) {
XELOGE(XT("xapi_thread_startup not implemented"));
XELOGE("xapi_thread_startup not implemented");
}
// Run user code.

View File

@@ -30,12 +30,12 @@ void HalReturnToFirmware_shim(
uint32_t routine = SHIM_GET_ARG_32(0);
XELOGD(
XT("HalReturnToFirmware(%d)"),
"HalReturnToFirmware(%d)",
routine);
// TODO(benvank): diediedie much more gracefully
// Not sure how to blast back up the stack in LLVM without exceptions, though.
XELOGE(XT("Game requested shutdown via HalReturnToFirmware"));
XELOGE("Game requested shutdown via HalReturnToFirmware");
exit(0);
}

View File

@@ -43,7 +43,7 @@ void NtAllocateVirtualMemory_shim(
XEASSERT(unknown == 0);
XELOGD(
XT("NtAllocateVirtualMemory(%.8X(%.8X), %.8X(%.8X), %.8X, %.8X, %.8X)"),
"NtAllocateVirtualMemory(%.8X(%.8X), %.8X(%.8X), %.8X, %.8X, %.8X)",
base_addr_ptr, base_addr_value,
region_size_ptr, region_size_value,
allocation_type, protect_bits, unknown);
@@ -116,7 +116,7 @@ void NtFreeVirtualMemory_shim(
XEASSERT(unknown == 0);
XELOGD(
XT("NtFreeVirtualMemory(%.8X(%.8X), %.8X(%.8X), %.8X, %.8X)"),
"NtFreeVirtualMemory(%.8X(%.8X), %.8X(%.8X), %.8X, %.8X)",
base_addr_ptr, base_addr_value,
region_size_ptr, region_size_value,
free_type, unknown);

View File

@@ -38,7 +38,7 @@ void XexCheckExecutablePrivilege_shim(
uint32_t privilege = SHIM_GET_ARG_32(0);
XELOGD(
XT("XexCheckExecutablePrivilege(%.8X)"),
"XexCheckExecutablePrivilege(%.8X)",
privilege);
// Privilege is bit position in xe_xex2_system_flags enum - so:
@@ -73,7 +73,7 @@ void XexGetModuleHandle_shim(
uint32_t module_handle_ptr = SHIM_GET_ARG_32(1);
XELOGD(
XT("XexGetModuleHandle(%s, %.8X)"),
"XexGetModuleHandle(%s, %.8X)",
module_name, module_handle_ptr);
XModule* module = state->GetModule(module_name);

View File

@@ -36,7 +36,7 @@ void RtlCompareMemory_shim(
uint32_t length = SHIM_GET_ARG_32(2);
XELOGD(
XT("RtlCompareMemory(%.8X, %.8X, %d)"),
"RtlCompareMemory(%.8X, %.8X, %d)",
source1, source2, length);
uint8_t* p1 = SHIM_MEM_ADDR(source1);
@@ -69,7 +69,7 @@ void RtlCompareMemoryUlong_shim(
uint32_t pattern = SHIM_GET_ARG_32(2);
XELOGD(
XT("RtlCompareMemoryUlong(%.8X, %d, %.8X)"),
"RtlCompareMemoryUlong(%.8X, %d, %.8X)",
source, length, pattern);
if ((source % 4) || (length % 4)) {
@@ -109,7 +109,7 @@ void RtlFillMemoryUlong_shim(
uint32_t pattern = SHIM_GET_ARG_32(2);
XELOGD(
XT("RtlFillMemoryUlong(%.8X, %d, %.8X)"),
"RtlFillMemoryUlong(%.8X, %d, %.8X)",
destination, length, pattern);
// NOTE: length must be % 4, so we can work on uint32s.
@@ -142,7 +142,7 @@ void RtlInitAnsiString_shim(
uint32_t source_ptr = SHIM_GET_ARG_32(1);
const char* source = source_ptr ? (char*)SHIM_MEM_ADDR(source_ptr) : NULL;
XELOGD(XT("RtlInitAnsiString(%.8X, %.8X = %s)"),
XELOGD("RtlInitAnsiString(%.8X, %.8X = %s)",
destination_ptr, source_ptr, source ? source : "<null>");
uint16_t length = source ? (uint16_t)xestrlena(source) : 0;
@@ -160,11 +160,11 @@ void RtlFreeAnsiString_shim(
uint32_t string_ptr = SHIM_GET_ARG_32(0);
XELOGD(XT("RtlFreeAnsiString(%.8X)"), string_ptr);
XELOGD("RtlFreeAnsiString(%.8X)", string_ptr);
//uint32_t buffer = SHIM_MEM_32(string_ptr + 4);
// TODO(benvanik): free the buffer
XELOGE(XT("RtlFreeAnsiString leaking buffer"));
XELOGE("RtlFreeAnsiString leaking buffer");
SHIM_SET_MEM_16(string_ptr + 0, 0);
SHIM_SET_MEM_16(string_ptr + 2, 0);
@@ -191,7 +191,7 @@ void RtlInitUnicodeString_shim(
const wchar_t* source =
source_ptr ? (const wchar_t*)SHIM_MEM_ADDR(source_ptr) : NULL;
XELOGD(XT("RtlInitUnicodeString(%.8X, %.8X = %ls)"),
XELOGD("RtlInitUnicodeString(%.8X, %.8X = %ls)",
destination_ptr, source_ptr, source ? source : L"<null>");
uint16_t length = source ? (uint16_t)xestrlenw(source) : 0;
@@ -209,11 +209,11 @@ void RtlFreeUnicodeString_shim(
uint32_t string_ptr = SHIM_GET_ARG_32(0);
XELOGD(XT("RtlFreeUnicodeString(%.8X)"), string_ptr);
XELOGD("RtlFreeUnicodeString(%.8X)", string_ptr);
//uint32_t buffer = SHIM_MEM_32(string_ptr + 4);
// TODO(benvanik): free the buffer
XELOGE(XT("RtlFreeUnicodeString leaking buffer"));
XELOGE("RtlFreeUnicodeString leaking buffer");
SHIM_SET_MEM_16(string_ptr + 0, 0);
SHIM_SET_MEM_16(string_ptr + 2, 0);
@@ -233,10 +233,10 @@ void RtlUnicodeStringToAnsiString_shim(
uint32_t source_ptr = SHIM_GET_ARG_32(1);
uint32_t alloc_dest = SHIM_GET_ARG_32(2);
XELOGD(XT("RtlUnicodeStringToAnsiString(%.8X, %.8X, %d)"),
XELOGD("RtlUnicodeStringToAnsiString(%.8X, %.8X, %d)",
destination_ptr, source_ptr, alloc_dest);
XELOGE(XT("RtlUnicodeStringToAnsiString not yet implemented"));
XELOGE("RtlUnicodeStringToAnsiString not yet implemented");
if (alloc_dest) {
// Allocate a new buffer to place the string into.
@@ -267,11 +267,11 @@ void RtlImageXexHeaderField_shim(
// 0x20401 (XEX_HEADER_DEFAULT_HEAP_SIZE), so that's all we'll support.
XELOGD(
XT("RtlImageXexHeaderField(%.8X, %.8X)"),
"RtlImageXexHeaderField(%.8X, %.8X)",
xex_header_base, image_field);
if (xex_header_base != 0x80101100) {
XELOGE(XT("RtlImageXexHeaderField with non-magic base NOT IMPLEMENTED"));
XELOGE("RtlImageXexHeaderField with non-magic base NOT IMPLEMENTED");
SHIM_SET_RETURN(0);
return;
}
@@ -295,7 +295,7 @@ void RtlImageXexHeaderField_shim(
return_value = 0;
break;
default:
XELOGE(XT("RtlImageXexHeaderField header field %.8X NOT IMPLEMENTED"),
XELOGE("RtlImageXexHeaderField header field %.8X NOT IMPLEMENTED",
image_field);
SHIM_SET_RETURN(0);
return;
@@ -349,7 +349,7 @@ void RtlInitializeCriticalSection_shim(
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
XELOGD(XT("RtlInitializeCriticalSection(%.8X)"), cs_ptr);
XELOGD("RtlInitializeCriticalSection(%.8X)", cs_ptr);
X_RTL_CRITICAL_SECTION* cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
cs->spin_count_div_256 = 0;
@@ -368,7 +368,7 @@ void RtlInitializeCriticalSectionAndSpinCount_shim(
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
uint32_t spin_count = SHIM_GET_ARG_32(1);
XELOGD(XT("RtlInitializeCriticalSectionAndSpinCount(%.8X, %d)"),
XELOGD("RtlInitializeCriticalSectionAndSpinCount(%.8X, %d)",
cs_ptr, spin_count);
// Spin count is rouned up to 256 intervals then packed in.
@@ -391,7 +391,7 @@ void RtlEnterCriticalSection_shim(
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
XELOGD(XT("RtlEnterCriticalSection(%.8X)"), cs_ptr);
XELOGD("RtlEnterCriticalSection(%.8X)", cs_ptr);
X_RTL_CRITICAL_SECTION* cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
@@ -414,7 +414,7 @@ spin:
// All out of spin waits, create a full waiter.
// TODO(benvanik): contention - do a real wait!
XELOGE(XT("RtlEnterCriticalSection tried to really lock!"));
XELOGE("RtlEnterCriticalSection tried to really lock!");
}
// Now own the lock.
@@ -430,7 +430,7 @@ void RtlTryEnterCriticalSection_shim(
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
XELOGD(XT("RtlTryEnterCriticalSection(%.8X)"), cs_ptr);
XELOGD("RtlTryEnterCriticalSection(%.8X)", cs_ptr);
X_RTL_CRITICAL_SECTION* cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
@@ -461,7 +461,7 @@ void RtlLeaveCriticalSection_shim(
uint32_t cs_ptr = SHIM_GET_ARG_32(0);
XELOGD(XT("RtlLeaveCriticalSection(%.8X)"), cs_ptr);
XELOGD("RtlLeaveCriticalSection(%.8X)", cs_ptr);
X_RTL_CRITICAL_SECTION* cs = (X_RTL_CRITICAL_SECTION*)SHIM_MEM_ADDR(cs_ptr);
@@ -477,7 +477,7 @@ void RtlLeaveCriticalSection_shim(
if (xe_atomic_dec_32(&cs->lock_count) != -1) {
// There were waiters - wake one of them.
// TODO(benvanik): wake a waiter.
XELOGE(XT("RtlLeaveCriticalSection would have woken a waiter"));
XELOGE("RtlLeaveCriticalSection would have woken a waiter");
}
}

View File

@@ -75,7 +75,7 @@ void ExCreateThread_shim(
uint32_t creation_flags = SHIM_GET_ARG_32(6);
XELOGD(
XT("ExCreateThread(%.8X, %d, %.8X, %.8X, %.8X, %.8X, %.8X)"),
"ExCreateThread(%.8X, %d, %.8X, %.8X, %.8X, %.8X, %.8X)",
handle_ptr,
stack_size,
thread_id_ptr,
@@ -92,7 +92,7 @@ void ExCreateThread_shim(
if (XFAILED(result_code)) {
// Failed!
thread->Release();
XELOGE(XT("Thread creation failed: %.8X"), result_code);
XELOGE("Thread creation failed: %.8X", result_code);
SHIM_SET_RETURN(result_code);
return;
}
@@ -112,7 +112,7 @@ void KeGetCurrentProcessType_shim(
// DWORD
XELOGD(
XT("KeGetCurrentProcessType()"));
"KeGetCurrentProcessType()");
SHIM_SET_RETURN(X_PROCTYPE_USER);
}
@@ -130,7 +130,7 @@ void KeTlsAlloc_shim(
// DWORD
XELOGD(
XT("KeTlsAlloc()"));
"KeTlsAlloc()");
uint32_t tls_index;
@@ -158,7 +158,7 @@ void KeTlsFree_shim(
uint32_t tls_index = SHIM_GET_ARG_32(0);
XELOGD(
XT("KeTlsFree(%.8X)"),
"KeTlsFree(%.8X)",
tls_index);
if (tls_index == X_TLS_OUT_OF_INDEXES) {
@@ -187,7 +187,7 @@ void KeTlsGetValue_shim(
uint32_t tls_index = SHIM_GET_ARG_32(0);
XELOGD(
XT("KeTlsGetValue(%.8X)"),
"KeTlsGetValue(%.8X)",
tls_index);
uint32_t value = 0;
@@ -199,7 +199,7 @@ void KeTlsGetValue_shim(
#endif // WIN32
if (!value) {
XELOGW(XT("KeTlsGetValue should SetLastError if result is NULL"));
XELOGW("KeTlsGetValue should SetLastError if result is NULL");
// TODO(benvanik): SetLastError
}
@@ -218,7 +218,7 @@ void KeTlsSetValue_shim(
uint32_t tls_value = SHIM_GET_ARG_32(1);
XELOGD(
XT("KeTlsSetValue(%.8X, %.8X)"),
"KeTlsSetValue(%.8X, %.8X)",
tls_index, tls_value);
int result_code = 0;