mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[KERNEL32] Fix 64 bit issues
This commit is contained in:
parent
9e066abe2a
commit
4f0a158a2f
12 changed files with 78 additions and 42 deletions
|
@ -154,8 +154,8 @@ BasepProbeForDllManifest(IN PVOID DllHandle,
|
|||
*ActCtx = NULL;
|
||||
|
||||
/* Check whether the image has manifest resource associated with it */
|
||||
Info.Type = (ULONG)RT_MANIFEST;
|
||||
Info.Name = (ULONG)ISOLATIONAWARE_MANIFEST_RESOURCE_ID;
|
||||
Info.Type = (ULONG_PTR)RT_MANIFEST;
|
||||
Info.Name = (ULONG_PTR)ISOLATIONAWARE_MANIFEST_RESOURCE_ID;
|
||||
Info.Language = 0;
|
||||
if (!(Status = LdrFindResource_U(DllHandle, &Info, 3, &Entry)))
|
||||
{
|
||||
|
|
|
@ -391,8 +391,15 @@ SetComputerNameToRegistry(LPCWSTR RegistryKey,
|
|||
UNICODE_STRING KeyName;
|
||||
UNICODE_STRING ValueName;
|
||||
HANDLE KeyHandle;
|
||||
SIZE_T StringLength;
|
||||
NTSTATUS Status;
|
||||
|
||||
StringLength = wcslen(lpBuffer);
|
||||
if (StringLength > ((MAXULONG / sizeof(WCHAR)) - 1))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&KeyName, RegistryKey);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&KeyName,
|
||||
|
@ -416,7 +423,7 @@ SetComputerNameToRegistry(LPCWSTR RegistryKey,
|
|||
0,
|
||||
REG_SZ,
|
||||
(PVOID)lpBuffer,
|
||||
(wcslen (lpBuffer) + 1) * sizeof(WCHAR));
|
||||
(StringLength + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
NtClose(KeyHandle);
|
||||
|
|
|
@ -453,8 +453,8 @@ ContinueDebugEvent(IN DWORD dwProcessId,
|
|||
NTSTATUS Status;
|
||||
|
||||
/* Set the Client ID */
|
||||
ClientId.UniqueProcess = (HANDLE)dwProcessId;
|
||||
ClientId.UniqueThread = (HANDLE)dwThreadId;
|
||||
ClientId.UniqueProcess = UlongToHandle(dwProcessId);
|
||||
ClientId.UniqueThread = UlongToHandle(dwThreadId);
|
||||
|
||||
/* Continue debugging */
|
||||
Status = DbgUiContinue(&ClientId, dwContinueStatus);
|
||||
|
|
|
@ -172,15 +172,20 @@ DllMain(HANDLE hDll,
|
|||
BaseWindowsSystemDirectory = BaseStaticServerData->WindowsSystemDirectory;
|
||||
|
||||
/* Construct the default path (using the static buffer) */
|
||||
_snwprintf(BaseDefaultPathBuffer,
|
||||
sizeof(BaseDefaultPathBuffer) / sizeof(WCHAR),
|
||||
Status = RtlStringCbPrintfW(BaseDefaultPathBuffer,
|
||||
sizeof(BaseDefaultPathBuffer),
|
||||
L".;%wZ;%wZ\\system;%wZ;",
|
||||
&BaseWindowsSystemDirectory,
|
||||
&BaseWindowsDirectory,
|
||||
&BaseWindowsDirectory);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NLS Init failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BaseDefaultPath.Buffer = BaseDefaultPathBuffer;
|
||||
BaseDefaultPath.Length = wcslen(BaseDefaultPathBuffer) * sizeof(WCHAR);
|
||||
BaseDefaultPath.Length = (USHORT)wcslen(BaseDefaultPathBuffer) * sizeof(WCHAR);
|
||||
BaseDefaultPath.MaximumLength = sizeof(BaseDefaultPathBuffer);
|
||||
|
||||
/* Use remaining part of the default path buffer for the append path */
|
||||
|
|
|
@ -26,8 +26,10 @@ _module_name_from_addr(const void* addr, void **module_start_addr,
|
|||
char* psz, size_t nChars, char** module_name)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
if (VirtualQuery(addr, &mbi, sizeof(mbi)) != sizeof(mbi) ||
|
||||
!GetModuleFileNameA((HMODULE)mbi.AllocationBase, psz, nChars))
|
||||
|
||||
if ((nChars > MAXDWORD) ||
|
||||
(VirtualQuery(addr, &mbi, sizeof(mbi)) != sizeof(mbi)) ||
|
||||
!GetModuleFileNameA((HMODULE)mbi.AllocationBase, psz, (DWORD)nChars))
|
||||
{
|
||||
psz[0] = '\0';
|
||||
*module_name = psz;
|
||||
|
@ -164,6 +166,7 @@ BasepCheckForReadOnlyResource(IN PVOID Ptr)
|
|||
{
|
||||
PVOID Data;
|
||||
ULONG Size, OldProtect;
|
||||
SIZE_T Size2;
|
||||
MEMORY_BASIC_INFORMATION mbi;
|
||||
NTSTATUS Status;
|
||||
LONG Ret = EXCEPTION_CONTINUE_SEARCH;
|
||||
|
@ -194,10 +197,10 @@ BasepCheckForReadOnlyResource(IN PVOID Ptr)
|
|||
{
|
||||
/* The user tried to write into the resources. Make the page
|
||||
writable... */
|
||||
Size = 1;
|
||||
Size2 = 1;
|
||||
Status = NtProtectVirtualMemory(NtCurrentProcess(),
|
||||
&Ptr,
|
||||
&Size,
|
||||
&Size2,
|
||||
PAGE_READWRITE,
|
||||
&OldProtect);
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -560,14 +563,14 @@ UnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
|
|||
* line. The biggest 32-bit unsigned int (0xFFFFFFFF == 4.294.967.295)
|
||||
* takes 10 decimal digits. We then count the terminating NULL.
|
||||
*/
|
||||
Length = wcslen(AeDebugPath) + 2*10 + 1;
|
||||
Length = (ULONG)wcslen(AeDebugPath) + 2*10 + 1;
|
||||
|
||||
/* Check whether the debugger path may be a relative path */
|
||||
if ((*AeDebugPath != L'"') &&
|
||||
(RtlDetermineDosPathNameType_U(AeDebugPath) == RtlPathTypeRelative))
|
||||
{
|
||||
/* Relative path, prepend SystemRoot\System32 */
|
||||
PrependLength = wcslen(SharedUserData->NtSystemRoot) + 10 /* == wcslen(L"\\System32\\") */;
|
||||
PrependLength = (ULONG)wcslen(SharedUserData->NtSystemRoot) + 10 /* == wcslen(L"\\System32\\") */;
|
||||
if (PrependLength + Length <= ARRAYSIZE(AeDebugCmdLine))
|
||||
{
|
||||
hr = StringCchPrintfW(AeDebugCmdLine,
|
||||
|
@ -830,8 +833,8 @@ IsBadReadPtr(IN LPCVOID lp,
|
|||
*Current;
|
||||
|
||||
/* Align the addresses */
|
||||
Current = (volatile CHAR *)ROUND_DOWN(Current, PageSize);
|
||||
Last = (PCHAR)ROUND_DOWN(Last, PageSize);
|
||||
Current = (volatile CHAR *)ALIGN_DOWN_POINTER_BY(Current, PageSize);
|
||||
Last = (PCHAR)ALIGN_DOWN_POINTER_BY(Last, PageSize);
|
||||
|
||||
/* Probe the entire range */
|
||||
while (Current != Last)
|
||||
|
@ -908,8 +911,8 @@ IsBadWritePtr(IN LPVOID lp,
|
|||
*Current = *Current;
|
||||
|
||||
/* Align the addresses */
|
||||
Current = (volatile CHAR *)ROUND_DOWN(Current, PageSize);
|
||||
Last = (PCHAR)ROUND_DOWN(Last, PageSize);
|
||||
Current = (volatile CHAR *)ALIGN_DOWN_POINTER_BY(Current, PageSize);
|
||||
Last = (PCHAR)ALIGN_DOWN_POINTER_BY(Last, PageSize);
|
||||
|
||||
/* Probe the entire range */
|
||||
while (Current != Last)
|
||||
|
|
|
@ -142,7 +142,7 @@ CreatePipe(PHANDLE hReadPipe,
|
|||
|
||||
/* Create the pipe name */
|
||||
swprintf(Buffer,
|
||||
L"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
|
||||
L"\\Device\\NamedPipe\\Win32Pipes.%p.%08x",
|
||||
NtCurrentTeb()->ClientId.UniqueProcess,
|
||||
PipeId);
|
||||
RtlInitUnicodeString(&PipeName, Buffer);
|
||||
|
|
|
@ -404,7 +404,7 @@ GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
|||
PVOID hMapped;
|
||||
ULONG Ordinal = 0;
|
||||
|
||||
if (HIWORD(lpProcName) != 0)
|
||||
if ((ULONG_PTR)lpProcName > MAXUSHORT)
|
||||
{
|
||||
/* Look up by name */
|
||||
RtlInitAnsiString(&ProcedureName, (LPSTR)lpProcName);
|
||||
|
@ -413,7 +413,7 @@ GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
|
|||
else
|
||||
{
|
||||
/* Look up by ordinal */
|
||||
Ordinal = (ULONG)lpProcName;
|
||||
Ordinal = PtrToUlong(lpProcName);
|
||||
}
|
||||
|
||||
/* Map provided handle */
|
||||
|
|
|
@ -118,7 +118,7 @@ BasepComputeProcessPath(IN PBASE_SEARCH_PATH_TYPE PathOrder,
|
|||
IN LPVOID Environment)
|
||||
{
|
||||
PWCHAR PathBuffer, Buffer, AppNameEnd, PathCurrent;
|
||||
ULONG PathLengthInBytes;
|
||||
SIZE_T PathLengthInBytes;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING EnvPath;
|
||||
PBASE_SEARCH_PATH_TYPE Order;
|
||||
|
@ -1040,7 +1040,7 @@ GetFullPathNameA(IN LPCSTR lpFileName,
|
|||
/* Yep, so in this case get the length of the file part too */
|
||||
Status = RtlUnicodeToMultiByteSize(&FilePartSize,
|
||||
Buffer,
|
||||
(LocalFilePart - Buffer) *
|
||||
(ULONG)(LocalFilePart - Buffer) *
|
||||
sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1231,7 +1231,7 @@ SearchPathA(IN LPCSTR lpPath OPTIONAL,
|
|||
/* Yep, so in this case get the length of the file part too */
|
||||
Status = RtlUnicodeToMultiByteSize(&FilePartSize,
|
||||
Buffer,
|
||||
(LocalFilePart - Buffer) *
|
||||
(ULONG)(LocalFilePart - Buffer) *
|
||||
sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1302,7 +1302,8 @@ SearchPathW(IN LPCWSTR lpPath OPTIONAL,
|
|||
OUT LPWSTR *lpFilePart OPTIONAL)
|
||||
{
|
||||
UNICODE_STRING FileNameString, ExtensionString, PathString, CallerBuffer;
|
||||
ULONG Flags, LengthNeeded, FilePartSize;
|
||||
ULONG Flags;
|
||||
SIZE_T LengthNeeded, FilePartSize;
|
||||
NTSTATUS Status;
|
||||
DWORD Result = 0;
|
||||
|
||||
|
@ -1456,10 +1457,9 @@ GetLongPathNameW(IN LPCWSTR lpszShortPath,
|
|||
IN DWORD cchBuffer)
|
||||
{
|
||||
PWCHAR Path, Original, First, Last, Buffer, Src, Dst;
|
||||
ULONG Length;
|
||||
SIZE_T Length, ReturnLength;
|
||||
WCHAR LastChar;
|
||||
HANDLE FindHandle;
|
||||
DWORD ReturnLength;
|
||||
ULONG ErrorMode;
|
||||
BOOLEAN Found = FALSE;
|
||||
WIN32_FIND_DATAW FindFileData;
|
||||
|
@ -1834,10 +1834,9 @@ GetShortPathNameW(IN LPCWSTR lpszLongPath,
|
|||
IN DWORD cchBuffer)
|
||||
{
|
||||
PWCHAR Path, Original, First, Last, Buffer, Src, Dst;
|
||||
ULONG Length;
|
||||
SIZE_T Length, ReturnLength;
|
||||
WCHAR LastChar;
|
||||
HANDLE FindHandle;
|
||||
DWORD ReturnLength;
|
||||
ULONG ErrorMode;
|
||||
BOOLEAN Found = FALSE;
|
||||
WIN32_FIND_DATAW FindFileData;
|
||||
|
|
|
@ -440,7 +440,7 @@ BasepSxsCloseHandles(IN PBASE_MSG_SXS_HANDLES Handles)
|
|||
if (Handles->ViewBase.QuadPart)
|
||||
{
|
||||
Status = NtUnmapViewOfSection(NtCurrentProcess(),
|
||||
(PVOID)Handles->ViewBase.LowPart);
|
||||
(PVOID)(ULONG_PTR)Handles->ViewBase.QuadPart);
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
}
|
||||
}
|
||||
|
@ -2310,7 +2310,8 @@ CreateProcessInternalW(IN HANDLE hUserToken,
|
|||
SECTION_IMAGE_INFORMATION ImageInformation;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
CLIENT_ID ClientId;
|
||||
ULONG NoWindow, RegionSize, StackSize, ErrorCode, Flags;
|
||||
ULONG NoWindow, StackSize, ErrorCode, Flags;
|
||||
SIZE_T RegionSize;
|
||||
USHORT ImageMachine;
|
||||
ULONG ParameterFlags, PrivilegeValue, HardErrorMode, ErrorResponse;
|
||||
ULONG_PTR ErrorParameters[2];
|
||||
|
@ -2342,7 +2343,8 @@ CreateProcessInternalW(IN HANDLE hUserToken,
|
|||
SIZE_T n;
|
||||
WCHAR SaveChar;
|
||||
ULONG Length, FileAttribs, CmdQuoteLength;
|
||||
ULONG CmdLineLength, ResultSize;
|
||||
ULONG ResultSize;
|
||||
SIZE_T EnvironmentLength, CmdLineLength;
|
||||
PWCHAR QuotedCmdLine, AnsiCmdCommand, ExtBuffer, CurrentDirectory;
|
||||
PWCHAR NullBuffer, ScanString, NameBuffer, SearchPath, DebuggerCmdLine;
|
||||
ANSI_STRING AnsiEnv;
|
||||
|
@ -2571,8 +2573,17 @@ CreateProcessInternalW(IN HANDLE hUserToken,
|
|||
AnsiEnv.Buffer = pcScan = (PCHAR)lpEnvironment;
|
||||
while ((*pcScan) || (*(pcScan + 1))) ++pcScan;
|
||||
|
||||
/* Make sure the environment is not too large */
|
||||
EnvironmentLength = (pcScan + sizeof(ANSI_NULL) - (PCHAR)lpEnvironment);
|
||||
if (EnvironmentLength > MAXUSHORT)
|
||||
{
|
||||
/* Fail */
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Create our ANSI String */
|
||||
AnsiEnv.Length = pcScan - (PCHAR)lpEnvironment + sizeof(ANSI_NULL);
|
||||
AnsiEnv.Length = (USHORT)EnvironmentLength;
|
||||
AnsiEnv.MaximumLength = AnsiEnv.Length + sizeof(ANSI_NULL);
|
||||
|
||||
/* Allocate memory for the Unicode Environment */
|
||||
|
@ -4003,10 +4014,11 @@ StartScan:
|
|||
if (VdmReserve)
|
||||
{
|
||||
/* Reserve the requested allocation */
|
||||
RegionSize = VdmReserve;
|
||||
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||
&BaseAddress,
|
||||
0,
|
||||
&VdmReserve,
|
||||
&RegionSize,
|
||||
MEM_RESERVE,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -4017,6 +4029,8 @@ StartScan:
|
|||
Result = FALSE;
|
||||
goto Quickie;
|
||||
}
|
||||
|
||||
VdmReserve = (ULONG)RegionSize;
|
||||
}
|
||||
|
||||
/* Check if we've already queried information on the section */
|
||||
|
@ -4267,7 +4281,12 @@ StartScan:
|
|||
|
||||
/* Write the remote PEB address and clear it locally, we no longer use it */
|
||||
CreateProcessMsg->PebAddressNative = RemotePeb;
|
||||
#ifdef _WIN64
|
||||
DPRINT1("TODO: WOW64 is not supported yet\n");
|
||||
CreateProcessMsg->PebAddressWow64 = 0;
|
||||
#else
|
||||
CreateProcessMsg->PebAddressWow64 = (ULONG)RemotePeb;
|
||||
#endif
|
||||
RemotePeb = NULL;
|
||||
|
||||
/* Now check what kind of architecture this image was made for */
|
||||
|
|
|
@ -746,7 +746,8 @@ BaseCreateVDMEnvironment(IN PWCHAR lpEnvironment,
|
|||
|
||||
BOOL Success = FALSE;
|
||||
NTSTATUS Status;
|
||||
ULONG RegionSize, EnvironmentSize = 0;
|
||||
ULONG EnvironmentSize = 0;
|
||||
SIZE_T RegionSize;
|
||||
PWCHAR Environment, NewEnvironment = NULL;
|
||||
ENV_NAME_TYPE NameType;
|
||||
ULONG NameLength, NumChars, Remaining;
|
||||
|
@ -1025,7 +1026,7 @@ NTAPI
|
|||
BaseDestroyVDMEnvironment(IN PANSI_STRING AnsiEnv,
|
||||
IN PUNICODE_STRING UnicodeEnv)
|
||||
{
|
||||
ULONG Dummy = 0;
|
||||
SIZE_T Dummy = 0;
|
||||
|
||||
/* Clear the ANSI buffer since Rtl creates this for us */
|
||||
if (AnsiEnv->Buffer) RtlFreeAnsiString(AnsiEnv);
|
||||
|
|
|
@ -29,8 +29,8 @@ VirtualAllocEx(IN HANDLE hProcess,
|
|||
NTSTATUS Status;
|
||||
|
||||
/* Make sure the address is within the granularity of the system (64K) */
|
||||
if ((lpAddress) &&
|
||||
(lpAddress < (PVOID)BaseStaticServerData->SysInfo.AllocationGranularity))
|
||||
if ((lpAddress != NULL) &&
|
||||
(lpAddress < UlongToPtr(BaseStaticServerData->SysInfo.AllocationGranularity)))
|
||||
{
|
||||
/* Fail the call */
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include <ndk/setypes.h>
|
||||
#include <ndk/umfuncs.h>
|
||||
|
||||
#include <ntstrsafe.h>
|
||||
|
||||
/* CSRSS Headers */
|
||||
#include <csr/csr.h>
|
||||
#include <win/base.h>
|
||||
|
|
Loading…
Reference in a new issue