Solved

Reset system uptime

Posted on 2003-11-13
5
1,509 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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