void nt_sleep(DWORD milliseconds)
{
static NTSTATUS(__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval) = (NTSTATUS(__stdcall*)(BOOL, PLARGE_INTEGER)) GetProcAddress(GetModuleHandleA(("ntdll.dll")), ("NtDelayExecution"));
static NTSTATUS(__stdcall *ZwSetTimerResolution)(IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution) = (NTSTATUS(__stdcall*)(ULONG, BOOLEAN, PULONG)) GetProcAddress(GetModuleHandleA(("ntdll.dll")), ("ZwSetTimerResolution"));
static bool once = true;
printf("ZwSetTimerResolution %p\n",ZwSetTimerResolution);
if (once && ZwSetTimerResolution!=NULL) {
ULONG actualResolution;
ZwSetTimerResolution(1, true, &actualResolution);
once = false;
}
LARGE_INTEGER interval;
interval.QuadPart = -1 * (int)(milliseconds * 10000);
printf("NtDelayExecution %p\n",NtDelayExecution);
if(NtDelayExecution!=NULL)
{
NtDelayExecution(false, &interval);
}
}
windows上使用底层的sleep函数
最新推荐文章于 2025-03-09 10:52:08 发布