*/
{
PVOID BaseAddress;
- NTSTATUS Status;
ULONG FATOffset;
ULONG ChunkSize;
PVOID Context;
{
return STATUS_UNSUCCESSFUL;
}
- CurrentCluster = (*(PULONG)(BaseAddress + (FATOffset % ChunkSize))) & 0x0fffffff;
+ CurrentCluster = (*(PULONG)((char*)BaseAddress + (FATOffset % ChunkSize))) & 0x0fffffff;
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
CurrentCluster = 0xffffffff;
CcUnpinData(Context);
*/
{
PVOID BaseAddress;
- NTSTATUS Status;
ULONG FATOffset;
ULONG ChunkSize;
PVOID Context;
{
return STATUS_UNSUCCESSFUL;
}
- CurrentCluster = *((PUSHORT)(BaseAddress + (FATOffset % ChunkSize)));
+ CurrentCluster = *((PUSHORT)((char*)BaseAddress + (FATOffset % ChunkSize)));
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
CurrentCluster = 0xffffffff;
CcUnpinData(Context);
*/
{
PUSHORT CBlock;
- ULONG FATOffset;
ULONG Entry;
- NTSTATUS Status;
PVOID BaseAddress;
PVOID Context;
LARGE_INTEGER Offset;
{
return STATUS_UNSUCCESSFUL;
}
- CBlock = (PUSHORT)(BaseAddress + (CurrentCluster * 12) / 8);
+ CBlock = (PUSHORT)((char*)BaseAddress + (CurrentCluster * 12) / 8);
if ((CurrentCluster % 2) == 0)
{
Entry = *CBlock & 0x0fff;
ULONG FatLength;
ULONG StartCluster;
ULONG i, j;
- NTSTATUS Status;
PVOID BaseAddress;
ULONG ChunkSize;
PVOID Context = 0;
return STATUS_UNSUCCESSFUL;
}
CHECKPOINT;
- Block = (PUSHORT)(BaseAddress + i % ChunkSize);
+ Block = (PUSHORT)((char*)BaseAddress + i % ChunkSize);
}
if (*Block == 0)
*/
{
ULONG FatLength;
- ULONG FATOffset;
ULONG StartCluster;
ULONG Entry;
PUSHORT CBlock;
ULONG i, j;
PVOID BaseAddress;
- NTSTATUS Status;
PVOID Context;
LARGE_INTEGER Offset;
{
for (i = StartCluster; i < FatLength; i++)
{
- CBlock = (PUSHORT)(BaseAddress + (i * 12) / 8);
+ CBlock = (PUSHORT)((char*)BaseAddress + (i * 12) / 8);
if ((i % 2) == 0)
{
Entry = *CBlock & 0xfff;
ULONG FatLength;
ULONG StartCluster;
ULONG i, j;
- NTSTATUS Status;
PVOID BaseAddress;
ULONG ChunkSize;
PVOID Context = 0;
DPRINT1("CcMapData(Offset %x, Length %d) failed\n", (ULONG)Offset.QuadPart, ChunkSize);
return STATUS_UNSUCCESSFUL;
}
- Block = (PULONG)(BaseAddress + i % ChunkSize);
+ Block = (PULONG)((char*)BaseAddress + i % ChunkSize);
}
if ((*Block & 0x0fffffff) == 0)
* FUNCTION: Counts free cluster in a FAT12 table
*/
{
- ULONG FATOffset;
ULONG Entry;
PVOID BaseAddress;
ULONG ulCount = 0;
ULONG i;
- NTSTATUS Status;
ULONG numberofclusters;
LARGE_INTEGER Offset;
PVOID Context;
for (i = 2; i < numberofclusters; i++)
{
- CBlock = (PUSHORT)(BaseAddress + (i * 12) / 8);
+ CBlock = (PUSHORT)((char*)BaseAddress + (i * 12) / 8);
if ((i % 2) == 0)
{
Entry = *CBlock & 0x0fff;
ULONG ulCount = 0;
ULONG i;
ULONG ChunkSize;
- NTSTATUS Status;
PVOID Context = NULL;
LARGE_INTEGER Offset;
ULONG FatLength;
{
return STATUS_UNSUCCESSFUL;
}
- Block = (PUSHORT)(BaseAddress + i % ChunkSize);
+ Block = (PUSHORT)((char*)BaseAddress + i % ChunkSize);
}
if (*Block == 0)
ulCount++;
ULONG ulCount = 0;
ULONG i;
ULONG ChunkSize;
- NTSTATUS Status;
PVOID Context = NULL;
LARGE_INTEGER Offset;
ULONG FatLength;
{
return STATUS_UNSUCCESSFUL;
}
- Block = (PULONG)(BaseAddress + i % ChunkSize);
+ Block = (PULONG)((char*)BaseAddress + i % ChunkSize);
}
if ((*Block & 0x0fffffff) == 0)
ulCount++;
ULONG FATsector;
ULONG FATOffset;
PUCHAR CBlock;
- int i;
- NTSTATUS Status;
PVOID BaseAddress;
PVOID Context;
LARGE_INTEGER Offset;
if ((ClusterToWrite % 2) == 0)
{
*OldValue = CBlock[FATOffset] + ((CBlock[FATOffset + 1] & 0x0f) << 8);
- CBlock[FATOffset] = NewValue;
+ CBlock[FATOffset] = (UCHAR)NewValue;
CBlock[FATOffset + 1] &= 0xf0;
CBlock[FATOffset + 1] |= (NewValue & 0xf00) >> 8;
}
*OldValue = (CBlock[FATOffset] >> 4) + (CBlock[FATOffset + 1] << 4);
CBlock[FATOffset] &= 0x0f;
CBlock[FATOffset] |= (NewValue & 0xf) << 4;
- CBlock[FATOffset + 1] = NewValue >> 4;
+ CBlock[FATOffset + 1] = (UCHAR)(NewValue >> 4);
}
/* Write the changed FAT sector(s) to disk */
FATsector = FATOffset / DeviceExt->FatInfo.BytesPerSector;
*/
{
PVOID BaseAddress;
- NTSTATUS Status;
ULONG FATOffset;
- ULONG i;
ULONG ChunkSize;
PVOID Context;
LARGE_INTEGER Offset;
}
DPRINT("Writing 0x%x for offset 0x%x 0x%x\n", NewValue, FATOffset,
ClusterToWrite);
- Cluster = ((PUSHORT)(BaseAddress + (FATOffset % ChunkSize)));
+ Cluster = ((PUSHORT)((char*)BaseAddress + (FATOffset % ChunkSize)));
*OldValue = *Cluster;
- *Cluster = NewValue;
+ *Cluster = (USHORT)NewValue;
CcSetDirtyPinnedData(Context, NULL);
CcUnpinData(Context);
return(STATUS_SUCCESS);
*/
{
PVOID BaseAddress;
- NTSTATUS Status;
ULONG FATOffset;
- ULONG i;
ULONG ChunkSize;
PVOID Context;
LARGE_INTEGER Offset;
}
DPRINT("Writing 0x%x for offset 0x%x 0x%x\n", NewValue, FATOffset,
ClusterToWrite);
- Cluster = ((PULONG)(BaseAddress + (FATOffset % ChunkSize)));
+ Cluster = ((PULONG)((char*)BaseAddress + (FATOffset % ChunkSize)));
*OldValue = *Cluster & 0x0fffffff;
*Cluster = (*Cluster & 0xf0000000) | (NewValue & 0x0fffffff);
return(Status);
}
-ULONG
+ULONGLONG
ClusterToSector(PDEVICE_EXTENSION DeviceExt,
ULONG Cluster)
/*
*/
{
return DeviceExt->FatInfo.dataStart +
- ((Cluster - 2) * DeviceExt->FatInfo.SectorsPerCluster);
+ ((ULONGLONG)(Cluster - 2) * DeviceExt->FatInfo.SectorsPerCluster);
+
}
NTSTATUS
return(Status);
}
-
-NTSTATUS
-GetNextSector(PDEVICE_EXTENSION DeviceExt,
- ULONG CurrentSector,
- PULONG NextSector,
- BOOLEAN Extend)
-/* Some functions don't have access to the cluster they're really reading from.
- Maybe this is a dirty solution, but it will allow them to handle fragmentation. */
-{
- NTSTATUS Status;
-
- DPRINT("GetNextSector(DeviceExt %x, CurrentSector %x)\n",
- DeviceExt,
- CurrentSector);
- if (CurrentSector<DeviceExt->FatInfo.dataStart || ((CurrentSector - DeviceExt->FatInfo.dataStart + 1) % DeviceExt->FatInfo.SectorsPerCluster))
- /* Basically, if the next sequential sector would be on a cluster border, then we'll need to check in the FAT */
- {
- (*NextSector)=CurrentSector+1;
- return (STATUS_SUCCESS);
- }
- else
- {
- CurrentSector = (CurrentSector - DeviceExt->FatInfo.dataStart) / DeviceExt->FatInfo.SectorsPerCluster + 2;
-
- Status = GetNextCluster(DeviceExt, CurrentSector, NextSector, Extend);
- if (!NT_SUCCESS(Status))
- {
- return(Status);
- }
- if ((*NextSector) == 0 || (*NextSector) == 0xffffffff)
- {
- /* The caller wants to know a sector. These FAT codes don't correspond to any sector. */
- return(STATUS_UNSUCCESSFUL);
- }
-
- (*NextSector) = ClusterToSector(DeviceExt,(*NextSector));
- return(STATUS_SUCCESS);
- }
-}
-
/* EOF */