Compiled date to stringAuthor: Dave Date: 05.03.12 - 2:43am Quick example of turning the time stamp embedded in an executable into a human readable string using vb6. This code has just been integrated into my pe editor classes as well. Private Sub Form_Load() Dim s, s2, d As Date s = timeStampToDate(&H5E1FC7C2) '= Jan 16 2020 2:17:38 d = CDate(s) s2 = Hex(DatetoTimeStamp(d)) '= &H5E1FC7C2 End Sub Property Get timeStampToDate(timestamp As Long) As String On Error Resume Next Dim base As Date Dim compiled As Date base = DateSerial(1970, 1, 1) compiled = DateAdd("s", timestamp, base) timeStampToDate = Format(compiled, "mmm d yyyy h:nn:ss") End Property Function DatetoTimeStamp(d As Date) As Long On Error Resume Next Dim base As Date Dim compiled As Date base = DateSerial(1970, 1, 1) DatetoTimeStamp = DateDiff("s", base, d) End Function Of for a standalone version: (x64 safe) Function GetCompileTime(Optional ByVal exe As String) As String Dim f As Long, i As Integer Dim stamp As Long, e_lfanew As Long Dim base As Date, compiled As Date On Error GoTo errExit If Len(exe) = 0 Then exe = App.Path & "" & App.EXEName & ".exe" End If FileLen exe 'throw error if not exist f = FreeFile Open exe For Binary Access Read As f Get f, , i If i <> &H5A4D Then GoTo errExit 'MZ check Get f, 60 + 1, e_lfanew Get f, e_lfanew + 1, i If i <> &H4550 Then GoTo errExit 'PE check Get f, e_lfanew + 9, stamp Close f base = DateSerial(1970, 1, 1) compiled = DateAdd("s", stamp, base) GetCompileTime = Format(compiled, "ddd, mmm d yyyy, h:nn:ss ") Exit Function errExit: Close f End Function Comments: (1)On 03.19.20 - 11:27am qvb6 wrote:
|
About Me More Blogs Main Site
|
||||||||||||||||||||||||||||||||||