XThread bool guest thread

This commit is contained in:
Dr. Chat 2015-07-05 13:37:10 -05:00
parent 6bb5b002e0
commit 4fdebd530f
4 changed files with 10 additions and 6 deletions

View File

@ -41,7 +41,8 @@ xe::mutex critical_region_;
XThread::XThread(KernelState* kernel_state, uint32_t stack_size,
uint32_t xapi_thread_startup, uint32_t start_address,
uint32_t start_context, uint32_t creation_flags)
uint32_t start_context, uint32_t creation_flags,
bool guest_thread)
: XObject(kernel_state, kTypeThread),
thread_id_(++next_xthread_id),
thread_handle_(0),
@ -50,7 +51,8 @@ XThread::XThread(KernelState* kernel_state, uint32_t stack_size,
thread_state_(0),
priority_(0),
affinity_(0),
irql_(0) {
irql_(0),
guest_thread_(guest_thread) {
creation_params_.stack_size = stack_size;
creation_params_.xapi_thread_startup = xapi_thread_startup;
creation_params_.start_address = start_address;
@ -758,7 +760,7 @@ void* XThread::GetWaitHandle() { return event_->GetWaitHandle(); }
XHostThread::XHostThread(KernelState* kernel_state, uint32_t stack_size,
uint32_t creation_flags, std::function<int()> host_fn)
: XThread(kernel_state, stack_size, 0, 0, 0, creation_flags),
: XThread(kernel_state, stack_size, 0, 0, 0, creation_flags, false),
host_fn_(host_fn) {}
void XHostThread::Execute() {

View File

@ -81,7 +81,7 @@ class XThread : public XObject {
public:
XThread(KernelState* kernel_state, uint32_t stack_size,
uint32_t xapi_thread_startup, uint32_t start_address,
uint32_t start_context, uint32_t creation_flags);
uint32_t start_context, uint32_t creation_flags, bool guest_thread);
virtual ~XThread();
static bool IsInThread(XThread* other);
@ -92,6 +92,7 @@ class XThread : public XObject {
uint32_t tls_ptr() const { return tls_address_; }
uint32_t pcr_ptr() const { return pcr_address_; }
uint32_t thread_state_ptr() const { return thread_state_address_; }
bool guest_thread() const { return guest_thread_; }
cpu::ThreadState* thread_state() const { return thread_state_; }
uint32_t thread_id() const { return thread_id_; }
@ -156,6 +157,7 @@ class XThread : public XObject {
uint32_t pcr_address_;
uint32_t thread_state_address_;
cpu::ThreadState* thread_state_;
bool guest_thread_; // Launched into guest code?
std::string name_;

View File

@ -206,7 +206,7 @@ X_STATUS XUserModule::Launch(uint32_t flags) {
// Create a thread to run in.
auto thread = object_ref<XThread>(
new XThread(kernel_state(), stack_size_, 0, entry_point_, 0, 0));
new XThread(kernel_state(), stack_size_, 0, entry_point_, 0, 0, true));
X_STATUS result = thread->Create();
if (XFAILED(result)) {

View File

@ -117,7 +117,7 @@ SHIM_CALL ExCreateThread_shim(PPCContext* ppc_context,
auto thread = object_ref<XThread>(
new XThread(kernel_state, stack_size, xapi_thread_startup, start_address,
start_context, creation_flags));
start_context, creation_flags, true));
X_STATUS result = thread->Create();
if (XFAILED(result)) {