I have the following function which tries to get access to parallel port:
NTSTATUS ClaimHardware( PDRIVER_OBJECT pDriverObj,
PDEVICE_OBJECT pDevObj,
ULONG portBase, // 0x378
ULONG portSpan, // 0x4
ULONG Irq) // 0x7
{
NTSTATUS status;
PHYSICAL_ADDRESS maxPortAddr;
PIO_RESOURCE_REQUIREMENTS_LIST pRRList;
int rrSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) +
sizeof(IO_RESOURCE_DESCRIPTOR);
pRRList = (PIO_RESOURCE_REQUIREMENTS_LIST)
ExAllocatePool(PagedPool, rrSize);
RtlZeroMemory(pRRList, rrSize);
pRRList->ListSize = rrSize;
pRRList->AlternativeLists = 1; // only 1 Resource List
pRRList->InterfaceType = Isa;
pRRList->List[0].Version = 1;
pRRList->List[0].Revision = 1;
pRRList->List[0].Count = 2; // 2 Resource Descriptors: port & irq
pRRList->List[0].Descriptors[0].Type = CmResourceTypePort;
pRRList->List[0].Descriptors[0].ShareDisposition = CmResourceShareDeviceExclusive;
pRRList->List[0].Descriptors[0].Flags = CM_RESOURCE_PORT_IO;
pRRList->List[0].Descriptors[0].u.Port.Length = portSpan;
pRRList->List[0].Descriptors[0].u.Port.Alignment = FILE_WORD_ALIGNMENT;
maxPortAddr.QuadPart = portBase;
pRRList->List[0].Descriptors[0].u.Port.MinimumAddress = maxPortAddr;
maxPortAddr.LowPart += portSpan-1;
pRRList->List[0].Descriptors[0].u.Port.MaximumAddress = maxPortAddr;
pRRList->List[0].Descriptors[1].Type = CmResourceTypeInterrupt;
pRRList->List[0].Descriptors[1].ShareDisposition = CmResourceShareDeviceExclusive;
pRRList->List[0].Descriptors[1].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
pRRList->List[0].Descriptors[1].u.Interrupt.MinimumVector = Irq;
pRRList->List[0].Descriptors[1].u.Interrupt.MaximumVector = Irq;
status = IoReportDetectedDevice(
pDriverObj, // DriverObject
Isa, // Bus type
-1, // Bus number
-1, // SlotNumber
NULL, // Driver RESOURCE_LIST
pRRList, // Device Resource List
FALSE, // Already claimed?
&pDevObj ); // device object
// Result: status = STATUS_NO_SUCH_DEVICE
ExFreePool(pRRList);
return status;
}
Function is called from DriverEntry. BIOS parallel port settings are:
Parallel port 378
Port Mode Normal
IRQ 7
Operating system: WinXP professional.
Is this code OK? Possibly there is conflict with existing parallel port driver. I tried to
prevent this disabling LPT1 in the Device Manager or uninstalling existing parallel port
driver. However, this doesn’t help and my driver cannot be loaded.
Note: I ask this question second time, possibly first question was too long and not clear. I hope this is not violation of message list rules. Thanks.
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.