diff options
| author | navewindre <nw@moneybot.cc> | 2024-07-12 00:55:39 +0200 |
|---|---|---|
| committer | navewindre <nw@moneybot.cc> | 2024-07-12 00:55:39 +0200 |
| commit | 2ebf959ec02048c15323e1bbfc63faedcf5067b6 (patch) | |
| tree | 18862ba5d3b4be44294c0a81317d31eace7ee150 /src/util.cpp | |
| parent | ecca2728f1a583ea484f8bdcda390a30e4906f1d (diff) | |
ha haaa
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp new file mode 100644 index 0000000..576dcbd --- /dev/null +++ b/src/util.cpp @@ -0,0 +1,42 @@ +//|_ _ _. _ ._ |_ _. _ | +//| | (/_ (_| \/ (/_ | | | | (_| (_ |< + +#include "util.h" +#include "syscall.h" + +ULONG u_thread_create( LPTHREAD_START_ROUTINE routine, void* param ) { + REG64 thread; + ULONG ret_id; + + nt_create_thread64( &thread, 0x1fffff, 0, GetCurrentProcess(), routine, param, 0 ); + ret_id = GetThreadId( (HANDLE)thread.u32[0] ); + + nt_close64( thread ); + + return ret_id; +} + +ULONG u_thread_create( HANDLE proc, LPTHREAD_START_ROUTINE routine, void* param ) { + REG64 thread; + ULONG ret_id; + + nt_create_thread64( &thread, 0x1fffff, 0, proc, routine, param, 0 ); + ret_id = GetThreadId( (HANDLE)thread.u32[0] ); + + nt_close64( thread ); + + return ret_id; +} + +void u_sleep( U64 ns ) { + static bool resolution_set = false; + if( !resolution_set ) { + ULONG timer_resolution; + nt_set_timer_resolution64( 1, true, &timer_resolution ); + resolution_set = true; + } + + LARGE_INTEGER interval; + interval.QuadPart = -1 * ns; + nt_delay_execution64( false, &interval ); +} |
