Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper implementation for GetSystemTime and GetLocalTime #73

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions dll/kernel32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,19 +1133,36 @@ namespace kernel32 {

void WIN_FUNC GetSystemTime(SYSTEMTIME *lpSystemTime) {
DEBUG_LOG("GetSystemTime\n");
lpSystemTime->wYear = 0;
lpSystemTime->wMonth = 0;
lpSystemTime->wDayOfWeek = 0;
lpSystemTime->wDay = 0;
lpSystemTime->wHour = 0;
lpSystemTime->wMinute = 0;
lpSystemTime->wSecond = 0;

time_t t = time(NULL);
struct tm *tm = gmtime(&t);
assert(tm != NULL);

lpSystemTime->wYear = tm->tm_year + 1900;
lpSystemTime->wMonth = tm->tm_mon + 1;
lpSystemTime->wDayOfWeek = tm->tm_wday;
lpSystemTime->wDay = tm->tm_mday;
lpSystemTime->wHour = tm->tm_hour;
lpSystemTime->wMinute = tm->tm_min;
lpSystemTime->wSecond = tm->tm_sec;
lpSystemTime->wMilliseconds = 0;
}

void WIN_FUNC GetLocalTime(SYSTEMTIME *lpSystemTime) {
DEBUG_LOG("GetLocalTime\n");
GetSystemTime(lpSystemTime);

time_t t = time(NULL);
struct tm *tm = localtime(&t);
assert(tm != NULL);

lpSystemTime->wYear = tm->tm_year + 1900;
lpSystemTime->wMonth = tm->tm_mon + 1;
lpSystemTime->wDayOfWeek = tm->tm_wday;
lpSystemTime->wDay = tm->tm_mday;
lpSystemTime->wHour = tm->tm_hour;
lpSystemTime->wMinute = tm->tm_min;
lpSystemTime->wSecond = tm->tm_sec;
lpSystemTime->wMilliseconds = 0;
}

int WIN_FUNC SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime, FILETIME *lpFileTime) {
Expand Down
Loading