Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reset system uptime

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

596 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