fix code that depends on GCC's void* pointer arithmetic extension

svn path=/trunk/; revision=16420
This commit is contained in:
Thomas Bluemel 2005-07-05 00:24:36 +00:00
parent a4a9299b16
commit 945ed508b6
30 changed files with 109 additions and 112 deletions

View file

@ -63,9 +63,9 @@ NTSTATUS STDCALL RamdrvDispatchReadWrite(PDEVICE_OBJECT DeviceObject,
Stk->Parameters.Read.Length = devext->Size - Stk->Parameters.Read.ByteOffset.u.LowPart; Stk->Parameters.Read.Length = devext->Size - Stk->Parameters.Read.ByteOffset.u.LowPart;
if( Stk->MajorFunction == IRP_MJ_READ ) if( Stk->MajorFunction == IRP_MJ_READ )
RtlCopyMemory( MmGetSystemAddressForMdl( Irp->MdlAddress ), RtlCopyMemory( MmGetSystemAddressForMdl( Irp->MdlAddress ),
devext->Buffer + Stk->Parameters.Read.ByteOffset.u.LowPart, (PVOID)((ULONG_PTR)devext->Buffer + Stk->Parameters.Read.ByteOffset.u.LowPart),
Stk->Parameters.Read.Length ); Stk->Parameters.Read.Length );
else RtlCopyMemory( devext->Buffer + Stk->Parameters.Read.ByteOffset.u.LowPart, else RtlCopyMemory( (PVOID)((ULONG_PTR)devext->Buffer + Stk->Parameters.Read.ByteOffset.u.LowPart),
MmGetSystemAddressForMdl( Irp->MdlAddress ), MmGetSystemAddressForMdl( Irp->MdlAddress ),
Stk->Parameters.Read.Length ); Stk->Parameters.Read.Length );
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;

View file

@ -69,10 +69,10 @@ CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
Record = (PDIR_RECORD)*Block; Record = (PDIR_RECORD)*Block;
while (Index < *pIndex) while (Index < *pIndex)
{ {
(*Ptr) += Record->RecordLength; (*Ptr) = (PVOID)((ULONG_PTR)(*Ptr) + Record->RecordLength);
(*CurrentOffset) += Record->RecordLength; (*CurrentOffset) += Record->RecordLength;
Record = *Ptr; Record = *Ptr;
if (*Ptr - *Block >= BLOCKSIZE || Record->RecordLength == 0) if ((ULONG_PTR)(*Ptr) - (ULONG_PTR)(*Block) >= BLOCKSIZE || Record->RecordLength == 0)
{ {
DPRINT("Map next sector\n"); DPRINT("Map next sector\n");
CcUnpinData(*Context); CcUnpinData(*Context);
@ -96,7 +96,7 @@ CdfsGetEntryName(PDEVICE_EXTENSION DeviceExt,
} }
} }
if (*Ptr - *Block >= BLOCKSIZE || Record->RecordLength == 0) if ((ULONG_PTR)(*Ptr) - (ULONG_PTR)(*Block) >= BLOCKSIZE || Record->RecordLength == 0)
{ {
DPRINT("Map next sector\n"); DPRINT("Map next sector\n");
CcUnpinData(*Context); CcUnpinData(*Context);
@ -259,11 +259,11 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
Record = (PDIR_RECORD) (Block + Offset % BLOCKSIZE); Record = (PDIR_RECORD) ((ULONG_PTR)Block + Offset % BLOCKSIZE);
if (Offset) if (Offset)
{ {
Offset += Record->RecordLength; Offset += Record->RecordLength;
Record = (PVOID)Record + Record->RecordLength; Record = (PDIR_RECORD)((ULONG_PTR)Record + Record->RecordLength);
} }
while(TRUE) while(TRUE)
@ -356,7 +356,7 @@ CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
} }
Offset += Record->RecordLength; Offset += Record->RecordLength;
Record = (PVOID)Record + Record->RecordLength; Record = (PDIR_RECORD)((ULONG_PTR)Record + Record->RecordLength);
DirIndex++; DirIndex++;
} }

View file

@ -580,7 +580,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
Offset += Record->RecordLength; Offset += Record->RecordLength;
BlockOffset += Record->RecordLength; BlockOffset += Record->RecordLength;
Record = (PDIR_RECORD)(Block + BlockOffset); Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
if (BlockOffset >= BLOCKSIZE || Record->RecordLength == 0) if (BlockOffset >= BLOCKSIZE || Record->RecordLength == 0)
{ {
DPRINT("Map next sector\n"); DPRINT("Map next sector\n");
@ -597,7 +597,7 @@ CdfsDirFindFile(PDEVICE_EXTENSION DeviceExt,
DPRINT("CcMapData() failed\n"); DPRINT("CcMapData() failed\n");
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
Record = (PDIR_RECORD)(Block + BlockOffset); Record = (PDIR_RECORD)((ULONG_PTR)Block + BlockOffset);
} }
if (Offset >= DirSize) if (Offset >= DirSize)

View file

@ -390,7 +390,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
Information = Irp->IoStatus.Information; Information = Irp->IoStatus.Information;
Length = IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length; Length = IoGetCurrentIrpStackLocation(Irp)->Parameters.Read.Length;
ASSERT (Information <= Length); ASSERT (Information <= Length);
Buffer += Information; Buffer = (PVOID)((ULONG_PTR)Buffer + Information);
Length -= Information; Length -= Information;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
@ -450,24 +450,24 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
while (Length > 0 && Fcb->ReadDataAvailable > 0) while (Length > 0 && Fcb->ReadDataAvailable > 0)
{ {
CopyLength = min(Fcb->ReadDataAvailable, Length); CopyLength = min(Fcb->ReadDataAvailable, Length);
if (Fcb->ReadPtr + CopyLength <= Fcb->Data + Fcb->MaxDataLength) if ((ULONG_PTR)Fcb->ReadPtr + CopyLength <= (ULONG_PTR)Fcb->Data + Fcb->MaxDataLength)
{ {
memcpy(Buffer, Fcb->ReadPtr, CopyLength); memcpy(Buffer, Fcb->ReadPtr, CopyLength);
Fcb->ReadPtr += CopyLength; Fcb->ReadPtr = (PVOID)((ULONG_PTR)Fcb->ReadPtr + CopyLength);
if (Fcb->ReadPtr == Fcb->Data + Fcb->MaxDataLength) if (Fcb->ReadPtr == (PVOID)((ULONG_PTR)Fcb->Data + Fcb->MaxDataLength))
{ {
Fcb->ReadPtr = Fcb->Data; Fcb->ReadPtr = Fcb->Data;
} }
} }
else else
{ {
TempLength = Fcb->Data + Fcb->MaxDataLength - Fcb->ReadPtr; TempLength = (ULONG)((ULONG_PTR)Fcb->Data + Fcb->MaxDataLength - (ULONG_PTR)Fcb->ReadPtr);
memcpy(Buffer, Fcb->ReadPtr, TempLength); memcpy(Buffer, Fcb->ReadPtr, TempLength);
memcpy(Buffer + TempLength, Fcb->Data, CopyLength - TempLength); memcpy((PVOID)((ULONG_PTR)Buffer + TempLength), Fcb->Data, CopyLength - TempLength);
Fcb->ReadPtr = Fcb->Data + CopyLength - TempLength; Fcb->ReadPtr = (PVOID)((ULONG_PTR)Fcb->Data + CopyLength - TempLength);
} }
Buffer += CopyLength; Buffer = (PVOID)((ULONG_PTR)Buffer + CopyLength);
Length -= CopyLength; Length -= CopyLength;
Information += CopyLength; Information += CopyLength;
@ -505,7 +505,7 @@ NpfsRead(IN PDEVICE_OBJECT DeviceObject,
if (Fcb->ReadDataAvailable > Length) if (Fcb->ReadDataAvailable > Length)
{ {
memmove(Fcb->Data, Fcb->Data + Length, memmove(Fcb->Data, (PVOID)((ULONG_PTR)Fcb->Data + Length),
Fcb->ReadDataAvailable - Length); Fcb->ReadDataAvailable - Length);
Fcb->ReadDataAvailable -= Length; Fcb->ReadDataAvailable -= Length;
Status = STATUS_MORE_ENTRIES; Status = STATUS_MORE_ENTRIES;
@ -694,21 +694,21 @@ NpfsWrite(PDEVICE_OBJECT DeviceObject,
while (Length > 0 && ReaderFcb->WriteQuotaAvailable > 0) while (Length > 0 && ReaderFcb->WriteQuotaAvailable > 0)
{ {
CopyLength = min(Length, ReaderFcb->WriteQuotaAvailable); CopyLength = min(Length, ReaderFcb->WriteQuotaAvailable);
if (ReaderFcb->WritePtr + CopyLength <= ReaderFcb->Data + ReaderFcb->MaxDataLength) if ((ULONG_PTR)ReaderFcb->WritePtr + CopyLength <= (ULONG_PTR)ReaderFcb->Data + ReaderFcb->MaxDataLength)
{ {
memcpy(ReaderFcb->WritePtr, Buffer, CopyLength); memcpy(ReaderFcb->WritePtr, Buffer, CopyLength);
ReaderFcb->WritePtr += CopyLength; ReaderFcb->WritePtr = (PVOID)((ULONG_PTR)ReaderFcb->WritePtr + CopyLength);
if (ReaderFcb->WritePtr == ReaderFcb->Data + ReaderFcb->MaxDataLength) if ((ULONG_PTR)ReaderFcb->WritePtr == (ULONG_PTR)ReaderFcb->Data + ReaderFcb->MaxDataLength)
{ {
ReaderFcb->WritePtr = ReaderFcb->Data; ReaderFcb->WritePtr = ReaderFcb->Data;
} }
} }
else else
{ {
TempLength = ReaderFcb->Data + ReaderFcb->MaxDataLength - ReaderFcb->WritePtr; TempLength = (ULONG)((ULONG_PTR)ReaderFcb->Data + ReaderFcb->MaxDataLength - (ULONG_PTR)ReaderFcb->WritePtr);
memcpy(ReaderFcb->WritePtr, Buffer, TempLength); memcpy(ReaderFcb->WritePtr, Buffer, TempLength);
memcpy(ReaderFcb->Data, Buffer + TempLength, CopyLength - TempLength); memcpy(ReaderFcb->Data, Buffer + TempLength, CopyLength - TempLength);
ReaderFcb->WritePtr = ReaderFcb->Data + CopyLength - TempLength; ReaderFcb->WritePtr = (PVOID)((ULONG_PTR)ReaderFcb->Data + CopyLength - TempLength);
} }
Buffer += CopyLength; Buffer += CopyLength;

View file

@ -125,7 +125,7 @@ NtfsDumpFileNameAttribute(PATTRIBUTE Attribute)
ResAttr = (PRESIDENT_ATTRIBUTE)Attribute; ResAttr = (PRESIDENT_ATTRIBUTE)Attribute;
// DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset); // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
FileNameAttr = (PFILENAME_ATTRIBUTE)((PVOID)ResAttr + ResAttr->ValueOffset); FileNameAttr = (PFILENAME_ATTRIBUTE)((ULONG_PTR)ResAttr + ResAttr->ValueOffset);
DbgPrint(" '%.*S' ", FileNameAttr->NameLength, FileNameAttr->Name); DbgPrint(" '%.*S' ", FileNameAttr->NameLength, FileNameAttr->Name);
} }
@ -141,7 +141,7 @@ NtfsDumpVolumeNameAttribute(PATTRIBUTE Attribute)
ResAttr = (PRESIDENT_ATTRIBUTE)Attribute; ResAttr = (PRESIDENT_ATTRIBUTE)Attribute;
// DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset); // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
VolumeName = (PWCHAR)((PVOID)ResAttr + ResAttr->ValueOffset); VolumeName = (PWCHAR)((ULONG_PTR)ResAttr + ResAttr->ValueOffset);
DbgPrint(" '%.*S' ", ResAttr->ValueLength / sizeof(WCHAR), VolumeName); DbgPrint(" '%.*S' ", ResAttr->ValueLength / sizeof(WCHAR), VolumeName);
} }
@ -157,7 +157,7 @@ NtfsDumpVolumeInformationAttribute(PATTRIBUTE Attribute)
ResAttr = (PRESIDENT_ATTRIBUTE)Attribute; ResAttr = (PRESIDENT_ATTRIBUTE)Attribute;
// DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset); // DbgPrint(" Length %lu Offset %hu ", ResAttr->ValueLength, ResAttr->ValueOffset);
VolInfoAttr = (PVOLINFO_ATTRIBUTE)((PVOID)ResAttr + ResAttr->ValueOffset); VolInfoAttr = (PVOLINFO_ATTRIBUTE)((ULONG_PTR)ResAttr + ResAttr->ValueOffset);
DbgPrint(" NTFS Version %u.%u Flags 0x%04hx ", DbgPrint(" NTFS Version %u.%u Flags 0x%04hx ",
VolInfoAttr->MajorVersion, VolInfoAttr->MajorVersion,
VolInfoAttr->MinorVersion, VolInfoAttr->MinorVersion,

View file

@ -208,7 +208,7 @@ ReadFileRecord (PDEVICE_EXTENSION Vcb,
ULONG n = m > 0 ? (index & m) : 0; ULONG n = m > 0 ? (index & m) : 0;
memcpy(file, p + n * BytesPerFileRecord, BytesPerFileRecord); memcpy(file, (PVOID)((ULONG_PTR)p + n * BytesPerFileRecord), BytesPerFileRecord);
ExFreePool(p); ExFreePool(p);
@ -290,7 +290,7 @@ BOOL bitset(PUCHAR bitmap, ULONG i)
VOID FixupUpdateSequenceArray(PFILE_RECORD_HEADER file) VOID FixupUpdateSequenceArray(PFILE_RECORD_HEADER file)
{ {
PUSHORT usa = (PUSHORT)((PVOID)file + file->Ntfs.UsaOffset); PUSHORT usa = (PUSHORT)((ULONG_PTR)file + file->Ntfs.UsaOffset);
PUSHORT sector = (PUSHORT)file; PUSHORT sector = (PUSHORT)file;
ULONG i; ULONG i;

View file

@ -225,7 +225,7 @@ PIP_PACKET ReassembleDatagram(
/* Copy the header into the buffer */ /* Copy the header into the buffer */
RtlCopyMemory(IPPacket->Header, &IPDR->IPv4Header, IPDR->HeaderSize); RtlCopyMemory(IPPacket->Header, &IPDR->IPv4Header, IPDR->HeaderSize);
Data = IPPacket->Header + IPDR->HeaderSize; Data = (PVOID)((ULONG_PTR)IPPacket->Header + IPDR->HeaderSize);
IPPacket->Data = Data; IPPacket->Data = Data;
/* Copy data from all fragments into buffer */ /* Copy data from all fragments into buffer */

View file

@ -44,7 +44,7 @@ NTSTATUS AddUDPHeaderIPv4(
sizeof(UDP_HEADER), (PVOID *)&UDPHeader ); sizeof(UDP_HEADER), (PVOID *)&UDPHeader );
/* Build UDP header */ /* Build UDP header */
UDPHeader = (PUDP_HEADER)(IPPacket->Data - sizeof(UDP_HEADER)); UDPHeader = (PUDP_HEADER)((ULONG_PTR)IPPacket->Data - sizeof(UDP_HEADER));
/* Port values are already big-endian values */ /* Port values are already big-endian values */
UDPHeader->SourcePort = LocalPort; UDPHeader->SourcePort = LocalPort;
UDPHeader->DestPort = RemotePort; UDPHeader->DestPort = RemotePort;

View file

@ -564,7 +564,7 @@ MiniportHalt(
NdisMDeregisterInterrupt(&Adapter->InterruptObject); NdisMDeregisterInterrupt(&Adapter->InterruptObject);
/* deregister i/o port range */ /* deregister i/o port range */
NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle, Adapter->IoBaseAddress, NUMBER_OF_PORTS, Adapter->PortOffset); NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle, Adapter->IoBaseAddress, NUMBER_OF_PORTS, (PVOID)Adapter->PortOffset);
/* free shared memory */ /* free shared memory */
MiFreeSharedMemory(Adapter); MiFreeSharedMemory(Adapter);
@ -852,8 +852,8 @@ MiniportInitialize(
} }
/* register an IO port range */ /* register an IO port range */
Status = NdisMRegisterIoPortRange(&Adapter->PortOffset, Adapter->MiniportAdapterHandle, Status = NdisMRegisterIoPortRange((PVOID*)&Adapter->PortOffset, Adapter->MiniportAdapterHandle,
Adapter->IoBaseAddress, NUMBER_OF_PORTS); (UINT)Adapter->IoBaseAddress, NUMBER_OF_PORTS);
if(Status != NDIS_STATUS_SUCCESS) if(Status != NDIS_STATUS_SUCCESS)
{ {
DPRINT1("NdisMRegisterIoPortRange failed: 0x%x\n", Status); DPRINT1("NdisMRegisterIoPortRange failed: 0x%x\n", Status);
@ -914,7 +914,7 @@ MiniportInitialize(
NdisMFreeMapRegisters(Adapter->MiniportAdapterHandle); /* doesn't hurt to free if we never alloc'd? */ NdisMFreeMapRegisters(Adapter->MiniportAdapterHandle); /* doesn't hurt to free if we never alloc'd? */
if(Adapter->PortOffset) if(Adapter->PortOffset)
NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle, Adapter->IoBaseAddress, NUMBER_OF_PORTS, Adapter->PortOffset); NdisMDeregisterIoPortRange(Adapter->MiniportAdapterHandle, Adapter->IoBaseAddress, NUMBER_OF_PORTS, (PVOID)Adapter->PortOffset);
if(InterruptRegistered) if(InterruptRegistered)
NdisMDeregisterInterrupt(&Adapter->InterruptObject); NdisMDeregisterInterrupt(&Adapter->InterruptObject);

View file

@ -57,7 +57,7 @@ typedef struct _ADAPTER
ULONG Flags; ULONG Flags;
ULONG InterruptVector; ULONG InterruptVector;
ULONG IoBaseAddress; ULONG IoBaseAddress;
PVOID PortOffset; ULONG_PTR PortOffset;
NDIS_MINIPORT_INTERRUPT InterruptObject; NDIS_MINIPORT_INTERRUPT InterruptObject;
NDIS_MEDIA_STATE MediaState; NDIS_MEDIA_STATE MediaState;
NDIS_MINIPORT_TIMER MediaDetectionTimer; NDIS_MINIPORT_TIMER MediaDetectionTimer;

View file

@ -487,7 +487,7 @@ NdisMStartBufferPhysicalMapping(
*/ */
{ {
PLOGICAL_ADAPTER Adapter = 0; PLOGICAL_ADAPTER Adapter = 0;
VOID *CurrentVa; PVOID CurrentVa;
ULONG TotalLength; ULONG TotalLength;
PHYSICAL_ADDRESS ReturnedAddress; PHYSICAL_ADDRESS ReturnedAddress;
UINT LoopCount = 0; UINT LoopCount = 0;
@ -514,7 +514,7 @@ NdisMStartBufferPhysicalMapping(
PhysicalAddressArray[LoopCount].Length = Length; PhysicalAddressArray[LoopCount].Length = Length;
TotalLength -= Length; TotalLength -= Length;
CurrentVa += Length; CurrentVa = (PVOID)((ULONG_PTR)CurrentVa + Length);
LoopCount++; LoopCount++;
} }

View file

@ -3066,7 +3066,7 @@ AtapiInitDma(PATAPI_MINIPORT_EXTENSION DevExt,
DPRINT("AtapiInitDma()\n"); DPRINT("AtapiInitDma()\n");
StartAddress = Srb->DataBuffer; StartAddress = Srb->DataBuffer;
EndAddress = StartAddress + Srb->DataTransferLength; EndAddress = (PVOID)((ULONG_PTR)StartAddress + Srb->DataTransferLength);
DevExt->PRDCount = 0; DevExt->PRDCount = 0;
while (StartAddress < EndAddress) while (StartAddress < EndAddress)
@ -3105,7 +3105,7 @@ AtapiInitDma(PATAPI_MINIPORT_EXTENSION DevExt,
return FALSE; return FALSE;
} }
PhysicalAddress.u.LowPart += tmpLength; PhysicalAddress.u.LowPart += tmpLength;
StartAddress += tmpLength; StartAddress = (PVOID)((ULONG_PTR)StartAddress + tmpLength);
Length -= tmpLength; Length -= tmpLength;
PRDEntry->PhysAddress = PhysicalAddress.u.LowPart; PRDEntry->PhysAddress = PhysicalAddress.u.LowPart;
} }
@ -3114,7 +3114,7 @@ AtapiInitDma(PATAPI_MINIPORT_EXTENSION DevExt,
PRDEntry->PhysAddress = PhysicalAddress.u.LowPart; PRDEntry->PhysAddress = PhysicalAddress.u.LowPart;
PRDEntry->Length = tmpLength; PRDEntry->Length = tmpLength;
PRDEntry++; PRDEntry++;
StartAddress += tmpLength; StartAddress = (PVOID)((ULONG_PTR)StartAddress + tmpLength);
PhysicalAddress.u.LowPart += tmpLength; PhysicalAddress.u.LowPart += tmpLength;
Length -= tmpLength; Length -= tmpLength;
} }

View file

@ -1485,10 +1485,10 @@ CdromDeviceControlCompletion (IN PDEVICE_OBJECT DeviceObject,
if (Retry == TRUE && if (Retry == TRUE &&
(ULONG)OrigNextIrpStack->Parameters.Others.Argument1 > 0) (ULONG)OrigNextIrpStack->Parameters.Others.Argument1 > 0)
{ {
DPRINT1 ("Try again (Retry count %lu)\n", DPRINT1 ("Try again (Retry count 0x%p)\n",
(ULONG)OrigNextIrpStack->Parameters.Others.Argument1); (ULONG)OrigNextIrpStack->Parameters.Others.Argument1);
(ULONG)OrigNextIrpStack->Parameters.Others.Argument1--; OrigNextIrpStack->Parameters.Others.Argument1 = (PVOID)((ULONG_PTR)OrigNextIrpStack->Parameters.Others.Argument1 - 1);
/* Release 'old' buffers */ /* Release 'old' buffers */
ExFreePool (Srb->SenseInfoBuffer); ExFreePool (Srb->SenseInfoBuffer);

View file

@ -478,7 +478,7 @@ ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension,
} }
if (Srb == NULL) if (Srb == NULL)
{ {
EndAddress = DeviceExtension->VirtualAddress + DeviceExtension->CommonBufferLength; EndAddress = (PVOID)((ULONG_PTR)DeviceExtension->VirtualAddress + DeviceExtension->CommonBufferLength);
if (VirtualAddress >= DeviceExtension->VirtualAddress && VirtualAddress < EndAddress) if (VirtualAddress >= DeviceExtension->VirtualAddress && VirtualAddress < EndAddress)
{ {
Offset = (ULONG_PTR)VirtualAddress - (ULONG_PTR)DeviceExtension->VirtualAddress; Offset = (ULONG_PTR)VirtualAddress - (ULONG_PTR)DeviceExtension->VirtualAddress;
@ -506,14 +506,14 @@ ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension,
} }
else else
{ {
EndAddress = Srb->DataBuffer + Srb->DataTransferLength; EndAddress = (PVOID)((ULONG_PTR)Srb->DataBuffer + Srb->DataTransferLength);
if (VirtualAddress == NULL) if (VirtualAddress == NULL)
{ {
VirtualAddress = Srb->DataBuffer; VirtualAddress = Srb->DataBuffer;
} }
else if (VirtualAddress < Srb->DataBuffer || VirtualAddress >= EndAddress) else if (VirtualAddress < Srb->DataBuffer || VirtualAddress >= EndAddress)
{ {
EndAddress = Srb->SenseInfoBuffer + Srb->SenseInfoBufferLength; EndAddress = (PVOID)((ULONG_PTR)Srb->SenseInfoBuffer + Srb->SenseInfoBufferLength);
if (VirtualAddress < Srb->SenseInfoBuffer || VirtualAddress >= EndAddress) if (VirtualAddress < Srb->SenseInfoBuffer || VirtualAddress >= EndAddress)
{ {
PhysicalAddress.QuadPart = 0LL; PhysicalAddress.QuadPart = 0LL;
@ -530,18 +530,18 @@ ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension,
} }
BufferLength = PAGE_SIZE - (ULONG_PTR)VirtualAddress % PAGE_SIZE; BufferLength = PAGE_SIZE - (ULONG_PTR)VirtualAddress % PAGE_SIZE;
while (VirtualAddress + BufferLength < EndAddress) while ((ULONG_PTR)VirtualAddress + BufferLength < (ULONG_PTR)EndAddress)
{ {
NextPhysicalAddress = MmGetPhysicalAddress(VirtualAddress + BufferLength); NextPhysicalAddress = MmGetPhysicalAddress((PVOID)((ULONG_PTR)VirtualAddress + BufferLength));
if (PhysicalAddress.QuadPart + BufferLength != NextPhysicalAddress.QuadPart) if (PhysicalAddress.QuadPart + BufferLength != NextPhysicalAddress.QuadPart)
{ {
break; break;
} }
BufferLength += PAGE_SIZE; BufferLength += PAGE_SIZE;
} }
if (VirtualAddress + BufferLength >= EndAddress) if ((ULONG_PTR)VirtualAddress + BufferLength >= (ULONG_PTR)EndAddress)
{ {
BufferLength = EndAddress - VirtualAddress; BufferLength = (ULONG)((ULONG_PTR)EndAddress - (ULONG_PTR)VirtualAddress);
} }
} }
if (Length != NULL) if (Length != NULL)
@ -1786,7 +1786,7 @@ SpiAllocateSrbExtension(PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
if (index != 0xffffffff) if (index != 0xffffffff)
{ {
DeviceExtension->CurrentSrbExtensions++; DeviceExtension->CurrentSrbExtensions++;
Srb->SrbExtension = DeviceExtension->VirtualAddress + index * DeviceExtension->SrbExtensionSize; Srb->SrbExtension = (PVOID)((ULONG_PTR)DeviceExtension->VirtualAddress + index * DeviceExtension->SrbExtensionSize);
} }
} }
DPRINT("%x\n", Srb->SrbExtension); DPRINT("%x\n", Srb->SrbExtension);

View file

@ -52,14 +52,14 @@ DIBtoVGA(SURFOBJ *Dest, SURFOBJ *Source, XLATEOBJ *ColorTranslation,
if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL)) if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
{ {
DIB_BltToVGA(DestRect->left, DestRect->top, dx, dy, DIB_BltToVGA(DestRect->left, DestRect->top, dx, dy,
Source->pvScan0 + SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1), (PVOID)((ULONG_PTR)Source->pvScan0 + SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1)),
Source->lDelta, SourcePoint->x % 2); Source->lDelta, SourcePoint->x % 2);
} }
else else
{ {
/* Perform color translation */ /* Perform color translation */
DIB_BltToVGAWithXlate(DestRect->left, DestRect->top, dx, dy, DIB_BltToVGAWithXlate(DestRect->left, DestRect->top, dx, dy,
Source->pvScan0 + SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1), (PVOID)((ULONG_PTR)Source->pvScan0 + SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1)),
Source->lDelta, ColorTranslation); Source->lDelta, ColorTranslation);
} }
return FALSE; return FALSE;

View file

@ -409,7 +409,7 @@ void DIB_BltFromVGA(int x, int y, int w, int h, void *b, int Dest_lDelta)
/* Reset the destination. */ /* Reset the destination. */
for (j = 0; j < h; j++) for (j = 0; j < h; j++)
{ {
memset(b + (j * Dest_lDelta), 0, abs(Dest_lDelta)); memset((PVOID)((ULONG_PTR)b + (j * Dest_lDelta)), 0, abs(Dest_lDelta));
} }
for (plane = 0; plane < 4; plane++) for (plane = 0; plane < 4; plane++)
@ -986,7 +986,7 @@ void DFB_BltToDIB(int x, int y, int w, int h, void *b, int bw, void *bdib, int d
int i, j, dib_shift; int i, j, dib_shift;
bpX = b; bpX = b;
dib = bdib + y * dibw + (x / 2); dib = (unsigned char *)bdib + y * dibw + (x / 2);
for (i=w; i>0; i--) { for (i=w; i>0; i--) {
@ -1015,7 +1015,7 @@ void DIB_BltToDFB(int x, int y, int w, int h, void *b, int bw, void *bdib, int d
int i, j, dib_shift, dib_and; int i, j, dib_shift, dib_and;
bpX = b; bpX = b;
dib = bdib + y * dibw + (x / 2); dib = (unsigned char *)bdib + y * dibw + (x / 2);
for (i=w; i>0; i--) { for (i=w; i>0; i--) {

View file

@ -57,7 +57,7 @@ IntVideoPortImageDirectoryEntryToData(
if (Va == 0) if (Va == 0)
return NULL; return NULL;
return (PVOID)(BaseAddress + Va); return (PVOID)((ULONG_PTR)BaseAddress + Va);
} }
PVOID STDCALL PVOID STDCALL
@ -103,7 +103,7 @@ IntVideoPortGetProcAddress(
((ULONG_PTR)BaseAddress + (ULONG_PTR)ExportDir->AddressOfNames); ((ULONG_PTR)BaseAddress + (ULONG_PTR)ExportDir->AddressOfNames);
for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++) for (i = 0; i < ExportDir->NumberOfNames; i++, NamePtr++, OrdinalPtr++)
{ {
if (!_strnicmp((PCHAR)FunctionName, (PCHAR)(BaseAddress + *NamePtr), if (!_strnicmp((PCHAR)FunctionName, (PCHAR)((ULONG_PTR)BaseAddress + *NamePtr),
strlen((PCHAR)FunctionName))) strlen((PCHAR)FunctionName)))
{ {
return (PVOID)((ULONG_PTR)BaseAddress + return (PVOID)((ULONG_PTR)BaseAddress +

View file

@ -25,7 +25,7 @@
sizeof (IMAGE_NT_SIGNATURE) + \ sizeof (IMAGE_NT_SIGNATURE) + \
sizeof (IMAGE_FILE_HEADER))) sizeof (IMAGE_FILE_HEADER)))
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) #define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
#define RVA(m, b) ((ULONG)b + m) #define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
#define NTSTAT_SEVERITY_SHIFT 30 #define NTSTAT_SEVERITY_SHIFT 30
#define NTSTAT_SEVERITY_MASK 0x00000003 #define NTSTAT_SEVERITY_MASK 0x00000003
#define NTSTAT_FACILITY_SHIFT 16 #define NTSTAT_FACILITY_SHIFT 16

View file

@ -13,11 +13,8 @@ void *_lsearch(const void *key, void *base, size_t *nelp, size_t width,
if (ret_find != NULL) if (ret_find != NULL)
return ret_find; return ret_find;
#ifdef __GNUC__ memcpy((void*)((int*)base + (*nelp*width)), key, width);
memcpy(base + (*nelp*width), key, width);
#else
memcpy((int*)base + (*nelp*width), key, width);
#endif
(*nelp)++; (*nelp)++;
return base; return base;
} }

View file

@ -54,11 +54,11 @@ InternalFindNextFile (
if (IData->pFileInfo->NextEntryOffset != 0) if (IData->pFileInfo->NextEntryOffset != 0)
{ {
IData->pFileInfo = (PVOID)IData->pFileInfo + IData->pFileInfo->NextEntryOffset; IData->pFileInfo = (PVOID)((ULONG_PTR)IData->pFileInfo + IData->pFileInfo->NextEntryOffset);
DPRINT("Found %.*S\n",IData->pFileInfo->FileNameLength/sizeof(WCHAR), IData->pFileInfo->FileName); DPRINT("Found %.*S\n",IData->pFileInfo->FileNameLength/sizeof(WCHAR), IData->pFileInfo->FileName);
return TRUE; return TRUE;
} }
IData->pFileInfo = (PVOID)IData + sizeof(KERNEL32_FIND_FILE_DATA); IData->pFileInfo = (PVOID)((ULONG_PTR)IData + sizeof(KERNEL32_FIND_FILE_DATA));
IData->pFileInfo->FileIndex = 0; IData->pFileInfo->FileIndex = 0;
Status = NtQueryDirectoryFile (IData->DirectoryHandle, Status = NtQueryDirectoryFile (IData->DirectoryHandle,
NULL, NULL,
@ -271,7 +271,7 @@ InternalFindFirstFile (
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return(NULL); return(NULL);
} }
IData->pFileInfo = (PVOID)IData + sizeof(KERNEL32_FIND_FILE_DATA); IData->pFileInfo = (PVOID)((ULONG_PTR)IData + sizeof(KERNEL32_FIND_FILE_DATA));
IData->pFileInfo->FileIndex = 0; IData->pFileInfo->FileIndex = 0;
Status = NtQueryDirectoryFile (IData->DirectoryHandle, Status = NtQueryDirectoryFile (IData->DirectoryHandle,

View file

@ -39,7 +39,7 @@ typedef struct __GLOBAL_LOCAL_HANDLE
#define HANDLE_TO_INTERN(h) ((PGLOBAL_HANDLE)(((char *)(h))-4)) #define HANDLE_TO_INTERN(h) ((PGLOBAL_HANDLE)(((char *)(h))-4))
#define INTERN_TO_HANDLE(i) ((HGLOBAL) &((i)->Pointer)) #define INTERN_TO_HANDLE(i) ((HGLOBAL) &((i)->Pointer))
#define POINTER_TO_HANDLE(p) (*(PHANDLE)(p - HANDLE_SIZE)) #define POINTER_TO_HANDLE(p) (*(PHANDLE)((ULONG_PTR)p - HANDLE_SIZE))
#define ISHANDLE(h) ((((ULONG)(h)) & 0x4)!=0) #define ISHANDLE(h) ((((ULONG)(h)) & 0x4)!=0)
#define ISPOINTER(h) ((((ULONG)(h)) & 0x4)==0) #define ISPOINTER(h) ((((ULONG)(h)) & 0x4)==0)
@ -105,7 +105,7 @@ GlobalAlloc(UINT uFlags,
if (palloc) if (palloc)
{ {
*(PHANDLE)palloc = INTERN_TO_HANDLE(phandle); *(PHANDLE)palloc = INTERN_TO_HANDLE(phandle);
phandle->Pointer = palloc + HANDLE_SIZE; phandle->Pointer = (PVOID)((ULONG_PTR)palloc + HANDLE_SIZE);
} }
else /*failed to allocate the memory block*/ else /*failed to allocate the memory block*/
{ {
@ -237,7 +237,7 @@ GlobalFree(HGLOBAL hMem)
} }
if(phandle->Pointer) if(phandle->Pointer)
RtlFreeHeap(GetProcessHeap(), 0, phandle->Pointer - HANDLE_SIZE); RtlFreeHeap(GetProcessHeap(), 0, (PVOID)((ULONG_PTR)phandle->Pointer - HANDLE_SIZE));
RtlFreeHeap(GetProcessHeap(), 0, phandle); RtlFreeHeap(GetProcessHeap(), 0, phandle);
} }
@ -549,7 +549,7 @@ GlobalReAlloc(HGLOBAL hMem,
if(phandle->Pointer) if(phandle->Pointer)
{ {
palloc = RtlReAllocateHeap(GetProcessHeap(), heap_flags, palloc = RtlReAllocateHeap(GetProcessHeap(), heap_flags,
phandle->Pointer - HANDLE_SIZE, (PVOID)((ULONG_PTR)phandle->Pointer - HANDLE_SIZE),
dwBytes + HANDLE_SIZE); dwBytes + HANDLE_SIZE);
if (0 == palloc) if (0 == palloc)
{ {
@ -558,7 +558,7 @@ GlobalReAlloc(HGLOBAL hMem,
else else
{ {
*(PHANDLE)palloc = hMem; *(PHANDLE)palloc = hMem;
phandle->Pointer = palloc + HANDLE_SIZE; phandle->Pointer = (PVOID)((ULONG_PTR)palloc + HANDLE_SIZE);
} }
} }
else else
@ -571,7 +571,7 @@ GlobalReAlloc(HGLOBAL hMem,
else else
{ {
*(PHANDLE)palloc = hMem; *(PHANDLE)palloc = hMem;
phandle->Pointer = palloc + HANDLE_SIZE; phandle->Pointer = (PVOID)((ULONG_PTR)palloc + HANDLE_SIZE);
} }
} }
} }
@ -579,7 +579,7 @@ GlobalReAlloc(HGLOBAL hMem,
{ {
if(phandle->Pointer) if(phandle->Pointer)
{ {
RtlFreeHeap(GetProcessHeap(), 0, phandle->Pointer - HANDLE_SIZE); RtlFreeHeap(GetProcessHeap(), 0, (PVOID)((ULONG_PTR)phandle->Pointer - HANDLE_SIZE));
phandle->Pointer = 0; phandle->Pointer = 0;
} }
} }
@ -613,7 +613,7 @@ GlobalSize(HGLOBAL hMem)
{ {
if (0 != phandle->Pointer)/*NOT DISCARDED*/ if (0 != phandle->Pointer)/*NOT DISCARDED*/
{ {
retval = RtlSizeHeap(GetProcessHeap(), 0, phandle->Pointer - HANDLE_SIZE); retval = RtlSizeHeap(GetProcessHeap(), 0, (PVOID)((ULONG_PTR)phandle->Pointer - HANDLE_SIZE));
if (retval == (SIZE_T)-1) /*RtlSizeHeap failed*/ if (retval == (SIZE_T)-1) /*RtlSizeHeap failed*/
{ {

View file

@ -505,7 +505,7 @@ static NTSTATUS KlInitPeb(HANDLE ProcessHandle,
while(*ptr++); while(*ptr++);
} }
ptr++; ptr++;
EnvSize = (PVOID)ptr - ParentEnv; EnvSize = (ULONG)((ULONG_PTR)ptr - (ULONG_PTR)ParentEnv);
} }
else if (NtCurrentPeb()->ProcessParameters->Environment != NULL) else if (NtCurrentPeb()->ProcessParameters->Environment != NULL)
{ {
@ -572,7 +572,7 @@ static NTSTATUS KlInitPeb(HANDLE ProcessHandle,
/* write pointer to environment */ /* write pointer to environment */
Offset = FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, Environment); Offset = FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, Environment);
NtWriteVirtualMemory(ProcessHandle, NtWriteVirtualMemory(ProcessHandle,
(PVOID)(PpbBase + Offset), (PVOID)((ULONG_PTR)PpbBase + Offset),
&EnvPtr, &EnvPtr,
sizeof(EnvPtr), sizeof(EnvPtr),
&BytesWritten); &BytesWritten);

View file

@ -48,7 +48,7 @@ CsrCaptureParameterBuffer(PVOID ParameterBuffer,
memcpy(Block, ParameterBuffer, ParameterBufferSize); memcpy(Block, ParameterBuffer, ParameterBufferSize);
} }
*ClientAddress = Block; *ClientAddress = Block;
*ServerAddress = Block - CsrSectionMapBase + CsrSectionMapServerBase; *ServerAddress = (PVOID)((ULONG_PTR)Block - (ULONG_PTR)CsrSectionMapBase + (ULONG_PTR)CsrSectionMapServerBase);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }

View file

@ -266,7 +266,7 @@ __true_LdrInitializeThunk (ULONG Unknown1,
&NlsTable); &NlsTable);
RtlResetRtlTranslations (&NlsTable); RtlResetRtlTranslations (&NlsTable);
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew); NTHeaders = (PIMAGE_NT_HEADERS)((ULONG_PTR)ImageBase + PEDosHeader->e_lfanew);
/* Get number of processors */ /* Get number of processors */
Status = ZwQuerySystemInformation(SystemBasicInformation, Status = ZwQuerySystemInformation(SystemBasicInformation,

View file

@ -162,7 +162,7 @@ static inline VOID LdrpTlsCallback(PLDR_DATA_TABLE_ENTRY Module, ULONG dwReason)
TRACE_LDR("%wZ - Calling tls callback at %x\n", TRACE_LDR("%wZ - Calling tls callback at %x\n",
&Module->BaseDllName, TlsCallback); &Module->BaseDllName, TlsCallback);
TlsCallback(Module->DllBase, dwReason, NULL); TlsCallback(Module->DllBase, dwReason, NULL);
TlsCallback++; TlsCallback = (PIMAGE_TLS_CALLBACK)((ULONG_PTR)TlsCallback + sizeof(PVOID));
} }
} }
} }
@ -205,7 +205,7 @@ LdrpInitializeTlsForThread(VOID)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
TlsData = (PVOID)TlsPointers + LdrpTlsCount * sizeof(PVOID); TlsData = (PVOID)((ULONG_PTR)TlsPointers + LdrpTlsCount * sizeof(PVOID));
Teb->ThreadLocalStoragePointer = TlsPointers; Teb->ThreadLocalStoragePointer = TlsPointers;
TlsInfo = LdrpTlsArray; TlsInfo = LdrpTlsArray;
@ -216,12 +216,12 @@ LdrpInitializeTlsForThread(VOID)
if (TlsInfo->TlsDataSize) if (TlsInfo->TlsDataSize)
{ {
memcpy(TlsData, TlsInfo->StartAddressOfRawData, TlsInfo->TlsDataSize); memcpy(TlsData, TlsInfo->StartAddressOfRawData, TlsInfo->TlsDataSize);
TlsData += TlsInfo->TlsDataSize; TlsData = (PVOID)((ULONG_PTR)TlsData + TlsInfo->TlsDataSize);
} }
if (TlsInfo->TlsZeroSize) if (TlsInfo->TlsZeroSize)
{ {
memset(TlsData, 0, TlsInfo->TlsZeroSize); memset(TlsData, 0, TlsInfo->TlsZeroSize);
TlsData += TlsInfo->TlsZeroSize; TlsData = (PVOID)((ULONG_PTR)TlsData + TlsInfo->TlsZeroSize);
} }
} }
} }
@ -471,7 +471,7 @@ LdrAddModuleEntry(PVOID ImageBase,
Module->DllBase = (PVOID)ImageBase; Module->DllBase = (PVOID)ImageBase;
Module->EntryPoint = (PVOID)NTHeaders->OptionalHeader.AddressOfEntryPoint; Module->EntryPoint = (PVOID)NTHeaders->OptionalHeader.AddressOfEntryPoint;
if (Module->EntryPoint != 0) if (Module->EntryPoint != 0)
Module->EntryPoint += (ULONG)Module->DllBase; Module->EntryPoint = (PVOID)((ULONG_PTR)Module->EntryPoint + (ULONG_PTR)Module->DllBase);
Module->SizeOfImage = LdrpGetResidentSize(NTHeaders); Module->SizeOfImage = LdrpGetResidentSize(NTHeaders);
if (NtCurrentPeb()->Ldr->Initialized == TRUE) if (NtCurrentPeb()->Ldr->Initialized == TRUE)
{ {
@ -803,7 +803,7 @@ LdrFindEntryForAddress(PVOID Address,
DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->DllBase); DPRINT("Scanning %wZ at %p\n", &ModulePtr->BaseDllName, ModulePtr->DllBase);
if ((Address >= ModulePtr->DllBase) && if ((Address >= ModulePtr->DllBase) &&
(Address <= (ModulePtr->DllBase + ModulePtr->SizeOfImage))) ((ULONG_PTR)Address <= ((ULONG_PTR)ModulePtr->DllBase + ModulePtr->SizeOfImage)))
{ {
*Module = ModulePtr; *Module = ModulePtr;
RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock);
@ -1030,7 +1030,7 @@ LdrGetExportByOrdinal (
ExportDir->AddressOfFunctions ExportDir->AddressOfFunctions
); );
DPRINT( DPRINT(
"LdrGetExportByOrdinal(Ordinal %d) = %x\n", "LdrGetExportByOrdinal(Ordinal %d) = %p\n",
Ordinal, Ordinal,
RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] ) RVA(BaseAddress, ExFunctions[Ordinal - ExportDir->Base] )
); );
@ -1270,7 +1270,7 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
{ {
Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / Count = (RelocationDir->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) /
sizeof(USHORT); sizeof(USHORT);
Page = ImageBase + RelocationDir->VirtualAddress; Page = (PVOID)((ULONG_PTR)ImageBase + (ULONG_PTR)RelocationDir->VirtualAddress);
TypeOffset = (PUSHORT)(RelocationDir + 1); TypeOffset = (PUSHORT)(RelocationDir + 1);
/* Unprotect the page(s) we're about to relocate. */ /* Unprotect the page(s) we're about to relocate. */
@ -1289,7 +1289,7 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
if (RelocationDir->VirtualAddress + PAGE_SIZE < if (RelocationDir->VirtualAddress + PAGE_SIZE <
NTHeaders->OptionalHeader.SizeOfImage) NTHeaders->OptionalHeader.SizeOfImage)
{ {
ProtectPage2 = ProtectPage + PAGE_SIZE; ProtectPage2 = (PVOID)((ULONG_PTR)ProtectPage + PAGE_SIZE);
Status = NtProtectVirtualMemory(NtCurrentProcess(), Status = NtProtectVirtualMemory(NtCurrentProcess(),
&ProtectPage2, &ProtectPage2,
&ProtectSize, &ProtectSize,
@ -1391,16 +1391,16 @@ LdrpProcessImportDirectoryEntry(PLDR_DATA_TABLE_ENTRY Module,
} }
/* Get the import address list. */ /* Get the import address list. */
ImportAddressList = (PVOID *)(Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
/* Get the list of functions to import. */ /* Get the list of functions to import. */
if (ImportModuleDirectory->OriginalFirstThunk != 0) if (ImportModuleDirectory->OriginalFirstThunk != 0)
{ {
FunctionNameList = (PULONG) (Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk); FunctionNameList = (PULONG) ((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
} }
else else
{ {
FunctionNameList = (PULONG)(Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
} }
/* Get the size of IAT. */ /* Get the size of IAT. */
@ -1550,16 +1550,16 @@ LdrpAdjustImportDirectory(PLDR_DATA_TABLE_ENTRY Module,
{ {
/* Get the import address list. */ /* Get the import address list. */
ImportAddressList = (PVOID *)(Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); ImportAddressList = (PVOID *)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
/* Get the list of functions to import. */ /* Get the list of functions to import. */
if (ImportModuleDirectory->OriginalFirstThunk != 0) if (ImportModuleDirectory->OriginalFirstThunk != 0)
{ {
FunctionNameList = (PULONG) (Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk); FunctionNameList = (PULONG) ((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->OriginalFirstThunk);
} }
else else
{ {
FunctionNameList = (PULONG)(Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk); FunctionNameList = (PULONG)((ULONG_PTR)Module->DllBase + (ULONG_PTR)ImportModuleDirectory->FirstThunk);
} }
/* Get the size of IAT. */ /* Get the size of IAT. */
@ -1585,15 +1585,15 @@ LdrpAdjustImportDirectory(PLDR_DATA_TABLE_ENTRY Module,
NTHeaders = RtlImageNtHeader (ImportedModule->DllBase); NTHeaders = RtlImageNtHeader (ImportedModule->DllBase);
Start = (PVOID)NTHeaders->OptionalHeader.ImageBase; Start = (PVOID)NTHeaders->OptionalHeader.ImageBase;
End = Start + ImportedModule->SizeOfImage; End = (PVOID)((ULONG_PTR)Start + ImportedModule->SizeOfImage);
Offset = ImportedModule->DllBase - Start; Offset = (ULONG)((ULONG_PTR)ImportedModule->DllBase - (ULONG_PTR)Start);
/* Walk through function list and fixup addresses. */ /* Walk through function list and fixup addresses. */
while (*FunctionNameList != 0L) while (*FunctionNameList != 0L)
{ {
if (*ImportAddressList >= Start && *ImportAddressList < End) if (*ImportAddressList >= Start && *ImportAddressList < End)
{ {
(*ImportAddressList) += Offset; (*ImportAddressList) = (PVOID)((ULONG_PTR)(*ImportAddressList) + Offset);
} }
ImportAddressList++; ImportAddressList++;
FunctionNameList++; FunctionNameList++;
@ -1903,7 +1903,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
* to the DLL's image. * to the DLL's image.
*/ */
DosHeader = (PIMAGE_DOS_HEADER) ImageBase; DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
NTHeaders = (PIMAGE_NT_HEADERS) (ImageBase + DosHeader->e_lfanew); NTHeaders = (PIMAGE_NT_HEADERS) ((ULONG_PTR)ImageBase + DosHeader->e_lfanew);
/* /*
* If the base address is different from the * If the base address is different from the
@ -1978,7 +1978,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase,
DPRINT("AddressOfEntryPoint = %x\n",(ULONG)NTHeaders->OptionalHeader.AddressOfEntryPoint); DPRINT("AddressOfEntryPoint = %x\n",(ULONG)NTHeaders->OptionalHeader.AddressOfEntryPoint);
if (NTHeaders->OptionalHeader.AddressOfEntryPoint != 0) if (NTHeaders->OptionalHeader.AddressOfEntryPoint != 0)
{ {
EntryPoint = (PEPFUNC) (ImageBase EntryPoint = (PEPFUNC) ((ULONG_PTR)ImageBase
+ NTHeaders->OptionalHeader.AddressOfEntryPoint); + NTHeaders->OptionalHeader.AddressOfEntryPoint);
} }
DPRINT("LdrPEStartup() = %x\n",EntryPoint); DPRINT("LdrPEStartup() = %x\n",EntryPoint);
@ -3108,17 +3108,17 @@ LdrProcessRelocationBlock(IN PVOID Address,
break; break;
case IMAGE_REL_BASED_HIGH: case IMAGE_REL_BASED_HIGH:
ShortPtr = (PUSHORT)(Address + Offset); ShortPtr = (PUSHORT)((ULONG_PTR)Address + Offset);
*ShortPtr += HIWORD(Delta); *ShortPtr += HIWORD(Delta);
break; break;
case IMAGE_REL_BASED_LOW: case IMAGE_REL_BASED_LOW:
ShortPtr = (PUSHORT)(Address + Offset); ShortPtr = (PUSHORT)((ULONG_PTR)Address + Offset);
*ShortPtr += LOWORD(Delta); *ShortPtr += LOWORD(Delta);
break; break;
case IMAGE_REL_BASED_HIGHLOW: case IMAGE_REL_BASED_HIGHLOW:
LongPtr = (PULONG)(Address + Offset); LongPtr = (PULONG)((ULONG_PTR)Address + Offset);
*LongPtr += Delta; *LongPtr += Delta;
break; break;

View file

@ -44,7 +44,7 @@ RtlRosInitializeContext
if(!NT_SUCCESS(nErrCode)) return nErrCode; if(!NT_SUCCESS(nErrCode)) return nErrCode;
/* too many parameters */ /* too many parameters */
if((nParamsSize + sizeof(ULONG_PTR)) > (SIZE_T)(pStackBase - pStackLimit)) if((nParamsSize + sizeof(ULONG_PTR)) > (SIZE_T)((ULONG_PTR)pStackBase - (ULONG_PTR)pStackLimit))
return STATUS_STACK_OVERFLOW; return STATUS_STACK_OVERFLOW;
memset(Context, 0, sizeof(CONTEXT)); memset(Context, 0, sizeof(CONTEXT));

View file

@ -72,7 +72,7 @@ RtlImageDirectoryEntryToData (
*Size = NtHeader->OptionalHeader.DataDirectory[Directory].Size; *Size = NtHeader->OptionalHeader.DataDirectory[Directory].Size;
if (bFlag) if (bFlag)
return (PVOID)(BaseAddress + Va); return (PVOID)((ULONG_PTR)BaseAddress + Va);
/* image mapped as ordinary file, we must find raw pointer */ /* image mapped as ordinary file, we must find raw pointer */
return (PVOID)RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL); return (PVOID)RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL);
@ -138,10 +138,10 @@ RtlImageRvaToVa (
*SectionHeader = Section; *SectionHeader = Section;
} }
return (ULONG)(BaseAddress + return (ULONG)((ULONG_PTR)BaseAddress +
Rva + Rva +
Section->PointerToRawData - Section->PointerToRawData -
Section->VirtualAddress); (ULONG_PTR)Section->VirtualAddress);
} }
/* EOF */ /* EOF */

View file

@ -161,7 +161,7 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
/* write pointer to environment */ /* write pointer to environment */
Offset = FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, Environment); Offset = FIELD_OFFSET(RTL_USER_PROCESS_PARAMETERS, Environment);
ZwWriteVirtualMemory(ProcessHandle, ZwWriteVirtualMemory(ProcessHandle,
(PVOID)(PpbBase + Offset), (PVOID)((ULONG_PTR)PpbBase + Offset),
&EnvPtr, &EnvPtr,
sizeof(EnvPtr), sizeof(EnvPtr),
&BytesWritten); &BytesWritten);
@ -291,7 +291,7 @@ RtlCreateUserProcess(
0, 0,
&Sii.StackReserve, &Sii.StackReserve,
&Sii.StackCommit, &Sii.StackCommit,
ImageBaseAddress + (ULONG)Sii.EntryPoint, (PVOID)((ULONG_PTR)ImageBaseAddress + (ULONG_PTR)Sii.EntryPoint),
(PVOID)PEB_BASE, (PVOID)PEB_BASE,
&ProcessInfo->ThreadHandle, &ProcessInfo->ThreadHandle,
&ProcessInfo->ClientId &ProcessInfo->ClientId

View file

@ -787,7 +787,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
!(QueryEntry->Flags & RTL_QUERY_REGISTRY_NOEXPAND)) !(QueryEntry->Flags & RTL_QUERY_REGISTRY_NOEXPAND))
{ {
DPRINT("Expand REG_MULTI_SZ type\n"); DPRINT("Expand REG_MULTI_SZ type\n");
StringPtr = (PWSTR)((PVOID)FullValueInfo + FullValueInfo->DataOffset); StringPtr = (PWSTR)((ULONG_PTR)FullValueInfo + FullValueInfo->DataOffset);
while (*StringPtr != 0) while (*StringPtr != 0)
{ {
StringLen = (wcslen(StringPtr) + 1) * sizeof(WCHAR); StringLen = (wcslen(StringPtr) + 1) * sizeof(WCHAR);
@ -807,7 +807,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
{ {
DPRINT("Expand REG_EXPAND_SZ type\n"); DPRINT("Expand REG_EXPAND_SZ type\n");
StringPtr = (PWSTR)((PVOID)FullValueInfo + FullValueInfo->DataOffset); StringPtr = (PWSTR)((ULONG_PTR)FullValueInfo + FullValueInfo->DataOffset);
ExpandBuffer = ExAllocatePool(PagedPool, FullValueInfo->DataLength * 2); ExpandBuffer = ExAllocatePool(PagedPool, FullValueInfo->DataLength * 2);
if (ExpandBuffer == NULL) if (ExpandBuffer == NULL)
{ {
@ -841,7 +841,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
{ {
Status = QueryEntry->QueryRoutine(ValueName, Status = QueryEntry->QueryRoutine(ValueName,
FullValueInfo->Type, FullValueInfo->Type,
(PVOID)FullValueInfo + FullValueInfo->DataOffset, (PVOID)((ULONG_PTR)FullValueInfo + FullValueInfo->DataOffset),
FullValueInfo->DataLength, FullValueInfo->DataLength,
Context, Context,
QueryEntry->EntryContext); QueryEntry->EntryContext);

View file

@ -534,7 +534,7 @@ LoadBitmapImage(HINSTANCE hInstance, LPCWSTR lpszName, UINT fuLoad)
} }
HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD); HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
} }
Data = (PVOID)BitmapInfo + HeaderSize; Data = (PVOID)((ULONG_PTR)BitmapInfo + HeaderSize);
PrivateInfo = RtlAllocateHeap(GetProcessHeap(), 0, HeaderSize); PrivateInfo = RtlAllocateHeap(GetProcessHeap(), 0, HeaderSize);
if (PrivateInfo == NULL) if (PrivateInfo == NULL)