如何确定VB app编译/创建日期

Roj*_*ito 1 vb.net vb6 decompiling updates

我的公司使用的软件,在它的页脚部分列出了2001 - 2002年.这是否足以让人相信该计划收到的最后一次重大改革或更新将是在2001 - 02年?

如果没有,有没有办法通过反编译软件,它是用VB6编写的?

Ňɏs*_*arp 5

我忘了链接器将时间戳粘贴到PE标头中.这是一个简短的VB.NET小程序,用于读取PE标头并转换时间戳:

Private Function GetPEDate(filename As String) As DateTime

    Dim dtUINT As UInt32
    Using fs As Stream = New FileStream(filename, 
                        FileMode.Open, FileAccess.Read),
        rdr As New BinaryReader(fs)

        ' move to PE location (60; 70 for 64 bit but
        ' there is no such thing as a 64bit VB6 app)
        fs.Position = &H3C
        Dim peHDR As UInt32 = rdr.ReadUInt32()       ' offset of start location
        fs.Position = peHDR

        Dim tmpUINT = rdr.ReadUInt32()            ' PE sig
        Dim tmpShrt = rdr.ReadUInt16              ' machine
        tmpShrt = rdr.ReadUInt16                  ' sections

        dtUINT = rdr.ReadUInt32()                 ' linker timestamp

    End Using
    ' SEE NOTE
    Dim dtCompiled As New DateTime(1970, 1, 1, 0, 0, 0)

    dtCompiled = dtCompiled.AddSeconds(dtUINT)
    dtCompiled = dtCompiled.AddHours( _ 
            TimeZone.CurrentTimeZone.GetUtcOffset(dtCompiled).Hours)

    Return dtCompiled
End Function
Run Code Online (Sandbox Code Playgroud)

要使用它:

Dim dt = GetPEDate(FullFilePath)
Console.WriteLine("App was compiled approx: {0}", dt.ToString)
Run Code Online (Sandbox Code Playgroud)

输出:

应用程序编译约:4/6/2004 11:54:07 AM

我用一些实际的旧VB6应用程序以及一些x86 VB.NET应用程序对此进行了测试,并且DateTime返回的是与Explorer报告的CreatedDate和/或Modified Date相比较的.

最初的时间是3个小时.在MSDN文档明确规定:

该字段保存自1969年12月31日下午4:00以来的秒数

但它恰好在3小时后关闭,而我的TZ距离美国东海岸,西雅图或GMT不到3.一个快速的谷歌由Jeff Atwood(包括另一个PE读者)发表这篇文章.将基准日期更改为1/1/1970 00:00:00并添加UTC调整将返回与Explorer匹配的时间.

显然MSDN错误或基准日期已过时.1/1/1970似乎更有可能因为对应于POSIX/Unix时间戳.