Put more thought into new signaling code

This commit is contained in:
Justine Tunney 2024-09-19 20:13:55 -07:00
parent 6107eb38f9
commit f68fc1f815
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
10 changed files with 127 additions and 51 deletions

View file

@ -27,7 +27,9 @@
#include "libc/runtime/internal.h"
#ifdef __x86_64__
__msabi extern typeof(DeleteFile) *const __imp_DeleteFileW;
__msabi extern typeof(TerminateProcess) *const __imp_TerminateProcess;
__msabi extern typeof(UnmapViewOfFile) *const __imp_UnmapViewOfFile;
/**
* Terminates the calling process and all of its threads.
@ -40,8 +42,8 @@ textwindows dontinstrument void TerminateThisProcess(uint32_t dwWaitStatus) {
atomic_ulong fake = 0;
real = __sig.process;
__sig.process = &fake;
UnmapViewOfFile(real);
DeleteFile(__sig_process_path(path, __pid));
__imp_UnmapViewOfFile(real);
__imp_DeleteFileW(__sig_process_path(path, __pid, false));
// "When a process terminates itself, TerminateProcess stops execution
// of the calling thread and does not return." -Quoth MSDN