--*/
#include "classp.h"
-#include "debug.h"
+
+#include <wmidata.h>
#define GESN_TIMEOUT_VALUE (0x4)
#define GESN_BUFFER_SIZE (0x8)
IN ULONG CountDown
);
-VOID
-NTAPI
-ClasspFailurePredict(
- IN PDEVICE_OBJECT DeviceObject,
- IN PFAILURE_PREDICTION_INFO Info
- );
+IO_WORKITEM_ROUTINE ClasspFailurePredict;
NTSTATUS
NTAPI
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => GESN::EXTERNAL: Event: %x Status %x Req %x\n",
externalInfo->ExternalEvent, externalInfo->ExternalStatus,
- (externalInfo->Request[0] >> 8) | externalInfo->Request[1]
+ (externalInfo->Request[0] << 8) | externalInfo->Request[1]
));
RtlZeroMemory(&externalData, sizeof(DEVICE_EVENT_EXTERNAL_REQUEST));
SET_FLAG(FdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME);
}
- InterlockedIncrement(&FdoExtension->MediaChangeCount);
+ InterlockedIncrement((PLONG)&FdoExtension->MediaChangeCount);
ClasspSetMediaChangeStateEx(FdoExtension,
MediaPresent,
FALSE,
)
{
#if DBG
- PUCHAR states[] = {"Unknown", "Present", "Not Present"};
+ PCSTR states[] = {"Unknown", "Present", "Not Present"};
#endif
MEDIA_CHANGE_DETECTION_STATE oldMediaState;
PMEDIA_CHANGE_DETECTION_INFO info = FdoExtension->MediaChangeDetectionInfo;
ClasspMediaChangeDetectionCompletion(
PDEVICE_OBJECT DeviceObject,
PIRP Irp,
- PSCSI_REQUEST_BLOCK Srb
+ PVOID Context
)
{
+ PSCSI_REQUEST_BLOCK srb = Context;
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
PCLASS_PRIVATE_FDO_DATA fdoData;
PMEDIA_CHANGE_DETECTION_INFO info;
info = fdoExtension->MediaChangeDetectionInfo;
ASSERT(info->MediaChangeIrp != NULL);
- ASSERT(!TEST_FLAG(Srb->SrbStatus, SRB_STATUS_QUEUE_FROZEN));
+ ASSERT(!TEST_FLAG(srb->SrbStatus, SRB_STATUS_QUEUE_FROZEN));
DBGTRACE(ClassDebugMCN, ("> ClasspMediaChangeDetectionCompletion: Device %p completed MCN irp %p.", DeviceObject, Irp));
/*
* This hack only applies to drives with the CAUSE_NOT_REPORTABLE_HACK bit set; this
* is set by disk.sys when HackCauseNotReportableHack is set for the drive in its BadControllers list.
*/
- if ((SRB_STATUS(Srb->SrbStatus) != SRB_STATUS_SUCCESS) &&
+ if ((SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) &&
TEST_FLAG(fdoExtension->ScanForSpecialFlags, CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK) &&
- (Srb->SenseInfoBufferLength >= RTL_SIZEOF_THROUGH_FIELD(SENSE_DATA, AdditionalSenseCode))){
+ (srb->SenseInfoBufferLength >= RTL_SIZEOF_THROUGH_FIELD(SENSE_DATA, AdditionalSenseCode))){
- PSENSE_DATA senseData = Srb->SenseInfoBuffer;
+ PSENSE_DATA senseData = srb->SenseInfoBuffer;
if ((senseData->SenseKey == SCSI_SENSE_NOT_READY) &&
(senseData->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY)){
- Srb->SrbStatus = SRB_STATUS_SUCCESS;
+ srb->SrbStatus = SRB_STATUS_SUCCESS;
}
}
// to call ClassError() with correct parameters.
//
status = STATUS_SUCCESS;
- if (SRB_STATUS(Srb->SrbStatus) != SRB_STATUS_SUCCESS) {
+ if (SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) {
- DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - failed - srb status=%s, sense=%s/%s/%s.", DBGGETSRBSTATUSSTR(Srb), DBGGETSENSECODESTR(Srb), DBGGETADSENSECODESTR(Srb), DBGGETADSENSEQUALIFIERSTR(Srb)));
+ DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - failed - srb status=%s, sense=%s/%s/%s.", DBGGETSRBSTATUSSTR(srb), DBGGETSENSECODESTR(srb), DBGGETADSENSECODESTR(srb), DBGGETADSENSEQUALIFIERSTR(srb)));
ClassInterpretSenseInfo(DeviceObject,
- Srb,
+ srb,
IRP_MJ_SCSI,
0,
0,
// free port-allocated sense buffer, if any.
//
- if (PORT_ALLOCATED_SENSE(fdoExtension, Srb)) {
- FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, Srb);
+ if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
+ FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
}
//
//
ASSERT(IoGetNextIrpStackLocation(Irp));
- IoGetNextIrpStackLocation(Irp)->Parameters.Scsi.Srb = Srb;
+ IoGetNextIrpStackLocation(Irp)->Parameters.Scsi.Srb = srb;
//
// Reset the MCN timer.
//
PWSTR nullMultiSz;
- PUCHAR vendorId;
- PUCHAR productId;
- PUCHAR revisionId;
+ PCSTR vendorId;
+ PCSTR productId;
+ PCSTR revisionId;
ULONG length;
ULONG offset;
if (deviceDescriptor->VendorIdOffset == 0) {
vendorId = NULL;
} else {
- vendorId = (PUCHAR) deviceDescriptor + deviceDescriptor->VendorIdOffset;
+ vendorId = (PCSTR) deviceDescriptor + deviceDescriptor->VendorIdOffset;
length = strlen(vendorId);
}
if ( deviceDescriptor->ProductIdOffset == 0 ) {
productId = NULL;
} else {
- productId = (PUCHAR) deviceDescriptor + deviceDescriptor->ProductIdOffset;
+ productId = (PCSTR) deviceDescriptor + deviceDescriptor->ProductIdOffset;
length += strlen(productId);
}
if ( deviceDescriptor->ProductRevisionOffset == 0 ) {
revisionId = NULL;
} else {
- revisionId = (PUCHAR) deviceDescriptor + deviceDescriptor->ProductRevisionOffset;
+ revisionId = (PCSTR) deviceDescriptor + deviceDescriptor->ProductRevisionOffset;
length += strlen(revisionId);
}
deviceString.Length = (USHORT)( length );
deviceString.MaximumLength = deviceString.Length + 1;
- deviceString.Buffer = (PUCHAR)ExAllocatePoolWithTag( NonPagedPool,
- deviceString.MaximumLength,
- CLASS_TAG_AUTORUN_DISABLE
- );
+ deviceString.Buffer = ExAllocatePoolWithTag( NonPagedPool,
+ deviceString.MaximumLength,
+ CLASS_TAG_AUTORUN_DISABLE
+ );
if (deviceString.Buffer == NULL) {
DebugPrint((ClassDebugMCN,
"ClassMediaChangeDisabledForHardware: Unable to alloc "
//
ClassDisableMediaChangeDetection(FdoExtension);
- InterlockedIncrement(&(fsContext->McnDisableCount));
+ InterlockedIncrement((PLONG)&fsContext->McnDisableCount);
} else {
LEAVE;
}
- InterlockedDecrement(&(fsContext->McnDisableCount));
+ InterlockedDecrement((PLONG)&fsContext->McnDisableCount);
ClassEnableMediaChangeDetection(FdoExtension);
}
// resets CountDown uses InterlockedExchange which is also
// atomic.
//
- countDown = InterlockedDecrement(&info->CountDown);
+ countDown = InterlockedDecrement((PLONG)&info->CountDown);
if (countDown == 0) {
DebugPrint((4, "ClasspTimerTick: Send FP irp for %p\n",
DebugPrint((1, "ClassTimerTick: Couldn't allocate "
"item - try again in one minute\n"));
- InterlockedExchange(&info->CountDown, 60);
+ InterlockedExchange((PLONG)&info->CountDown, 60);
} else {
NTAPI
ClasspFailurePredict(
IN PDEVICE_OBJECT DeviceObject,
- IN PFAILURE_PREDICTION_INFO Info
+ IN PVOID Context
)
{
+ PFAILURE_PREDICTION_INFO info = Context;
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
PIO_WORKITEM workItem;
STORAGE_PREDICT_FAILURE checkFailure;
NTSTATUS status;
- ASSERT(Info != NULL);
+ ASSERT(info != NULL);
DebugPrint((1, "ClasspFailurePredict: Polling for failure\n"));
// the lock.
//
- InterlockedExchange(&Info->CountDown, Info->Period);
- workItem = InterlockedExchangePointer(&(Info->WorkQueueItem), NULL);
+ InterlockedExchange((PLONG)&info->CountDown, info->Period);
+ workItem = InterlockedExchangePointer(&info->WorkQueueItem, NULL);
if (ClasspCanSendPollingIrp(fdoExtension)) {
if (PollingPeriod != 0) {
- InterlockedExchange(&info->Period, PollingPeriod);
+ InterlockedExchange((PLONG)&info->Period, PollingPeriod);
}
- InterlockedExchange(&info->CountDown, info->Period);
+ InterlockedExchange((PLONG)&info->CountDown, info->Period);
info->Method = FailurePredictionMethod;
if (FailurePredictionMethod != FailurePredictionNone) {