[REACTOS] Fix a number of MSVC warnings

This commit is contained in:
Timo Kreuzer 2021-06-29 18:50:15 +02:00
parent b1c6c91d1f
commit 5d8e834897
43 changed files with 175 additions and 86 deletions

View file

@ -338,7 +338,7 @@ LoadDialog(
LPWORD Offset; LPWORD Offset;
WORD FontSize; WORD FontSize;
WCHAR FontName[100]; WCHAR FontName[100];
WORD Length; SIZE_T Length;
int width; int width;
DWORD units = GetDialogBaseUnits(); DWORD units = GetDialogBaseUnits();

View file

@ -73,7 +73,8 @@ static
DWORD DWORD
ServiceInit(VOID) ServiceInit(VOID)
{ {
LSA_STRING ProcessName, PackageName; LSA_STRING ProcessName = RTL_CONSTANT_STRING("Workstation");
LSA_STRING PackageName = RTL_CONSTANT_STRING(MSV1_0_PACKAGE_NAME);
LSA_OPERATIONAL_MODE Mode; LSA_OPERATIONAL_MODE Mode;
HANDLE hThread; HANDLE hThread;
NTSTATUS Status; NTSTATUS Status;
@ -84,10 +85,6 @@ ServiceInit(VOID)
VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo); VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
GetVersionExW(&VersionInfo); GetVersionExW(&VersionInfo);
ProcessName.Buffer = "Workstation";
ProcessName.Length = strlen(ProcessName.Buffer);
ProcessName.MaximumLength = ProcessName.Length + 1;
Status = LsaRegisterLogonProcess(&ProcessName, Status = LsaRegisterLogonProcess(&ProcessName,
&LsaHandle, &LsaHandle,
&Mode); &Mode);
@ -97,10 +94,6 @@ ServiceInit(VOID)
return 1; return 1;
} }
PackageName.Buffer = MSV1_0_PACKAGE_NAME;
PackageName.Length = strlen(PackageName.Buffer);
PackageName.MaximumLength = PackageName.Length + 1;
Status = LsaLookupAuthenticationPackage(LsaHandle, Status = LsaLookupAuthenticationPackage(LsaHandle,
&PackageName, &PackageName,
&LsaAuthenticationPackage); &LsaAuthenticationPackage);

View file

@ -320,7 +320,7 @@ CheckForValidPEAndVendor(
RtlStringCbCopyNW(VendorName->Buffer, VendorName->MaximumLength, RtlStringCbCopyNW(VendorName->Buffer, VendorName->MaximumLength,
pvData, BufLen * sizeof(WCHAR)); pvData, BufLen * sizeof(WCHAR));
VendorName->Length = wcslen(VendorName->Buffer) * sizeof(WCHAR); VendorName->Length = (USHORT)wcslen(VendorName->Buffer) * sizeof(WCHAR);
Success = TRUE; Success = TRUE;
} }

View file

@ -78,7 +78,7 @@ CreateNestedKey(PHANDLE KeyHandle,
break; break;
} }
*Ptr = (WCHAR)0; *Ptr = (WCHAR)0;
LocalKeyName.Length = wcslen(LocalKeyName.Buffer) * sizeof(WCHAR); LocalKeyName.Length = (Ptr - LocalKeyName.Buffer) * sizeof(WCHAR);
Status = NtCreateKey(&LocalKeyHandle, Status = NtCreateKey(&LocalKeyHandle,
KEY_CREATE_SUB_KEY, KEY_CREATE_SUB_KEY,
@ -110,7 +110,7 @@ CreateNestedKey(PHANDLE KeyHandle,
NtClose(LocalKeyHandle); NtClose(LocalKeyHandle);
LocalKeyName.Buffer[LocalKeyName.Length / sizeof(WCHAR)] = L'\\'; LocalKeyName.Buffer[LocalKeyName.Length / sizeof(WCHAR)] = L'\\';
LocalKeyName.Length = wcslen(LocalKeyName.Buffer) * sizeof(WCHAR); LocalKeyName.Length = (USHORT)wcslen(LocalKeyName.Buffer) * sizeof(WCHAR);
Status = NtCreateKey(&LocalKeyHandle, Status = NtCreateKey(&LocalKeyHandle,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,

View file

@ -1026,7 +1026,7 @@ ReadCommand(
{ {
/* If this character insertion will cause screen scrolling, /* If this character insertion will cause screen scrolling,
* adjust the saved origin of the command prompt. */ * adjust the saved origin of the command prompt. */
tempscreen = strlen(str + current) + curx; tempscreen = (USHORT)strlen(str + current) + curx;
if ((tempscreen % State->maxx) == (State->maxx - 1) && if ((tempscreen % State->maxx) == (State->maxx - 1) &&
(tempscreen / State->maxx) + cury == (State->maxy - 1)) (tempscreen / State->maxx) + cury == (State->maxy - 1))
{ {

View file

@ -140,7 +140,7 @@ MUIClearPage(
CONSOLE_ClearStyledText(entry[index].X, CONSOLE_ClearStyledText(entry[index].X,
entry[index].Y, entry[index].Y,
entry[index].Flags, entry[index].Flags,
strlen(entry[index].Buffer)); (USHORT)strlen(entry[index].Buffer));
index++; index++;
} }
} }
@ -347,7 +347,7 @@ MUIClearText(
CONSOLE_ClearTextXY( CONSOLE_ClearTextXY(
entry[Index].X, entry[Index].X,
entry[Index].Y, entry[Index].Y,
(ULONG)strlen(entry[Index].Buffer)); (USHORT)strlen(entry[Index].Buffer));
/* Increment the index and loop over next entires with the same ID */ /* Increment the index and loop over next entires with the same ID */
Index++; Index++;
@ -404,7 +404,7 @@ MUIClearStyledText(
entry[Index].X, entry[Index].X,
entry[Index].Y, entry[Index].Y,
Flags, Flags,
(ULONG)strlen(entry[Index].Buffer)); (USHORT)strlen(entry[Index].Buffer));
/* Increment the index and loop over next entires with the same ID */ /* Increment the index and loop over next entires with the same ID */
Index++; Index++;

View file

@ -240,7 +240,7 @@ DrawProgressBar(
if (Bar->UpdateProgressProc && if (Bar->UpdateProgressProc &&
Bar->UpdateProgressProc(Bar, TRUE, TextBuffer, ARRAYSIZE(TextBuffer))) Bar->UpdateProgressProc(Bar, TRUE, TextBuffer, ARRAYSIZE(TextBuffer)))
{ {
coPos.X = Bar->Left + (Bar->Width - strlen(TextBuffer) + 1) / 2; coPos.X = Bar->Left + (Bar->Width - (USHORT)strlen(TextBuffer) + 1) / 2;
coPos.Y = Bar->Top; coPos.Y = Bar->Top;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
TextBuffer, TextBuffer,
@ -383,7 +383,7 @@ ProgressSetStep(
if (Bar->UpdateProgressProc && if (Bar->UpdateProgressProc &&
Bar->UpdateProgressProc(Bar, FALSE, TextBuffer, ARRAYSIZE(TextBuffer))) Bar->UpdateProgressProc(Bar, FALSE, TextBuffer, ARRAYSIZE(TextBuffer)))
{ {
coPos.X = Bar->Left + (Bar->Width - strlen(TextBuffer) + 1) / 2; coPos.X = Bar->Left + (Bar->Width - (USHORT)strlen(TextBuffer) + 1) / 2;
coPos.Y = Bar->Top; coPos.Y = Bar->Top;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,
TextBuffer, TextBuffer,

View file

@ -981,6 +981,7 @@ CabinetExtractFile(
PCFFOLDER CurrentFolder; PCFFOLDER CurrentFolder;
LARGE_INTEGER MaxDestFileSize; LARGE_INTEGER MaxDestFileSize;
LONG InputLength, OutputLength; LONG InputLength, OutputLength;
SIZE_T StringLength;
char Chunk[512]; char Chunk[512];
if (wcscmp(Search->Cabinet, CabinetContext->CabinetName) != 0) if (wcscmp(Search->Cabinet, CabinetContext->CabinetName) != 0)
@ -1039,8 +1040,9 @@ CabinetExtractFile(
{ {
RtlInitAnsiString(&AnsiString, Search->File->FileName); RtlInitAnsiString(&AnsiString, Search->File->FileName);
wcscpy(DestName, CabinetContext->DestPath); wcscpy(DestName, CabinetContext->DestPath);
UnicodeString.MaximumLength = sizeof(DestName) - wcslen(DestName) * sizeof(WCHAR); StringLength = wcslen(DestName);
UnicodeString.Buffer = DestName + wcslen(DestName); UnicodeString.MaximumLength = sizeof(DestName) - (USHORT)StringLength * sizeof(WCHAR);
UnicodeString.Buffer = DestName + StringLength;
UnicodeString.Length = 0; UnicodeString.Length = 0;
RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, FALSE); RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, FALSE);

View file

@ -1907,7 +1907,7 @@ ShowPartitionSizeInputBox(SHORT Left,
coPos.X = Left + 2; coPos.X = Left + 2;
coPos.Y = Top + 2; coPos.Y = Top + 2;
strcpy(Buffer, MUIGetString(STRING_PARTITIONSIZE)); strcpy(Buffer, MUIGetString(STRING_PARTITIONSIZE));
iLeft = coPos.X + strlen(Buffer) + 1; iLeft = coPos.X + (USHORT)strlen(Buffer) + 1;
iTop = coPos.Y; iTop = coPos.Y;
WriteConsoleOutputCharacterA(StdOutput, WriteConsoleOutputCharacterA(StdOutput,

View file

@ -96,7 +96,7 @@
* 30-Apr-2004 (Filip Navara <xnavara@volny.cz>) * 30-Apr-2004 (Filip Navara <xnavara@volny.cz>)
* Fixed problems when the screen was scrolled away. * Fixed problems when the screen was scrolled away.
* *
* 28-September-2007 (Hervé Poussineau) * 28-September-2007 (Hervé Poussineau)
* Added history possibilities to right key. * Added history possibilities to right key.
*/ */
@ -142,7 +142,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
SHORT orgy; SHORT orgy;
SHORT curx; /*current x/y cursor position*/ SHORT curx; /*current x/y cursor position*/
SHORT cury; SHORT cury;
SHORT tempscreen; SIZE_T tempscreen;
INT count; /*used in some for loops*/ INT count; /*used in some for loops*/
INT current = 0; /*the position of the cursor in the string (str)*/ INT current = 0; /*the position of the cursor in the string (str)*/
INT charcount = 0;/*chars in the string (str)*/ INT charcount = 0;/*chars in the string (str)*/

View file

@ -476,9 +476,16 @@ ScmSetServicePassword(
UNICODE_STRING Password; UNICODE_STRING Password;
NTSTATUS Status; NTSTATUS Status;
DWORD dwError = ERROR_SUCCESS; DWORD dwError = ERROR_SUCCESS;
SIZE_T ServiceNameLength;
RtlZeroMemory(&ObjectAttributes, sizeof(OBJECT_ATTRIBUTES)); RtlZeroMemory(&ObjectAttributes, sizeof(OBJECT_ATTRIBUTES));
ServiceNameLength = wcslen(pszServiceName);
if (ServiceNameLength > (UNICODE_STRING_MAX_CHARS - 4))
{
return ERROR_INVALID_PARAMETER;
}
Status = LsaOpenPolicy(NULL, Status = LsaOpenPolicy(NULL,
&ObjectAttributes, &ObjectAttributes,
POLICY_CREATE_SECRET, POLICY_CREATE_SECRET,
@ -486,7 +493,7 @@ ScmSetServicePassword(
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
return RtlNtStatusToDosError(Status); return RtlNtStatusToDosError(Status);
ServiceName.Length = (wcslen(pszServiceName) + 4) * sizeof(WCHAR); ServiceName.Length = ((USHORT)ServiceNameLength + 4) * sizeof(WCHAR);
ServiceName.MaximumLength = ServiceName.Length + sizeof(WCHAR); ServiceName.MaximumLength = ServiceName.Length + sizeof(WCHAR);
ServiceName.Buffer = HeapAlloc(GetProcessHeap(), ServiceName.Buffer = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,

View file

@ -176,11 +176,18 @@ OpenLSAPolicyHandle(IN LPWSTR SystemName,
LSA_OBJECT_ATTRIBUTES LsaObjectAttributes = {0}; LSA_OBJECT_ATTRIBUTES LsaObjectAttributes = {0};
LSA_UNICODE_STRING LsaSystemName, *psn; LSA_UNICODE_STRING LsaSystemName, *psn;
NTSTATUS Status; NTSTATUS Status;
SIZE_T NameLength;
if (SystemName != NULL && SystemName[0] != L'\0') if (SystemName != NULL && SystemName[0] != L'\0')
{ {
NameLength = wcslen(SystemName);
if (NameLength > UNICODE_STRING_MAX_CHARS)
{
return FALSE;
}
LsaSystemName.Buffer = SystemName; LsaSystemName.Buffer = SystemName;
LsaSystemName.Length = wcslen(SystemName) * sizeof(WCHAR); LsaSystemName.Length = NameLength * sizeof(WCHAR);
LsaSystemName.MaximumLength = LsaSystemName.Length + sizeof(WCHAR); LsaSystemName.MaximumLength = LsaSystemName.Length + sizeof(WCHAR);
psn = &LsaSystemName; psn = &LsaSystemName;
} }

View file

@ -42,8 +42,8 @@ GetCurrentHwProfileA(LPHW_PROFILE_INFOA lpHwProfileInfo)
lpHwProfileInfo->dwDockInfo = ProfileInfo.dwDockInfo; lpHwProfileInfo->dwDockInfo = ProfileInfo.dwDockInfo;
/* Convert the profile GUID to ANSI */ /* Convert the profile GUID to ANSI */
StringU.Buffer = (PWCHAR)ProfileInfo.szHwProfileGuid; StringU.Buffer = ProfileInfo.szHwProfileGuid;
StringU.Length = wcslen(ProfileInfo.szHwProfileGuid) * sizeof(WCHAR); StringU.Length = (USHORT)wcslen(ProfileInfo.szHwProfileGuid) * sizeof(WCHAR);
StringU.MaximumLength = HW_PROFILE_GUIDLEN * sizeof(WCHAR); StringU.MaximumLength = HW_PROFILE_GUIDLEN * sizeof(WCHAR);
StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileGuid; StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileGuid;
StringA.Length = 0; StringA.Length = 0;
@ -58,8 +58,8 @@ GetCurrentHwProfileA(LPHW_PROFILE_INFOA lpHwProfileInfo)
} }
/* Convert the profile name to ANSI */ /* Convert the profile name to ANSI */
StringU.Buffer = (PWCHAR)ProfileInfo.szHwProfileName; StringU.Buffer = ProfileInfo.szHwProfileName;
StringU.Length = wcslen(ProfileInfo.szHwProfileName) * sizeof(WCHAR); StringU.Length = (USHORT)wcslen(ProfileInfo.szHwProfileName) * sizeof(WCHAR);
StringU.MaximumLength = MAX_PROFILE_LEN * sizeof(WCHAR); StringU.MaximumLength = MAX_PROFILE_LEN * sizeof(WCHAR);
StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileName; StringA.Buffer = (PCHAR)&lpHwProfileInfo->szHwProfileName;
StringA.Length = 0; StringA.Length = 0;

View file

@ -961,7 +961,7 @@ CreateNestedKey(PHKEY KeyHandle,
} }
*Ptr = (WCHAR)0; *Ptr = (WCHAR)0;
LocalKeyName.Length = wcslen(LocalKeyName.Buffer) * sizeof(WCHAR); LocalKeyName.Length = (USHORT)wcslen(LocalKeyName.Buffer) * sizeof(WCHAR);
Status = NtCreateKey(&LocalKeyHandle, Status = NtCreateKey(&LocalKeyHandle,
KEY_CREATE_SUB_KEY, KEY_CREATE_SUB_KEY,

View file

@ -105,7 +105,7 @@ BaseCheckVDM(IN ULONG BinaryType,
PWCHAR CurrentDir = NULL; PWCHAR CurrentDir = NULL;
PWCHAR ShortAppName = NULL; PWCHAR ShortAppName = NULL;
PWCHAR ShortCurrentDir = NULL; PWCHAR ShortCurrentDir = NULL;
ULONG Length; SIZE_T Length;
PCHAR AnsiCmdLine = NULL; PCHAR AnsiCmdLine = NULL;
PCHAR AnsiAppName = NULL; PCHAR AnsiAppName = NULL;
PCHAR AnsiCurDirectory = NULL; PCHAR AnsiCurDirectory = NULL;
@ -283,16 +283,24 @@ BaseCheckVDM(IN ULONG BinaryType,
goto Cleanup; goto Cleanup;
} }
/* Make sure that the command line isn't too long */
Length = wcslen(CommandLine);
if (Length > UNICODE_STRING_MAX_CHARS - 1)
{
Status = STATUS_INVALID_PARAMETER;
goto Cleanup;
}
/* Setup the input parameters */ /* Setup the input parameters */
CheckVdm->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; CheckVdm->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
CheckVdm->BinaryType = BinaryType; CheckVdm->BinaryType = BinaryType;
CheckVdm->CodePage = CP_ACP; CheckVdm->CodePage = CP_ACP;
CheckVdm->dwCreationFlags = CreationFlags; CheckVdm->dwCreationFlags = CreationFlags;
CheckVdm->CurDrive = CurrentDirectory[0] - L'A'; CheckVdm->CurDrive = CurrentDirectory[0] - L'A';
CheckVdm->CmdLen = wcslen(CommandLine) + 1; CheckVdm->CmdLen = (USHORT)Length + 1;
CheckVdm->AppLen = wcslen(ShortAppName) + 1; CheckVdm->AppLen = (USHORT)wcslen(ShortAppName) + 1;
CheckVdm->PifLen = 0; // TODO: PIF file support! CheckVdm->PifLen = 0; // TODO: PIF file support!
CheckVdm->CurDirectoryLen = wcslen(ShortCurrentDir) + 1; CheckVdm->CurDirectoryLen = (USHORT)wcslen(ShortCurrentDir) + 1;
CheckVdm->EnvLen = AnsiEnvironment->Length; CheckVdm->EnvLen = AnsiEnvironment->Length;
CheckVdm->DesktopLen = (StartupInfo->lpDesktop != NULL) ? (wcslen(StartupInfo->lpDesktop) + 1) : 0; CheckVdm->DesktopLen = (StartupInfo->lpDesktop != NULL) ? (wcslen(StartupInfo->lpDesktop) + 1) : 0;
CheckVdm->TitleLen = (StartupInfo->lpTitle != NULL) ? (wcslen(StartupInfo->lpTitle) + 1) : 0; CheckVdm->TitleLen = (StartupInfo->lpTitle != NULL) ? (wcslen(StartupInfo->lpTitle) + 1) : 0;

View file

@ -96,9 +96,18 @@ LsapCreateSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
PSID *SidPtr) PSID *SidPtr)
{ {
PWELL_KNOWN_SID SidEntry; PWELL_KNOWN_SID SidEntry;
SIZE_T AccountNameLength, DomainNameLength;
PULONG p; PULONG p;
ULONG i; ULONG i;
AccountNameLength = wcslen(AccountName);
DomainNameLength = wcslen(DomainName);
if ((AccountNameLength > UNICODE_STRING_MAX_CHARS) ||
(DomainNameLength > UNICODE_STRING_MAX_CHARS))
{
return FALSE;
}
SidEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WELL_KNOWN_SID)); SidEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WELL_KNOWN_SID));
if (SidEntry == NULL) if (SidEntry == NULL)
return FALSE; return FALSE;
@ -126,7 +135,7 @@ LsapCreateSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
// RtlInitUnicodeString(&SidEntry->AccountName, // RtlInitUnicodeString(&SidEntry->AccountName,
// AccountName); // AccountName);
SidEntry->AccountName.Length = wcslen(AccountName) * sizeof(WCHAR); SidEntry->AccountName.Length = (USHORT)AccountNameLength * sizeof(WCHAR);
SidEntry->AccountName.MaximumLength = SidEntry->AccountName.Length + sizeof(WCHAR); SidEntry->AccountName.MaximumLength = SidEntry->AccountName.Length + sizeof(WCHAR);
SidEntry->AccountName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, SidEntry->AccountName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0,
SidEntry->AccountName.MaximumLength); SidEntry->AccountName.MaximumLength);
@ -142,7 +151,7 @@ LsapCreateSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
// RtlInitUnicodeString(&SidEntry->DomainName, // RtlInitUnicodeString(&SidEntry->DomainName,
// DomainName); // DomainName);
SidEntry->DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); SidEntry->DomainName.Length = (USHORT)DomainNameLength * sizeof(WCHAR);
SidEntry->DomainName.MaximumLength = SidEntry->DomainName.Length + sizeof(WCHAR); SidEntry->DomainName.MaximumLength = SidEntry->DomainName.Length + sizeof(WCHAR);
SidEntry->DomainName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, SidEntry->DomainName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0,
SidEntry->DomainName.MaximumLength); SidEntry->DomainName.MaximumLength);

View file

@ -99,7 +99,7 @@ LsarpLookupPrivilegeName(PLUID Value,
if (NameBuffer == NULL) if (NameBuffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
NameBuffer->Length = wcslen(WellKnownPrivileges[Priv].Name) * sizeof(WCHAR); NameBuffer->Length = (USHORT)wcslen(WellKnownPrivileges[Priv].Name) * sizeof(WCHAR);
NameBuffer->MaximumLength = NameBuffer->Length + sizeof(WCHAR); NameBuffer->MaximumLength = NameBuffer->Length + sizeof(WCHAR);
NameBuffer->Buffer = MIDL_user_allocate(NameBuffer->MaximumLength); NameBuffer->Buffer = MIDL_user_allocate(NameBuffer->MaximumLength);
@ -354,7 +354,7 @@ LsapLookupAccountRightName(ULONG RightValue,
if (NameBuffer == NULL) if (NameBuffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
NameBuffer->Length = wcslen(WellKnownRights[i].Name) * sizeof(WCHAR); NameBuffer->Length = (USHORT)wcslen(WellKnownRights[i].Name) * sizeof(WCHAR);
NameBuffer->MaximumLength = NameBuffer->Length + sizeof(WCHAR); NameBuffer->MaximumLength = NameBuffer->Length + sizeof(WCHAR);
NameBuffer->Buffer = MIDL_user_allocate(NameBuffer->MaximumLength); NameBuffer->Buffer = MIDL_user_allocate(NameBuffer->MaximumLength);

View file

@ -580,7 +580,7 @@ DoChangePassword(
Ptr = (LPWSTR)((ULONG_PTR)RequestBuffer + sizeof(MSV1_0_CHANGEPASSWORD_REQUEST)); Ptr = (LPWSTR)((ULONG_PTR)RequestBuffer + sizeof(MSV1_0_CHANGEPASSWORD_REQUEST));
/* Pack the domain name */ /* Pack the domain name */
RequestBuffer->DomainName.Length = wcslen(Domain) * sizeof(WCHAR); RequestBuffer->DomainName.Length = (USHORT)wcslen(Domain) * sizeof(WCHAR);
RequestBuffer->DomainName.MaximumLength = RequestBuffer->DomainName.Length + sizeof(WCHAR); RequestBuffer->DomainName.MaximumLength = RequestBuffer->DomainName.Length + sizeof(WCHAR);
RequestBuffer->DomainName.Buffer = Ptr; RequestBuffer->DomainName.Buffer = Ptr;
@ -591,7 +591,7 @@ DoChangePassword(
Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->DomainName.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->DomainName.MaximumLength);
/* Pack the user name */ /* Pack the user name */
RequestBuffer->AccountName.Length = wcslen(UserName) * sizeof(WCHAR); RequestBuffer->AccountName.Length = (USHORT)wcslen(UserName) * sizeof(WCHAR);
RequestBuffer->AccountName.MaximumLength = RequestBuffer->AccountName.Length + sizeof(WCHAR); RequestBuffer->AccountName.MaximumLength = RequestBuffer->AccountName.Length + sizeof(WCHAR);
RequestBuffer->AccountName.Buffer = Ptr; RequestBuffer->AccountName.Buffer = Ptr;
@ -602,7 +602,7 @@ DoChangePassword(
Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->AccountName.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->AccountName.MaximumLength);
/* Pack the old password */ /* Pack the old password */
RequestBuffer->OldPassword.Length = wcslen(OldPassword) * sizeof(WCHAR); RequestBuffer->OldPassword.Length = (USHORT)wcslen(OldPassword) * sizeof(WCHAR);
RequestBuffer->OldPassword.MaximumLength = RequestBuffer->OldPassword.Length + sizeof(WCHAR); RequestBuffer->OldPassword.MaximumLength = RequestBuffer->OldPassword.Length + sizeof(WCHAR);
RequestBuffer->OldPassword.Buffer = Ptr; RequestBuffer->OldPassword.Buffer = Ptr;
@ -613,7 +613,7 @@ DoChangePassword(
Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->OldPassword.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + RequestBuffer->OldPassword.MaximumLength);
/* Pack the new password */ /* Pack the new password */
RequestBuffer->NewPassword.Length = wcslen(NewPassword1) * sizeof(WCHAR); RequestBuffer->NewPassword.Length = (USHORT)wcslen(NewPassword1) * sizeof(WCHAR);
RequestBuffer->NewPassword.MaximumLength = RequestBuffer->NewPassword.Length + sizeof(WCHAR); RequestBuffer->NewPassword.MaximumLength = RequestBuffer->NewPassword.Length + sizeof(WCHAR);
RequestBuffer->NewPassword.Buffer = Ptr; RequestBuffer->NewPassword.Buffer = Ptr;

View file

@ -102,18 +102,24 @@ BuildInteractiveProfileBuffer(IN PLSA_CLIENT_REQUEST ClientRequest,
PVOID ClientBaseAddress = NULL; PVOID ClientBaseAddress = NULL;
LPWSTR Ptr; LPWSTR Ptr;
ULONG BufferLength; ULONG BufferLength;
USHORT ComputerNameLength;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
*ProfileBuffer = NULL; *ProfileBuffer = NULL;
*ProfileBufferLength = 0; *ProfileBufferLength = 0;
if (UIntPtrToUShort(wcslen(ComputerName), &ComputerNameLength) != S_OK)
{
return STATUS_INVALID_PARAMETER;
}
BufferLength = sizeof(MSV1_0_INTERACTIVE_PROFILE) + BufferLength = sizeof(MSV1_0_INTERACTIVE_PROFILE) +
UserInfo->All.FullName.Length + sizeof(WCHAR) + UserInfo->All.FullName.Length + sizeof(WCHAR) +
UserInfo->All.HomeDirectory.Length + sizeof(WCHAR) + UserInfo->All.HomeDirectory.Length + sizeof(WCHAR) +
UserInfo->All.HomeDirectoryDrive.Length + sizeof(WCHAR) + UserInfo->All.HomeDirectoryDrive.Length + sizeof(WCHAR) +
UserInfo->All.ScriptPath.Length + sizeof(WCHAR) + UserInfo->All.ScriptPath.Length + sizeof(WCHAR) +
UserInfo->All.ProfilePath.Length + sizeof(WCHAR) + UserInfo->All.ProfilePath.Length + sizeof(WCHAR) +
((wcslen(ComputerName) + 3) * sizeof(WCHAR)); ((ComputerNameLength + 3) * sizeof(WCHAR));
LocalBuffer = DispatchTable.AllocateLsaHeap(BufferLength); LocalBuffer = DispatchTable.AllocateLsaHeap(BufferLength);
if (LocalBuffer == NULL) if (LocalBuffer == NULL)
@ -204,7 +210,7 @@ BuildInteractiveProfileBuffer(IN PLSA_CLIENT_REQUEST ClientRequest,
Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->HomeDirectoryDrive.MaximumLength); Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->HomeDirectoryDrive.MaximumLength);
LocalBuffer->LogonServer.Length = (wcslen(ComputerName) + 2) * sizeof(WCHAR); LocalBuffer->LogonServer.Length = (ComputerNameLength + 2) * sizeof(WCHAR);
LocalBuffer->LogonServer.MaximumLength = LocalBuffer->LogonServer.Length + sizeof(WCHAR); LocalBuffer->LogonServer.MaximumLength = LocalBuffer->LogonServer.Length + sizeof(WCHAR);
LocalBuffer->LogonServer.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer); LocalBuffer->LogonServer.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);
wcscpy(Ptr, L"\\"); wcscpy(Ptr, L"\\");

View file

@ -8,6 +8,7 @@
#include <windef.h> #include <windef.h>
#include <winbase.h> #include <winbase.h>
#include <winreg.h> #include <winreg.h>
#include <intsafe.h>
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ndk/cmfuncs.h> #include <ndk/cmfuncs.h>
#include <ndk/kefuncs.h> #include <ndk/kefuncs.h>

View file

@ -403,12 +403,19 @@ AccpOpenLSAPolicyHandle(IN LPWSTR SystemName,
{ {
LSA_OBJECT_ATTRIBUTES LsaObjectAttributes = {0}; LSA_OBJECT_ATTRIBUTES LsaObjectAttributes = {0};
LSA_UNICODE_STRING LsaSystemName, *psn; LSA_UNICODE_STRING LsaSystemName, *psn;
SIZE_T SystemNameLength;
NTSTATUS Status; NTSTATUS Status;
if (SystemName != NULL && SystemName[0] != L'\0') if (SystemName != NULL && SystemName[0] != L'\0')
{ {
SystemNameLength = wcslen(SystemName);
if (SystemNameLength > UNICODE_STRING_MAX_CHARS)
{
return ERROR_INVALID_PARAMETER;
}
LsaSystemName.Buffer = SystemName; LsaSystemName.Buffer = SystemName;
LsaSystemName.Length = wcslen(SystemName) * sizeof(WCHAR); LsaSystemName.Length = (USHORT)SystemNameLength * sizeof(WCHAR);
LsaSystemName.MaximumLength = LsaSystemName.Length + sizeof(WCHAR); LsaSystemName.MaximumLength = LsaSystemName.Length + sizeof(WCHAR);
psn = &LsaSystemName; psn = &LsaSystemName;
} }
@ -498,10 +505,17 @@ AccpLookupSidByName(IN LSA_HANDLE PolicyHandle,
PLSA_REFERENCED_DOMAIN_LIST ReferencedDomains = NULL; PLSA_REFERENCED_DOMAIN_LIST ReferencedDomains = NULL;
PLSA_TRANSLATED_SID2 TranslatedSid = NULL; PLSA_TRANSLATED_SID2 TranslatedSid = NULL;
DWORD SidLen; DWORD SidLen;
SIZE_T NameLength;
DWORD Ret = ERROR_SUCCESS; DWORD Ret = ERROR_SUCCESS;
NameLength = wcslen(Name);
if (NameLength > UNICODE_STRING_MAX_CHARS)
{
return ERROR_INVALID_PARAMETER;
}
LsaNames[0].Buffer = Name; LsaNames[0].Buffer = Name;
LsaNames[0].Length = wcslen(Name) * sizeof(WCHAR); LsaNames[0].Length = (USHORT)NameLength * sizeof(WCHAR);
LsaNames[0].MaximumLength = LsaNames[0].Length + sizeof(WCHAR); LsaNames[0].MaximumLength = LsaNames[0].Length + sizeof(WCHAR);
Status = LsaLookupNames2(PolicyHandle, Status = LsaLookupNames2(PolicyHandle,

View file

@ -784,16 +784,24 @@ HRESULT STDMETHODCALLTYPE CShellLink::Load(IStream *stm)
*/ */
static HRESULT Stream_WriteString(IStream* stm, LPCWSTR str) static HRESULT Stream_WriteString(IStream* stm, LPCWSTR str)
{ {
USHORT len = wcslen(str) + 1; // FIXME: Possible overflows? SIZE_T length;
USHORT len;
DWORD count; DWORD count;
length = wcslen(str) + 1;
if (length > MAXUSHORT)
{
return E_INVALIDARG;
}
len = (USHORT)length;
HRESULT hr = stm->Write(&len, sizeof(len), &count); HRESULT hr = stm->Write(&len, sizeof(len), &count);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
len *= sizeof(WCHAR); length *= sizeof(WCHAR);
hr = stm->Write(str, len, &count); hr = stm->Write(str, (ULONG)length, &count);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;

View file

@ -102,17 +102,25 @@ static LPITEMIDLIST _ILCreatePrinterItem(PRINTER_INFO_4W *pi)
PIDLPrinterStruct * p; PIDLPrinterStruct * p;
int size0 = (char*)&tmp.u.cprinter.szName - (char*)&tmp.u.cprinter; int size0 = (char*)&tmp.u.cprinter.szName - (char*)&tmp.u.cprinter;
int size = size0; int size = size0;
SIZE_T cchPrinterName, cchServerName;
cchPrinterName = wcslen(pi->pPrinterName);
cchServerName = wcslen(pi->pServerName);
if ((cchPrinterName + cchServerName) > (MAXUSHORT - 2))
{
return NULL;
}
tmp.type = 0x00; tmp.type = 0x00;
tmp.u.cprinter.dummy = 0xFF; tmp.u.cprinter.dummy = 0xFF;
if (pi->pPrinterName) if (pi->pPrinterName)
tmp.u.cprinter.offsServer = wcslen(pi->pPrinterName) + 1; tmp.u.cprinter.offsServer = cchPrinterName + 1;
else else
tmp.u.cprinter.offsServer = 1; tmp.u.cprinter.offsServer = 1;
size += tmp.u.cprinter.offsServer * sizeof(WCHAR); size += tmp.u.cprinter.offsServer * sizeof(WCHAR);
if (pi->pServerName) if (pi->pServerName)
size += (wcslen(pi->pServerName) + 1) * sizeof(WCHAR); size += (cchServerName + 1) * sizeof(WCHAR);
else else
size += sizeof(WCHAR); size += sizeof(WCHAR);

View file

@ -38,10 +38,20 @@ SetAccountsDomainSid(
SAM_HANDLE DomainHandle = NULL; SAM_HANDLE DomainHandle = NULL;
DOMAIN_NAME_INFORMATION DomainNameInfo; DOMAIN_NAME_INFORMATION DomainNameInfo;
SIZE_T DomainNameLength = 0;
NTSTATUS Status; NTSTATUS Status;
DPRINT("SYSSETUP: SetAccountsDomainSid\n"); DPRINT("SYSSETUP: SetAccountsDomainSid\n");
if (DomainName != NULL)
{
DomainNameLength = wcslen(DomainName);
if (DomainNameLength > UNICODE_STRING_MAX_CHARS)
{
return STATUS_INVALID_PARAMETER;
}
}
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES); ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES);
@ -69,7 +79,7 @@ SetAccountsDomainSid(
else else
{ {
Info.DomainName.Buffer = (LPWSTR)DomainName; Info.DomainName.Buffer = (LPWSTR)DomainName;
Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); Info.DomainName.Length = DomainNameLength * sizeof(WCHAR);
Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR); Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
} }
@ -81,7 +91,7 @@ SetAccountsDomainSid(
else else
{ {
Info.DomainName.Buffer = (LPWSTR)DomainName; Info.DomainName.Buffer = (LPWSTR)DomainName;
Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); Info.DomainName.Length = DomainNameLength * sizeof(WCHAR);
Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR); Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
Info.DomainSid = DomainSid; Info.DomainSid = DomainSid;
} }
@ -99,7 +109,7 @@ SetAccountsDomainSid(
LsaClose(PolicyHandle); LsaClose(PolicyHandle);
DomainNameInfo.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR); DomainNameInfo.DomainName.Length = DomainNameLength * sizeof(WCHAR);
DomainNameInfo.DomainName.MaximumLength = DomainNameInfo.DomainName.Length + sizeof(WCHAR); DomainNameInfo.DomainName.MaximumLength = DomainNameInfo.DomainName.Length + sizeof(WCHAR);
DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName; DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName;
@ -147,10 +157,20 @@ SetPrimaryDomain(LPCWSTR DomainName,
POLICY_PRIMARY_DOMAIN_INFO Info; POLICY_PRIMARY_DOMAIN_INFO Info;
LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle; LSA_HANDLE PolicyHandle;
SIZE_T DomainNameLength = 0;
NTSTATUS Status; NTSTATUS Status;
DPRINT1("SYSSETUP: SetPrimaryDomain()\n"); DPRINT1("SYSSETUP: SetPrimaryDomain()\n");
if (DomainName != NULL)
{
DomainNameLength = wcslen(DomainName);
if (DomainNameLength > UNICODE_STRING_MAX_CHARS)
{
return STATUS_INVALID_PARAMETER;
}
}
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES); ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES);
@ -178,7 +198,7 @@ SetPrimaryDomain(LPCWSTR DomainName,
else else
{ {
Info.Name.Buffer = (LPWSTR)DomainName; Info.Name.Buffer = (LPWSTR)DomainName;
Info.Name.Length = wcslen(DomainName) * sizeof(WCHAR); Info.Name.Length = DomainNameLength * sizeof(WCHAR);
Info.Name.MaximumLength = Info.Name.Length + sizeof(WCHAR); Info.Name.MaximumLength = Info.Name.Length + sizeof(WCHAR);
} }
@ -190,7 +210,7 @@ SetPrimaryDomain(LPCWSTR DomainName,
else else
{ {
Info.Name.Buffer = (LPWSTR)DomainName; Info.Name.Buffer = (LPWSTR)DomainName;
Info.Name.Length = wcslen(DomainName) * sizeof(WCHAR); Info.Name.Length = DomainNameLength * sizeof(WCHAR);
Info.Name.MaximumLength = Info.Name.Length + sizeof(WCHAR); Info.Name.MaximumLength = Info.Name.Length + sizeof(WCHAR);
Info.Sid = DomainSid; Info.Sid = DomainSid;
} }
@ -1251,6 +1271,8 @@ SetNewAccountName(
if (dwLength == 0) if (dwLength == 0)
return; return;
ASSERT(dwLength <= UNICODE_STRING_MAX_CHARS);
pszName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR)); pszName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength * sizeof(WCHAR));
if (pszName == NULL) if (pszName == NULL)
{ {
@ -1280,7 +1302,7 @@ SetNewAccountName(
goto done; goto done;
} }
NameInfo.UserName.Length = wcslen(pszName) * sizeof(WCHAR); NameInfo.UserName.Length = (USHORT)wcslen(pszName) * sizeof(WCHAR);
NameInfo.UserName.MaximumLength = NameInfo.UserName.Length + sizeof(WCHAR); NameInfo.UserName.MaximumLength = NameInfo.UserName.Length + sizeof(WCHAR);
NameInfo.UserName.Buffer = pszName; NameInfo.UserName.Buffer = pszName;
NameInfo.FullName.Length = 0; NameInfo.FullName.Length = 0;

View file

@ -20,6 +20,7 @@ Abstract:
typedef PVOID PBCB; //**** Bcb's are now part of the cache module typedef PVOID PBCB; //**** Bcb's are now part of the cache module
#ifdef __REACTOS__ #ifdef __REACTOS__
#undef __volatile
#define __volatile volatile #define __volatile volatile
#endif #endif

View file

@ -42,7 +42,7 @@ NpReadAlias(
{ {
PNPFS_QUERY_VALUE_CONTEXT QueryContext = Context; PNPFS_QUERY_VALUE_CONTEXT QueryContext = Context;
PWSTR CurrentString; PWSTR CurrentString;
USHORT Length; SIZE_T Length;
PNPFS_ALIAS CurrentAlias; PNPFS_ALIAS CurrentAlias;
UNICODE_STRING TempString; UNICODE_STRING TempString;
PUNICODE_STRING CurrentTargetName; PUNICODE_STRING CurrentTargetName;

View file

@ -4,7 +4,7 @@
* FILE: drivers/kbdclass/kbdclass.c * FILE: drivers/kbdclass/kbdclass.c
* PURPOSE: Keyboard class driver * PURPOSE: Keyboard class driver
* *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/ */
#include "kbdclass.h" #include "kbdclass.h"
@ -321,7 +321,7 @@ CreateClassDeviceObject(
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
DeviceNameU.Length = 0; DeviceNameU.Length = 0;
DeviceNameU.MaximumLength = DeviceNameU.MaximumLength =
wcslen(L"\\Device\\") * sizeof(WCHAR) /* "\Device\" */ (USHORT)wcslen(L"\\Device\\") * sizeof(WCHAR) /* "\Device\" */
+ DriverExtension->DeviceBaseName.Length /* "KeyboardClass" */ + DriverExtension->DeviceBaseName.Length /* "KeyboardClass" */
+ 4 * sizeof(WCHAR) /* Id between 0 and 9999 */ + 4 * sizeof(WCHAR) /* Id between 0 and 9999 */
+ sizeof(UNICODE_NULL); /* Final NULL char */ + sizeof(UNICODE_NULL); /* Final NULL char */

View file

@ -4,7 +4,7 @@
* FILE: drivers/mouclass/mouclass.c * FILE: drivers/mouclass/mouclass.c
* PURPOSE: Mouse class driver * PURPOSE: Mouse class driver
* *
* PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org) * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
*/ */
#include "mouclass.h" #include "mouclass.h"
@ -297,7 +297,7 @@ CreateClassDeviceObject(
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject); DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
DeviceNameU.Length = 0; DeviceNameU.Length = 0;
DeviceNameU.MaximumLength = DeviceNameU.MaximumLength =
wcslen(L"\\Device\\") * sizeof(WCHAR) /* "\Device\" */ (USHORT)wcslen(L"\\Device\\") * sizeof(WCHAR) /* "\Device\" */
+ DriverExtension->DeviceBaseName.Length /* "PointerClass" */ + DriverExtension->DeviceBaseName.Length /* "PointerClass" */
+ 4 * sizeof(WCHAR) /* Id between 0 and 9999 */ + 4 * sizeof(WCHAR) /* Id between 0 and 9999 */
+ sizeof(UNICODE_NULL); /* Final NULL char */ + sizeof(UNICODE_NULL); /* Final NULL char */

View file

@ -266,7 +266,7 @@ DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
} }
UniqueId = Irp->AssociatedIrp.SystemBuffer; UniqueId = Irp->AssociatedIrp.SystemBuffer;
UniqueId->UniqueIdLength = wcslen(&DriveInfo->DeviceNameBuffer[0]) * sizeof(WCHAR); UniqueId->UniqueIdLength = (USHORT)wcslen(&DriveInfo->DeviceNameBuffer[0]) * sizeof(WCHAR);
if(OutputLength < FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + UniqueId->UniqueIdLength) if(OutputLength < FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + UniqueId->UniqueIdLength)
{ {
@ -291,7 +291,7 @@ DeviceIoctlPassive(PDRIVE_INFO DriveInfo, PIRP Irp)
} }
Name = Irp->AssociatedIrp.SystemBuffer; Name = Irp->AssociatedIrp.SystemBuffer;
Name->NameLength = wcslen(&DriveInfo->DeviceNameBuffer[0]) * sizeof(WCHAR); Name->NameLength = (USHORT)wcslen(&DriveInfo->DeviceNameBuffer[0]) * sizeof(WCHAR);
if(OutputLength < FIELD_OFFSET(MOUNTDEV_NAME, Name) + Name->NameLength) if(OutputLength < FIELD_OFFSET(MOUNTDEV_NAME, Name) + Name->NameLength)
{ {

View file

@ -140,7 +140,7 @@ struct UnicodeString : public RtlUnicodeString {
UnicodeString(size_t len, LPWSTR buffer) UnicodeString(size_t len, LPWSTR buffer)
{ {
alloc_len = len; alloc_len = (WORD)len;
string_ptr = buffer; string_ptr = buffer;
} }

View file

@ -233,7 +233,7 @@ extern "C" int wmain (int argc, wchar_t **argv)
// Now set back to the beginning // Now set back to the beginning
ScreenInfo.dwCursorPosition.X = 0; ScreenInfo.dwCursorPosition.X = 0;
ScreenInfo.dwCursorPosition.Y -= Drives.size(); ScreenInfo.dwCursorPosition.Y -= (USHORT)Drives.size();
SetConsoleCursorPosition (Screen, ScreenInfo.dwCursorPosition); SetConsoleCursorPosition (Screen, ScreenInfo.dwCursorPosition);
for (size_t d = 0; d < Drives.size (); d++) for (size_t d = 0; d < Drives.size (); d++)

View file

@ -182,10 +182,10 @@ private:
} }
string present_value( DWORD type, const char *data, DWORD len ) { string present_value( DWORD type, const char *data, DWORD len ) {
switch( type ) { //switch( type ) {
default: //default:
return bindump( data, len ); return bindump( data, len );
} //}
} }
void process_valid_request( HKEY open_reg_key, string key_name ) { void process_valid_request( HKEY open_reg_key, string key_name ) {

View file

@ -67,7 +67,7 @@ public:
virtual BOOL Stop(); virtual BOOL Stop();
virtual LPCServerClientSocket OnGetSocket(LPCServerSocket lpServerSocket); virtual LPCServerClientSocket OnGetSocket(LPCServerSocket lpServerSocket);
virtual LPCServerClientThread OnGetThread(LPCServerClientSocket Socket); virtual LPCServerClientThread OnGetThread(LPCServerClientSocket Socket);
virtual void OnAccept(const LPCServerClientThread lpThread); virtual void OnAccept(LPCServerClientThread lpThread);
private: private:
HTTPdState State; HTTPdState State;
}; };

View file

@ -44,25 +44,25 @@ WriteStringAt(LPWSTR lpString,
WORD wColor) WORD wColor)
{ {
DWORD cWritten = 0; DWORD cWritten = 0;
WORD wLen; DWORD dwLen;
if (!lpString || *lpString == 0) return; if (!lpString || *lpString == 0) return;
wLen = wcslen(lpString); dwLen = (DWORD)wcslen(lpString);
/* Don't bother writing text when erasing */ /* Don't bother writing text when erasing */
if (wColor) if (wColor)
{ {
WriteConsoleOutputCharacterW(ScreenBuffer, WriteConsoleOutputCharacterW(ScreenBuffer,
lpString, lpString,
wLen, dwLen,
xy, xy,
&cWritten); &cWritten);
} }
FillConsoleOutputAttribute(ScreenBuffer, FillConsoleOutputAttribute(ScreenBuffer,
wColor, wColor,
wLen, dwLen,
xy, xy,
&cWritten); &cWritten);
} }
@ -103,7 +103,7 @@ DisplayTitle(VOID)
LPWSTR szTitle = L"ReactOS Coders Console Parade"; LPWSTR szTitle = L"ReactOS Coders Console Parade";
COORD xy; COORD xy;
xy.X = (ScreenBufferInfo.dwSize.X - wcslen(szTitle)) / 2; xy.X = (ScreenBufferInfo.dwSize.X - (USHORT)wcslen(szTitle)) / 2;
xy.Y = ScreenBufferInfo.dwSize.Y / 2; xy.Y = ScreenBufferInfo.dwSize.Y / 2;
WriteStringAt(szTitle, xy, WriteStringAt(szTitle, xy,

View file

@ -106,8 +106,8 @@ void DrawScene(HWND hwnd, HDC dc, int ticks)
angle += ticks * 0.01; angle += ticks * 0.01;
colorh += ticks * 0.003; colorh += ticks * 0.003;
if (colorh > 360.0) colorh -= 360.0; if (colorh > 360.0) colorh -= 360.0;
HLStoRGB(colorh, 1.0, 0.7, &rval, &gval, &bval); HLStoRGB(colorh, 1.0f, 0.7f, &rval, &gval, &bval);
DrawCylinder(lvls, angle, 0.2); DrawCylinder(lvls, angle, 0.2f);
SwapBuffers(dc); SwapBuffers(dc);
EndPaint(hwnd, &ps); EndPaint(hwnd, &ps);
} }
@ -134,7 +134,7 @@ void MyPixelFormat(HDC dc)
void InitGL(HWND hwnd) void InitGL(HWND hwnd)
{ {
GLfloat lightpos[4] = {2.0, 2.0, -2.0, 0.7}; GLfloat lightpos[4] = {2.0f, 2.0f, -2.0f, 0.7f};
GLfloat ca = 1.0; GLfloat ca = 1.0;
dc = GetDC(hwnd); dc = GetDC(hwnd);
MyPixelFormat(dc); MyPixelFormat(dc);

View file

@ -8,6 +8,7 @@
#ifdef HAVE_APITEST #ifdef HAVE_APITEST
#include <apitest.h> #include <apitest.h>
#define ATLASSUME(x) /*empty*/ #define ATLASSUME(x) /*empty*/
#undef ATLASSERT
#define ATLASSERT(x) /*empty*/ #define ATLASSERT(x) /*empty*/
#else #else
#include "atltest.h" #include "atltest.h"

View file

@ -159,7 +159,7 @@ typedef ACPI_ENUM_CHILDREN_OUTPUT_BUFFER UNALIGNED *PACPI_ENUM_CHILDREN_OUTPUT_B
#define ACPI_METHOD_SET_ARGUMENT_STRING( Argument, StrData ) \ #define ACPI_METHOD_SET_ARGUMENT_STRING( Argument, StrData ) \
{ Argument->Type = ACPI_METHOD_ARGUMENT_STRING; \ { Argument->Type = ACPI_METHOD_ARGUMENT_STRING; \
Argument->DataLength = strlen((PCHAR)StrData) + sizeof(UCHAR); \ Argument->DataLength = (USHORT)strlen((PCHAR)StrData) + sizeof(UCHAR); \
RtlCopyMemory(&Argument->Data[0],(PUCHAR)StrData,Argument->DataLength); } RtlCopyMemory(&Argument->Data[0],(PUCHAR)StrData,Argument->DataLength); }
#define ACPI_METHOD_SET_ARGUMENT_BUFFER( Argument, BuffData, BuffLength ) \ #define ACPI_METHOD_SET_ARGUMENT_BUFFER( Argument, BuffData, BuffLength ) \

View file

@ -46,9 +46,11 @@ typedef _Return_type_success_(return >= 0) long NTSTATUS;
#ifndef _HRESULT_DEFINED #ifndef _HRESULT_DEFINED
typedef _Return_type_success_(return >= 0) long HRESULT; typedef _Return_type_success_(return >= 0) long HRESULT;
#endif #endif
#ifndef SUCCEEDED
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
#define FAILED(hr) (((HRESULT)(hr)) < 0) #define FAILED(hr) (((HRESULT)(hr)) < 0)
#define S_OK ((HRESULT)0L) #define S_OK ((HRESULT)0L)
#endif
#define INTSAFE_RESULT HRESULT #define INTSAFE_RESULT HRESULT
#define INTSAFE_SUCCESS S_OK #define INTSAFE_SUCCESS S_OK
#define INTSAFE_E_ARITHMETIC_OVERFLOW ((HRESULT)0x80070216L) #define INTSAFE_E_ARITHMETIC_OVERFLOW ((HRESULT)0x80070216L)

View file

@ -6,7 +6,7 @@
*/ */
__int64 CDECL _wtoi64_l(const wchar_t *str, _locale_t locale) __int64 CDECL _wtoi64_l(const wchar_t *str, _locale_t locale)
{ {
ULONGLONG RunningTotal = 0; LONGLONG RunningTotal = 0;
BOOL bMinus = FALSE; BOOL bMinus = FALSE;
while (iswctype((int)*str, _SPACE)) { while (iswctype((int)*str, _SPACE)) {
@ -191,7 +191,7 @@ unsigned __int64 CDECL _wcstoui64_l(const wchar_t *nptr,
if(endptr) if(endptr)
*endptr = (wchar_t*)nptr; *endptr = (wchar_t*)nptr;
return negative ? -ret : ret; return negative ? -(__int64)ret : ret;
} }
/********************************************************************* /*********************************************************************

View file

@ -124,7 +124,7 @@ NDIS_STATUS LoopRegisterAdapter(
Loopback->Name.Buffer = L"Loopback"; Loopback->Name.Buffer = L"Loopback";
Loopback->Name.MaximumLength = Loopback->Name.Length = Loopback->Name.MaximumLength = Loopback->Name.Length =
wcslen(Loopback->Name.Buffer) * sizeof(WCHAR); (USHORT)wcslen(Loopback->Name.Buffer) * sizeof(WCHAR);
AddrInitIPv4(&Loopback->Unicast, LOOPBACK_ADDRESS_IPv4); AddrInitIPv4(&Loopback->Unicast, LOOPBACK_ADDRESS_IPv4);
AddrInitIPv4(&Loopback->Netmask, LOOPBACK_ADDRMASK_IPv4); AddrInitIPv4(&Loopback->Netmask, LOOPBACK_ADDRMASK_IPv4);

View file

@ -1131,7 +1131,7 @@ static VOID WINAPI DosInitialize(LPWORD Stack)
/* Get the DOS BIOS file name (NULL-terminated) */ /* Get the DOS BIOS file name (NULL-terminated) */
// FIXME: Isn't it possible to use some DS:SI instead?? // FIXME: Isn't it possible to use some DS:SI instead??
LPCSTR DosBiosFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP()); LPCSTR DosBiosFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP());
setIP(getIP() + strlen(DosBiosFileName) + 1); // Skip it setIP(getIP() + (USHORT)strlen(DosBiosFileName) + 1); // Skip it
DPRINT("DosInitialize('%s')\n", DosBiosFileName); DPRINT("DosInitialize('%s')\n", DosBiosFileName);

View file

@ -109,7 +109,7 @@ LONG copy_servername_from_name(LPCWSTR name, LPWSTR target)
FIXME("found %s\n", debugstr_wn(server, serverlen)); FIXME("found %s\n", debugstr_wn(server, serverlen));
if (serverlen > MAX_COMPUTERNAME_LENGTH) return -serverlen; if (serverlen > MAX_COMPUTERNAME_LENGTH) return -(LONG)serverlen;
if (target) if (target)
{ {

View file

@ -111,7 +111,7 @@ ClassNameToVersion(
ERR("Couldn't get atom name for atom %x !\n", LOWORD((DWORD_PTR)lpszClass)); ERR("Couldn't get atom name for atom %x !\n", LOWORD((DWORD_PTR)lpszClass));
return NULL; return NULL;
} }
SectionName.Length = wcslen(SectionNameBuf) * sizeof(WCHAR); SectionName.Length = (USHORT)wcslen(SectionNameBuf) * sizeof(WCHAR);
TRACE("ClassNameToVersion got name %wZ from atom\n", &SectionName); TRACE("ClassNameToVersion got name %wZ from atom\n", &SectionName);
} }
else else