File Creation/Modifiy Time
Results 1 to 5 of 5

Thread: File Creation/Modifiy Time

  1. #1
    Senior Member
    Join Date
    Sep 2003
    Posts
    279

    File Creation/Modifiy Time

    Ever had a virus that sayd it was created in th year 1980? Or the year before your computer was created? Have you ever wanted to know how it was done? Well here is a little VB script that will explain it.

    This calls all the API and Constants needed
    Private Const GENERIC_WRITE = &H40000000
    Private Const OPEN_EXISTING = 3
    Private Const FILE_SHARE_READ = &H1
    Private Const FILE_SHARE_WRITE = &H2
    Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
    Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
    Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function LocalFileTimeToFileTime Lib "kernel32" (lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
    Private Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
    End Type
    Creats a var called SYSTEMTIME that will store the time settings in it
    Private Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
    End Type

    Private Sub Form_Load()
    'DIMS and SETS variables
    NOTE: strFileName should egual your file and path i.e. C:\autoexec.bat

    Dim strYear, strMonth, strDay, strHour, strMinute, strSecond, strFileName
    strFileName = "<FILE PATH AND NAME>"
    Dim m_Date As Date, lngHandle As Long
    Dim udtFileTime As FILETIME
    Dim udtLocalTime As FILETIME
    Dim udtSystemTime As SYSTEMTIME

    'Sets time
    udtSystemTime.wYear = strYear
    udtSystemTime.wMonth = strMonth
    udtSystemTime.wDay = strDay
    udtSystemTime.wDayOfWeek = strDay - 1
    udtSystemTime.wHour = strHour
    udtSystemTime.wMinute = strMinute
    udtSystemTime.wSecond = strSecond
    udtSystemTime.wMilliseconds = 0

    [b]' convert system time to local time[b]
    SystemTimeToFileTime udtSystemTime, udtLocalTime
    ' convert local time to GMT
    LocalFileTimeToFileTime udtLocalTime, udtFileTime
    ' open the file to get the filehandle
    lngHandle = CreateFile(strFileName, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
    ' change date/time property of the file
    SetFileTime lngHandle, udtFileTime, udtFileTime, udtFileTime
    ' close the handle
    CloseHandle lngHandle
    End Sub
    This script is also good if you want to hide a file from being searched for by Date Created or Modified. I belive that you can set a file's date to a minimum of January 1, 1600, and the maximun i am not sure of.

    I was just playing around with this and thought it would be a nice piece of information to add to the AO database.

    I included a compiled version of that script above so that you can test this if you want.
    AntiOnline Quick Forum Version 2b Click Here
    10010101000000110010001100111

  2. #2
    Member
    Join Date
    Sep 2003
    Posts
    76
    Haha, thats pretty cool, didn't know you could do that. Now that i think of it, itd be a funny joke to play on a friend. "Hey, check out my new program 'Blah Blah'. " Right click it: Created January 1, 1600.

  3. #3
    Senior Member
    Join Date
    Sep 2003
    Posts
    279
    lol, yes i did that also.
    AntiOnline Quick Forum Version 2b Click Here
    10010101000000110010001100111

  4. #4
    Senior Member
    Join Date
    Jun 2003
    Posts
    236
    or you could just use the touch command
    That which does not kill me makes me stronger -- Friedrich Nietzche

  5. #5
    Senior Member
    Join Date
    Sep 2003
    Posts
    279
    Yes, you could use that but this is how a program would go about changing its own creation time.

    Here is more information about the touch command

    http://publib16.boulder.ibm.com/pser...mds5/touch.htm
    AntiOnline Quick Forum Version 2b Click Here
    10010101000000110010001100111

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •