Skip to content

Commit

Permalink
add force-sleepskip
Browse files Browse the repository at this point in the history
  • Loading branch information
rep committed Jul 20, 2014
1 parent 565545b commit 5cfcf3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion hook_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5cfcf3a

Please sign in to comment.