From 5cfcf3a50a1d1947ba61409e1dd135b4354b7d25 Mon Sep 17 00:00:00 2001 From: rep Date: Sun, 20 Jul 2014 12:12:21 +0200 Subject: [PATCH] add force-sleepskip --- config.c | 3 +++ config.h | 3 +++ hook_sleep.c | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 9ef3bbd..852a0fc 100644 --- a/config.c +++ b/config.c @@ -75,6 +75,9 @@ void read_config() else if(!strcmp(key, "host-port")) { g_config.host_port = atoi(value); } + else if(!strcmp(key, "force-sleepskip")) { + g_config.force_sleepskip = value[0] == '1'; + } } } fclose(fp); diff --git a/config.h b/config.h index 010c555..b72358e 100644 --- a/config.h +++ b/config.h @@ -38,6 +38,9 @@ struct { // do we want to enable the retaddr check? int retaddr_check; + // do we force sleep-skipping despite threads? + int force_sleepskip; + // server ip and port unsigned int host_ip; unsigned short host_port; diff --git a/hook_sleep.c b/hook_sleep.c index 753c5dc..100c75c 100644 --- a/hook_sleep.c +++ b/hook_sleep.c @@ -22,6 +22,7 @@ along with this program. If not, see . #include "ntapi.h" #include "log.h" #include "pipe.h" +#include "config.h" // only skip Sleep()'s the first five seconds #define MAX_SLEEP_SKIP_DIFF 5000 @@ -120,7 +121,10 @@ HOOKDEF(NTSTATUS, WINAPI, NtQuerySystemTime, void disable_sleep_skip() { - sleep_skip_active = 0; + if (sleep_skip_active && !g_config.force_sleepskip) { + pipe("INFO:Disabling sleep skipping."); + sleep_skip_active = 0; + } } void init_sleep_skip(int first_process)