mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-27 15:11:01 +00:00
Thread handle fixes (#125)
This commit is contained in:
@@ -347,7 +347,7 @@ class moved_marker
|
|||||||
bool was_moved_{false};
|
bool was_moved_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
class emulator_thread : ref_counted_object
|
class emulator_thread : public ref_counted_object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
emulator_thread(x64_emulator& emu)
|
emulator_thread(x64_emulator& emu)
|
||||||
|
|||||||
@@ -430,6 +430,16 @@ namespace
|
|||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (h.value.type == handle_types::thread)
|
||||||
|
{
|
||||||
|
const auto t = c.proc.threads.get(h);
|
||||||
|
if (t == c.proc.active_thread && t->ref_count == 1)
|
||||||
|
{
|
||||||
|
// TODO: Better handle ref counting
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto* handle_store = get_handle_store(c.proc, h);
|
auto* handle_store = get_handle_store(c.proc, h);
|
||||||
if (handle_store && handle_store->erase(h))
|
if (handle_store && handle_store->erase(h))
|
||||||
{
|
{
|
||||||
@@ -3519,10 +3529,11 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool return_next_thread = thread_handle == NULL_HANDLE;
|
bool return_next_thread = thread_handle == NULL_HANDLE;
|
||||||
for (const auto& t : c.proc.threads)
|
for (auto& t : c.proc.threads)
|
||||||
{
|
{
|
||||||
if (return_next_thread && !t.second.is_terminated())
|
if (return_next_thread && !t.second.is_terminated())
|
||||||
{
|
{
|
||||||
|
++t.second.ref_count;
|
||||||
new_thread_handle.write(c.proc.threads.make_handle(t.first));
|
new_thread_handle.write(c.proc.threads.make_handle(t.first));
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user