From 9609a550e01b116cd1b4ca26ae0aa596182e7f9e Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 13 Apr 2025 10:22:46 +0200 Subject: [PATCH] Add APC test --- src/samples/test-sample/test.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/samples/test-sample/test.cpp b/src/samples/test-sample/test.cpp index 62254120..4fc7c567 100644 --- a/src/samples/test-sample/test.cpp +++ b/src/samples/test-sample/test.cpp @@ -431,6 +431,26 @@ namespace const auto epoch_time = std::chrono::system_clock::now().time_since_epoch(); printf("Time: %lld\n", std::chrono::duration_cast(epoch_time).count()); } + + bool test_apc() + { + bool executed = false; + QueueUserAPC( + +[](ULONG_PTR param) { + *reinterpret_cast(param) = true; // + }, + GetCurrentThread(), reinterpret_cast(&executed)); + + Sleep(1); + + if (executed) + { + return false; + } + + SleepEx(1, TRUE); + return executed; + } } #define RUN_TEST(func, name) \ @@ -461,8 +481,7 @@ int main(const int argc, const char* argv[]) RUN_TEST(test_native_exceptions, "Native Exceptions") RUN_TEST(test_tls, "TLS") RUN_TEST(test_socket, "Socket") - - Sleep(1); + RUN_TEST(test_apc, "APC") return valid ? 0 : 1; }