From 13dcd751f012406744e53f702eaa4db60ac944e6 Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Thu, 29 Aug 2024 20:57:38 +0800 Subject: [PATCH 1/5] 1.14.7 --- Sandboxie/core/dll/kernel.c | 86 ++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index 3305ba5fb7..dcfa4acbca 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -74,6 +74,11 @@ typedef LANGID (*P_GetSystemDefaultLangID)(); typedef BOOL (*P_GetVolumeInformationByHandleW)(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize); +typedef void (*P_GetLocalTime)(LPSYSTEMTIME lpSystemTime); + +typedef void (*P_GetSystemTime)(LPSYSTEMTIME lpSystemTime); + +typedef void (*P_GetSystemTimeAsFileTime)(LPFILETIME lpSystemTimeAsFileTime); //typedef int (*P_GetLocaleInfoEx)(LPCWSTR lpLocaleName, LCTYPE LCType, LPWSTR lpLCData, int cchData); //typedef int (*P_GetLocaleInfoA)(LCID Locale, LCTYPE LCType, LPSTR lpLCData, int cchData); @@ -110,6 +115,9 @@ P_GetSystemDefaultLocaleName __sys_GetSystemDefaultLocaleName = NULL; P_GetSystemDefaultLCID __sys_GetSystemDefaultLCID = NULL; P_GetSystemDefaultLangID __sys_GetSystemDefaultLangID = NULL; P_GetVolumeInformationByHandleW __sys_GetVolumeInformationByHandleW = NULL; +P_GetSystemTime __sys_GetSystemTime = NULL; +P_GetSystemTimeAsFileTime __sys_GetSystemTimeAsFileTime = NULL; +P_GetLocalTime __sys_GetLocalTime = NULL; LCID Kernel_CustomLCID = 0; @@ -161,7 +169,12 @@ static LCID Kernel_GetSystemDefaultLCID(); static LANGID Kernel_GetSystemDefaultLangID(); static BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameBuffer, DWORD nVolumeNameSize, LPDWORD lpVolumeSerialNumber, LPDWORD lpMaximumComponentLength, LPDWORD lpFileSystemFlags, LPWSTR lpFileSystemNameBuffer, DWORD nFileSystemNameSize); - + +static void Kernel_GetLocalTime(LPSYSTEMTIME lpSystemTime); + +static void Kernel_GetSystemTime(LPSYSTEMTIME lpSystemTime); + +static void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime); //--------------------------------------------------------------------------- // Kernel_Init //--------------------------------------------------------------------------- @@ -270,6 +283,11 @@ _FX BOOLEAN Kernel_Init() SBIEDLL_HOOK(Kernel_, GetVolumeInformationByHandleW); } } + if (SbieApi_QueryConfBool(NULL, L"TimeOffset", FALSE)) { + SBIEDLL_HOOK(Kernel_, GetSystemTime); + SBIEDLL_HOOK(Kernel_, GetSystemTimeAsFileTime); + SBIEDLL_HOOK(Kernel_, GetLocalTime); + } return TRUE; } @@ -542,3 +560,69 @@ _FX BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameB } return rtn; } +_FX void Kernel_GetLocalTime(LPSYSTEMTIME lpSystemTime) { + __sys_GetLocalTime(lpSystemTime); + if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { + lpSystemTime->wYear += SbieApi_QueryConfNumber(NULL,"TimeOffsetYear",0); + lpSystemTime->wDay += SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + + } + else { + lpSystemTime->wYear -= SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + } +} + +_FX void Kernel_GetSystemTime(LPSYSTEMTIME lpSystemTime) { + __sys_GetSystemTime(lpSystemTime); + if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { + lpSystemTime->wYear += SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay += SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + + } + else { + lpSystemTime->wYear -= SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + } +} + +_FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { + LPSYSTEMTIME lpSystemTime; + __sys_GetSystemTimeAsFileTime(lpSystemTimeAsFileTime); + if (FileTimeToSystemTime(lpSystemTimeAsFileTime, lpSystemTime)) { + if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { + lpSystemTime->wYear += SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay += SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + + } + else { + lpSystemTime->wYear -= SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + } + SystemTimeToFileTime(lpSystemTime, lpSystemTimeAsFileTime); + } +} From 03b9b42fb0805f5761003f84f46418f1379b4781 Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Thu, 29 Aug 2024 21:42:57 +0800 Subject: [PATCH 2/5] fix --- Sandboxie/core/dll/kernel.c | 72 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index dcfa4acbca..da708dfc9d 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -563,42 +563,42 @@ _FX BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameB _FX void Kernel_GetLocalTime(LPSYSTEMTIME lpSystemTime) { __sys_GetLocalTime(lpSystemTime); if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { - lpSystemTime->wYear += SbieApi_QueryConfNumber(NULL,"TimeOffsetYear",0); - lpSystemTime->wDay += SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); - lpSystemTime->wHour += SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); - lpSystemTime->wMonth += SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); - lpSystemTime->wMinute += SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); - lpSystemTime->wSecond += SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + lpSystemTime->wYear += (WORD)SbieApi_QueryConfNumber(NULL,"TimeOffsetYear",0); + lpSystemTime->wDay += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } else { - lpSystemTime->wYear -= SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); - lpSystemTime->wDay -= SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); - lpSystemTime->wHour -= SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); - lpSystemTime->wMonth -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); - lpSystemTime->wMinute -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); - lpSystemTime->wSecond -= SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + lpSystemTime->wYear -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } } _FX void Kernel_GetSystemTime(LPSYSTEMTIME lpSystemTime) { __sys_GetSystemTime(lpSystemTime); if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { - lpSystemTime->wYear += SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); - lpSystemTime->wDay += SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); - lpSystemTime->wHour += SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); - lpSystemTime->wMonth += SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); - lpSystemTime->wMinute += SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); - lpSystemTime->wSecond += SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + lpSystemTime->wYear += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } else { - lpSystemTime->wYear -= SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); - lpSystemTime->wDay -= SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); - lpSystemTime->wHour -= SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); - lpSystemTime->wMonth -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); - lpSystemTime->wMinute -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); - lpSystemTime->wSecond -= SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + lpSystemTime->wYear -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } } @@ -607,21 +607,21 @@ _FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { __sys_GetSystemTimeAsFileTime(lpSystemTimeAsFileTime); if (FileTimeToSystemTime(lpSystemTimeAsFileTime, lpSystemTime)) { if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { - lpSystemTime->wYear += SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); - lpSystemTime->wDay += SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); - lpSystemTime->wHour += SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); - lpSystemTime->wMonth += SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); - lpSystemTime->wMinute += SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); - lpSystemTime->wSecond += SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + lpSystemTime->wYear += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } else { - lpSystemTime->wYear -= SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); - lpSystemTime->wDay -= SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); - lpSystemTime->wHour -= SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); - lpSystemTime->wMonth -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); - lpSystemTime->wMinute -= SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); - lpSystemTime->wSecond -= SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + lpSystemTime->wYear -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } SystemTimeToFileTime(lpSystemTime, lpSystemTimeAsFileTime); } From 0b6c1d079d62fa1b266bfb82cae09707ef0b0d0e Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Thu, 29 Aug 2024 21:53:13 +0800 Subject: [PATCH 3/5] Fix --- Sandboxie/core/dll/kernel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index da708dfc9d..4d8afd338f 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -603,7 +603,8 @@ _FX void Kernel_GetSystemTime(LPSYSTEMTIME lpSystemTime) { } _FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { - LPSYSTEMTIME lpSystemTime; + LPSYSTEMTIME lpSystemTime=(LPSYSTEMTIME)malloc(sizeof(LPSYSTEMTIME)); + memset(lpSystemTimeAsFileTime, 0, sizeof(lpSystemTimeAsFileTime)); __sys_GetSystemTimeAsFileTime(lpSystemTimeAsFileTime); if (FileTimeToSystemTime(lpSystemTimeAsFileTime, lpSystemTime)) { if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { @@ -624,5 +625,6 @@ _FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } SystemTimeToFileTime(lpSystemTime, lpSystemTimeAsFileTime); + free(lpSystemTime); } } From e1d40caf0216ed85195afa6c795bf1fd84833faf Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Thu, 29 Aug 2024 22:02:58 +0800 Subject: [PATCH 4/5] fix --- Sandboxie/core/dll/kernel.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index 4d8afd338f..4ce65a71e9 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -79,6 +79,8 @@ typedef void (*P_GetLocalTime)(LPSYSTEMTIME lpSystemTime); typedef void (*P_GetSystemTime)(LPSYSTEMTIME lpSystemTime); typedef void (*P_GetSystemTimeAsFileTime)(LPFILETIME lpSystemTimeAsFileTime); + +typedef void (*P_GetSystemTimePreciseAsFileTime)(LPFILETIME lpSystemTimeAsFileTime); //typedef int (*P_GetLocaleInfoEx)(LPCWSTR lpLocaleName, LCTYPE LCType, LPWSTR lpLCData, int cchData); //typedef int (*P_GetLocaleInfoA)(LCID Locale, LCTYPE LCType, LPSTR lpLCData, int cchData); @@ -119,6 +121,8 @@ P_GetSystemTime __sys_GetSystemTime = NULL; P_GetSystemTimeAsFileTime __sys_GetSystemTimeAsFileTime = NULL; P_GetLocalTime __sys_GetLocalTime = NULL; +P_GetSystemTimePreciseAsFileTime __sys_GetSystemTimePreciseAsFileTime = NULL; + LCID Kernel_CustomLCID = 0; extern POOL* Dll_Pool; @@ -175,6 +179,8 @@ static void Kernel_GetLocalTime(LPSYSTEMTIME lpSystemTime); static void Kernel_GetSystemTime(LPSYSTEMTIME lpSystemTime); static void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime); + +static void Kernel_GetSystemTimePreciseAsFileTime(LPFILETIME lpSystemTimeAsFileTime); //--------------------------------------------------------------------------- // Kernel_Init //--------------------------------------------------------------------------- @@ -286,6 +292,10 @@ _FX BOOLEAN Kernel_Init() if (SbieApi_QueryConfBool(NULL, L"TimeOffset", FALSE)) { SBIEDLL_HOOK(Kernel_, GetSystemTime); SBIEDLL_HOOK(Kernel_, GetSystemTimeAsFileTime); + void* GetSystemTimePreciseAsFileTime = GetProcAddress(Dll_KernelBase ? Dll_KernelBase : Dll_Kernel32, "GetSystemTimePreciseAsFileTime"); + if (GetSystemTimePreciseAsFileTime) { + SBIEDLL_HOOK(Kernel_, GetSystemTimePreciseAsFileTime); + } SBIEDLL_HOOK(Kernel_, GetLocalTime); } return TRUE; @@ -628,3 +638,29 @@ _FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { free(lpSystemTime); } } +_FX void Kernel_GetSystemTimePreciseAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { + LPSYSTEMTIME lpSystemTime = (LPSYSTEMTIME)malloc(sizeof(LPSYSTEMTIME)); + memset(lpSystemTimeAsFileTime, 0, sizeof(lpSystemTimeAsFileTime)); + __sys_GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime); + if (FileTimeToSystemTime(lpSystemTimeAsFileTime, lpSystemTime)) { + if (SbieApi_QueryConfBool(NULL, L"TimeOffsetPlus", TRUE)) { + lpSystemTime->wYear += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond += (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + + } + else { + lpSystemTime->wYear -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetYear", 0); + lpSystemTime->wDay -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetDay", 0); + lpSystemTime->wHour -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetHour", 0); + lpSystemTime->wMonth -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMonth", 0); + lpSystemTime->wMinute -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetMinute", 0); + lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); + } + SystemTimeToFileTime(lpSystemTime, lpSystemTimeAsFileTime); + free(lpSystemTime); + } +} From 8f1d444854a3e8d214c6b5666fea5ec30be15636 Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Thu, 29 Aug 2024 22:05:22 +0800 Subject: [PATCH 5/5] fix --- Sandboxie/core/dll/kernel.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index 4ce65a71e9..b9d2590332 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -613,7 +613,7 @@ _FX void Kernel_GetSystemTime(LPSYSTEMTIME lpSystemTime) { } _FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { - LPSYSTEMTIME lpSystemTime=(LPSYSTEMTIME)malloc(sizeof(LPSYSTEMTIME)); + LPSYSTEMTIME lpSystemTime=(LPSYSTEMTIME)Dll_Alloc(sizeof(LPSYSTEMTIME)); memset(lpSystemTimeAsFileTime, 0, sizeof(lpSystemTimeAsFileTime)); __sys_GetSystemTimeAsFileTime(lpSystemTimeAsFileTime); if (FileTimeToSystemTime(lpSystemTimeAsFileTime, lpSystemTime)) { @@ -635,11 +635,11 @@ _FX void Kernel_GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } SystemTimeToFileTime(lpSystemTime, lpSystemTimeAsFileTime); - free(lpSystemTime); + Dll_Free(lpSystemTime); } } _FX void Kernel_GetSystemTimePreciseAsFileTime(LPFILETIME lpSystemTimeAsFileTime) { - LPSYSTEMTIME lpSystemTime = (LPSYSTEMTIME)malloc(sizeof(LPSYSTEMTIME)); + LPSYSTEMTIME lpSystemTime = (LPSYSTEMTIME)Dll_Alloc(sizeof(LPSYSTEMTIME)); memset(lpSystemTimeAsFileTime, 0, sizeof(lpSystemTimeAsFileTime)); __sys_GetSystemTimePreciseAsFileTime(lpSystemTimeAsFileTime); if (FileTimeToSystemTime(lpSystemTimeAsFileTime, lpSystemTime)) { @@ -661,6 +661,6 @@ _FX void Kernel_GetSystemTimePreciseAsFileTime(LPFILETIME lpSystemTimeAsFileTime lpSystemTime->wSecond -= (WORD)SbieApi_QueryConfNumber(NULL, "TimeOffsetSecond", 0); } SystemTimeToFileTime(lpSystemTime, lpSystemTimeAsFileTime); - free(lpSystemTime); + Dll_Free(lpSystemTime); } }