diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index e56448bb4..61e864671 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -150,12 +150,15 @@ uint8_t GetFakeCpuNumber(uint8_t proc_mask) { X_STATUS XThread::Create() { // Thread kernel object // This call will also setup the native pointer for us. - uint8_t* guest_object = CreateNative(sizeof(X_THREAD)); + auto guest_object = CreateNative(sizeof(X_KTHREAD)); if (!guest_object) { XELOGW("Unable to allocate thread object"); return X_STATUS_NO_MEMORY; } + guest_object->header.type = 6; + StashNative(&guest_object->header, this); + auto module = kernel_state()->GetExecutableModule(); // Allocate thread scratch. @@ -268,15 +271,9 @@ X_STATUS XThread::Create() { pcr->current_cpu = GetFakeCpuNumber(proc_mask); // Current CPU(?) pcr->dpc_active = 0; // DPC active bool? - // Thread state block - struct XTEB { - xe::be unk_00; // 0x0 - xe::be unk_04; // 0x4 - X_LIST_ENTRY unk_08; // 0x8 - X_LIST_ENTRY unk_10; // 0x10 - }; - // Setup the thread state block (last error/etc). + // TODO: This is actually a KTHREAD object. Use the one from CreateNative + // instead. uint8_t* p = memory()->TranslateVirtual(thread_state_address_); xe::store_and_swap(p + 0x000, 6); xe::store_and_swap(p + 0x008, thread_state_address_ + 0x008); diff --git a/src/xenia/kernel/objects/xthread.h b/src/xenia/kernel/objects/xthread.h index 95b3719cf..1365a3091 100644 --- a/src/xenia/kernel/objects/xthread.h +++ b/src/xenia/kernel/objects/xthread.h @@ -66,14 +66,9 @@ struct XAPC { }; // http://www.nirsoft.net/kernel_struct/vista/KTHREAD.html -struct X_THREAD { - X_DISPATCH_HEADER header; - xe::be cycle_time; - xe::be high_cycle_time; // FIXME: Needed? - xe::be quantum_target; - xe::be initial_stack_ptr; - xe::be stack_limit_ptr; - xe::be kernel_stack_ptr; +struct X_KTHREAD { + X_DISPATCH_HEADER header; // 0x0 + char unk_04[0xAA0]; // 0x4 // This struct is actually quite long... so uh, not filling this out! };