Merge remote-tracking branch 'CookiePLMonster/thread-refcounts' into canary
PR 1506
This commit is contained in:
parent
b90a00b7e9
commit
53915fd34b
|
@ -194,6 +194,7 @@ X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) {
|
|||
if (entry->object) {
|
||||
auto object = entry->object;
|
||||
entry->object = nullptr;
|
||||
assert_zero(entry->handle_ref_count);
|
||||
entry->handle_ref_count = 0;
|
||||
|
||||
// Walk the object's handles and remove this one.
|
||||
|
|
|
@ -69,7 +69,7 @@ dword_result_t ObLookupThreadByThreadId(dword_t thread_id,
|
|||
}
|
||||
|
||||
// Retain the object. Will be released in ObDereferenceObject.
|
||||
thread->Retain();
|
||||
thread->RetainHandle();
|
||||
*out_object_ptr = thread->guest_object();
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ dword_result_t ObReferenceObjectByHandle(dword_t handle,
|
|||
|
||||
// Caller takes the reference.
|
||||
// It's released in ObDereferenceObject.
|
||||
object->Retain();
|
||||
object->RetainHandle();
|
||||
if (out_object_ptr.guest_address()) {
|
||||
*out_object_ptr = native_ptr;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ dword_result_t ObDereferenceObject(dword_t native_ptr) {
|
|||
auto object = XObject::GetNativeObject<XObject>(
|
||||
kernel_state(), kernel_memory()->TranslateVirtual(native_ptr));
|
||||
if (object) {
|
||||
object->Release();
|
||||
object->ReleaseHandle();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -141,7 +141,6 @@ dword_result_t ExCreateThread(lpdword_t handle_ptr, dword_t stack_size,
|
|||
// TODO(Gliniak): Temporary solution, requires more research // && !stack_size
|
||||
*handle_ptr = thread->handle();
|
||||
} else {
|
||||
thread->RetainHandle();
|
||||
*handle_ptr = thread->handle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ XObject::XObject(KernelState* kernel_state, Type type)
|
|||
}
|
||||
|
||||
XObject::~XObject() {
|
||||
assert_true(handles_.empty());
|
||||
assert_zero(pointer_ref_count_);
|
||||
|
||||
if (allocated_guest_object_) {
|
||||
|
|
Loading…
Reference in New Issue