mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:23:01 +00:00
[SHUTDOWN] Actually all shutdown.exe utilities from all Windows (>= XP) versions (and not just Vista+) support a comment string of up to 512, *EVEN IF* they mention in their help message that the comment can only be up to 127 characters long. I have really tested that ;-) (And what is more, shutdown's utility from Whistler support an arbitrary comment length!) So here I remove the code that imposes this limit and I just check for no more than 512 characters. I also fix an out-of-bounds check for argv.
This commit is contained in:
parent
11f0e2c0f6
commit
f34a30fec4
3 changed files with 2 additions and 56 deletions
|
@ -45,59 +45,6 @@ REASON shutdownReason[] =
|
|||
{L"P" , 7, 0, SHTDN_REASON_MAJOR_POWER | SHTDN_REASON_MINOR_ENVIRONMENT} /* Legacy API shutdown (Planned) */
|
||||
};
|
||||
|
||||
/*
|
||||
* This command helps to work around the fact that the shutdown utility has
|
||||
* different upper limits for the comment flag since each version of Windows
|
||||
* seems to have different upper limits.
|
||||
*/
|
||||
BOOL CheckCommentLength(LPCWSTR comment)
|
||||
{
|
||||
DWORD finalLength = 0;
|
||||
size_t strLength = 0;
|
||||
DWORD osVersion = 0;
|
||||
DWORD osMajorVersion = 0;
|
||||
DWORD osMinorVersion = 0;
|
||||
|
||||
/* An empty string is always valid. */
|
||||
if (!comment || *comment == 0)
|
||||
return TRUE;
|
||||
|
||||
/* Grab the version of the current Operating System. */
|
||||
osVersion = GetVersion();
|
||||
|
||||
osMajorVersion = (DWORD)(LOBYTE(LOWORD(osVersion)));
|
||||
osMinorVersion = (DWORD)(HIBYTE(LOWORD(osVersion)));
|
||||
|
||||
/*
|
||||
* Check to make sure that the proper length is being used
|
||||
* based upon the version of Windows currently being used.
|
||||
*/
|
||||
if (osMajorVersion == 5) /* Windows XP/2003 */
|
||||
{
|
||||
if ((osMinorVersion == 1) || (osMinorVersion == 2))
|
||||
{
|
||||
finalLength = 127;
|
||||
}
|
||||
}
|
||||
else if (osMajorVersion == 6) /* Windows Vista/7/2008 */
|
||||
{
|
||||
if ((osMinorVersion == 0) || (osMinorVersion == 1))
|
||||
{
|
||||
finalLength = 512;
|
||||
}
|
||||
}
|
||||
|
||||
/* Grab the length of the comment string. */
|
||||
strLength = wcslen(comment);
|
||||
|
||||
/*
|
||||
* Compare the size of the string to make sure
|
||||
* it fits with the current version of Windows,
|
||||
* and return TRUE or FALSE accordingly.
|
||||
*/
|
||||
return (strLength <= finalLength);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function parses the reason code to a usable format that will specify
|
||||
* why the user wants to shut the computer down. Although this is used for
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue