mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 12:55:42 +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;
|
||||
SYSTEMTIME SysTime, LocalTime;
|
||||
UINT Length;
|
||||
TIME_ZONE_INFORMATION TimeInfo;
|
||||
|
||||
hFile = CreateFileW(pFullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (!hFile)
|
||||
|
@ -30,10 +31,13 @@ GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize)
|
|||
}
|
||||
CloseHandle(hFile);
|
||||
|
||||
if(!GetTimeZoneInformation(&TimeInfo))
|
||||
return FALSE;
|
||||
|
||||
if (!FileTimeToSystemTime(&AccessTime, &SysTime))
|
||||
return FALSE;
|
||||
|
||||
if (!SystemTimeToTzSpecificLocalTime(NULL, &SysTime, &LocalTime))
|
||||
if (!SystemTimeToTzSpecificLocalTime(&TimeInfo, &SysTime, &LocalTime))
|
||||
return FALSE;
|
||||
|
||||
Length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &LocalTime, NULL, szTime, szTimeSize);
|
||||
|
@ -82,7 +86,7 @@ DriverFilesCallback(IN PVOID Context,
|
|||
else
|
||||
{
|
||||
/* set file version */
|
||||
if (GetFileVersion(pFullPath, szVer))
|
||||
if (GetFileVersion(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
|
||||
SendMessageW(hDlgCtrls[1], WM_SETTEXT, 0, (LPARAM)szVer);
|
||||
/* set file time */
|
||||
if (GetFileModifyTime(pFullPath, szVer, sizeof(szVer)/sizeof(WCHAR)))
|
||||
|
|
|
@ -100,7 +100,7 @@ FindProviderIndex(LPCWSTR szGuid, DIRECTPLAY_GUID * PreDefProviders)
|
|||
}
|
||||
|
||||
BOOL
|
||||
GetFileVersion(LPCWSTR szAppName, WCHAR * szVer)
|
||||
GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize)
|
||||
{
|
||||
UINT VerSize;
|
||||
DWORD DummyHandle;
|
||||
|
@ -150,9 +150,14 @@ GetFileVersion(LPCWSTR szAppName, WCHAR * szVer)
|
|||
pResult = NULL;
|
||||
bResult = VerQueryValueW(pBuf, szBuffer, (LPVOID *)&pResult, &VerSize);
|
||||
|
||||
if (VerSize && bResult && pResult)
|
||||
if (VerSize < szVerSize && bResult && 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;
|
||||
}
|
||||
|
||||
|
@ -254,7 +259,7 @@ EnumerateServiceProviders(HKEY hKey, HWND hDlgCtrl, DIRECTPLAY_GUID * PreDefProv
|
|||
Item.iItem = ProviderIndex + ItemCount;
|
||||
SendMessageW(hDlgCtrl, LVM_SETITEM, 0, (LPARAM)&Item);
|
||||
/* retrieve file version */
|
||||
if (!GetFileVersion(szResult, szTemp))
|
||||
if (!GetFileVersion(szResult, szTemp, sizeof(szTemp)/sizeof(WCHAR)))
|
||||
{
|
||||
szTemp[0] = L'\0';
|
||||
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 GetFileVersion(LPCWSTR szAppName, WCHAR * szVer);
|
||||
BOOL GetFileVersion(LPCWSTR szAppName, WCHAR * szVer, DWORD szVerSize);
|
||||
BOOL GetFileModifyTime(LPCWSTR pFullPath, WCHAR * szTime, int szTimeSize);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue