mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 07:33:20 +00:00
- query current time zone
- retrieve localized country for a version - pass length parameter to avoid potential buffer overflows svn path=/trunk/; revision=33187
This commit is contained in:
parent
5d1a36463e
commit
dd03a00484
3 changed files with 15 additions and 6 deletions
|
@ -18,6 +18,7 @@ GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize)
|
||||||
FILETIME AccessTime;
|
FILETIME AccessTime;
|
||||||
SYSTEMTIME SysTime, LocalTime;
|
SYSTEMTIME SysTime, LocalTime;
|
||||||
UINT Length;
|
UINT Length;
|
||||||
|
TIME_ZONE_INFORMATION TimeInfo;
|
||||||
|
|
||||||
hFile = CreateFileW(pFullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
hFile = CreateFileW(pFullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (!hFile)
|
if (!hFile)
|
||||||
|
@ -30,10 +31,13 @@ GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize)
|
||||||
}
|
}
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
if(!GetTimeZoneInformation(&TimeInfo))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (!FileTimeToSystemTime(&AccessTime, &SysTime))
|
if (!FileTimeToSystemTime(&AccessTime, &SysTime))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!SystemTimeToTzSpecificLocalTime(NULL, &SysTime, &LocalTime))
|
if (!SystemTimeToTzSpecificLocalTime(&TimeInfo, &SysTime, &LocalTime))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
Length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &LocalTime, NULL, szTime, szTimeSize);
|
Length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &LocalTime, NULL, szTime, szTimeSize);
|
||||||
|
@ -82,7 +86,7 @@ DriverFilesCallback(IN PVOID Context,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* set file version */
|
/* set file version */
|
||||||
if (GetFileVersion(pFullPath, szVer))
|
if (GetFileVersion(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
|
||||||
SendMessageW(hDlgCtrls[1], WM_SETTEXT, 0, (LPARAM)szVer);
|
SendMessageW(hDlgCtrls[1], WM_SETTEXT, 0, (LPARAM)szVer);
|
||||||
/* set file time */
|
/* set file time */
|
||||||
if (GetFileModifyTime(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
|
if (GetFileModifyTime(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
|
||||||
|
|
|
@ -100,7 +100,7 @@ FindProviderIndex(LPCWSTR szGuid, DIRECTPLAY_GUID * PreDefProviders)
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
GetFileVersion(LPCWSTR szAppName, WCHAR * szVer)
|
GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize)
|
||||||
{
|
{
|
||||||
UINT VerSize;
|
UINT VerSize;
|
||||||
DWORD DummyHandle;
|
DWORD DummyHandle;
|
||||||
|
@ -150,9 +150,14 @@ GetFileVersion(LPCWSTR szAppName, WCHAR * szVer)
|
||||||
pResult = NULL;
|
pResult = NULL;
|
||||||
bResult = VerQueryValueW(pBuf, szBuffer, (LPVOID *)&pResult, &VerSize);
|
bResult = VerQueryValueW(pBuf, szBuffer, (LPVOID *)&pResult, &VerSize);
|
||||||
|
|
||||||
if (VerSize && bResult && pResult)
|
if (VerSize < szVerSize && bResult && pResult)
|
||||||
{
|
{
|
||||||
wcscpy(szVer, pResult);
|
wcscpy(szVer, pResult);
|
||||||
|
if (GetLocaleInfoW(MAKELCID(lang, SORT_DEFAULT), LOCALE_SLANGUAGE, &szVer[VerSize], szVerSize-VerSize))
|
||||||
|
{
|
||||||
|
szVer[VerSize-1] = L' ';
|
||||||
|
szVer[szVerSize-1] = L'\0';
|
||||||
|
}
|
||||||
bResult = TRUE;
|
bResult = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +259,7 @@ EnumerateServiceProviders(HKEY hKey, HWND hDlgCtrl, DIRECTPLAY_GUID * PreDefProv
|
||||||
Item.iItem = ProviderIndex + ItemCount;
|
Item.iItem = ProviderIndex + ItemCount;
|
||||||
SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
|
SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
|
||||||
/* retrieve file version */
|
/* retrieve file version */
|
||||||
if (!GetFileVersion(szResult, szTemp))
|
if (!GetFileVersion(szResult, szTemp, sizeof(szTemp)/sizeof(WCHAR)))
|
||||||
{
|
{
|
||||||
szTemp[0] = L'\0';
|
szTemp[0] = L'\0';
|
||||||
LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTemp, sizeof(szTemp)/sizeof(WCHAR));
|
LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTemp, sizeof(szTemp)/sizeof(WCHAR));
|
||||||
|
|
|
@ -43,6 +43,6 @@ BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPW
|
||||||
BOOL StartDDTest(HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult, INT TestNr);
|
BOOL StartDDTest(HWND hWnd, HINSTANCE hInstance, INT resTestDescription, INT resResult, INT TestNr);
|
||||||
|
|
||||||
|
|
||||||
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer);
|
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize);
|
||||||
BOOL GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize);
|
BOOL GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue