Skip to content

Commit

Permalink
randomize startup time based on a value initialized in the analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
jbremer committed Nov 4, 2013
1 parent d782377 commit 4ab9d3d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void read_config()
else if(!strcmp(key, "first-process")) {
g_config.first_process = value[0] == '1';
}
else if(!strcmp(key, "startup-time")) {
g_config.startup_time = atoi(value);
}
else if(!strcmp(key, "retaddr-check")) {
g_config.retaddr_check = value[0] == '1';
}
Expand Down
3 changes: 3 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ struct {
// is this the first process or not?
int first_process;

// how many milliseconds since startup
unsigned int startup_time;

// do we want to enable the retaddr check?
int retaddr_check;

Expand Down
3 changes: 3 additions & 0 deletions cuckoomon.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
// initialize the Sleep() skipping stuff
init_sleep_skip(g_config.first_process);

// we skip a random given amount of milliseconds each run
init_startup_time(g_config.startup_time);

// disable the retaddr check if the user wants so
if(g_config.retaddr_check == 0) {
hook_disable_retaddr_check();
Expand Down
5 changes: 5 additions & 0 deletions hook_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,8 @@ void init_sleep_skip(int first_process)
disable_sleep_skip();
}
}

void init_startup_time(unsigned int startup_time)
{
time_skipped.QuadPart += (unsigned __int64) startup_time * 10000;
}
1 change: 1 addition & 0 deletions hook_sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

void disable_sleep_skip();
void init_sleep_skip(int first_process);
void init_startup_time(unsigned int startup_time);

0 comments on commit 4ab9d3d

Please sign in to comment.