#include <windows.h>
#include <stdio.h>

void SetFileTimeTo2015(const wchar_t* filePath) {
    // Open the file with write access to modify its timestamps
    HANDLE hFile = CreateFile(
        filePath,                 // File path
        GENERIC_WRITE,            // Write access
        FILE_SHARE_READ,          // Allow other processes to read the file
        NULL,                     // Default security attributes
        OPEN_EXISTING,            // Open the existing file
        FILE_ATTRIBUTE_NORMAL,    // Normal file attributes
        NULL                      // No template file
    );

    if (hFile == INVALID_HANDLE_VALUE) {
        printf("Failed to open file. Error: %lu\\n", GetLastError());
        return;
    }

    // Define the desired timestamp (January 1, 2015, at 12:00:00 AM)
    SYSTEMTIME systemTime;
    systemTime.wYear = 2015;
    systemTime.wMonth = 9;
    systemTime.wDay = 17;
    systemTime.wHour = 5;
    systemTime.wMinute = 16;
    systemTime.wSecond = 13;
    systemTime.wMilliseconds = 0;

    // Convert SYSTEMTIME to FILETIME
    FILETIME fileTime;
    if (!SystemTimeToFileTime(&systemTime, &fileTime)) {
        printf("Failed to convert system time to file time. Error: %lu\\n", GetLastError());
        CloseHandle(hFile);
        return;
    }

    // Set the creation, last access, and last write times to the same timestamp
    if (!SetFileTime(hFile, &fileTime, &fileTime, &fileTime)) {
        printf("Failed to set file time. Error: %lu\\n", GetLastError());
    }
    else {
        printf("File timestamp successfully updated to 2015.\\n");
    }

    // Close the file handle
    CloseHandle(hFile);
}

int main() {
    const wchar_t* filePath = L"C:\\\\Users\\\\Evasion\\\\source\\\\repos\\\\KernelCallBacks\\\\x64\\\\Debug\\\\KernelCallBacks.exe"; // Replace with your file path

    SetFileTimeTo2015(filePath);

    return 0;
}