flat assembler
Message board for the users of flat assembler.

Index > Windows > UpTime

Author
Thread Post new topic Reply to topic
Yardman



Joined: 12 Apr 2005
Posts: 244
Location: US
Yardman 14 Jan 2012, 08:53
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 04:37; edited 3 times in total
Post 14 Jan 2012, 08:53
View user's profile Send private message Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 14 Jan 2012, 09:50
Thank you Yardman. Smile

Some things to maybe consider, hibernation time and what happens after ~50 days.

Some newer API's which may be interesting...

GetTickCount64

QueryUnbiasedInterruptTime


Description:
Filesize: 6.54 KB
Viewed: 3546 Time(s)

Up.png


Post 14 Jan 2012, 09:50
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 15 Jan 2012, 04:52
> Some newer API's which may be interesting...
> GetTickCount64

Added in Vista but should have been in (the CPU ?) since the beginning Sad

> Some things to maybe consider, hibernation time and what happens after ~50 days

One more: http://en.wikipedia.org/wiki/Leap_second Evil or Very Mad

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 15 Jan 2012, 04:52
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 244
Location: US
Yardman 16 Jan 2012, 01:30
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 04:37; edited 1 time in total
Post 16 Jan 2012, 01:30
View user's profile Send private message Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 16 Jan 2012, 03:51
Yardman wrote:
Alphonso,I suppose that 64 bit progamming is here.
And I will start to pick it up.

A good idea IMO, but you can run both those API's with 32-bit.

A rough example
Code:
format PE GUI 6.0                         ; Vista and up

include 'win32a.inc'

            sub     esp,100h              ; Buffer
            mov     ebp,esp

            invoke  GetTickCount64        ; 64bit value returned in EDX:EAX
            mov     ebx,1000
            call    div64
            mov     [ebp],ecx             ; msecs

            mov     ebx,60
            call    div64
            mov     [ebp+4],ecx           ; sec

            call    div64
            mov     [ebp+8],ecx           ; mins

            mov     ebx,24
            call    div64
            mov     [ebp+0ch],ecx         ; hrs
            mov     [ebp+10h],edx         ; lots of days!
            mov     [ebp+14h],eax         ; days
            lea     ebx,[ebp+18h]         ; Print buffer

            cinvoke wsprintf,ebx,wsformat,[ebp+14h],[ebp+10h],[ebp+0ch],[ebp+8],[ebp+04h],[ebp]
            invoke  MessageBoxA,0,ebx,Tit,MB_TOPMOST
            add    esp,100h

 exit:      invoke  ExitProcess,0

;------------------------
 div64:
            push    eax
            mov     eax,edx
            xor     edx,edx
            div     ebx
            mov     ecx,eax
            pop     eax
            div     ebx
            xchg    edx,ecx
            ret
;------------------------

         Tit             db 'Up Time',0
         wsformat        db 'From reboot ',9,'%4I64u Days, %02u Hours %02u Mins, %02u.%03u Secs',0

data import

 library kernel32,'KERNEL32.DLL',\
         user32,'USER32.DLL'

 import kernel32,\
        GetTickCount64,'GetTickCount64',\
        ExitProcess,'ExitProcess'

 import user32,\
        wsprintf,'wsprintfA',\
        MessageBoxA,'MessageBoxA'

end data

    


Not sure how leap time is relevant, for instance if the system has been running for 1 hour and a leap day occurs it is still 1 hour and not 25 hours. Should be good for ~584 million years of uptime lol.
Post 16 Jan 2012, 03:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 16 Jan 2012, 03:59
Alphonso wrote:
Not sure how leap time is relevant, for instance if the system has been running for 1 hour and a leap day occurs it is still 1 hour and not 25 hours.
Leap time is irrelevant. The tick counter is purely a local thing. It counts ticks of the system oscillator and is completely insensitive to external human customs of leap days/seconds and daylight saving adjustments.
Post 16 Jan 2012, 03:59
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.