Re: Compiler Produces Incorrect Code
From: cristalink (cristalink_at_nospam.nospam)
Date: 12/30/04
- Next message: Matt Taylor: "Re: Compiler Produces Incorrect Code"
- Previous message: Max Paklin: "Re: IRP_MN_QUERY_PNP_DEVICE_STATE in BDA device driver"
- In reply to: Matt Taylor: "Re: Compiler Produces Incorrect Code"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 31 Dec 2004 07:19:41 +1300
> > because MyControlInternal is static. Where's the code for
> MyControlInternal?
> [...]
>
> A bit lengthy, but here it is:
I meant the assembly code, at least up to the first use of eax...
-- http://www.firestreamer.com - NTBackup to DVD and DV "Matt Taylor" <com.sisecure@mtaylor> wrote in message news:e7SAd.203679$6w6.183910@tornado.tampabay.rr.com... > "cristalink" <cristalink@nospam.nospam> wrote in message > news:OJqmpLg7EHA.3836@tk2msftngp13.phx.gbl... > > eax may well be used as a parameter due to compiler optimizations, esp. > > because MyControlInternal is static. Where's the code for > MyControlInternal? > [...] > > A bit lengthy, but here it is: > > static NTSTATUS MyIoControlInternal(PDEVICE_OBJECT DeviceObject, > PFILE_OBJECT FileObject, > ULONG IoControlCode, > PVOID InputBuffer, > ULONG InputBufferLength, > PVOID OutputBuffer, > ULONG OutputBufferLength, > IO_STATUS_BLOCK *pISB) > { > KEVENT ke; > PIRP Irp; > PIO_STACK_LOCATION IrpSp; > PVOID Buffer, TempInputBuffer, TempOutputBuffer; > NTSTATUS stat; > > // NOTE: This can never overflow > if ((InputBufferLength + OutputBufferLength) > 0) > { > if ((Buffer = ExAllocatePool(NonPagedPool, InputBufferLength + > OutputBufferLength)) == NULL) > { > MyDebugLog("ExAllocatePoolWithTag failed\n"); > return STATUS_INSUFFICIENT_RESOURCES; > } > > TempInputBuffer = Buffer; > TempOutputBuffer = (PVOID)((size_t) TempInputBuffer + InputBufferLength); > > if (InputBufferLength > 0) > RtlCopyMemory(TempInputBuffer, InputBuffer, InputBufferLength); > } > else > { > Buffer = NULL; > } > > KeInitializeEvent(&ke, NotificationEvent, FALSE); > > Irp = IoBuildDeviceIoControlRequest(IoControlCode, > DeviceObject, > TempInputBuffer, > InputBufferLength, > TempOutputBuffer, > OutputBufferLength, > FALSE, > &ke, > pISB); > > if (Irp == NULL) > { > if (Buffer != NULL) > ExFreePool(Buffer); > > MyDebugLog("IoBuildDeviceIoControlRequest failed\n"); > return STATUS_INSUFFICIENT_RESOURCES; > } > > IrpSp = IoGetCurrentIrpStackLocation(Irp) - 1; > IrpSp->FileObject = FileObject; > > // NOTE: seems the event is not getting set for certain IOCTLs. > IoCompletion seems to fix it. > IoSetCompletionRoutine(Irp, MySetEventIoCompletion, &ke, TRUE, TRUE, TRUE); > stat = IoCallDriver(DeviceObject, Irp); > KeWaitForSingleObject(&ke, Executive, KernelMode, FALSE, NULL); > IoFreeIrp(Irp); > > stat = pISB->Status; > > if (Buffer != NULL) > { > if (OutputBufferLength > 0) > RtlCopyMemory(OutputBuffer, TempOutputBuffer, OutputBufferLength); > > if (Buffer != NULL) > ExFreePool(Buffer); > } > > return stat; > } > > -Matt > >
- Next message: Matt Taylor: "Re: Compiler Produces Incorrect Code"
- Previous message: Max Paklin: "Re: IRP_MN_QUERY_PNP_DEVICE_STATE in BDA device driver"
- In reply to: Matt Taylor: "Re: Compiler Produces Incorrect Code"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|