[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
This commit is contained in:
Timo Kreuzer 2018-04-03 15:13:17 -06:00 committed by GitHub
parent d5f744ff31
commit 6b1ca75899
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 243 additions and 85 deletions

View file

@ -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();

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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 {

View file

@ -13,8 +13,6 @@
#define NDEBUG
#include <debug.h>
#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;

View file

@ -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 */
{

View file

@ -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<n>)
#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);

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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)
{

View file

@ -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;

View file

@ -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));
}

View file

@ -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));

View file

@ -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;

View file

@ -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

View file

@ -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;
}

View file

@ -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