flat assembler
Message board for the users of flat assembler.

Index > Windows > How to get Unix time in Windows

Author
Thread Post new topic Reply to topic
Core i7



Joined: 14 Nov 2024
Posts: 48
Location: Socket on motherboard
Core i7 28 Mar 2025, 04:43
Hello everyone!
In the "TimeDataStamp" field of executable files exe\dll\sys, the time is stored in 32-bit Unix format (dword). How can I convert the current system time (UTC) to write it to the "TimeDateStamp" field of the file's PE header? I looked for a function among Win32API, but it seems there is no such function. The source code of the FASM compiler should contain this procedure - help me find it. Thank you.
Post 28 Mar 2025, 04:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 28 Mar 2025, 05:55
It is possible to use GetSystemTimeAsFileTime and divide by 10^7 to get seconds since the epoch. Then adjust the epoch by adding/subtracting some seconds to put it into the wanted timezone.
Post 28 Mar 2025, 05:55
View user's profile Send private message Visit poster's website Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 48
Location: Socket on motherboard
Core i7 28 Mar 2025, 06:19
@revolution - great!
I just found it on the Microsoft website, only this is the reverse conversion from TimeDataStamp to FileTime.
https://learn.microsoft.com/en-us/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time

I wonder why engineers didn't introduce a special API for this, otherwise it turns out there is time, but no function (you have to do it manually).
Post 28 Mar 2025, 06:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20632
Location: In your JS exploiting you and your system
revolution 28 Mar 2025, 06:37
I find the search engines to be "less good" when searching for technical information. It's better to read the manuals and docs, or ask a real person (like on this board), than to rely on an Internet search to uncover something, IMO.

Many of the popular engines available today are becoming more focussed on displaying sales sites in preference to informational sites.
Post 28 Mar 2025, 06:37
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.