Solved

Reset system uptime

Posted on 2003-11-13
5
1,507 Views
Last Modified: 2013-12-03
I've got an application on a windows XP machine (XP embedded) that makes use of the windows time functions getTickCount and timeGetTime.  These return the amount of time that has elapsed since the machine booted and they roll over every 49.7 days.  The rollover might cause problems with my application.  I've reviewed the code and everything looks right, but I need to be sure.

What I need is some way EXTERNAL to my program to fake a rollover.  Basically set my clock to some time just before a rollover then start my app and let the rollover occur.  Or even be able to boot the OS with the time already close to rolling over.

I suspect that this is impossible, but it would make my life a LOT easier if there were a way to do it.  
0
Comment
Question by:abodenha
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9746097
I would just use a wrapper function that would look like this :

// comment out when finished testing
#define SIMUL_ROLLOVER

DWORD WrapperGetTickCount(VOID)
{
#ifdef SIMUL_ROLLOVER
#define DELAY 10000
    static DWORD offset = 0;
    static BOOL first = TRUE;
    if (first) {
        first = FALSE;
        offset = 0xFFFFFFFF - DELAY - GetTickCount();
    }
    return offset + GetTickCount();
#else
    return GetTickCount();
#endif
}


and just replace all occurences of GetTickCount() in the code by WrapperGetTickCount()
0
 

Author Comment

by:abodenha
ID: 9749281
Nice try, and it's an approach I considered.  The problem is that its a large and complex system made up of multiple programs each of which is dependent on several libraries.  Not all of these libs have source available.

Also we need to be able to test the actual binaries we're going to ship.  If we run a test and then have to recompile the test is invalidated.  Basically it becomes a good debugging tool, but it's not useful for validation.

Instrumenting the code is not an option.
0
 
LVL 16

Accepted Solution

by:
_nn_ earned 225 total points
ID: 9749781
Hmm, multiple programs ? In this case, since I don't know of APIs which would allow to somehow reset or control that counter, my last idea would be to use a hook : http://www.codeguru.com/system/apihook.html

I know... not very satisfactory, but maybe better than nothing. Good luck.
0
 

Author Comment

by:abodenha
ID: 9749946
Hmmm...  I hadn't thought of that.  It looks like a pain in the butt but it might just give me what I need.  I'll poke at that a bit later today.  If it looks like I can make it work I'll accept that as an answer.

Thanks.
0
 

Author Comment

by:abodenha
ID: 9750759
It looks like I should be able to create a kernel level driver to set up global overrides for any system calls I want.  Your comment on hooks got me looking in the right place.

Thanks for the help.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now