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:
1 parent
1f5477cf66
commit
b7fcfce6f7
140 files changed
+7649
-3943
No files matched your search
@@ -62,7 +62,7 @@ static SYS_NET_IRP_STATS query_stats(void) {
|
||||
SYS_NET_IRP_STATS stats;
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
uint32_t status = SysQueryKernelStats(SYS_KERNEL_STATS_NET_IRP, &stats, sizeof(stats), 0);
|
||||
if (status != STATUS_SUCCESS)
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail_status("query net irp stats", status);
|
||||
if (stats.Size != sizeof(stats))
|
||||
fail("net irp stats size mismatch");
|
||||
@@ -93,20 +93,20 @@ static void set_u32_option(uint32_t socket, uint32_t option, uint32_t value) {
|
||||
req.Value = &value;
|
||||
req.ValueSize = sizeof(value);
|
||||
uint32_t status = SysSetSocketOption(socket, &req);
|
||||
if (status != STATUS_SUCCESS)
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail_status("set socket option", status);
|
||||
}
|
||||
|
||||
// Waits for an async socket request to publish a terminal IOSB status.
|
||||
static void wait_for_async(uint32_t event, SYS_IO_STATUS_BLOCK* iosb, const char* what) {
|
||||
for (uint32_t i = 0; i < 200u && iosb->Status == STATUS_PENDING; ++i) {
|
||||
for (uint32_t i = 0; i < 200u && iosb->Status == NTLSTATUS_PENDING; ++i) {
|
||||
uint32_t status = SysWait(event, 0);
|
||||
if (status != STATUS_SUCCESS && status != STATUS_ALERTED &&
|
||||
status != STATUS_KERNEL_APC && status != STATUS_USER_APC) {
|
||||
if (status != NTLSTATUS_SUCCESS && status != NTLSTATUS_ALERTED &&
|
||||
status != NTLSTATUS_KERNEL_APC && status != NTLSTATUS_USER_APC) {
|
||||
fail_status(what, status);
|
||||
}
|
||||
}
|
||||
if (iosb->Status == STATUS_PENDING)
|
||||
if (iosb->Status == NTLSTATUS_PENDING)
|
||||
fail("async request stayed pending");
|
||||
}
|
||||
|
||||
@@ -114,12 +114,12 @@ static void wait_for_async(uint32_t event, SYS_IO_STATUS_BLOCK* iosb, const char
|
||||
static void check_nonblocking_receive(void) {
|
||||
uint32_t udp = 0;
|
||||
uint32_t status = SysCreateSocket(SYS_AF_INET, SYS_SOCK_DGRAM, SYS_IPPROTO_UDP, &udp);
|
||||
if (status != STATUS_SUCCESS)
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail_status("create udp socket", status);
|
||||
|
||||
SYS_SOCKET_ADDRESS bindAddress = make_ipv4(0, 0, 0, 0, NET_IRP_SMOKE_UDP_PORT);
|
||||
status = SysBindSocket(udp, &bindAddress, sizeof(bindAddress));
|
||||
if (status != STATUS_SUCCESS) {
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
SysCloseHandle(udp);
|
||||
fail_status("bind udp socket", status);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ static void check_nonblocking_receive(void) {
|
||||
|
||||
status = SysRecvFromSocket(udp, &req);
|
||||
SysCloseHandle(udp);
|
||||
if (status != STATUS_WOULD_BLOCK)
|
||||
if (status != NTLSTATUS_WOULD_BLOCK)
|
||||
fail_status("nonblocking udp recvfrom", status);
|
||||
}
|
||||
|
||||
@@ -151,19 +151,19 @@ static void check_nonblocking_receive(void) {
|
||||
static void check_async_receive_cancel(void) {
|
||||
uint32_t udp = 0;
|
||||
uint32_t status = SysCreateSocket(SYS_AF_INET, SYS_SOCK_DGRAM, SYS_IPPROTO_UDP, &udp);
|
||||
if (status != STATUS_SUCCESS)
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail_status("create cancel udp socket", status);
|
||||
|
||||
SYS_SOCKET_ADDRESS bindAddress = make_ipv4(0, 0, 0, 0, NET_IRP_SMOKE_UDP_PORT + 1u);
|
||||
status = SysBindSocket(udp, &bindAddress, sizeof(bindAddress));
|
||||
if (status != STATUS_SUCCESS) {
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
SysCloseHandle(udp);
|
||||
fail_status("bind cancel udp socket", status);
|
||||
}
|
||||
|
||||
uint32_t event = 0;
|
||||
status = SysCreateEvent(EVENT_AUTO_RESET, 0, &event);
|
||||
if (status != STATUS_SUCCESS) {
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
SysCloseHandle(udp);
|
||||
fail_status("create event", status);
|
||||
}
|
||||
@@ -193,7 +193,7 @@ static void check_async_receive_cancel(void) {
|
||||
|
||||
SYS_NET_IRP_STATS beforeSubmit = query_stats();
|
||||
status = SysSocketIoAsync(&req);
|
||||
if (status != STATUS_PENDING || requestHandle == 0) {
|
||||
if (status != NTLSTATUS_PENDING || requestHandle == 0) {
|
||||
SysCloseHandle(event);
|
||||
SysCloseHandle(udp);
|
||||
fail_status("submit async recvfrom", status);
|
||||
@@ -213,17 +213,17 @@ static void check_async_receive_cancel(void) {
|
||||
fail("async recvfrom did not enter the IRP path");
|
||||
|
||||
uint32_t cancelStatus = SysCancelIo(requestHandle);
|
||||
if (cancelStatus != STATUS_SUCCESS && cancelStatus != STATUS_PENDING)
|
||||
if (cancelStatus != NTLSTATUS_SUCCESS && cancelStatus != NTLSTATUS_PENDING)
|
||||
fail_status("cancel async recvfrom", cancelStatus);
|
||||
|
||||
wait_for_async(event, &iosb, "wait async recvfrom cancel");
|
||||
if (iosb.Status != STATUS_CANCELLED)
|
||||
if (iosb.Status != NTLSTATUS_CANCELLED)
|
||||
fail_status("async recvfrom iosb", iosb.Status);
|
||||
if (iosb.Information != 0)
|
||||
fail("async recvfrom cancel transferred bytes");
|
||||
|
||||
status = SysWaitSingle(requestHandle, 0, 0);
|
||||
if (status != STATUS_SUCCESS)
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail_status("wait cancelled request handle", status);
|
||||
|
||||
SysCloseHandle(requestHandle);
|
||||
@@ -235,7 +235,7 @@ static void check_async_receive_cancel(void) {
|
||||
static void try_http_async_success(void) {
|
||||
uint32_t tcp = 0;
|
||||
uint32_t status = SysCreateSocket(SYS_AF_INET, SYS_SOCK_STREAM, SYS_IPPROTO_TCP, &tcp);
|
||||
if (status != STATUS_SUCCESS) {
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
print("net_irp_smoke: http success path skipped create status=");
|
||||
print_u64(status);
|
||||
print("\n");
|
||||
@@ -244,7 +244,7 @@ static void try_http_async_success(void) {
|
||||
|
||||
SYS_SOCKET_ADDRESS address = make_ipv4(10, 0, 2, 2, NET_IRP_SMOKE_HTTP_PORT);
|
||||
status = SysConnectSocket(tcp, &address, sizeof(address));
|
||||
if (status != STATUS_SUCCESS) {
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
print("net_irp_smoke: http success path skipped connect status=");
|
||||
print_u64(status);
|
||||
print("\n");
|
||||
@@ -254,7 +254,7 @@ static void try_http_async_success(void) {
|
||||
|
||||
uint32_t event = 0;
|
||||
status = SysCreateEvent(EVENT_AUTO_RESET, 0, &event);
|
||||
if (status != STATUS_SUCCESS) {
|
||||
if (status != NTLSTATUS_SUCCESS) {
|
||||
SysCloseHandle(tcp);
|
||||
fail_status("create http event", status);
|
||||
}
|
||||
@@ -276,10 +276,10 @@ static void try_http_async_success(void) {
|
||||
sendReq.RequestHandleOut = &sendRequest;
|
||||
|
||||
status = SysSocketIoAsync(&sendReq);
|
||||
if (status != STATUS_PENDING || sendRequest == 0)
|
||||
if (status != NTLSTATUS_PENDING || sendRequest == 0)
|
||||
fail_status("submit async send", status);
|
||||
wait_for_async(event, &sendIosb, "wait async send");
|
||||
if (sendIosb.Status != STATUS_SUCCESS)
|
||||
if (sendIosb.Status != NTLSTATUS_SUCCESS)
|
||||
fail_status("async send iosb", sendIosb.Status);
|
||||
if (sendIosb.Information != sizeof(requestText) - 1u)
|
||||
fail("async send byte count mismatch");
|
||||
@@ -303,10 +303,10 @@ static void try_http_async_success(void) {
|
||||
recvReq.RequestHandleOut = &recvRequest;
|
||||
|
||||
status = SysSocketIoAsync(&recvReq);
|
||||
if (status != STATUS_PENDING || recvRequest == 0)
|
||||
if (status != NTLSTATUS_PENDING || recvRequest == 0)
|
||||
fail_status("submit async recv", status);
|
||||
wait_for_async(event, &recvIosb, "wait async recv");
|
||||
if (recvIosb.Status != STATUS_SUCCESS)
|
||||
if (recvIosb.Status != NTLSTATUS_SUCCESS)
|
||||
fail_status("async recv iosb", recvIosb.Status);
|
||||
if (recvIosb.Information == 0)
|
||||
fail("async recv returned no bytes");
|
||||
|
||||
Reference in new issue
Block a user