Hello:

I need a win32asm subroutine that will take the current time (invoke GetLocalTime, ADDR systime) and convert it to total number of seconds from epoch like the C funtion time();

I have searched this site and googled around without finding anything useful.

Is it possible to call the C function time(); from my asm program? If so, how I do dis? Do I pass the time function the ptr to the systime structure? Or can someone point me to a code snippet in asm that can do the conversion (prefered metheod)?

Thanks in advance!

SS
Posted on 2006-11-08 12:29:27 by SideSwipe
Posted on 2006-11-08 14:26:51 by SpooK
Hey thanks Spook !

RtlTimeToSecondsSince1970 did the trick.

SS
Posted on 2006-11-08 20:54:30 by SideSwipe

Hey thanks Spook !

RtlTimeToSecondsSince1970 did the trick.

SS


I was hoping you'd see that one ;)
Posted on 2006-11-09 15:55:48 by SpooK
Be warned, though:
RtlTimeToSecondsSince1970 is available for use in Windows 2000 and Windows XP. It may be altered or unavailable in subsequent versions.


Is it possible to call the C function time(); from my asm program? If so, how I do dis?

Calling a function from msvcrt is like calling a function from any other DLL. You just have to use the proper calling convention (standard winapi funcions use 'stdcall', while msvcrt uses 'cdecl').

If you don't (want to) have the required .lib, you can use the following method: > * <.
Posted on 2006-11-10 08:52:50 by ti_mo_n
Ketil helped me once out which this snipplet which converts a filetime to seconds since 01.01.1601. Using the SystemTimeToFileTime Api one can translate pretty quickly back and forth any date.

mov ecx,10*1000*1000
mov eax,ftime.dwHighDateTime
xor edx,edx
div ecx
mov ftime.dwHighDateTime,eax
mov eax,ftime.dwLowDateTime
div ecx
mov ftime.dwLowDateTime,eax
mov ecx,24*60*60
mov edx,ftime.dwHighDateTime
mov eax,ftime.dwLowDateTime
div ecx
;eax contains days since 01.01.1601
Posted on 2006-11-10 11:20:49 by JimmyClif