1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
//|_ _ _. _ ._ |_ _. _ |
//| | (/_ (_| \/ (/_ | | | | (_| (_ |<
#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 );
}
void u_bin_dump( void* data, U64 size, U32 stride ) {
if( stride < 1 )
stride = 8;
U8* bytes = (U8*)data;
for( U64 i = 0; i < size; ++i ) {
if( i % stride == 0 )
clogc( CONFG_LIGHTGREEN, "[0x%02X] | ", i );
clogc( bytes[i]? CONFG_WHITE : CONFG_RED, "%02X ", bytes[i] );
if( i % stride == (stride - 1) )
printf( "\n" );
}
}
|