Yes, thank you ;)
A forum for reverse engineering, OS internals and malware analysis
Especially last one APTI requestWell, I'll trust you.
Tigzy wrote:Well...Hello, Tigzy
So anybody needing some code APTI could ask me, will give him short functionnal sample.
BOOLEAN
SptiRequest(
IN BOOLEAN IsRead,
IN WCHAR VolumeLabel,
IN PVOID pBuffer,
IN ULONG SectorOffset,
IN ULONG SectorNumber
)
{
BOOLEAN Result = FALSE;
WCHAR DosRootPathName[] = L"\\\\.\\C:";
HANDLE DiskHandle = NULL;
ULONG RequestLength = sizeof(SCSI_PASS_THROUGH_DIRECT) + sizeof(SENSE_DATA);
PSCSI_PASS_THROUGH_DIRECT pSrb = NULL;
ULONG BytesRead = 0;
ULONG BytesPerSector = 512;
DosRootPathName[4] = VolumeLabel;
GetDiskFreeSpaceW(&DosRootPathName[4], NULL, &BytesPerSector, NULL, NULL);
DiskHandle = CreateFileW(DosRootPathName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if(INVALID_HANDLE_VALUE != DiskHandle)
{
pSrb = MemAlloc(RequestLength);
if(pSrb)
{
RtlZeroMemory(pSrb, RequestLength);
pSrb->Length = sizeof(SCSI_PASS_THROUGH);
pSrb->CdbLength = 10;
pSrb->SenseInfoLength = sizeof(SENSE_DATA);
pSrb->DataIn = IsRead ? SCSI_IOCTL_DATA_OUT : SCSI_IOCTL_DATA_IN;
pSrb->DataTransferLength = SectorNumber * BytesPerSector;
pSrb->TimeOutValue = 500;
pSrb->DataBuffer = pBuffer;
pSrb->SenseInfoOffset = sizeof(SCSI_PASS_THROUGH);
pSrb->Cdb[0] = IsRead ? 0x28 : 0x2A;
pSrb->Cdb[2] = HIBYTE(HIWORD(SectorOffset));
pSrb->Cdb[3] = LOBYTE(HIWORD(SectorOffset));
pSrb->Cdb[4] = HIBYTE(LOWORD(SectorOffset));
pSrb->Cdb[5] = LOBYTE(LOWORD(SectorOffset));
pSrb->Cdb[7] = HIBYTE(LOWORD(SectorNumber));
pSrb->Cdb[8] = LOBYTE(LOWORD(SectorNumber));
Result = DeviceIoControl(DiskHandle, IOCTL_SCSI_PASS_THROUGH_DIRECT, pSrb, RequestLength, pSrb, RequestLength, &BytesRead, NULL);
MemFree(pSrb);
}
CloseHandle(DiskHandle);
}
return Result;
}