KeQueryBasePriorityThread and implementing Set.

This commit is contained in:
Ben Vanik 2014-01-08 22:22:34 -08:00
parent 036d12581e
commit 5644f0fd40
3 changed files with 34 additions and 2 deletions

View File

@ -382,6 +382,14 @@ void XThread::LowerIrql(uint32_t new_irql) {
irql_ = new_irql;
}
int32_t XThread::QueryPriority() {
return GetThreadPriority(thread_handle_);
}
void XThread::SetPriority(int32_t increment) {
SetThreadPriority(thread_handle_, increment);
}
X_STATUS XThread::Resume(uint32_t* out_suspend_count) {
DWORD result = ResumeThread(thread_handle_);
if (result >= 0) {

View File

@ -59,6 +59,9 @@ public:
uint32_t RaiseIrql(uint32_t new_irql);
void LowerIrql(uint32_t new_irql);
int32_t QueryPriority();
void SetPriority(int32_t increment);
X_STATUS Resume(uint32_t* out_suspend_count);
X_STATUS Suspend(uint32_t* out_suspend_count);
X_STATUS Delay(

View File

@ -302,6 +302,26 @@ SHIM_CALL KeSetAffinityThread_shim(
}
SHIM_CALL KeQueryBasePriorityThread_shim(
PPCContext* ppc_state, KernelState* state) {
uint32_t thread_ptr = SHIM_GET_ARG_32(0);
XELOGD(
"KeQueryBasePriorityThread(%.8X)",
thread_ptr);
int32_t priority = 0;
XThread* thread = (XThread*)XObject::GetObject(
state, SHIM_MEM_ADDR(thread_ptr));
if (thread) {
priority = thread->QueryPriority();
}
SHIM_SET_RETURN(priority);
}
uint32_t xeKeSetBasePriorityThread(void* thread_ptr, int32_t increment) {
KernelState* state = shared_kernel_state_;
XEASSERTNOTNULL(state);
@ -310,8 +330,8 @@ uint32_t xeKeSetBasePriorityThread(void* thread_ptr, int32_t increment) {
XThread* thread = (XThread*)XObject::GetObject(state, thread_ptr);
if (thread) {
// TODO(benvanik): implement.
XELOGW("KeSetBasePriority not implemented");
prev_priority = thread->QueryPriority();
thread->SetPriority(increment);
}
return prev_priority;
@ -1282,6 +1302,7 @@ void xe::kernel::xboxkrnl::RegisterThreadingExports(
SHIM_SET_MAPPING("xboxkrnl.exe", KeResumeThread, state);
SHIM_SET_MAPPING("xboxkrnl.exe", NtSuspendThread, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeSetAffinityThread, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeQueryBasePriorityThread, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeSetBasePriorityThread, state);
SHIM_SET_MAPPING("xboxkrnl.exe", KeGetCurrentProcessType, state);