From 6b1ca7589902463a3c4a621e09fc5ef0b5aab9f0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 3 Apr 2018 15:13:17 -0600 Subject: [PATCH] [REACTOS] Fix 64 bit build (#465) * [HAL] Simplify HalpReboot() and make it portable * [NTOS:MM] Cast constant to PVOID * [BINPATCH] Fix 64 bit build * [VFDDRV] Fix 64 bit build and buffer overruns * [USBOHCI] Fix structure alignment issues * [ATL_APITEST] Fix 64 bit build * [XDK] Update unwind structures in winnt.h * [NTDLL_APITEST] Fix 64 bit build * [NTDLL_WINETEST] Fix 64 bit build * [TFTPD] Fix x64 build * [USBPORT] Fix a C_ASSERT * [DSOUND] Fix x64 build * [HAL] Remove obsolete GetPteAddress() macro --- base/services/tftpd/tftpd.cpp | 2 +- dll/directx/wine/dsound/buffer.c | 4 +- dll/directx/wine/dsound/primary.c | 2 +- drivers/usb/usbohci_new/usbohci.h | 11 ++- drivers/usb/usbport/usbport.h | 2 +- hal/halx86/generic/reboot.c | 19 +---- .../sysutils/utils/binpatch/patch.c | 40 ++++----- modules/rosapps/drivers/vfd/vfddev.c | 23 ++++++ modules/rosapps/drivers/vfd/vfddrv.h | 4 + modules/rosapps/drivers/vfd/vfdimg.c | 4 + modules/rosapps/drivers/vfd/vfdlink.c | 29 +++++++ modules/rostests/apitests/atl/CComObject.cpp | 2 +- .../apitests/ntdll/LdrEnumResources.c | 2 +- .../apitests/ntdll/NtAcceptConnectPort.c | 12 +-- .../apitests/ntdll/NtApphelpCacheControl.c | 4 + .../rostests/apitests/ntdll/NtCreateFile.c | 2 +- .../rostests/apitests/ntdll/RtlAllocateHeap.c | 2 +- .../ntdll/RtlDosPathNameToNtPathName_U.c | 2 +- .../apitests/ntdll/RtlpEnsureBufferSize.c | 4 +- modules/rostests/winetests/ntdll/exception.c | 35 +++++++- ntoskrnl/mm/ARM3/mminit.c | 2 +- sdk/include/xdk/winnt_old.h | 82 ++++++++++++++++--- sdk/lib/rtl/amd64/unwind.c | 35 ++++---- sdk/lib/rtl/rtlp.h | 4 + 24 files changed, 243 insertions(+), 85 deletions(-) diff --git a/base/services/tftpd/tftpd.cpp b/base/services/tftpd/tftpd.cpp index 106d7cdd9b3..7e0968a0a54 100644 --- a/base/services/tftpd/tftpd.cpp +++ b/base/services/tftpd/tftpd.cpp @@ -1009,7 +1009,7 @@ void processRequest(void *lpParam) continue; errno = 0; - req.bytesReady = (MYDWORD)outPtr - (MYDWORD)&req.mesout; + req.bytesReady = (const char*)outPtr - (const char*)&req.mesout; //printf("Bytes Ready=%u\n", req.bytesReady); send(req.sock, (const char*)&req.mesout, req.bytesReady, 0); errno = WSAGetLastError(); diff --git a/dll/directx/wine/dsound/buffer.c b/dll/directx/wine/dsound/buffer.c index 89b516cacce..e70501f5b21 100644 --- a/dll/directx/wine/dsound/buffer.c +++ b/dll/directx/wine/dsound/buffer.c @@ -1302,7 +1302,7 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_Get( prop.s.Set = *guidPropSet; prop.s.Id = dwPropID; prop.s.Flags = 0; /* unused */ - prop.s.InstanceId = (ULONG)This->dsb->device; + prop.s.InstanceId = (ULONG_PTR)This->dsb->device; hres = IDsDriverPropertySet_Get(ps, &prop, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned); @@ -1339,7 +1339,7 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_Set( prop.s.Set = *guidPropSet; prop.s.Id = dwPropID; prop.s.Flags = 0; /* unused */ - prop.s.InstanceId = (ULONG)This->dsb->device; + prop.s.InstanceId = (ULONG_PTR)This->dsb->device; hres = IDsDriverPropertySet_Set(ps,&prop,pInstanceData,cbInstanceData,pPropData,cbPropData); IDsDriverPropertySet_Release(ps); diff --git a/dll/directx/wine/dsound/primary.c b/dll/directx/wine/dsound/primary.c index 0df7850b12f..b04a526929e 100644 --- a/dll/directx/wine/dsound/primary.c +++ b/dll/directx/wine/dsound/primary.c @@ -90,7 +90,7 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) /* DRV_QUERYDSOUNDIFACE is a "Wine extension" to get the DSound interface */ if (ds_hw_accel != DS_HW_ACCEL_EMULATION && !forcewave) - waveOutMessage((HWAVEOUT)device->drvdesc.dnDevNode, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&device->driver, 0); + waveOutMessage((HWAVEOUT)(DWORD_PTR)device->drvdesc.dnDevNode, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&device->driver, 0); /* Get driver description */ if (device->driver) { diff --git a/drivers/usb/usbohci_new/usbohci.h b/drivers/usb/usbohci_new/usbohci.h index 281b6c856d3..4d468b5991f 100644 --- a/drivers/usb/usbohci_new/usbohci.h +++ b/drivers/usb/usbohci_new/usbohci.h @@ -38,7 +38,7 @@ extern USBPORT_REGISTRATION_PACKET RegPacket; typedef struct _OHCI_TRANSFER *POHCI_TRANSFER; -typedef union _OHCI_HW_TRANSFER_DESCRIPTOR { +typedef union DECLSPEC_ALIGN(32) _OHCI_HW_TRANSFER_DESCRIPTOR { struct { OHCI_TRANSFER_DESCRIPTOR gTD; // must be aligned to a 16-byte boundary USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket; @@ -50,6 +50,7 @@ typedef union _OHCI_HW_TRANSFER_DESCRIPTOR { } OHCI_HW_TRANSFER_DESCRIPTOR, *POHCI_HW_TRANSFER_DESCRIPTOR; C_ASSERT(sizeof(OHCI_HW_TRANSFER_DESCRIPTOR) == 32); +C_ASSERT(_alignof(OHCI_HW_TRANSFER_DESCRIPTOR) == 32); typedef struct _OHCI_HCD_TD { /* Hardware part */ @@ -64,7 +65,11 @@ typedef struct _OHCI_HCD_TD { ULONG Pad[1]; } OHCI_HCD_TD, *POHCI_HCD_TD; +#ifdef _WIN64 +C_ASSERT(sizeof(OHCI_HCD_TD) == 96); +#else C_ASSERT(sizeof(OHCI_HCD_TD) == 64); +#endif typedef struct _OHCI_HCD_ED { /* Hardware part */ @@ -73,7 +78,11 @@ typedef struct _OHCI_HCD_ED { ULONG PhysicalAddress; ULONG Flags; LIST_ENTRY HcdEDLink; +#ifdef _WIN64 + ULONG Pad[6]; +#else ULONG Pad[8]; +#endif } OHCI_HCD_ED, *POHCI_HCD_ED; C_ASSERT(sizeof(OHCI_HCD_ED) == 64); diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h index 20386f4845e..7895b97bdef 100644 --- a/drivers/usb/usbport/usbport.h +++ b/drivers/usb/usbport/usbport.h @@ -402,7 +402,7 @@ typedef struct _USBPORT_DEVICE_EXTENSION { #if !defined(_M_X64) C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x500); #else -C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x600); +C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x690); #endif typedef struct _USBPORT_RH_DESCRIPTORS { diff --git a/hal/halx86/generic/reboot.c b/hal/halx86/generic/reboot.c index 068cc17a8af..587b116c6f0 100644 --- a/hal/halx86/generic/reboot.c +++ b/hal/halx86/generic/reboot.c @@ -13,8 +13,6 @@ #define NDEBUG #include -#define GetPteAddress(x) (PHARDWARE_PTE)(((((ULONG_PTR)(x)) >> 12) << 2) + 0xC0000000) - /* PRIVATE FUNCTIONS *********************************************************/ VOID @@ -29,22 +27,13 @@ VOID NTAPI HalpReboot(VOID) { + PHYSICAL_ADDRESS PhysicalAddress; UCHAR Data; PVOID ZeroPageMapping; - PHARDWARE_PTE Pte; - /* Get a PTE in the HAL reserved region */ - ZeroPageMapping = (PVOID)(0xFFC00000 + PAGE_SIZE); - Pte = GetPteAddress(ZeroPageMapping); - - /* Make it valid and map it to the first physical page */ - Pte->Valid = 1; - Pte->Write = 1; - Pte->Owner = 1; - Pte->PageFrameNumber = 0; - - /* Flush the TLB by resetting CR3 */ - __writecr3(__readcr3()); + /* Map the first physical page */ + PhysicalAddress.QuadPart = 0; + ZeroPageMapping = HalpMapPhysicalMemory64(PhysicalAddress, 1); /* Enable warm reboot */ ((PUSHORT)ZeroPageMapping)[0x239] = 0x1234; diff --git a/modules/rosapps/applications/sysutils/utils/binpatch/patch.c b/modules/rosapps/applications/sysutils/utils/binpatch/patch.c index e2a13c3a625..e793c661f1d 100644 --- a/modules/rosapps/applications/sysutils/utils/binpatch/patch.c +++ b/modules/rosapps/applications/sysutils/utils/binpatch/patch.c @@ -16,7 +16,7 @@ typedef struct _PatchedByte { - int offset; /*!< File offset of the patched byte. */ + uintptr_t offset; /*!< File offset of the patched byte. */ unsigned char expected; /*!< Expected (original) value of the byte. */ unsigned char patched; /*!< Patched (new) value for the byte. */ } PatchedByte; @@ -24,7 +24,7 @@ typedef struct _PatchedByte typedef struct _PatchedFile { const char *name; /*!< Name of the file to be patched. */ - int fileSize; /*!< Size of the file in bytes. */ + size_t fileSize; /*!< Size of the file in bytes. */ int patchCount; /*!< Number of patches for the file. */ PatchedByte *patches; /*!< Patches for the file. */ } PatchedFile; @@ -53,11 +53,11 @@ static char m_patchBuffer[SIZEOF_PATCH_BUFFER_MAGIC + PATCH_BUFFER_SIZE] = /** HELPER FUNCTIONS **********************************************************/ static void * -loadFile(const char *fileName, int *fileSize_) +loadFile(const char *fileName, size_t *fileSize_) { FILE *f; struct stat sb; - int fileSize; + size_t fileSize; void *p; /* Open the file */ @@ -82,7 +82,7 @@ loadFile(const char *fileName, int *fileSize_) if (p == NULL) { fclose(f); - printf("Couldn't allocate %d bytes for file %s!\n", fileSize, fileName); + printf("Couldn't allocate %Id bytes for file %s!\n", fileSize, fileName); return NULL; } @@ -103,7 +103,7 @@ loadFile(const char *fileName, int *fileSize_) static int -saveFile(const char *fileName, void *file, int fileSize) +saveFile(const char *fileName, void *file, size_t fileSize) { FILE *f; @@ -136,7 +136,8 @@ compareFiles( { const char *patchedFileName = patchedFile->name; unsigned char *origChunk, *patchedChunk; - int origSize, patchedSize, i, patchCount; + size_t origSize, patchedSize; + int i, patchCount; PatchedByte *patches = NULL; int patchesArrayCount = 0; @@ -154,7 +155,7 @@ compareFiles( { free(origChunk); free(patchedChunk); - printf("File size of %s and %s differs (%d != %d)\n", + printf("File size of %s and %s differs (%Iu != %Iu)\n", originalFileName, patchedFileName, origSize, patchedSize); return -1; @@ -179,7 +180,7 @@ compareFiles( free(patches); free(origChunk); free(patchedChunk); - printf("\nOut of memory (tried to allocated %d bytes)\n", + printf("\nOut of memory (tried to allocated %Id bytes)\n", patchCount * sizeof (PatchedByte)); return -1; } @@ -213,7 +214,7 @@ static int outputPatch(const char *outputFileName) { char *patchExe, *patchBuffer = NULL; - int i, size, patchExeSize, patchSize, stringSize, stringOffset, patchOffset; + size_t i, size, patchExeSize, patchSize, stringSize, stringOffset, patchOffset; Patch *patch; PatchedFile *files; @@ -229,7 +230,7 @@ outputPatch(const char *outputFileName) } if ((stringSize + patchSize) > PATCH_BUFFER_SIZE) { - printf("Patch is too big - %d bytes maximum, %d bytes needed\n", + printf("Patch is too big - %u bytes maximum, %Iu bytes needed\n", PATCH_BUFFER_SIZE, stringSize + patchSize); return -1; } @@ -316,14 +317,14 @@ loadPatch() return -1; } - m_patch.name = p + (int)patch->name; + m_patch.name = p + (intptr_t)patch->name; m_patch.fileCount = patch->fileCount; - m_patch.files = (PatchedFile *)(p + (int)patch->files); + m_patch.files = (PatchedFile *)(p + (intptr_t)patch->files); for (i = 0; i < m_patch.fileCount; i++) { - m_patch.files[i].name = p + (int)m_patch.files[i].name; - m_patch.files[i].patches = (PatchedByte *)(p + (int)m_patch.files[i].patches); + m_patch.files[i].name = p + (intptr_t)m_patch.files[i].name; + m_patch.files[i].patches = (PatchedByte *)(p + (intptr_t)m_patch.files[i].patches); } printf("Patch %s loaded...\n", m_patch.name); @@ -386,7 +387,8 @@ createPatch() static int applyPatch() { - int c, i, j, fileSize, makeBackup; + int c, i, j, makeBackup; + size_t fileSize; unsigned char *file; char *p; const char *fileName; @@ -415,12 +417,12 @@ applyPatch() { printf("----------------------\n" "File name: %s\n" - "File size: %d bytes\n", + "File size: %Id bytes\n", m_patch.files[i].name, m_patch.files[i].fileSize); printf("Patch count: %d\n", m_patch.files[i].patchCount); for (j = 0; j < m_patch.files[i].patchCount; j++) { - printf(" Offset 0x%x 0x%02x -> 0x%02x\n", + printf(" Offset 0x%Ix 0x%02x -> 0x%02x\n", m_patch.files[i].patches[j].offset, m_patch.files[i].patches[j].expected, m_patch.files[i].patches[j].patched); @@ -483,7 +485,7 @@ applyPatch_file_open_error: if (fileSize != m_patch.files[i].fileSize) { free(file); - printf("File %s has unexpected filesize of %d bytes (%d bytes expected)\n", + printf("File %s has unexpected filesize of %Id bytes (%Id bytes expected)\n", fileName, fileSize, m_patch.files[i].fileSize); if (fileName != m_patch.files[i].name) /* manually entered filename */ { diff --git a/modules/rosapps/drivers/vfd/vfddev.c b/modules/rosapps/drivers/vfd/vfddev.c index 6aee0bcd8a2..137ce595e56 100644 --- a/modules/rosapps/drivers/vfd/vfddev.c +++ b/modules/rosapps/drivers/vfd/vfddev.c @@ -62,10 +62,17 @@ VfdCreateDevice( physical_num = 0; do { +#ifndef __REACTOS__ name_buffer[sizeof(name_buffer) - 1] = UNICODE_NULL; _snwprintf(name_buffer, sizeof(name_buffer) - 1, L"\\Device\\Floppy%lu", physical_num); +#else + name_buffer[ARRAYSIZE(name_buffer) - 1] = UNICODE_NULL; + + _snwprintf(name_buffer, ARRAYSIZE(name_buffer) - 1, + L"\\Device\\Floppy%lu", physical_num); +#endif RtlInitUnicodeString(&unicode_name, name_buffer); @@ -130,11 +137,19 @@ VfdCreateDevice( // Create the interface link (\??\VirtualFD) +#ifndef __REACTOS__ name_buffer[sizeof(name_buffer) - 1] = UNICODE_NULL; _snwprintf(name_buffer, sizeof(name_buffer) - 1, L"\\??\\" VFD_DEVICE_BASENAME L"%lu", device_extension->DeviceNumber); +#else + name_buffer[ARRAYSIZE(name_buffer) - 1] = UNICODE_NULL; + + _snwprintf(name_buffer, ARRAYSIZE(name_buffer) - 1, + L"\\??\\" VFD_DEVICE_BASENAME L"%lu", + device_extension->DeviceNumber); +#endif RtlInitUnicodeString(&unicode_name, name_buffer); @@ -352,11 +367,19 @@ VfdDeleteDevice( // Remove the interface symbolic link +#ifndef __REACTOS__ name_buffer[sizeof(name_buffer) - 1] = UNICODE_NULL; _snwprintf(name_buffer, sizeof(name_buffer) - 1, L"\\??\\" VFD_DEVICE_BASENAME L"%lu", device_extension->DeviceNumber); +#else + name_buffer[ARRAYSIZE(name_buffer) - 1] = UNICODE_NULL; + + _snwprintf(name_buffer, ARRAYSIZE(name_buffer) - 1, + L"\\??\\" VFD_DEVICE_BASENAME L"%lu", + device_extension->DeviceNumber); +#endif RtlInitUnicodeString(&unicode_name, name_buffer); diff --git a/modules/rosapps/drivers/vfd/vfddrv.h b/modules/rosapps/drivers/vfd/vfddrv.h index 589ca894cc1..4760d3b7a0f 100644 --- a/modules/rosapps/drivers/vfd/vfddrv.h +++ b/modules/rosapps/drivers/vfd/vfddrv.h @@ -248,7 +248,11 @@ VfdQueryImage( IN PDEVICE_EXTENSION DeviceExtension, OUT PVFD_IMAGE_INFO ImageInfo, IN ULONG BufferLength, +#ifndef __REACTOS__ OUT PULONG ReturnLength); +#else + OUT PSIZE_T ReturnLength); +#endif // // vfdrdwr.c diff --git a/modules/rosapps/drivers/vfd/vfdimg.c b/modules/rosapps/drivers/vfd/vfdimg.c index b6cabe04ab1..c04d1978ffb 100644 --- a/modules/rosapps/drivers/vfd/vfdimg.c +++ b/modules/rosapps/drivers/vfd/vfdimg.c @@ -467,7 +467,11 @@ VfdQueryImage( IN PDEVICE_EXTENSION DeviceExtension, OUT PVFD_IMAGE_INFO ImageInfo, IN ULONG BufferLength, +#ifndef __REACTOS__ OUT PULONG ReturnLength) +#else + OUT PSIZE_T ReturnLength) +#endif { // Check output buffer length diff --git a/modules/rosapps/drivers/vfd/vfdlink.c b/modules/rosapps/drivers/vfd/vfdlink.c index 0d32cd2bd0e..d6ba9034b2f 100644 --- a/modules/rosapps/drivers/vfd/vfdlink.c +++ b/modules/rosapps/drivers/vfd/vfdlink.c @@ -49,7 +49,11 @@ VfdSetLink( // // Delete the old drive letter // +#ifndef __REACTOS__ name_buf[sizeof(name_buf) - 1] = UNICODE_NULL; +#else + name_buf[ARRAYSIZE(name_buf) - 1] = UNICODE_NULL; +#endif _snwprintf(name_buf, sizeof(name_buf) - 1, L"\\??\\%wc:", DeviceExtension->DriveLetter); @@ -85,12 +89,21 @@ VfdSetLink( // Create a new drive letter // +#ifndef __REACTOS__ name_buf[sizeof(name_buf) - 1] = UNICODE_NULL; _snwprintf(name_buf, sizeof(name_buf) - 1, (OsMajorVersion >= 5) ? L"\\??\\Global\\%wc:" : L"\\??\\%wc:", DriveLetter); +#else + name_buf[ARRAYSIZE(name_buf) - 1] = UNICODE_NULL; + + _snwprintf(name_buf, ARRAYSIZE(name_buf) - 1, + (OsMajorVersion >= 5) ? + L"\\??\\Global\\%wc:" : L"\\??\\%wc:", + DriveLetter); +#endif RtlInitUnicodeString(&unicode_name, name_buf); @@ -133,11 +146,19 @@ VfdLoadLink( RtlZeroMemory(params, sizeof(params)); +#ifndef __REACTOS__ name_buf[sizeof(name_buf) - 1] = UNICODE_NULL; _snwprintf(name_buf, sizeof(name_buf) - 1, VFD_REG_DRIVE_LETTER L"%lu", DeviceExtension->DeviceNumber); +#else + name_buf[ARRAYSIZE(name_buf) - 1] = UNICODE_NULL; + + _snwprintf(name_buf, ARRAYSIZE(name_buf) - 1, + VFD_REG_DRIVE_LETTER L"%lu", + DeviceExtension->DeviceNumber); +#endif params[0].Flags = RTL_QUERY_REGISTRY_DIRECT; params[0].Name = name_buf; @@ -192,11 +213,19 @@ VfdStoreLink( return STATUS_DRIVER_INTERNAL_ERROR; } +#ifndef __REACTOS__ name_buf[sizeof(name_buf) - 1] = UNICODE_NULL; _snwprintf(name_buf, sizeof(name_buf) - 1, VFD_REG_DRIVE_LETTER L"%lu", DeviceExtension->DeviceNumber); +#else + name_buf[ARRAYSIZE(name_buf) - 1] = UNICODE_NULL; + + _snwprintf(name_buf, ARRAYSIZE(name_buf) - 1, + VFD_REG_DRIVE_LETTER L"%lu", + DeviceExtension->DeviceNumber); +#endif letter = DeviceExtension->DriveLetter; diff --git a/modules/rostests/apitests/atl/CComObject.cpp b/modules/rostests/apitests/atl/CComObject.cpp index 840f88a9676..9703267df6d 100644 --- a/modules/rostests/apitests/atl/CComObject.cpp +++ b/modules/rostests/apitests/atl/CComObject.cpp @@ -67,7 +67,7 @@ public: return E_NOTIMPL; } - static HRESULT WINAPI FuncBlind(void* pv, REFIID riid, LPVOID* ppv, DWORD dw) + static HRESULT WINAPI FuncBlind(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) { InterlockedIncrement(&g_BLIND); return E_FAIL; diff --git a/modules/rostests/apitests/ntdll/LdrEnumResources.c b/modules/rostests/apitests/ntdll/LdrEnumResources.c index 7d63ecc90a3..c18aab8e193 100644 --- a/modules/rostests/apitests/ntdll/LdrEnumResources.c +++ b/modules/rostests/apitests/ntdll/LdrEnumResources.c @@ -169,7 +169,7 @@ InitializeTestImage( TestImage->NtHeaders.FileHeader.Characteristics = 0; TestImage->NtHeaders.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR32_MAGIC; - TestImage->NtHeaders.OptionalHeader.ImageBase = (DWORD)TestImage; + TestImage->NtHeaders.OptionalHeader.ImageBase = (DWORD_PTR)TestImage; TestImage->NtHeaders.OptionalHeader.SizeOfImage = sizeof(TEST_IMAGE); TestImage->NtHeaders.OptionalHeader.SizeOfHeaders = sizeof(IMAGE_DOS_HEADER) + sizeof(IMAGE_NT_HEADERS); diff --git a/modules/rostests/apitests/ntdll/NtAcceptConnectPort.c b/modules/rostests/apitests/ntdll/NtAcceptConnectPort.c index 359f06382fb..78800c6984c 100644 --- a/modules/rostests/apitests/ntdll/NtAcceptConnectPort.c +++ b/modules/rostests/apitests/ntdll/NtAcceptConnectPort.c @@ -51,10 +51,10 @@ ServerThread( "DataLength = %u\n", Message.Header.u1.s1.DataLength); ok(Message.Header.u2.s2.Type == LPC_CONNECTION_REQUEST, "Type = %x\n", Message.Header.u2.s2.Type); - ok(Message.Header.ClientId.UniqueProcess == (HANDLE)GetCurrentProcessId(), + ok(Message.Header.ClientId.UniqueProcess == UlongToHandle(GetCurrentProcessId()), "UniqueProcess = %p, expected %lx\n", Message.Header.ClientId.UniqueProcess, GetCurrentProcessId()); - ok(Message.Header.ClientId.UniqueThread == (HANDLE)ClientThreadId, + ok(Message.Header.ClientId.UniqueThread == UlongToHandle(ClientThreadId), "UniqueThread = %p, expected %x\n", Message.Header.ClientId.UniqueThread, ClientThreadId); ok(Message.Message == TEST_CONNECTION_INFO_SIGNATURE1, "Message = %lx\n", Message.Message); @@ -82,10 +82,10 @@ ServerThread( "DataLength = %u\n", Message.Header.u1.s1.DataLength); ok(Message.Header.u2.s2.Type == LPC_CONNECTION_REQUEST, "Type = %x\n", Message.Header.u2.s2.Type); - ok(Message.Header.ClientId.UniqueProcess == (HANDLE)GetCurrentProcessId(), + ok(Message.Header.ClientId.UniqueProcess == UlongToHandle(GetCurrentProcessId()), "UniqueProcess = %p, expected %lx\n", Message.Header.ClientId.UniqueProcess, GetCurrentProcessId()); - ok(Message.Header.ClientId.UniqueThread == (HANDLE)ClientThreadId, + ok(Message.Header.ClientId.UniqueThread == UlongToHandle(ClientThreadId), "UniqueThread = %p, expected %x\n", Message.Header.ClientId.UniqueThread, ClientThreadId); ok(Message.Message == TEST_CONNECTION_INFO_SIGNATURE2, "Message = %lx\n", Message.Message); @@ -115,10 +115,10 @@ ServerThread( "DataLength = %u\n", Message.Header.u1.s1.DataLength); ok(Message.Header.u2.s2.Type == LPC_DATAGRAM, "Type = %x\n", Message.Header.u2.s2.Type); - ok(Message.Header.ClientId.UniqueProcess == (HANDLE)GetCurrentProcessId(), + ok(Message.Header.ClientId.UniqueProcess == UlongToHandle(GetCurrentProcessId()), "UniqueProcess = %p, expected %lx\n", Message.Header.ClientId.UniqueProcess, GetCurrentProcessId()); - ok(Message.Header.ClientId.UniqueThread == (HANDLE)ClientThreadId, + ok(Message.Header.ClientId.UniqueThread == UlongToHandle(ClientThreadId), "UniqueThread = %p, expected %x\n", Message.Header.ClientId.UniqueThread, ClientThreadId); ok(Message.Message == TEST_MESSAGE_MESSAGE, "Message = %lx\n", Message.Message); diff --git a/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c b/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c index d0ffde08809..5044d3bbd67 100644 --- a/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c +++ b/modules/rostests/apitests/ntdll/NtApphelpCacheControl.c @@ -170,7 +170,11 @@ static void RunApphelpCacheControlTests(SC_HANDLE service_handle) RequestAddition(service_handle, TRUE); Status = CallCacheControl(&ntPath, TRUE, ApphelpCacheServiceLookup); ok_ntstatus(Status, STATUS_SUCCESS); +#ifdef _WIN64 + CacheEntry.ImageHandle = (HANDLE)0x8000000000000000ULL; +#else CacheEntry.ImageHandle = (HANDLE)0x80000000; +#endif Status = pNtApphelpCacheControl(ApphelpCacheServiceLookup, &CacheEntry); ok_ntstatus(Status, STATUS_NOT_FOUND); diff --git a/modules/rostests/apitests/ntdll/NtCreateFile.c b/modules/rostests/apitests/ntdll/NtCreateFile.c index 147028dd4ee..88f5649a975 100644 --- a/modules/rostests/apitests/ntdll/NtCreateFile.c +++ b/modules/rostests/apitests/ntdll/NtCreateFile.c @@ -15,7 +15,7 @@ START_TEST(NtCreateFile) Status = NtCreateFile(&FileHandle, FILE_READ_DATA, - (POBJECT_ATTRIBUTES)0xCCCCCCCC, + (POBJECT_ATTRIBUTES)(ULONG_PTR)0xCCCCCCCCCCCCCCCCULL, &StatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, diff --git a/modules/rostests/apitests/ntdll/RtlAllocateHeap.c b/modules/rostests/apitests/ntdll/RtlAllocateHeap.c index 77e72f33706..6a327bb09f0 100644 --- a/modules/rostests/apitests/ntdll/RtlAllocateHeap.c +++ b/modules/rostests/apitests/ntdll/RtlAllocateHeap.c @@ -62,7 +62,7 @@ START_TEST(RtlAllocateHeap) _SEH2_TRY { - hHeap = RtlCreateHeap(HEAP_CREATE_ALIGN_16, NULL, 0, 0, NULL, (PRTL_HEAP_PARAMETERS)0xdeadbeef); + hHeap = RtlCreateHeap(HEAP_CREATE_ALIGN_16, NULL, 0, 0, NULL, (PRTL_HEAP_PARAMETERS)(ULONG_PTR)0xdeadbeefdeadbeefULL); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { diff --git a/modules/rostests/apitests/ntdll/RtlDosPathNameToNtPathName_U.c b/modules/rostests/apitests/ntdll/RtlDosPathNameToNtPathName_U.c index 3b0dcb24c10..915b460bdcc 100644 --- a/modules/rostests/apitests/ntdll/RtlDosPathNameToNtPathName_U.c +++ b/modules/rostests/apitests/ntdll/RtlDosPathNameToNtPathName_U.c @@ -145,7 +145,7 @@ static void test2(LPCWSTR pwsz, LPCWSTR pwszExpected, LPCWSTR pwszExpectedPartNa check_result(bOK, "NtName does not match expected"); if (!bOK) { - printf("input: : %2u chars \"%S\"\n", wcslen(pwsz), pwsz); + printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz); printf("Expected: %2u chars \"%S\"\n", lenExp, pwszExpected); printf("Actual : %2u chars \"%S\"\n", lenAct, lenAct ? pwszActual : L"(null)"); return; diff --git a/modules/rostests/apitests/ntdll/RtlpEnsureBufferSize.c b/modules/rostests/apitests/ntdll/RtlpEnsureBufferSize.c index 79bf5ddfb90..e4583d43822 100644 --- a/modules/rostests/apitests/ntdll/RtlpEnsureBufferSize.c +++ b/modules/rostests/apitests/ntdll/RtlpEnsureBufferSize.c @@ -47,10 +47,10 @@ static BOOL IsBlockFromHeap(HANDLE hHeap, PVOID ptr) he.dwSize = sizeof(he); - if (Heap32First(&he, GetCurrentProcessId(), (DWORD)hHeap)) + if (Heap32First(&he, GetCurrentProcessId(), (DWORD_PTR)hHeap)) { do { - if ((DWORD)ptr >= he.dwAddress && (DWORD)ptr <= (he.dwAddress + he.dwBlockSize)) + if ((DWORD_PTR)ptr >= he.dwAddress && (DWORD_PTR)ptr <= (he.dwAddress + he.dwBlockSize)) ret = TRUE; } while (!ret && Heap32Next(&he)); } diff --git a/modules/rostests/winetests/ntdll/exception.c b/modules/rostests/winetests/ntdll/exception.c index acbde7b2cb4..7d3c89acafb 100644 --- a/modules/rostests/winetests/ntdll/exception.c +++ b/modules/rostests/winetests/ntdll/exception.c @@ -59,6 +59,7 @@ static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL); static NTSTATUS (WINAPI *pNtClose)(HANDLE); #if defined(__x86_64__) +#ifndef __REACTOS__ typedef struct { ULONG Count; @@ -115,6 +116,7 @@ typedef struct _JUMP_BUFFER SETJMP_FLOAT128 Xmm14; SETJMP_FLOAT128 Xmm15; } _JUMP_BUFFER; +#endif // __REACTOS__ static BOOLEAN (CDECL *pRtlAddFunctionTable)(RUNTIME_FUNCTION*, DWORD, DWORD64); static BOOLEAN (CDECL *pRtlDeleteFunctionTable)(RUNTIME_FUNCTION*); @@ -1608,10 +1610,12 @@ static void test_thread_context(void) #define is_wow64 0 +#ifndef __REACTOS__ #define UNW_FLAG_NHANDLER 0 #define UNW_FLAG_EHANDLER 1 #define UNW_FLAG_UHANDLER 2 #define UNW_FLAG_CHAININFO 4 +#endif // __REACTOS__ #define UWOP_PUSH_NONVOL 0 #define UWOP_ALLOC_LARGE 1 @@ -1730,15 +1734,25 @@ static void call_virtual_unwind( int testnum, const struct unwind_test *test ) if (j == rsp) /* rsp is special */ { +#ifndef __REACTOS__ ok( !ctx_ptr.u2.IntegerContext[j], "%u/%u: rsp should not be set in ctx_ptr\n", testnum, i ); +#else + ok(!ctx_ptr.IntegerContext[j], + "%u/%u: rsp should not be set in ctx_ptr\n", testnum, i); +#endif // __REACTOS__ + ok( context.Rsp == (ULONG64)fake_stack + test->results[i].regs[k][1], "%u/%u: register rsp wrong %p/%p\n", testnum, i, (void *)context.Rsp, (char *)fake_stack + test->results[i].regs[k][1] ); continue; } +#ifndef __REACTOS__ if (ctx_ptr.u2.IntegerContext[j]) +#else + if (ctx_ptr.IntegerContext[j]) +#endif // __REACTOS__ { ok( k < nb_regs, "%u/%u: register %s should not be set to %lx\n", testnum, i, reg_names[j], *(&context.Rax + j) ); @@ -1950,6 +1964,7 @@ static void test_restore_context(void) fltsave = &buf.Xmm6; for (i = 0; i < 10; i++) { +#ifndef __REACTOS__ ok(fltsave[i].Part[0] == ctx.u.FltSave.XmmRegisters[i + 6].Low, "longjmp failed for Xmm%d, expected %lx, got %lx\n", i + 6, fltsave[i].Part[0], ctx.u.FltSave.XmmRegisters[i + 6].Low); @@ -1957,6 +1972,15 @@ static void test_restore_context(void) ok(fltsave[i].Part[1] == ctx.u.FltSave.XmmRegisters[i + 6].High, "longjmp failed for Xmm%d, expected %lx, got %lx\n", i + 6, fltsave[i].Part[1], ctx.u.FltSave.XmmRegisters[i + 6].High); +#else + ok(fltsave[i].Part[0] == ctx.FltSave.XmmRegisters[i + 6].Low, + "longjmp failed for Xmm%d, expected %lx, got %lx\n", i + 6, + fltsave[i].Part[0], ctx.FltSave.XmmRegisters[i + 6].Low); + + ok(fltsave[i].Part[1] == ctx.FltSave.XmmRegisters[i + 6].High, + "longjmp failed for Xmm%d, expected %lx, got %lx\n", i + 6, + fltsave[i].Part[1], ctx.FltSave.XmmRegisters[i + 6].High); +#endif } } else @@ -2150,14 +2174,23 @@ static void test___C_specific_handler(void) rec.ExceptionFlags = 2; /* EH_UNWINDING */ frame = 0x1234; memset(&dispatch, 0, sizeof(dispatch)); +#ifndef __REACTOS__ dispatch.ImageBase = (ULONG_PTR)GetModuleHandleA(NULL); dispatch.ControlPc = dispatch.ImageBase + 0x200; - dispatch.HandlerData = &scope_table; +#else + dispatch.ImageBase = GetModuleHandleA(NULL); + dispatch.ControlPc = (ULONG_PTR)dispatch.ImageBase + 0x200; +#endif + dispatch.HandlerData = &scope_table; dispatch.ContextRecord = &context; scope_table.Count = 1; scope_table.ScopeRecord[0].BeginAddress = 0x200; scope_table.ScopeRecord[0].EndAddress = 0x400; +#ifndef __REACTOS__ scope_table.ScopeRecord[0].HandlerAddress = (ULONG_PTR)termination_handler-dispatch.ImageBase; +#else + scope_table.ScopeRecord[0].HandlerAddress = ((ULONG_PTR)termination_handler - (ULONG_PTR)dispatch.ImageBase); +#endif scope_table.ScopeRecord[0].JumpTarget = 0; memset(&context, 0, sizeof(context)); diff --git a/ntoskrnl/mm/ARM3/mminit.c b/ntoskrnl/mm/ARM3/mminit.c index 9b57931cbcb..e8cf1dc0014 100644 --- a/ntoskrnl/mm/ARM3/mminit.c +++ b/ntoskrnl/mm/ARM3/mminit.c @@ -240,7 +240,7 @@ PMMPTE MiHighestUserPxe; #endif /* These variables define the system cache address space */ -PVOID MmSystemCacheStart = MI_SYSTEM_CACHE_START; +PVOID MmSystemCacheStart = (PVOID)MI_SYSTEM_CACHE_START; PVOID MmSystemCacheEnd; ULONG MmSizeOfSystemCacheInPages; MMSUPPORT MmSystemCacheWs; diff --git a/sdk/include/xdk/winnt_old.h b/sdk/include/xdk/winnt_old.h index 06299a6b238..59076df80d3 100644 --- a/sdk/include/xdk/winnt_old.h +++ b/sdk/include/xdk/winnt_old.h @@ -1420,6 +1420,12 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS { } DUMMYUNIONNAME2; } KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS; +#define UNW_FLAG_NHANDLER 0x0 +#define UNW_FLAG_EHANDLER 0x1 +#define UNW_FLAG_UHANDLER 0x2 +#define UNW_FLAG_CHAININFO 0x4 +#define UNW_FLAG_NO_EPILOGUE 0x80000000UL + #define RUNTIME_FUNCTION_INDIRECT 0x1 typedef struct _RUNTIME_FUNCTION { @@ -1439,7 +1445,10 @@ typedef struct _UNWIND_HISTORY_TABLE_ENTRY typedef struct _UNWIND_HISTORY_TABLE { DWORD Count; - UCHAR Search; + BYTE LocalHint; + BYTE GlobalHint; + BYTE Search; + BYTE Once; ULONG64 LowAddress; ULONG64 HighAddress; UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE]; @@ -1448,19 +1457,61 @@ typedef struct _UNWIND_HISTORY_TABLE typedef _Function_class_(GET_RUNTIME_FUNCTION_CALLBACK) PRUNTIME_FUNCTION -(*PGET_RUNTIME_FUNCTION_CALLBACK)( - _In_ DWORD64 ControlPc, - _In_opt_ PVOID Context); +GET_RUNTIME_FUNCTION_CALLBACK( + _In_ DWORD64 ControlPc, + _In_opt_ PVOID Context); +typedef GET_RUNTIME_FUNCTION_CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK; typedef _Function_class_(OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK) -_Must_inspect_result_ DWORD -(*POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK)( - _In_ HANDLE Process, - _In_ PVOID TableAddress, - _Out_ PDWORD Entries, - _Out_ PRUNTIME_FUNCTION *Functions); +OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK( + _In_ HANDLE Process, + _In_ PVOID TableAddress, + _Out_ PDWORD Entries, + _Out_ PRUNTIME_FUNCTION* Functions); +typedef OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK *POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK; + +struct _EXCEPTION_POINTERS; +typedef +LONG +(*PEXCEPTION_FILTER) ( + struct _EXCEPTION_POINTERS *ExceptionPointers, + PVOID EstablisherFrame); + +typedef +VOID +(*PTERMINATION_HANDLER) ( + BOOLEAN AbnormalTermination, + PVOID EstablisherFrame); + +typedef struct _DISPATCHER_CONTEXT +{ + ULONG64 ControlPc; + PVOID ImageBase; + PVOID FunctionEntry; + PVOID EstablisherFrame; + ULONG64 TargetIp; + PVOID ContextRecord; + PEXCEPTION_ROUTINE LanguageHandler; + PVOID HandlerData; + PUNWIND_HISTORY_TABLE HistoryTable; + ULONG ScopeIndex; + ULONG Fill0; +} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; + +typedef struct _SCOPE_TABLE_AMD64 +{ + DWORD Count; + struct + { + DWORD BeginAddress; + DWORD EndAddress; + DWORD HandlerAddress; + DWORD JumpTarget; + } ScopeRecord[1]; +} SCOPE_TABLE_AMD64, *PSCOPE_TABLE_AMD64; +typedef SCOPE_TABLE_AMD64 SCOPE_TABLE, *PSCOPE_TABLE; #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback" @@ -1513,6 +1564,17 @@ RtlVirtualUnwind( _Out_ PDWORD64 EstablisherFrame, _Inout_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers); +NTSYSAPI +VOID +NTAPI +RtlUnwindEx( + _In_opt_ PVOID TargetFrame, + _In_opt_ PVOID TargetIp, + _In_opt_ struct _EXCEPTION_RECORD *ExceptionRecord, + _In_ PVOID ReturnValue, + _In_ struct _CONTEXT *ContextRecord, + _In_opt_ PUNWIND_HISTORY_TABLE HistoryTable); + #elif defined(_PPC_) #define CONTEXT_CONTROL 1L #define CONTEXT_FLOATING_POINT 2L diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c index d854b8ec6e4..989669e97f7 100644 --- a/sdk/lib/rtl/amd64/unwind.c +++ b/sdk/lib/rtl/amd64/unwind.c @@ -28,10 +28,6 @@ #define UWOP_SAVE_XMM128_FAR 9 #define UWOP_PUSH_MACHFRAME 10 -#define UNW_FLAG_NHANDLER 0 -#define UNW_FLAG_EHANDLER 1 -#define UNW_FLAG_UHANDLER 2 -#define UNW_FLAG_CHAININFO 4 typedef unsigned char UBYTE; @@ -348,18 +344,17 @@ RtlpTryToUnwindEpilog( return TRUE; } - PEXCEPTION_ROUTINE NTAPI RtlVirtualUnwind( - IN ULONG HandlerType, - IN ULONG64 ImageBase, - IN ULONG64 ControlPc, - IN PRUNTIME_FUNCTION FunctionEntry, - IN OUT PCONTEXT Context, - OUT PVOID *HandlerData, - OUT PULONG64 EstablisherFrame, - IN OUT PKNONVOLATILE_CONTEXT_POINTERS ContextPointers) + _In_ ULONG HandlerType, + _In_ ULONG64 ImageBase, + _In_ ULONG64 ControlPc, + _In_ PRUNTIME_FUNCTION FunctionEntry, + _Inout_ PCONTEXT Context, + _Outptr_ PVOID *HandlerData, + _Out_ PULONG64 EstablisherFrame, + _Inout_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers) { PUNWIND_INFO UnwindInfo; ULONG_PTR CodeOffset; @@ -499,14 +494,14 @@ RtlVirtualUnwind( VOID NTAPI RtlUnwindEx( - IN ULONG64 TargetFrame, - IN ULONG64 TargetIp, - IN PEXCEPTION_RECORD ExceptionRecord, - IN PVOID ReturnValue, - OUT PCONTEXT OriginalContext, - IN PUNWIND_HISTORY_TABLE HistoryTable) + _In_opt_ PVOID TargetFrame, + _In_opt_ PVOID TargetIp, + _In_opt_ PEXCEPTION_RECORD ExceptionRecord, + _In_ PVOID ReturnValue, + _In_ PCONTEXT ContextRecord, + _In_opt_ struct _UNWIND_HISTORY_TABLE *HistoryTable) { - UNIMPLEMENTED; + __debugbreak(); return; } diff --git a/sdk/lib/rtl/rtlp.h b/sdk/lib/rtl/rtlp.h index d0d4a410337..1d13f7a61b5 100644 --- a/sdk/lib/rtl/rtlp.h +++ b/sdk/lib/rtl/rtlp.h @@ -74,10 +74,12 @@ RtlCallVectoredContinueHandlers( IN PCONTEXT Context ); +#ifdef _M_IX86 typedef struct _DISPATCHER_CONTEXT { PEXCEPTION_REGISTRATION_RECORD RegistrationPointer; } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; +#endif /* These provide support for sharing code between User and Kernel RTL */ PVOID @@ -157,6 +159,7 @@ RtlpClearInDbgPrint( /* i386/except.S */ +#ifdef _M_IX86 EXCEPTION_DISPOSITION NTAPI RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord, @@ -164,6 +167,7 @@ RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context, PVOID DispatcherContext, PEXCEPTION_ROUTINE ExceptionHandler); +#endif EXCEPTION_DISPOSITION NTAPI