From fdab8cd5ecdf3b35a1bd4dbb0511241aa37ee57f Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 13 Apr 2025 10:37:39 +0200 Subject: [PATCH] Extend APC test --- src/samples/test-sample/test.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/samples/test-sample/test.cpp b/src/samples/test-sample/test.cpp index 4fc7c567..a3b03a34 100644 --- a/src/samples/test-sample/test.cpp +++ b/src/samples/test-sample/test.cpp @@ -434,22 +434,24 @@ namespace bool test_apc() { - bool executed = false; - QueueUserAPC( - +[](ULONG_PTR param) { - *reinterpret_cast(param) = true; // - }, - GetCurrentThread(), reinterpret_cast(&executed)); + int executions = 0; + + auto* apc_func = +[](ULONG_PTR param) { + *reinterpret_cast(param) += 1; // + }; + + QueueUserAPC(apc_func, GetCurrentThread(), reinterpret_cast(&executions)); + QueueUserAPC(apc_func, GetCurrentThread(), reinterpret_cast(&executions)); Sleep(1); - if (executed) + if (executions != 0) { return false; } SleepEx(1, TRUE); - return executed; + return executions == 2; } }