Solved

Reset system uptime

Posted on 2003-11-13
5
1,518 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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