XThread initialize the dispatch header
This commit is contained in:
parent
e54477d0e4
commit
1ea5a4b7b4
|
@ -150,12 +150,15 @@ uint8_t GetFakeCpuNumber(uint8_t proc_mask) {
|
||||||
X_STATUS XThread::Create() {
|
X_STATUS XThread::Create() {
|
||||||
// Thread kernel object
|
// Thread kernel object
|
||||||
// This call will also setup the native pointer for us.
|
// This call will also setup the native pointer for us.
|
||||||
uint8_t* guest_object = CreateNative(sizeof(X_THREAD));
|
auto guest_object = CreateNative<X_KTHREAD>(sizeof(X_KTHREAD));
|
||||||
if (!guest_object) {
|
if (!guest_object) {
|
||||||
XELOGW("Unable to allocate thread object");
|
XELOGW("Unable to allocate thread object");
|
||||||
return X_STATUS_NO_MEMORY;
|
return X_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guest_object->header.type = 6;
|
||||||
|
StashNative(&guest_object->header, this);
|
||||||
|
|
||||||
auto module = kernel_state()->GetExecutableModule();
|
auto module = kernel_state()->GetExecutableModule();
|
||||||
|
|
||||||
// Allocate thread scratch.
|
// Allocate thread scratch.
|
||||||
|
@ -268,15 +271,9 @@ X_STATUS XThread::Create() {
|
||||||
pcr->current_cpu = GetFakeCpuNumber(proc_mask); // Current CPU(?)
|
pcr->current_cpu = GetFakeCpuNumber(proc_mask); // Current CPU(?)
|
||||||
pcr->dpc_active = 0; // DPC active bool?
|
pcr->dpc_active = 0; // DPC active bool?
|
||||||
|
|
||||||
// Thread state block
|
|
||||||
struct XTEB {
|
|
||||||
xe::be<uint32_t> unk_00; // 0x0
|
|
||||||
xe::be<uint32_t> unk_04; // 0x4
|
|
||||||
X_LIST_ENTRY unk_08; // 0x8
|
|
||||||
X_LIST_ENTRY unk_10; // 0x10
|
|
||||||
};
|
|
||||||
|
|
||||||
// Setup the thread state block (last error/etc).
|
// 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_);
|
uint8_t* p = memory()->TranslateVirtual(thread_state_address_);
|
||||||
xe::store_and_swap<uint32_t>(p + 0x000, 6);
|
xe::store_and_swap<uint32_t>(p + 0x000, 6);
|
||||||
xe::store_and_swap<uint32_t>(p + 0x008, thread_state_address_ + 0x008);
|
xe::store_and_swap<uint32_t>(p + 0x008, thread_state_address_ + 0x008);
|
||||||
|
|
|
@ -66,14 +66,9 @@ struct XAPC {
|
||||||
};
|
};
|
||||||
|
|
||||||
// http://www.nirsoft.net/kernel_struct/vista/KTHREAD.html
|
// http://www.nirsoft.net/kernel_struct/vista/KTHREAD.html
|
||||||
struct X_THREAD {
|
struct X_KTHREAD {
|
||||||
X_DISPATCH_HEADER header;
|
X_DISPATCH_HEADER header; // 0x0
|
||||||
xe::be<uint64_t> cycle_time;
|
char unk_04[0xAA0]; // 0x4
|
||||||
xe::be<uint32_t> high_cycle_time; // FIXME: Needed?
|
|
||||||
xe::be<uint64_t> quantum_target;
|
|
||||||
xe::be<uint32_t> initial_stack_ptr;
|
|
||||||
xe::be<uint32_t> stack_limit_ptr;
|
|
||||||
xe::be<uint32_t> kernel_stack_ptr;
|
|
||||||
|
|
||||||
// This struct is actually quite long... so uh, not filling this out!
|
// This struct is actually quite long... so uh, not filling this out!
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue