[DRIVERS] Fix 64 bit issues

This commit is contained in:
Timo Kreuzer 2018-04-23 11:27:49 +02:00
parent f8bf0e9c3a
commit 9e066abe2a
27 changed files with 61 additions and 60 deletions

View file

@ -183,7 +183,7 @@
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
((type *)((char *)(ptr)-(uintptr_t)(&((type *)0)->member)))
/**
* list_for_each - iterate over a list

View file

@ -217,7 +217,7 @@ ACPI_THREAD_ID
AcpiOsGetThreadId (void)
{
/* Thread ID must be non-zero */
return (ULONG)PsGetCurrentThreadId() + 1;
return (ULONG_PTR)PsGetCurrentThreadId() + 1;
}
ACPI_STATUS

View file

@ -60,7 +60,7 @@ arbusno_Constructor(IN PVOID DeviceExtension,
UNREFERENCED_PARAMETER(Interface);
/* Make sure it's the expected interface */
if ((ULONG)InterfaceData != CmResourceTypeBusNumber)
if ((ULONG_PTR)InterfaceData != CmResourceTypeBusNumber)
{
/* Arbiter support must have been initialized first */
if (FdoExtension->ArbitersInitialized)

View file

@ -74,7 +74,7 @@ ario_Constructor(IN PVOID DeviceExtension,
UNREFERENCED_PARAMETER(Interface);
/* Make sure it's the expected interface */
if ((ULONG)InterfaceData != CmResourceTypePort)
if ((ULONG_PTR)InterfaceData != CmResourceTypePort)
{
/* Arbiter support must have been initialized first */
if (FdoExtension->ArbitersInitialized)
@ -170,7 +170,7 @@ armem_Constructor(IN PVOID DeviceExtension,
UNREFERENCED_PARAMETER(Interface);
/* Make sure it's the expected interface */
if ((ULONG)InterfaceData != CmResourceTypeMemory)
if ((ULONG_PTR)InterfaceData != CmResourceTypeMemory)
{
/* Arbiter support must have been initialized first */
if (FdoExtension->ArbitersInitialized)

View file

@ -59,7 +59,7 @@ tranirq_Constructor(IN PVOID DeviceExtension,
UNREFERENCED_PARAMETER(Size);
/* Make sure it's the right resource type */
if ((ULONG)InterfaceData != CmResourceTypeInterrupt)
if ((ULONG_PTR)InterfaceData != CmResourceTypeInterrupt)
{
/* Fail this invalid request */
DPRINT1("PCI - IRQ trans constructor doesn't like %p in InterfaceSpecificData\n",
@ -69,7 +69,7 @@ tranirq_Constructor(IN PVOID DeviceExtension,
/* Get the bus, and use this as the interface-specific data */
BaseBus = FdoExtension->BaseBus;
InterfaceData = (PVOID)BaseBus;
InterfaceData = UlongToPtr(BaseBus);
/* Check if this is the root bus */
if (PCI_IS_ROOT_FDO(FdoExtension))

View file

@ -158,7 +158,7 @@ MuppIsDfsEnabled(VOID)
return TRUE;
}
return ((ULONG)KeyQueryOutput.KeyInfo.Data != 1);
return ((ULONG_PTR)KeyQueryOutput.KeyInfo.Data != 1);
}
VOID

View file

@ -255,7 +255,7 @@ FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
/* Store the old count and increment */
Result = &Object->PointerCount;
InterlockedIncrement((PLONG)&Object->PointerCount);
InterlockedIncrementSizeT(&Object->PointerCount);
/* Return the initial value */
return *Result;
@ -264,7 +264,7 @@ FltpObjectPointerReference(_In_ PFLT_OBJECT Object)
VOID
FltpObjectPointerDereference(_In_ PFLT_OBJECT Object)
{
if (!InterlockedDecrement((PLONG)Object->PointerCount))
if (InterlockedDecrementSizeT(&Object->PointerCount) == 0)
{
// Cleanup
FLT_ASSERT(FALSE);

View file

@ -22,7 +22,7 @@ static NTSTATUS NTAPI SendComplete
PIO_STACK_LOCATION NextIrpSp;
PAFD_SEND_INFO SendReq = NULL;
PAFD_MAPBUF Map;
UINT TotalBytesCopied = 0, TotalBytesProcessed = 0, SpaceAvail, i;
SIZE_T TotalBytesCopied = 0, TotalBytesProcessed = 0, SpaceAvail, i;
UINT SendLength, BytesCopied;
BOOLEAN HaltSendQueue;

View file

@ -512,7 +512,7 @@ MiniRequestComplete(
/* We are doing this internally, so we'll signal this event we've stashed in the MacBlock */
ASSERT(MacBlock->Unknown1 != NULL);
ASSERT(MacBlock->Unknown3 == NULL);
MacBlock->Unknown3 = (PVOID)Status;
MacBlock->Unknown3 = UlongToPtr(Status);
KeSetEvent(MacBlock->Unknown1, IO_NO_INCREMENT, FALSE);
}
@ -789,7 +789,7 @@ MiniSetInformation(
if (NdisStatus == NDIS_STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
NdisStatus = (NDIS_STATUS)MacBlock->Unknown3;
NdisStatus = PtrToUlong(MacBlock->Unknown3);
}
*BytesRead = NdisRequest->DATA.SET_INFORMATION.BytesRead;
@ -849,7 +849,7 @@ MiniQueryInformation(
if (NdisStatus == NDIS_STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
NdisStatus = (NDIS_STATUS)MacBlock->Unknown3;
NdisStatus = PtrToUlong(MacBlock->Unknown3);
}
*BytesWritten = NdisRequest->DATA.QUERY_INFORMATION.BytesWritten;

View file

@ -72,7 +72,7 @@
#define CP CHECKPOINT
#define ASSERT_KM_POINTER(_x) \
ASSERT(((PVOID)_x) != (PVOID)0xcccccccc); \
ASSERT(((PVOID)_x) >= (PVOID)0x80000000);
ASSERT(((ULONG_PTR)(_x)) != (ULONG_PTR)0xccccccccccccccccULL); \
ASSERT(((PVOID)(_x)) >= MmSystemRangeStart);
/* EOF */

View file

@ -121,7 +121,7 @@ PdoWrite(IN PDEVICE_OBJECT DeviceObject,
do
{
KeStallExecutionProcessor(10);
PortStatus = READ_PORT_UCHAR((PUCHAR)(FdoDeviceExtension->BaseAddress + 1));
PortStatus = READ_PORT_UCHAR(UlongToPtr(FdoDeviceExtension->BaseAddress + 1));
ulCount++;
}
while (ulCount < 500000 && !(PortStatus & LP_PBUSY));
@ -138,15 +138,15 @@ PdoWrite(IN PDEVICE_OBJECT DeviceObject,
}
/* Write character */
WRITE_PORT_UCHAR((PUCHAR)FdoDeviceExtension->BaseAddress, Buffer[i]);
WRITE_PORT_UCHAR(UlongToPtr(FdoDeviceExtension->BaseAddress), Buffer[i]);
KeStallExecutionProcessor(10);
WRITE_PORT_UCHAR((PUCHAR)(FdoDeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP | LP_PSTROBE));
WRITE_PORT_UCHAR(UlongToPtr(FdoDeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP | LP_PSTROBE));
KeStallExecutionProcessor(10);
WRITE_PORT_UCHAR((PUCHAR)(FdoDeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP));
WRITE_PORT_UCHAR(UlongToPtr(FdoDeviceExtension->BaseAddress + 2), (LP_PSELECP | LP_PINITP));
}
Irp->IoStatus.Information = 0;

View file

@ -393,7 +393,7 @@ ChanMgrCreateChannel(OUT PSAC_CHANNEL *Channel,
{
/* Free slot found, attempt to use it */
ASSERT(!CHANNEL_SLOT_IS_IN_USE(i));
_InterlockedCompareExchange((PLONG)&ChannelArray[i], (LONG)NewChannel, 0);
InterlockedCompareExchangePointer((PVOID*)&ChannelArray[i], NewChannel, NULL);
if (ChannelArray[i] == NewChannel) break;
}
}

View file

@ -64,7 +64,7 @@ TimerDpcRoutine(IN PKDPC Dpc,
IN PVOID SystemArgument2)
{
HEADLESS_RSP_GET_BYTE ByteValue;
ULONG ValueSize;
SIZE_T ValueSize;
BOOLEAN GotChar;
NTSTATUS Status;
PSAC_DEVICE_EXTENSION SacExtension;

View file

@ -397,7 +397,7 @@ GetRegistryValueBuffer(IN PCWSTR KeyName,
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DestinationString;
HANDLE Handle;
SIZE_T ResultLength = 0;
ULONG ResultLength = 0;
SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: Entering.\n");
CHECK_PARAMETER1(KeyName);
CHECK_PARAMETER2(ValueName);
@ -539,7 +539,7 @@ TranslateMachineInformationXML(IN PWCHAR *Buffer,
IN PWCHAR ExtraData)
{
NTSTATUS Status;
ULONG Size;
SIZE_T Size;
PWCHAR p;
CHECK_PARAMETER1(Buffer);
@ -694,7 +694,7 @@ InitializeMachineInformation(VOID)
ULONG SuiteTypeMessage;
BOOLEAN SetupInProgress = FALSE;
GUID SystemGuid;
ULONG RealSize, Size, OutputSize;
SIZE_T RealSize, Size, OutputSize;
PKEY_VALUE_PARTIAL_INFORMATION PartialInfo;
RTL_OSVERSIONINFOEXW VersionInformation;
SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Entering.\n");
@ -1102,7 +1102,7 @@ RegisterBlueScreenMachineInformation(VOID)
{
PWCHAR XmlBuffer;
PHEADLESS_CMD_SET_BLUE_SCREEN_DATA BsBuffer;
ULONG Length, HeaderLength, TotalLength;
SIZE_T Length, HeaderLength, TotalLength;
NTSTATUS Status;
ULONG i;

View file

@ -134,7 +134,7 @@ FdcFdoStartDevice(
PartialDescriptor->u.Port.Start.u.LowPart,
PartialDescriptor->u.Port.Length);
if (PartialDescriptor->u.Port.Length >= 6)
DeviceExtension->ControllerInfo.BaseAddress = (PUCHAR)PartialDescriptor->u.Port.Start.u.LowPart;
DeviceExtension->ControllerInfo.BaseAddress = (PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart;
break;
case CmResourceTypeInterrupt:
@ -206,7 +206,7 @@ FdcFdoConfigCallback(
if (PartialDescriptor->Type == CmResourceTypePort)
{
if ((PUCHAR)PartialDescriptor->u.Port.Start.LowPart == DeviceExtension->ControllerInfo.BaseAddress)
if ((PUCHAR)(ULONG_PTR)PartialDescriptor->u.Port.Start.QuadPart == DeviceExtension->ControllerInfo.BaseAddress)
ControllerFound = TRUE;
}
}

View file

@ -221,7 +221,7 @@ CUSBHardwareDevice::SetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd)
{
PULONG Register;
Register = (PULONG)UsbCmd;
WRITE_REGISTER_ULONG((PULONG)((ULONG)m_Base + EHCI_USBCMD), *Register);
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + EHCI_USBCMD), *Register);
}
VOID
@ -230,19 +230,19 @@ CUSBHardwareDevice::GetCommandRegister(PEHCI_USBCMD_CONTENT UsbCmd)
{
PULONG Register;
Register = (PULONG)UsbCmd;
*Register = READ_REGISTER_ULONG((PULONG)((ULONG)m_Base + EHCI_USBCMD));
*Register = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + EHCI_USBCMD));
}
ULONG
CUSBHardwareDevice::EHCI_READ_REGISTER_ULONG(ULONG Offset)
{
return READ_REGISTER_ULONG((PULONG)((ULONG)m_Base + Offset));
return READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + Offset));
}
VOID
CUSBHardwareDevice::EHCI_WRITE_REGISTER_ULONG(ULONG Offset, ULONG Value)
{
WRITE_REGISTER_ULONG((PULONG)((ULONG)m_Base + Offset), Value);
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + Offset), Value);
}
VOID
@ -384,7 +384,7 @@ CUSBHardwareDevice::PnpStart(
//
// each entry is a 4 bit field EHCI 2.2.5
//
Value = READ_REGISTER_UCHAR((PUCHAR)(ULONG)ResourceBase + EHCI_HCSP_PORTROUTE + Count);
Value = READ_REGISTER_UCHAR((PUCHAR)(ULONG_PTR)ResourceBase + EHCI_HCSP_PORTROUTE + Count);
m_Capabilities.PortRoute[Count*2] = (Value & 0xF0);
if ((Count*2) + 1 < m_Capabilities.HCSParams.PortCount)
@ -397,7 +397,7 @@ CUSBHardwareDevice::PnpStart(
//
// Set m_Base to the address of Operational Register Space
//
m_Base = (PULONG)((ULONG)ResourceBase + m_Capabilities.Length);
m_Base = (PULONG)((ULONG_PTR)ResourceBase + m_Capabilities.Length);
break;
}
}
@ -1282,7 +1282,7 @@ InterruptServiceRoutine(
return TRUE;
}
KeInsertQueueDpc(&This->m_IntDpcObject, This, (PVOID)CStatus);
KeInsertQueueDpc(&This->m_IntDpcObject, This, UlongToPtr(CStatus));
return TRUE;
}
@ -1299,7 +1299,7 @@ EhciDeferredRoutine(
EHCI_USBCMD_CONTENT UsbCmd;
This = (CUSBHardwareDevice*) SystemArgument1;
CStatus = (ULONG) SystemArgument2;
CStatus = PtrToUlong(SystemArgument2);
DPRINT("EhciDeferredRoutine CStatus %lx\n", CStatus);

View file

@ -1412,7 +1412,7 @@ InterruptServiceRoutine(
// defer processing
//
DPRINT("Status %x Acknowledge %x FrameNumber %x\n", Status, Acknowledge, This->m_HCCA->CurrentFrameNumber);
KeInsertQueueDpc(&This->m_IntDpcObject, (PVOID)Status, (PVOID)(DoneHead & ~1));
KeInsertQueueDpc(&This->m_IntDpcObject, UlongToPtr(Status), UlongToPtr(DoneHead & ~1));
//
// interrupt handled
@ -1436,8 +1436,8 @@ OhciDeferredRoutine(
// get parameters
//
This = (CUSBHardwareDevice*)DeferredContext;
CStatus = (ULONG) SystemArgument1;
DoneHead = (ULONG)SystemArgument2;
CStatus = PtrToUlong(SystemArgument1);
DoneHead = PtrToUlong(SystemArgument2);
DPRINT("OhciDeferredRoutine Status %x DoneHead %x\n", CStatus, DoneHead);

View file

@ -99,9 +99,9 @@ USBSTOR_IsCSWValid(
return FALSE;
}
if (Context->csw->Tag != (ULONG)Context->csw)
if (Context->csw->Tag != (ULONG_PTR)Context->csw)
{
DPRINT1("[USBSTOR] Expected Tag %x but got %x\n", (ULONG)Context->csw, Context->csw->Tag);
DPRINT1("[USBSTOR] Expected Tag %Ix but got %x\n", (ULONG_PTR)Context->csw, Context->csw->Tag);
return FALSE;
}
@ -660,7 +660,7 @@ USBSTOR_SendRequest(
//
// now build the cbw
//
USBSTOR_BuildCBW((ULONG)Context->cbw,
USBSTOR_BuildCBW(PtrToUlong(Context->cbw),
TransferDataLength,
PDODeviceExtension->LUN,
CommandLength,

View file

@ -295,7 +295,7 @@ CUSBHardwareDevice::PnpStart(
//
// Store Resource base
//
m_Base = (PULONG)ResourceDescriptor->u.Port.Start.LowPart; //FIXME
m_Base = (PULONG)(ULONG_PTR)ResourceDescriptor->u.Port.Start.QuadPart; //FIXME
DPRINT("UHCI Base %p Length %x\n", m_Base, ResourceDescriptor->u.Port.Length);
break;
}
@ -559,7 +559,7 @@ CUSBHardwareDevice::GlobalReset()
// back up start of modify register
//
ASSERT(m_Base);
UCHAR sofValue = READ_PORT_UCHAR((PUCHAR)((ULONG)m_Base + UHCI_SOFMOD));
UCHAR sofValue = READ_PORT_UCHAR((PUCHAR)m_Base + UHCI_SOFMOD);
//
// perform global reset
@ -592,7 +592,7 @@ CUSBHardwareDevice::GlobalReset()
//
// restore start of modify register
//
WRITE_PORT_UCHAR((PUCHAR)((ULONG)m_Base + UHCI_SOFMOD), sofValue);
WRITE_PORT_UCHAR((PUCHAR)m_Base + UHCI_SOFMOD, sofValue);
}
NTSTATUS
@ -1340,7 +1340,7 @@ CUSBHardwareDevice::WriteRegister8(
IN ULONG Register,
IN UCHAR Value)
{
WRITE_PORT_UCHAR((PUCHAR)((ULONG)m_Base + Register), Value);
WRITE_PORT_UCHAR((PUCHAR)((PUCHAR)m_Base + Register), Value);
}
@ -1349,7 +1349,7 @@ CUSBHardwareDevice::WriteRegister16(
ULONG Register,
USHORT Value)
{
WRITE_PORT_USHORT((PUSHORT)((ULONG)m_Base + Register), Value);
WRITE_PORT_USHORT((PUSHORT)((PUCHAR)m_Base + Register), Value);
}
@ -1358,7 +1358,7 @@ CUSBHardwareDevice::WriteRegister32(
ULONG Register,
ULONG Value)
{
WRITE_PORT_ULONG((PULONG)((ULONG)m_Base + Register), Value);
WRITE_PORT_ULONG((PULONG)((PUCHAR)m_Base + Register), Value);
}
@ -1366,7 +1366,7 @@ UCHAR
CUSBHardwareDevice::ReadRegister8(
ULONG Register)
{
return READ_PORT_UCHAR((PUCHAR)((ULONG)m_Base + Register));
return READ_PORT_UCHAR((PUCHAR)((PUCHAR)m_Base + Register));
}
@ -1374,7 +1374,7 @@ USHORT
CUSBHardwareDevice::ReadRegister16(
ULONG Register)
{
return READ_PORT_USHORT((PUSHORT)((ULONG)m_Base + Register));
return READ_PORT_USHORT((PUSHORT)((PUCHAR)m_Base + Register));
}
@ -1382,7 +1382,7 @@ ULONG
CUSBHardwareDevice::ReadRegister32(
ULONG Register)
{
return READ_PORT_ULONG((PULONG)((ULONG)m_Base + Register));
return READ_PORT_ULONG((PULONG)((PUCHAR)m_Base + Register));
}
VOID

View file

@ -408,7 +408,8 @@ CHubController::HandlePnp(
PPNP_BUS_INFORMATION BusInformation;
PDEVICE_RELATIONS DeviceRelations;
NTSTATUS Status;
ULONG Index = 0, Length;
ULONG Index = 0;
SIZE_T Length;
USHORT VendorID, DeviceID;
ULONG HiSpeed, NumPorts;
WCHAR Buffer[300];

View file

@ -22,6 +22,6 @@ KeQueryActiveProcessorCount(OUT PKAFFINITY ActiveProcessors OPTIONAL)
*ActiveProcessors = ActiveMap;
}
RtlInitializeBitMap(&Bitmap, &ActiveMap, sizeof(ActiveMap) * 8);
RtlInitializeBitMap(&Bitmap, (PULONG)&ActiveMap, sizeof(ActiveMap) * 8);
return RtlNumberOfSetBits(&Bitmap);
}

View file

@ -2312,7 +2312,7 @@ RxDereferenceAndDeleteRxContext_Real(
/* Is ShadowCrit still owned? Shouldn't happen! */
if (RxContext->ShadowCritOwner != 0)
{
DPRINT1("ShadowCritOwner not null! %p\n", (PVOID)RxContext->ShadowCritOwner);
DPRINT1("ShadowCritOwner not null! %lx\n", RxContext->ShadowCritOwner);
ASSERT(FALSE);
}
#endif

View file

@ -108,7 +108,7 @@ mxdMessage(
DeviceId,
(LPWAVEOPENDESC) Parameter1, /* unused */
Parameter2,
(DWORD*) PrivateHandle);
(DWORD_PTR*) PrivateHandle);
VALIDATE_MMSYS_PARAMETER(*(DWORD_PTR*)PrivateHandle);
break;
}

View file

@ -153,7 +153,7 @@ DetectNt4SoundDevices(
IN PWSTR BaseDeviceName,
IN SOUND_DEVICE_DETECTED_PROC SoundDeviceDetectedProc)
{
ULONG DeviceNameLength = 0;
SIZE_T DeviceNameLength = 0;
PWSTR DeviceName = NULL;
ULONG Index = 0;
HANDLE DeviceHandle;

View file

@ -21,7 +21,7 @@ OpenSoundDriverParametersRegKey(
IN LPWSTR ServiceName,
OUT PHKEY KeyHandle)
{
ULONG KeyLength;
SIZE_T KeyLength;
PWCHAR ParametersKeyName;
VALIDATE_MMSYS_PARAMETER( ServiceName );
@ -75,7 +75,7 @@ OpenSoundDeviceRegKey(
IN DWORD DeviceIndex,
OUT PHKEY KeyHandle)
{
DWORD PathLength;
SIZE_T PathLength;
PWCHAR RegPath;
VALIDATE_MMSYS_PARAMETER( ServiceName );

View file

@ -386,7 +386,7 @@ MMixerGetMidiDevicePath(
PMIXER_LIST MixerList;
LPMIXER_DATA MixerData;
LPMIDI_INFO MidiInfo;
ULONG Length;
SIZE_T Length;
MIXER_STATUS Status;
/* verify mixer context */

View file

@ -665,7 +665,7 @@ MMixerGetWaveDevicePath(
PMIXER_LIST MixerList;
LPMIXER_DATA MixerData;
LPWAVE_INFO WaveInfo;
ULONG Length;
SIZE_T Length;
MIXER_STATUS Status;
/* verify mixer context */