[KERNEL32][CONSRV]

Fix few MSVC dword -> short warnings (basically). Thanks GCC for not having noticed them...

svn path=/branches/condrv_restructure/; revision=63804
This commit is contained in:
Hermès Bélusca-Maïto 2014-08-04 17:13:43 +00:00
parent 9fd5cfb5f8
commit e3a5ed0e2b
5 changed files with 52 additions and 54 deletions

View file

@ -20,9 +20,9 @@
static BOOL
IntAddConsoleAlias(LPCVOID Source,
DWORD SourceBufferLength,
USHORT SourceBufferLength,
LPCVOID Target,
DWORD TargetBufferLength,
USHORT TargetBufferLength,
LPCVOID lpExeName,
BOOLEAN bUnicode)
{
@ -31,9 +31,9 @@ IntAddConsoleAlias(LPCVOID Source,
PCSR_CAPTURE_BUFFER CaptureBuffer;
ULONG CapturedStrings;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@ -43,7 +43,7 @@ IntAddConsoleAlias(LPCVOID Source,
/* Determine the needed sizes */
ConsoleAliasRequest->SourceLength = SourceBufferLength;
ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ConsoleAliasRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ConsoleAliasRequest->Unicode =
ConsoleAliasRequest->Unicode2 = bUnicode;
@ -120,9 +120,8 @@ AddConsoleAliasW(LPCWSTR lpSource,
LPCWSTR lpTarget,
LPCWSTR lpExeName)
{
DWORD SourceBufferLength, TargetBufferLength;
SourceBufferLength = wcslen(lpSource) * sizeof(WCHAR);
TargetBufferLength = (lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0);
USHORT SourceBufferLength = (USHORT)wcslen(lpSource) * sizeof(WCHAR);
USHORT TargetBufferLength = (USHORT)(lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0);
DPRINT1("AddConsoleAliasW entered with lpSource '%S' lpTarget '%S' lpExeName '%S'\n",
lpSource, lpTarget, lpExeName);
@ -145,9 +144,8 @@ AddConsoleAliasA(LPCSTR lpSource,
LPCSTR lpTarget,
LPCSTR lpExeName)
{
DWORD SourceBufferLength, TargetBufferLength;
SourceBufferLength = strlen(lpSource) * sizeof(CHAR);
TargetBufferLength = (lpTarget ? strlen(lpTarget) * sizeof(CHAR) : 0);
USHORT SourceBufferLength = (USHORT)strlen(lpSource) * sizeof(CHAR);
USHORT TargetBufferLength = (USHORT)(lpTarget ? strlen(lpTarget) * sizeof(CHAR) : 0);
DPRINT1("AddConsoleAliasA entered with lpSource '%s' lpTarget '%s' lpExeName '%s'\n",
lpSource, lpTarget, lpExeName);
@ -163,9 +161,9 @@ AddConsoleAliasA(LPCSTR lpSource,
static DWORD
IntGetConsoleAlias(LPVOID Source,
DWORD SourceBufferLength,
USHORT SourceBufferLength,
LPVOID Target,
DWORD TargetBufferLength,
USHORT TargetBufferLength,
LPVOID lpExeName,
BOOLEAN bUnicode)
{
@ -173,7 +171,7 @@ IntGetConsoleAlias(LPVOID Source,
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (Source == NULL || Target == NULL)
{
@ -181,7 +179,7 @@ IntGetConsoleAlias(LPVOID Source,
return 0;
}
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@ -191,7 +189,7 @@ IntGetConsoleAlias(LPVOID Source,
/* Determine the needed sizes */
ConsoleAliasRequest->SourceLength = SourceBufferLength;
ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ConsoleAliasRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ConsoleAliasRequest->Unicode =
ConsoleAliasRequest->Unicode2 = bUnicode;
@ -240,9 +238,9 @@ IntGetConsoleAlias(LPVOID Source,
}
/* Copy the returned target string into the user buffer */
memcpy(Target,
ConsoleAliasRequest->Target,
ConsoleAliasRequest->TargetLength);
RtlCopyMemory(Target,
ConsoleAliasRequest->Target,
ConsoleAliasRequest->TargetLength);
/* Release the capture buffer and exit */
CsrFreeCaptureBuffer(CaptureBuffer);
@ -265,7 +263,7 @@ GetConsoleAliasW(LPWSTR lpSource,
lpSource, lpExeName);
return IntGetConsoleAlias(lpSource,
wcslen(lpSource) * sizeof(WCHAR),
(USHORT)wcslen(lpSource) * sizeof(WCHAR),
lpTargetBuffer,
TargetBufferLength,
lpExeName,
@ -287,7 +285,7 @@ GetConsoleAliasA(LPSTR lpSource,
lpSource, lpExeName);
return IntGetConsoleAlias(lpSource,
strlen(lpSource) * sizeof(CHAR),
(USHORT)strlen(lpSource) * sizeof(CHAR),
lpTargetBuffer,
TargetBufferLength,
lpExeName,
@ -305,9 +303,9 @@ IntGetConsoleAliases(LPVOID AliasBuffer,
PCONSOLE_GETALLALIASES GetAllAliasesRequest = &ApiMessage.Data.GetAllAliasesRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@ -316,7 +314,7 @@ IntGetConsoleAliases(LPVOID AliasBuffer,
GetAllAliasesRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
/* Determine the needed sizes */
GetAllAliasesRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetAllAliasesRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetAllAliasesRequest->Unicode =
GetAllAliasesRequest->Unicode2 = bUnicode;
@ -354,9 +352,9 @@ IntGetConsoleAliases(LPVOID AliasBuffer,
}
/* Copy the returned aliases string into the user buffer */
memcpy(AliasBuffer,
GetAllAliasesRequest->AliasesBuffer,
GetAllAliasesRequest->AliasesBufferLength);
RtlCopyMemory(AliasBuffer,
GetAllAliasesRequest->AliasesBuffer,
GetAllAliasesRequest->AliasesBufferLength);
/* Release the capture buffer and exit */
CsrFreeCaptureBuffer(CaptureBuffer);
@ -410,16 +408,16 @@ IntGetConsoleAliasesLength(LPVOID lpExeName, BOOLEAN bUnicode)
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &ApiMessage.Data.GetAllAliasesLengthRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
GetAllAliasesLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
GetAllAliasesLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetAllAliasesLengthRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetAllAliasesLengthRequest->Unicode =
GetAllAliasesLengthRequest->Unicode2 = bUnicode;
@ -511,9 +509,9 @@ IntGetConsoleAliasExes(PVOID lpExeNameBuffer,
return 0;
}
memcpy(lpExeNameBuffer,
GetAliasesExesRequest->ExeNames,
GetAliasesExesRequest->Length);
RtlCopyMemory(lpExeNameBuffer,
GetAliasesExesRequest->ExeNames,
GetAliasesExesRequest->Length);
CsrFreeCaptureBuffer(CaptureBuffer);

View file

@ -1887,10 +1887,10 @@ IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
ULONG NumChars = (ULONG)(lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) : strlen(lpConsoleTitle)) : 0);
TitleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
TitleRequest->Length = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
TitleRequest->Unicode = bUnicode;
CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);

View file

@ -58,16 +58,16 @@ IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOLEAN bUnicode)
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &ApiMessage.Data.ExpungeCommandHistoryRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return;
}
ExpungeCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
ExpungeCommandHistoryRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ExpungeCommandHistoryRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ExpungeCommandHistoryRequest->Unicode =
ExpungeCommandHistoryRequest->Unicode2 = bUnicode;
@ -106,9 +106,9 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &ApiMessage.Data.GetCommandHistoryRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
@ -116,7 +116,7 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName
GetCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
GetCommandHistoryRequest->HistoryLength = cbHistory;
GetCommandHistoryRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetCommandHistoryRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetCommandHistoryRequest->Unicode =
GetCommandHistoryRequest->Unicode2 = bUnicode;
@ -153,9 +153,9 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName
return 0;
}
memcpy(lpHistory,
GetCommandHistoryRequest->History,
GetCommandHistoryRequest->HistoryLength);
RtlCopyMemory(lpHistory,
GetCommandHistoryRequest->History,
GetCommandHistoryRequest->HistoryLength);
CsrFreeCaptureBuffer(CaptureBuffer);
@ -170,16 +170,16 @@ IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &ApiMessage.Data.GetCommandHistoryLengthRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
GetCommandHistoryLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
GetCommandHistoryLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetCommandHistoryLengthRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
GetCommandHistoryLengthRequest->Unicode =
GetCommandHistoryLengthRequest->Unicode2 = bUnicode;
@ -225,9 +225,9 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &ApiMessage.Data.SetHistoryNumberCommandsRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
if (lpExeName == NULL || dwNumChars == 0)
if (lpExeName == NULL || NumChars == 0)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@ -235,7 +235,7 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
SetHistoryNumberCommandsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
SetHistoryNumberCommandsRequest->NumCommands = dwNumCommands;
SetHistoryNumberCommandsRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
SetHistoryNumberCommandsRequest->ExeLength = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
SetHistoryNumberCommandsRequest->Unicode =
SetHistoryNumberCommandsRequest->Unicode2 = bUnicode;

View file

@ -422,7 +422,7 @@ typedef struct
typedef struct
{
HANDLE ConsoleHandle;
DWORD Length;
ULONG Length;
PVOID Title;
BOOLEAN Unicode;
} CONSOLE_GETSETCONSOLETITLE, *PCONSOLE_GETSETCONSOLETITLE;

View file

@ -284,9 +284,9 @@ typedef struct _CONSOLE
/** Put those things in TEXTMODE_SCREEN_BUFFER ?? **/
PWCHAR LineBuffer; /* Current line being input, in line buffered mode */
WORD LineMaxSize; /* Maximum size of line in characters (including CR+LF) */
WORD LineSize; /* Current size of line */
WORD LinePos; /* Current position within line */
ULONG LineMaxSize; /* Maximum size of line in characters (including CR+LF) */
ULONG LineSize; /* Current size of line */
ULONG LinePos; /* Current position within line */
BOOLEAN LineComplete; /* User pressed enter, ready to send back to client */
BOOLEAN LineUpPressed;
BOOLEAN LineInsertToggle; /* Replace character over cursor instead of inserting */