mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-02 12:23:31 +00:00
- Bugfix: As szBuf was not null-terminated after the _tcscpy, the Processor Name String could have been wrapped wrong (ie. when it contained more spaces after character 30)
- Use a consistent indentation in SetProcNameString svn path=/trunk/; revision=27781
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* PURPOSE: General System Information
|
||||
* COPYRIGHT: Copyright Thomas Weidenmueller <[email protected]>
|
||||
* Copyright 2006 Ged Murphy <[email protected]>
|
||||
* Copyright 2006 Colin Finck <[email protected]>
|
||||
* Copyright 2006-2007 Colin Finck <[email protected]>
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -118,83 +118,86 @@ SetProcNameString(HWND hwnd,
|
||||
UINT uID1,
|
||||
UINT uID2)
|
||||
{
|
||||
LPTSTR lpBuf = NULL;
|
||||
DWORD BufSize = 0;
|
||||
DWORD Type;
|
||||
INT Ret = 0;
|
||||
TCHAR szBuf[31];
|
||||
TCHAR* szLastSpace;
|
||||
INT LastSpace = 0;
|
||||
|
||||
if (RegQueryValueEx(hKey,
|
||||
Value,
|
||||
NULL,
|
||||
&Type,
|
||||
NULL,
|
||||
&BufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
lpBuf = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
BufSize);
|
||||
if (!lpBuf) return 0;
|
||||
LPTSTR lpBuf = NULL;
|
||||
DWORD BufSize = 0;
|
||||
DWORD Type;
|
||||
INT Ret = 0;
|
||||
TCHAR szBuf[31];
|
||||
TCHAR* szLastSpace;
|
||||
INT LastSpace = 0;
|
||||
|
||||
if (RegQueryValueEx(hKey,
|
||||
Value,
|
||||
NULL,
|
||||
&Type,
|
||||
NULL,
|
||||
&BufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
lpBuf = HeapAlloc(GetProcessHeap(),
|
||||
0,
|
||||
BufSize);
|
||||
if (!lpBuf) return 0;
|
||||
|
||||
if (RegQueryValueEx(hKey,
|
||||
Value,
|
||||
NULL,
|
||||
&Type,
|
||||
(PBYTE)lpBuf,
|
||||
&BufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
if(BufSize > ((30 + 1) * sizeof(TCHAR)))
|
||||
{
|
||||
/* Wrap the Processor Name String like XP does: *
|
||||
* - Take the first 30 characters and look for the last space. *
|
||||
* Then wrap the string after this space. *
|
||||
* - If no space is found, wrap the string after character 30. *
|
||||
* *
|
||||
* For example the Processor Name String of a Pentium 4 is right-aligned. *
|
||||
* With this wrapping the first line looks centered. */
|
||||
if (RegQueryValueEx(hKey,
|
||||
Value,
|
||||
NULL,
|
||||
&Type,
|
||||
(PBYTE)lpBuf,
|
||||
&BufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
if(BufSize > ((30 + 1) * sizeof(TCHAR)))
|
||||
{
|
||||
/* Wrap the Processor Name String like XP does: *
|
||||
* - Take the first 30 characters and look for the last space. *
|
||||
* Then wrap the string after this space. *
|
||||
* - If no space is found, wrap the string after character 30. *
|
||||
* *
|
||||
* For example the Processor Name String of a Pentium 4 is right-aligned. *
|
||||
* With this wrapping the first line looks centered. */
|
||||
|
||||
_tcsncpy(szBuf, lpBuf, 30);
|
||||
szLastSpace = _tcsrchr(szBuf, ' ');
|
||||
|
||||
if(szLastSpace == 0)
|
||||
LastSpace = 30;
|
||||
else
|
||||
LastSpace = (szLastSpace - szBuf);
|
||||
|
||||
_tcsncpy(szBuf, lpBuf, LastSpace);
|
||||
szBuf[LastSpace] = 0;
|
||||
|
||||
SetDlgItemText(hwnd,
|
||||
uID1,
|
||||
szBuf);
|
||||
|
||||
SetDlgItemText(hwnd,
|
||||
uID2,
|
||||
lpBuf+LastSpace+1);
|
||||
|
||||
/* Return the number of used lines */
|
||||
Ret = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDlgItemText(hwnd,
|
||||
uID1,
|
||||
lpBuf);
|
||||
|
||||
Ret = 1;
|
||||
}
|
||||
}
|
||||
_tcsncpy(szBuf, lpBuf, 30);
|
||||
szBuf[30] = 0;
|
||||
szLastSpace = _tcsrchr(szBuf, ' ');
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
lpBuf);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
if(szLastSpace == 0)
|
||||
LastSpace = 30;
|
||||
else
|
||||
{
|
||||
LastSpace = (szLastSpace - szBuf);
|
||||
szBuf[LastSpace] = 0;
|
||||
}
|
||||
|
||||
_tcsncpy(szBuf, lpBuf, LastSpace);
|
||||
|
||||
SetDlgItemText(hwnd,
|
||||
uID1,
|
||||
szBuf);
|
||||
|
||||
SetDlgItemText(hwnd,
|
||||
uID2,
|
||||
lpBuf+LastSpace+1);
|
||||
|
||||
/* Return the number of used lines */
|
||||
Ret = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDlgItemText(hwnd,
|
||||
uID1,
|
||||
lpBuf);
|
||||
|
||||
Ret = 1;
|
||||
}
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(),
|
||||
0,
|
||||
lpBuf);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static VOID
|
||||
|
||||
Reference in New Issue
Block a user