https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a2f7de7ee85024dd4f15e…
commit a2f7de7ee85024dd4f15ea62f5a6f6340e2890f8
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Mon Jan 1 12:07:50 2018 +0100
Amd64/misc 64bit fixes (#236)
[REACTOS] Misc 64 bit fixes
* [NTOS:MM] Allow MEM_DOS_LIM in NtMapViewOfSection on x64 as well
* [NTOS:MM] Implement x64 version of MmIsDisabledPage
* [HAL] Remove obsolete code
* [NTOS:KE] Fix amd64 version of KeContextToTrapFrame and KeTrapFrameToContext
* [XDK] Fix CONTEXT_XSTATE definition
* [PCNET] Convert physical address types from pointers to PHYSICAL_ADDRESS
---
dll/ntdll/dbg/dbgui.c | 7 ++-
dll/win32/kernel32/client/handle.c | 2 +-
dll/win32/kernel32/winnls/string/format_msg.c | 7 +--
dll/win32/shell32/dialogs/dialogs.cpp | 2 +-
drivers/network/afd/afd/main.c | 2 +-
drivers/network/dd/pcnet/pcnet.c | 50 +++++++++++-----------
drivers/network/dd/pcnet/pcnet.h | 10 ++---
.../applications/explorer-old/shell/mainframe.cpp | 2 +-
.../applications/explorer-old/utility/utility.cpp | 6 +--
.../applications/explorer-old/utility/window.h | 6 +--
ntoskrnl/ke/amd64/context.c | 30 +++++++------
ntoskrnl/ke/amd64/cpu.c | 10 -----
ntoskrnl/ke/bug.c | 2 +-
ntoskrnl/mm/ARM3/section.c | 2 +-
ntoskrnl/mm/amd64/page.c | 6 ++-
sdk/include/ndk/ketypes.h | 2 +-
sdk/include/xdk/amd64/ke.h | 2 +-
17 files changed, 72 insertions(+), 76 deletions(-)
diff --git a/dll/ntdll/dbg/dbgui.c b/dll/ntdll/dbg/dbgui.c
index 80b0a1dcb5..ccc89fb89b 100644
--- a/dll/ntdll/dbg/dbgui.c
+++ b/dll/ntdll/dbg/dbgui.c
@@ -64,11 +64,10 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE
WaitStateChange,
NTSTATUS Status;
THREAD_BASIC_INFORMATION ThreadBasicInfo;
LPDEBUG_EVENT DebugEvent = Win32DebugEvent;
-
+
/* Write common data */
- DebugEvent->dwProcessId = (DWORD)WaitStateChange->
- AppClientId.UniqueProcess;
- DebugEvent->dwThreadId = (DWORD)WaitStateChange->AppClientId.UniqueThread;
+ DebugEvent->dwProcessId =
PtrToUlong(WaitStateChange->AppClientId.UniqueProcess);
+ DebugEvent->dwThreadId =
PtrToUlong(WaitStateChange->AppClientId.UniqueThread);
/* Check what kind of even this is */
switch (WaitStateChange->NewState)
diff --git a/dll/win32/kernel32/client/handle.c b/dll/win32/kernel32/client/handle.c
index 3e5cbcf455..3e116f5cbe 100644
--- a/dll/win32/kernel32/client/handle.c
+++ b/dll/win32/kernel32/client/handle.c
@@ -20,7 +20,7 @@ TranslateStdHandle(IN HANDLE hHandle)
{
PRTL_USER_PROCESS_PARAMETERS Ppb = NtCurrentPeb()->ProcessParameters;
- switch ((ULONG)hHandle)
+ switch ((ULONG_PTR)hHandle)
{
case STD_INPUT_HANDLE: return Ppb->StandardInput;
case STD_OUTPUT_HANDLE: return Ppb->StandardOutput;
diff --git a/dll/win32/kernel32/winnls/string/format_msg.c
b/dll/win32/kernel32/winnls/string/format_msg.c
index 2f01c204aa..389cf1fad8 100644
--- a/dll/win32/kernel32/winnls/string/format_msg.c
+++ b/dll/win32/kernel32/winnls/string/format_msg.c
@@ -63,14 +63,15 @@ static LPWSTR load_message( HMODULE module, UINT id, WORD lang )
{
MESSAGE_RESOURCE_ENTRY *mre;
WCHAR *buffer;
- NTSTATUS status;
+ NTSTATUS Status;
TRACE("module = %p, id = %08x\n", module, id );
if (!module) module = GetModuleHandleW( NULL );
- if ((status = RtlFindMessage( module, (ULONG)RT_MESSAGETABLE, lang, id, &mre ))
!= STATUS_SUCCESS)
+ Status = RtlFindMessage(module, (ULONG_PTR)RT_MESSAGETABLE, lang, id, &mre);
+ if (!NT_SUCCESS(Status))
{
- SetLastError( RtlNtStatusToDosError(status) );
+ SetLastError(RtlNtStatusToDosError(Status));
return NULL;
}
diff --git a/dll/win32/shell32/dialogs/dialogs.cpp
b/dll/win32/shell32/dialogs/dialogs.cpp
index 3d66374ce3..f266e79787 100644
--- a/dll/win32/shell32/dialogs/dialogs.cpp
+++ b/dll/win32/shell32/dialogs/dialogs.cpp
@@ -113,7 +113,7 @@ INT_PTR CALLBACK PickIconProc(HWND hwndDlg,
{
case WM_INITDIALOG:
pIconContext = (PPICK_ICON_CONTEXT)lParam;
- SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG)pIconContext);
+ SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, 32, 0);
EnumResourceNamesW(pIconContext->hLibrary, RT_ICON, EnumPickIconResourceProc,
(LPARAM)pIconContext->hDlgCtrl);
diff --git a/drivers/network/afd/afd/main.c b/drivers/network/afd/afd/main.c
index df2eccc835..8cdfb1a269 100644
--- a/drivers/network/afd/afd/main.c
+++ b/drivers/network/afd/afd/main.c
@@ -27,7 +27,7 @@ void OskitDumpBuffer( PCHAR Data, UINT Len ) {
for( i = 0; i < Len; i++ ) {
if( i && !(i & 0xf) ) DbgPrint( "\n" );
- if( !(i & 0xf) ) DbgPrint( "%08x: ", (UINT)(Data + i) );
+ if( !(i & 0xf) ) DbgPrint( "%p: ", (Data + i) );
DbgPrint( " %02x", Data[i] & 0xff );
}
DbgPrint("\n");
diff --git a/drivers/network/dd/pcnet/pcnet.c b/drivers/network/dd/pcnet/pcnet.c
index 26a6527036..0a78530765 100644
--- a/drivers/network/dd/pcnet/pcnet.c
+++ b/drivers/network/dd/pcnet/pcnet.c
@@ -139,8 +139,8 @@ MiniportHandleInterrupt(
IndicatedData = TRUE;
RtlZeroMemory(Descriptor, sizeof(RECEIVE_DESCRIPTOR));
- Descriptor->RBADR =
- (ULONG)(Adapter->ReceiveBufferPtrPhys +
Adapter->CurrentReceiveDescriptorIndex * BUFFER_SIZE);
+ Descriptor->RBADR = Adapter->ReceiveBufferPtrPhys.QuadPart +
+ (Adapter->CurrentReceiveDescriptorIndex *
BUFFER_SIZE);
Descriptor->BCNT = (-BUFFER_SIZE) | 0xf000;
Descriptor->FLAGS |= RD_OWN;
@@ -308,11 +308,9 @@ MiFreeSharedMemory(
{
NDIS_PHYSICAL_ADDRESS PhysicalAddress;
- PhysicalAddress.u.HighPart = 0;
-
if(Adapter->InitializationBlockVirt)
{
- PhysicalAddress.u.LowPart = (ULONG)Adapter->InitializationBlockPhys;
+ PhysicalAddress = Adapter->InitializationBlockPhys;
NdisMFreeSharedMemory(Adapter->MiniportAdapterHandle,
Adapter->InitializationBlockLength,
FALSE, Adapter->InitializationBlockVirt, PhysicalAddress);
Adapter->InitializationBlockVirt = NULL;
@@ -320,7 +318,7 @@ MiFreeSharedMemory(
if(Adapter->TransmitDescriptorRingVirt)
{
- PhysicalAddress.u.LowPart = (ULONG)Adapter->TransmitDescriptorRingPhys;
+ PhysicalAddress = Adapter->TransmitDescriptorRingPhys;
NdisMFreeSharedMemory(Adapter->MiniportAdapterHandle,
Adapter->TransmitDescriptorRingLength,
FALSE, Adapter->TransmitDescriptorRingVirt, PhysicalAddress);
Adapter->TransmitDescriptorRingVirt = NULL;
@@ -328,7 +326,7 @@ MiFreeSharedMemory(
if(Adapter->ReceiveDescriptorRingVirt)
{
- PhysicalAddress.u.LowPart = (ULONG)Adapter->ReceiveDescriptorRingPhys;
+ PhysicalAddress = Adapter->ReceiveDescriptorRingPhys;
NdisMFreeSharedMemory(Adapter->MiniportAdapterHandle,
Adapter->ReceiveDescriptorRingLength,
FALSE, Adapter->ReceiveDescriptorRingVirt, PhysicalAddress);
Adapter->ReceiveDescriptorRingVirt = NULL;
@@ -336,7 +334,7 @@ MiFreeSharedMemory(
if(Adapter->TransmitBufferPtrVirt)
{
- PhysicalAddress.u.LowPart = (ULONG)Adapter->TransmitBufferPtrPhys;
+ PhysicalAddress = Adapter->TransmitBufferPtrPhys;
NdisMFreeSharedMemory(Adapter->MiniportAdapterHandle,
Adapter->TransmitBufferLength,
TRUE, Adapter->TransmitBufferPtrVirt, PhysicalAddress);
Adapter->TransmitBufferPtrVirt = NULL;
@@ -344,7 +342,7 @@ MiFreeSharedMemory(
if(Adapter->ReceiveBufferPtrVirt)
{
- PhysicalAddress.u.LowPart = (ULONG)Adapter->ReceiveBufferPtrPhys;
+ PhysicalAddress = Adapter->ReceiveBufferPtrPhys;
NdisMFreeSharedMemory(Adapter->MiniportAdapterHandle,
Adapter->ReceiveBufferLength,
TRUE, Adapter->ReceiveBufferPtrVirt, PhysicalAddress);
Adapter->ReceiveBufferPtrVirt = NULL;
@@ -383,13 +381,13 @@ MiAllocateSharedMemory(
return NDIS_STATUS_RESOURCES;
}
- if(((ULONG)Adapter->InitializationBlockVirt & 0x00000003) != 0)
+ if (((ULONG_PTR)Adapter->InitializationBlockVirt & 0x00000003) != 0)
{
DPRINT1("address 0x%x not dword-aligned\n",
Adapter->InitializationBlockVirt);
return NDIS_STATUS_RESOURCES;
}
- Adapter->InitializationBlockPhys =
(PINITIALIZATION_BLOCK)NdisGetPhysicalAddressLow(PhysicalAddress);
+ Adapter->InitializationBlockPhys = PhysicalAddress;
/* allocate the transport descriptor ring */
Adapter->TransmitDescriptorRingLength = sizeof(TRANSMIT_DESCRIPTOR) *
BufferCount;
@@ -404,13 +402,13 @@ MiAllocateSharedMemory(
continue;
}
- if (((ULONG)Adapter->TransmitDescriptorRingVirt & 0x00000003) != 0)
+ if (((ULONG_PTR)Adapter->TransmitDescriptorRingVirt & 0x00000003) != 0)
{
DPRINT1("address 0x%x not dword-aligned\n",
Adapter->TransmitDescriptorRingVirt);
return NDIS_STATUS_RESOURCES;
}
- Adapter->TransmitDescriptorRingPhys =
(PTRANSMIT_DESCRIPTOR)NdisGetPhysicalAddressLow(PhysicalAddress);
+ Adapter->TransmitDescriptorRingPhys = PhysicalAddress;
RtlZeroMemory(Adapter->TransmitDescriptorRingVirt, sizeof(TRANSMIT_DESCRIPTOR) *
BufferCount);
/* allocate the receive descriptor ring */
@@ -426,13 +424,13 @@ MiAllocateSharedMemory(
continue;
}
- if (((ULONG)Adapter->ReceiveDescriptorRingVirt & 0x00000003) != 0)
+ if (((ULONG_PTR)Adapter->ReceiveDescriptorRingVirt & 0x00000003) != 0)
{
DPRINT1("address 0x%x not dword-aligned\n",
Adapter->ReceiveDescriptorRingVirt);
return NDIS_STATUS_RESOURCES;
}
- Adapter->ReceiveDescriptorRingPhys =
(PRECEIVE_DESCRIPTOR)NdisGetPhysicalAddressLow(PhysicalAddress);
+ Adapter->ReceiveDescriptorRingPhys = PhysicalAddress;
RtlZeroMemory(Adapter->ReceiveDescriptorRingVirt, sizeof(RECEIVE_DESCRIPTOR) *
BufferCount);
/* allocate transmit buffers */
@@ -448,13 +446,13 @@ MiAllocateSharedMemory(
continue;
}
- if (((ULONG)Adapter->TransmitBufferPtrVirt & 0x00000003) != 0)
+ if(((ULONG_PTR)Adapter->TransmitBufferPtrVirt & 0x00000003) != 0)
{
DPRINT1("address 0x%x not dword-aligned\n",
Adapter->TransmitBufferPtrVirt);
return NDIS_STATUS_RESOURCES;
}
- Adapter->TransmitBufferPtrPhys =
(PCHAR)NdisGetPhysicalAddressLow(PhysicalAddress);
+ Adapter->TransmitBufferPtrPhys = PhysicalAddress;
RtlZeroMemory(Adapter->TransmitBufferPtrVirt, BUFFER_SIZE * BufferCount);
/* allocate receive buffers */
@@ -470,13 +468,13 @@ MiAllocateSharedMemory(
continue;
}
- if (((ULONG)Adapter->ReceiveBufferPtrVirt & 0x00000003) != 0)
+ if (((ULONG_PTR)Adapter->ReceiveBufferPtrVirt & 0x00000003) != 0)
{
DPRINT1("address 0x%x not dword-aligned\n",
Adapter->ReceiveBufferPtrVirt);
return NDIS_STATUS_RESOURCES;
}
- Adapter->ReceiveBufferPtrPhys =
(PCHAR)NdisGetPhysicalAddressLow(PhysicalAddress);
+ Adapter->ReceiveBufferPtrPhys = PhysicalAddress;
RtlZeroMemory(Adapter->ReceiveBufferPtrVirt, BUFFER_SIZE * BufferCount);
break;
@@ -495,7 +493,7 @@ MiAllocateSharedMemory(
TransmitDescriptor = Adapter->TransmitDescriptorRingVirt;
for(i = 0; i < BufferCount; i++)
{
- (TransmitDescriptor+i)->TBADR = (ULONG)Adapter->TransmitBufferPtrPhys + i *
BUFFER_SIZE;
+ (TransmitDescriptor+i)->TBADR = Adapter->TransmitBufferPtrPhys.QuadPart + i *
BUFFER_SIZE;
(TransmitDescriptor+i)->BCNT = 0xf000 | -BUFFER_SIZE; /* 2's compliment +
set top 4 bits */
(TransmitDescriptor+i)->FLAGS = TD1_STP | TD1_ENP;
}
@@ -506,7 +504,7 @@ MiAllocateSharedMemory(
ReceiveDescriptor = Adapter->ReceiveDescriptorRingVirt;
for(i = 0; i < BufferCount; i++)
{
- (ReceiveDescriptor+i)->RBADR = (ULONG)Adapter->ReceiveBufferPtrPhys + i *
BUFFER_SIZE;
+ (ReceiveDescriptor+i)->RBADR = Adapter->ReceiveBufferPtrPhys.QuadPart + i *
BUFFER_SIZE;
(ReceiveDescriptor+i)->BCNT = 0xf000 | -BUFFER_SIZE; /* 2's compliment +
set top 4 bits */
(ReceiveDescriptor+i)->FLAGS = RD_OWN;
}
@@ -542,12 +540,12 @@ MiPrepareInitializationBlock(
/* set up receive ring */
DPRINT("Receive ring physical address: 0x%x\n",
Adapter->ReceiveDescriptorRingPhys);
- Adapter->InitializationBlockVirt->RDRA =
(ULONG)Adapter->ReceiveDescriptorRingPhys;
+ Adapter->InitializationBlockVirt->RDRA =
Adapter->ReceiveDescriptorRingPhys.QuadPart;
Adapter->InitializationBlockVirt->RLEN = (Adapter->LogBufferCount << 4)
& 0xf0;
/* set up transmit ring */
DPRINT("Transmit ring physical address: 0x%x\n",
Adapter->TransmitDescriptorRingPhys);
- Adapter->InitializationBlockVirt->TDRA =
(ULONG)Adapter->TransmitDescriptorRingPhys;
+ Adapter->InitializationBlockVirt->TDRA =
Adapter->TransmitDescriptorRingPhys.QuadPart;
Adapter->InitializationBlockVirt->TLEN = (Adapter->LogBufferCount << 4)
& 0xf0;
}
@@ -730,9 +728,9 @@ MiInitChip(
/* set up csr1 and csr2 with init block */
NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR1);
- NdisRawWritePortUshort(Adapter->PortOffset + RDP,
(USHORT)((ULONG)Adapter->InitializationBlockPhys & 0xffff));
+ NdisRawWritePortUshort(Adapter->PortOffset + RDP,
(USHORT)(Adapter->InitializationBlockPhys.LowPart & 0xffff));
NdisRawWritePortUshort(Adapter->PortOffset + RAP, CSR2);
- NdisRawWritePortUshort(Adapter->PortOffset + RDP,
(USHORT)((ULONG)Adapter->InitializationBlockPhys >> 16) & 0xffff);
+ NdisRawWritePortUshort(Adapter->PortOffset + RDP,
(USHORT)(Adapter->InitializationBlockPhys.LowPart >> 16) & 0xffff);
DPRINT("programmed with init block\n");
@@ -1223,7 +1221,7 @@ MiniportSend(
Adapter->CurrentTransmitEndIndex %= Adapter->BufferCount;
Desc->FLAGS = TD1_OWN | TD1_STP | TD1_ENP;
- Desc->BCNT = 0xf000 | -TotalPacketLength;
+ Desc->BCNT = 0xf000 | -(INT)TotalPacketLength;
NdisMSynchronizeWithInterrupt(&Adapter->InterruptObject, MiSyncStartTransmit,
Adapter);
diff --git a/drivers/network/dd/pcnet/pcnet.h b/drivers/network/dd/pcnet/pcnet.h
index 5389c3ee96..578d1da7ad 100644
--- a/drivers/network/dd/pcnet/pcnet.h
+++ b/drivers/network/dd/pcnet/pcnet.h
@@ -79,27 +79,27 @@ typedef struct _ADAPTER
/* initialization block */
ULONG InitializationBlockLength;
PINITIALIZATION_BLOCK InitializationBlockVirt;
- PINITIALIZATION_BLOCK InitializationBlockPhys;
+ PHYSICAL_ADDRESS InitializationBlockPhys;
/* transmit descriptor ring */
ULONG TransmitDescriptorRingLength;
PTRANSMIT_DESCRIPTOR TransmitDescriptorRingVirt;
- PTRANSMIT_DESCRIPTOR TransmitDescriptorRingPhys;
+ PHYSICAL_ADDRESS TransmitDescriptorRingPhys;
/* transmit buffers */
ULONG TransmitBufferLength;
PCHAR TransmitBufferPtrVirt;
- PCHAR TransmitBufferPtrPhys;
+ PHYSICAL_ADDRESS TransmitBufferPtrPhys;
/* receive descriptor ring */
ULONG ReceiveDescriptorRingLength;
PRECEIVE_DESCRIPTOR ReceiveDescriptorRingVirt;
- PRECEIVE_DESCRIPTOR ReceiveDescriptorRingPhys;
+ PHYSICAL_ADDRESS ReceiveDescriptorRingPhys;
/* receive buffers */
ULONG ReceiveBufferLength;
PCHAR ReceiveBufferPtrVirt;
- PCHAR ReceiveBufferPtrPhys;
+ PHYSICAL_ADDRESS ReceiveBufferPtrPhys;
/* buffer count */
ULONG BufferCount;
diff --git a/modules/rosapps/applications/explorer-old/shell/mainframe.cpp
b/modules/rosapps/applications/explorer-old/shell/mainframe.cpp
index dd8618a756..6cda867b92 100644
--- a/modules/rosapps/applications/explorer-old/shell/mainframe.cpp
+++ b/modules/rosapps/applications/explorer-old/shell/mainframe.cpp
@@ -418,7 +418,7 @@ int MainFrameBase::Command(int id, int code)
HINSTANCE hinst = ShellExecute(_hwnd, NULL/*operation*/, dlg.cmd/*file*/,
NULL/*parameters*/, NULL/*dir*/, dlg.cmdshow);
- if ((int)hinst <= 32)
+ if ((INT_PTR)hinst <= 32)
display_error(_hwnd, GetLastError());
}
break;}
diff --git a/modules/rosapps/applications/explorer-old/utility/utility.cpp
b/modules/rosapps/applications/explorer-old/utility/utility.cpp
index d20c73b633..9fe745e4c1 100644
--- a/modules/rosapps/applications/explorer-old/utility/utility.cpp
+++ b/modules/rosapps/applications/explorer-old/utility/utility.cpp
@@ -192,7 +192,7 @@ BOOL launch_file(HWND hwnd, LPCTSTR cmd, UINT nCmdShow, LPCTSTR
parameters)
HINSTANCE hinst = ShellExecute(hwnd, NULL/*operation*/, cmd, parameters, NULL/*dir*/,
nCmdShow);
- if ((int)hinst <= 32) {
+ if ((INT_PTR)hinst <= 32) {
display_error(hwnd, GetLastError());
return FALSE;
}
@@ -205,7 +205,7 @@ BOOL launch_fileA(HWND hwnd, LPSTR cmd, UINT nCmdShow, LPCSTR
parameters)
{
HINSTANCE hinst = ShellExecuteA(hwnd, NULL/*operation*/, cmd, parameters, NULL/*dir*/,
nCmdShow);
- if ((int)hinst <= 32) {
+ if ((INT_PTR)hinst <= 32) {
display_error(hwnd, GetLastError());
return FALSE;
}
@@ -387,7 +387,7 @@ BOOL launch_cpanel(HWND hwnd, LPCTSTR applet)
_tcscpy(parameters, TEXT("shell32.dll,Control_RunDLL "));
_tcscat(parameters, applet);
- return ((int)ShellExecute(hwnd, TEXT("open"), TEXT("rundll32.exe"),
parameters, NULL, SW_SHOWDEFAULT) > 32);
+ return ((INT_PTR)ShellExecute(hwnd, TEXT("open"),
TEXT("rundll32.exe"), parameters, NULL, SW_SHOWDEFAULT) > 32);
}
diff --git a/modules/rosapps/applications/explorer-old/utility/window.h
b/modules/rosapps/applications/explorer-old/utility/window.h
index 3bf913adfb..391f42a76d 100644
--- a/modules/rosapps/applications/explorer-old/utility/window.h
+++ b/modules/rosapps/applications/explorer-old/utility/window.h
@@ -838,7 +838,7 @@ protected:
{
if (!_cmd.empty()) {
HINSTANCE hinst = ShellExecute(GetParent(_hwnd), _T("open"), _cmd, 0, 0,
SW_SHOWNORMAL);
- return (int)hinst > HINSTANCE_ERROR;
+ return (INT_PTR)hinst > HINSTANCE_ERROR;
}
return true;
@@ -861,7 +861,7 @@ struct ToolTip : public WindowHandle
void add(HWND hparent, HWND htool, LPCTSTR txt=LPSTR_TEXTCALLBACK, LPARAM lparam=0)
{
TOOLINFO ti = {
- sizeof(TOOLINFO), TTF_SUBCLASS|TTF_IDISHWND|TTF_TRANSPARENT, hparent, (UINT)htool,
+ sizeof(TOOLINFO), TTF_SUBCLASS|TTF_IDISHWND|TTF_TRANSPARENT, hparent,
(UINT_PTR)htool,
{0,0,0,0}, 0, (LPTSTR)txt, lparam
};
@@ -893,7 +893,7 @@ struct ToolTip : public WindowHandle
void remove(HWND hparent, HWND htool)
{
TOOLINFO ti = {
- sizeof(TOOLINFO), TTF_IDISHWND, hparent, (UINT)htool,
+ sizeof(TOOLINFO), TTF_IDISHWND, hparent, (UINT_PTR)htool,
{0,0,0,0}, 0, 0, 0
};
diff --git a/ntoskrnl/ke/amd64/context.c b/ntoskrnl/ke/amd64/context.c
index ec20efa4d4..3e21cae319 100644
--- a/ntoskrnl/ke/amd64/context.c
+++ b/ntoskrnl/ke/amd64/context.c
@@ -57,8 +57,9 @@ KeContextToTrapFrame(IN PCONTEXT Context,
/* Handle floating point registers */
if ((ContextFlags & CONTEXT_FLOATING_POINT) &&
- (Context->SegCs & MODE_MASK))
+ ((Context->SegCs & MODE_MASK) != KernelMode))
{
+ TrapFrame->MxCsr = Context->MxCsr;
TrapFrame->Xmm0 = Context->Xmm0;
TrapFrame->Xmm1 = Context->Xmm1;
TrapFrame->Xmm2 = Context->Xmm2;
@@ -84,7 +85,7 @@ KeContextToTrapFrame(IN PCONTEXT Context,
if (ContextFlags & CONTEXT_CONTROL)
{
/* Check if this was a Kernel Trap */
- if (Context->SegCs == KGDT64_R0_CODE)
+ if ((Context->SegCs & MODE_MASK) == KernelMode)
{
/* Set valid selectors */
TrapFrame->SegCs = KGDT64_R0_CODE;
@@ -107,7 +108,7 @@ KeContextToTrapFrame(IN PCONTEXT Context,
if (ContextFlags & CONTEXT_SEGMENTS)
{
/* Check if this was a Kernel Trap */
- if (Context->SegCs == KGDT64_R0_CODE)
+ if ((Context->SegCs & MODE_MASK) == KernelMode)
{
/* Set valid selectors */
TrapFrame->SegDs = KGDT64_R3_DATA | RPL_MASK;
@@ -147,14 +148,20 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
IN PKEXCEPTION_FRAME ExceptionFrame,
IN OUT PCONTEXT Context)
{
+ ULONG ContextFlags;
KIRQL OldIrql;
/* Do this at APC_LEVEL */
OldIrql = KeGetCurrentIrql();
if (OldIrql < APC_LEVEL) KeRaiseIrql(APC_LEVEL, &OldIrql);
+ /* Make sure we have an amd64 context, then remove the flag */
+ ContextFlags = Context->ContextFlags;
+ ASSERT(ContextFlags & CONTEXT_AMD64);
+ ContextFlags &= ~CONTEXT_AMD64;
+
/* Handle integer registers */
- if ((Context->ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER)
+ if (ContextFlags & CONTEXT_INTEGER)
{
Context->Rax = TrapFrame->Rax;
Context->Rbx = TrapFrame->Rbx;
@@ -178,8 +185,8 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
}
/* Handle floating point registers */
- if (((Context->ContextFlags & CONTEXT_FLOATING_POINT) ==
- CONTEXT_FLOATING_POINT) && (TrapFrame->SegCs & MODE_MASK))
+ if ((ContextFlags & CONTEXT_FLOATING_POINT) &&
+ ((TrapFrame->SegCs & MODE_MASK) != KernelMode))
{
Context->Xmm0 = TrapFrame->Xmm0;
Context->Xmm1 = TrapFrame->Xmm1;
@@ -203,10 +210,10 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
}
/* Handle control registers */
- if ((Context->ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL)
+ if (ContextFlags & CONTEXT_CONTROL)
{
/* Check if this was a Kernel Trap */
- if (TrapFrame->SegCs == KGDT64_R0_CODE)
+ if ((TrapFrame->SegCs & MODE_MASK) == KernelMode)
{
/* Set valid selectors */
Context->SegCs = KGDT64_R0_CODE;
@@ -226,10 +233,10 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
}
/* Handle segment selectors */
- if ((Context->ContextFlags & CONTEXT_SEGMENTS) == CONTEXT_SEGMENTS)
+ if (ContextFlags & CONTEXT_SEGMENTS)
{
/* Check if this was a Kernel Trap */
- if (TrapFrame->SegCs == KGDT64_R0_CODE)
+ if ((TrapFrame->SegCs & MODE_MASK) == KernelMode)
{
/* Set valid selectors */
Context->SegDs = KGDT64_R3_DATA | RPL_MASK;
@@ -248,8 +255,7 @@ KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
}
/* Handle debug registers */
- if ((Context->ContextFlags & CONTEXT_DEBUG_REGISTERS) ==
- CONTEXT_DEBUG_REGISTERS)
+ if (ContextFlags & CONTEXT_DEBUG_REGISTERS)
{
/* Copy the debug registers */
Context->Dr0 = TrapFrame->Dr0;
diff --git a/ntoskrnl/ke/amd64/cpu.c b/ntoskrnl/ke/amd64/cpu.c
index 730bda1d9a..3c2b706a90 100644
--- a/ntoskrnl/ke/amd64/cpu.c
+++ b/ntoskrnl/ke/amd64/cpu.c
@@ -54,16 +54,9 @@ VOID
NTAPI
KiSetProcessorType(VOID)
{
- ULONG64 EFlags;
CPU_INFO CpuInfo;
ULONG Stepping, Type;
- /* Start by assuming no CPUID data */
- KeGetCurrentPrcb()->CpuID = 0;
-
- /* Save EFlags */
- EFlags = __readeflags();
-
/* Do CPUID 1 now */
KiCpuId(&CpuInfo, 1);
@@ -85,9 +78,6 @@ KiSetProcessorType(VOID)
KeGetCurrentPrcb()->CpuID = TRUE;
KeGetCurrentPrcb()->CpuType = (UCHAR)Type;
KeGetCurrentPrcb()->CpuStep = (USHORT)Stepping;
-
- /* Restore EFLAGS */
- __writeeflags(EFlags);
}
ULONG
diff --git a/ntoskrnl/ke/bug.c b/ntoskrnl/ke/bug.c
index 899debd191..a92acb1bab 100644
--- a/ntoskrnl/ke/bug.c
+++ b/ntoskrnl/ke/bug.c
@@ -716,7 +716,7 @@ KiDisplayBlueScreen(IN ULONG MessageId,
/* Show the technical Data */
sprintf(AnsiName,
"\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
- KiBugCheckData[0],
+ (ULONG)KiBugCheckData[0],
(PVOID)KiBugCheckData[1],
(PVOID)KiBugCheckData[2],
(PVOID)KiBugCheckData[3],
diff --git a/ntoskrnl/mm/ARM3/section.c b/ntoskrnl/mm/ARM3/section.c
index c9b5daf13d..6a2710e0be 100644
--- a/ntoskrnl/mm/ARM3/section.c
+++ b/ntoskrnl/mm/ARM3/section.c
@@ -3567,7 +3567,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
ACCESS_MASK DesiredAccess;
ULONG ProtectionMask;
KPROCESSOR_MODE PreviousMode = ExGetPreviousMode();
-#ifdef _M_IX86
+#if defined(_M_IX86) || defined(_M_AMD64)
static const ULONG ValidAllocationType = (MEM_TOP_DOWN | MEM_LARGE_PAGES |
MEM_DOS_LIM | SEC_NO_CHANGE | MEM_RESERVE);
#else
diff --git a/ntoskrnl/mm/amd64/page.c b/ntoskrnl/mm/amd64/page.c
index 864302bd42..c5f6158d81 100644
--- a/ntoskrnl/mm/amd64/page.c
+++ b/ntoskrnl/mm/amd64/page.c
@@ -312,8 +312,10 @@ MmIsDisabledPage(PEPROCESS Process, PVOID Address)
{
MMPTE Pte;
Pte.u.Long = MiGetPteValueForProcess(Process, Address);
- __debugbreak(); // FIXME
- return !Pte.u.Hard.Valid && !(Pte.u.Long & 0x800) &&
Pte.u.Hard.PageFrameNumber;
+
+ return (Pte.u.Hard.Valid == 0) &&
+ (Pte.u.Trans.Transition == 0) &&
+ (Pte.u.Hard.PageFrameNumber != 0);
}
BOOLEAN
diff --git a/sdk/include/ndk/ketypes.h b/sdk/include/ndk/ketypes.h
index 7963217d8b..839a0d77d7 100644
--- a/sdk/include/ndk/ketypes.h
+++ b/sdk/include/ndk/ketypes.h
@@ -1975,7 +1975,7 @@ typedef struct _KPROCESS
LIST_ENTRY ProfileListHead;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONG_PTR DirectoryTableBase;
- ULONG Unused0;
+ ULONG_PTR Unused0;
#else
ULONG_PTR DirectoryTableBase[2];
#endif
diff --git a/sdk/include/xdk/amd64/ke.h b/sdk/include/xdk/amd64/ke.h
index f16b721455..90abb70311 100644
--- a/sdk/include/xdk/amd64/ke.h
+++ b/sdk/include/xdk/amd64/ke.h
@@ -191,7 +191,7 @@ $if (_NTDDK_)
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)
#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS |
CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)
-#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L)
+#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x40L)
#define CONTEXT_EXCEPTION_ACTIVE 0x8000000
#define CONTEXT_SERVICE_ACTIVE 0x10000000