?
Solved

Reset system uptime

Posted on 2003-11-13
5
Medium Priority
?
1,527 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 675 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

777 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