implement user mode catchable exceptions, refactor system status codes to use NTLSTATUS_ prefix, update build scripts to use shared literal macros for linker arguments, update named queue lifetime cleanup to include KeNamedQueueUnpublishHandle.

This commit is contained in:
maksw committed 2026-06-27 20:38:43 +02:00
1 parent 1f5477cf66
commit b7fcfce6f7
140 files changed
+7649 -3943

No files matched your search

@@ -119,7 +119,7 @@ static void sender_thread(uintptr_t arg) {
msg.Type = TEST_MESSAGE_WAKE;
msg.Param[0] = TEST_WAKE_VALUE;
ctx->Status = send_queue(ctx->Queue, &msg, SYS_WAIT_TIMEOUT_INFINITE);
SysExitThread(ctx->Status == STATUS_SUCCESS ? 0 : 1);
SysExitThread(ctx->Status == NTLSTATUS_SUCCESS ? 0 : 1);
}
// Fills one queue with immediate sends until the queue reports would-block.
@@ -131,9 +131,9 @@ static void fill_until_would_block(uint32_t queue) {
for (; sends < TEST_FILL_LIMIT; sends++) {
msg.Param[0] = sends;
uint32_t s = send_queue(queue, &msg, 0);
if (s == STATUS_WOULD_BLOCK)
if (s == NTLSTATUS_WOULD_BLOCK)
break;
if (s != STATUS_SUCCESS)
if (s != NTLSTATUS_SUCCESS)
fail_status("fill send", s);
}
@@ -145,20 +145,20 @@ static void fill_until_would_block(uint32_t queue) {
static void test_queue_empty_and_full(void) {
uint32_t queue = 0;
uint32_t s = SysCreateQueue(&queue);
if (s != STATUS_SUCCESS) fail_status("create empty queue", s);
if (s != NTLSTATUS_SUCCESS) fail_status("create empty queue", s);
TEST_QUEUE_MESSAGE msg = {0};
expect_status("empty nonblocking receive", recv_queue(queue, &msg, 0), STATUS_WOULD_BLOCK);
expect_status("empty finite receive", recv_queue(queue, &msg, 20), STATUS_TIMEOUT);
expect_status("empty nonblocking receive", recv_queue(queue, &msg, 0), NTLSTATUS_WOULD_BLOCK);
expect_status("empty finite receive", recv_queue(queue, &msg, 20), NTLSTATUS_TIMEOUT);
SysCloseHandle(queue);
queue = 0;
s = SysCreateQueue(&queue);
if (s != STATUS_SUCCESS) fail_status("create full queue", s);
if (s != NTLSTATUS_SUCCESS) fail_status("create full queue", s);
fill_until_would_block(queue);
expect_status("full nonblocking send", send_queue(queue, &msg, 0), STATUS_WOULD_BLOCK);
expect_status("full finite send", send_queue(queue, &msg, 20), STATUS_TIMEOUT);
expect_status("full nonblocking send", send_queue(queue, &msg, 0), NTLSTATUS_WOULD_BLOCK);
expect_status("full finite send", send_queue(queue, &msg, 20), NTLSTATUS_TIMEOUT);
SysCloseHandle(queue);
}
@@ -166,9 +166,9 @@ static void test_queue_empty_and_full(void) {
static void test_queue_infinite_receive_wakeup(void) {
uint32_t queue = 0;
uint32_t s = SysCreateQueue(&queue);
if (s != STATUS_SUCCESS) fail_status("create wake queue", s);
if (s != NTLSTATUS_SUCCESS) fail_status("create wake queue", s);
TEST_SENDER_CONTEXT ctx = { queue, STATUS_PENDING };
TEST_SENDER_CONTEXT ctx = { queue, NTLSTATUS_PENDING };
uint32_t threadHandle = 0;
uint32_t threadId = 0;
SYS_CREATE_THREAD_REQUEST req = {
@@ -180,17 +180,17 @@ static void test_queue_infinite_receive_wakeup(void) {
&threadId
};
s = SysCreateThread(&req);
if (s != STATUS_SUCCESS) fail_status("create sender", s);
if (s != NTLSTATUS_SUCCESS) fail_status("create sender", s);
TEST_QUEUE_MESSAGE msg = {0};
s = recv_queue(queue, &msg, SYS_WAIT_TIMEOUT_INFINITE);
if (s != STATUS_SUCCESS) fail_status("infinite receive", s);
if (s != NTLSTATUS_SUCCESS) fail_status("infinite receive", s);
if (msg.Type != TEST_MESSAGE_WAKE || msg.Param[0] != TEST_WAKE_VALUE)
fail("wake message payload mismatch");
s = SysWait(threadHandle, SYS_WAIT_FLAG_NONE);
if (s != STATUS_SUCCESS) fail_status("wait sender", s);
if (ctx.Status != STATUS_SUCCESS) fail_status("sender status", ctx.Status);
if (s != NTLSTATUS_SUCCESS) fail_status("wait sender", s);
if (ctx.Status != NTLSTATUS_SUCCESS) fail_status("sender status", ctx.Status);
SysCloseHandle(threadHandle);
SysCloseHandle(queue);
@@ -200,11 +200,11 @@ static void test_queue_infinite_receive_wakeup(void) {
static void test_queue_request_validation(void) {
uint32_t queue = 0;
uint32_t s = SysCreateQueue(&queue);
if (s != STATUS_SUCCESS) fail_status("create validation queue", s);
if (s != NTLSTATUS_SUCCESS) fail_status("create validation queue", s);
TEST_QUEUE_MESSAGE msg = {0};
expect_status("null send request", SysSendQueue((const SYS_QUEUE_SEND_REQUEST*)0), STATUS_INVALID_PARAMETER);
expect_status("null recv request", SysRecvQueue((const SYS_QUEUE_RECV_REQUEST*)0), STATUS_INVALID_PARAMETER);
expect_status("null send request", SysSendQueue((const SYS_QUEUE_SEND_REQUEST*)0), NTLSTATUS_INVALID_PARAMETER);
expect_status("null recv request", SysRecvQueue((const SYS_QUEUE_RECV_REQUEST*)0), NTLSTATUS_INVALID_PARAMETER);
SYS_QUEUE_SEND_REQUEST sendReq = {
0,
@@ -213,15 +213,15 @@ static void test_queue_request_validation(void) {
0,
&msg,
};
expect_status("bad send size", SysSendQueue(&sendReq), STATUS_INVALID_PARAMETER);
expect_status("bad send size", SysSendQueue(&sendReq), NTLSTATUS_INVALID_PARAMETER);
sendReq.Size = sizeof(sendReq);
sendReq.Flags = 1;
expect_status("bad send flags", SysSendQueue(&sendReq), STATUS_INVALID_PARAMETER);
expect_status("bad send flags", SysSendQueue(&sendReq), NTLSTATUS_INVALID_PARAMETER);
sendReq.Flags = SYS_QUEUE_FLAG_NONE;
sendReq.Message = (const void*)0;
expect_status("bad send message", SysSendQueue(&sendReq), STATUS_INVALID_PARAMETER);
expect_status("bad send message", SysSendQueue(&sendReq), NTLSTATUS_INVALID_PARAMETER);
SYS_QUEUE_RECV_REQUEST recvReq = {
sizeof(recvReq),
@@ -230,7 +230,7 @@ static void test_queue_request_validation(void) {
0,
(void*)0,
};
expect_status("bad recv message", SysRecvQueue(&recvReq), STATUS_INVALID_PARAMETER);
expect_status("bad recv message", SysRecvQueue(&recvReq), NTLSTATUS_INVALID_PARAMETER);
SysCloseHandle(queue);
}