|
|
Comments and Discussions
|
|
 |

|
i need to replace a printer for another computer to send the "output" of the lpt1 to a file.
I have some problems to read the data, status and control ports, I mean, i can't manage the busy and acknowledge in the second computer, in fact, i can't read what the first computer is sending to the printer. Could you please help me? or telling me what can i do for solve my problem?
Thank you in advance for your attention.
Regards
|
|
|
|

|
there is no reference in the code for KeInitializeDpc. the driver crashes as of result...
|
|
|
|

|
Hello All,
We have developed complete Device Driver, by this Device Driver we are able to communicate with the FTDI Chipset , means we can read Device Descriptors, Endpoint Information, even we are able to write the data to USB Device, but during read operation we are not receiving the correct data.
For reading USB Data we have used following Functions of DDK
UsbBuildInterruptOrBulkTransferRequest(
urb,
sizeof (struct _URB_BULK_OR_INTERRUPT_TRANSFER),
PipeHandle,
&Extension->ReadData,
NULL,
ReadLength, //64,
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
NULL);
IoSetCompletionRoutine(
Irp,
(PIO_COMPLETION_ROUTINE) ReadDataFun,
Extension,
TRUE,
TRUE,
TRUE);
Other querry is contents of ReadData buffer after UsbBuildInterruptOrBulkTransferRequest() function should remain same while
testing in ReadDataFun() function or it will change after calling IoSetCompletionRoutine() function &
We are always getting contents of ReadData buffer as 0x11,0x60 Why?
Please if anybody can help out for any alternate way or if anything wrong in the above fucntions.
I have also tried with _CallUSBD Function but with that also I am getting same results.
also if anyboudy can tell me by using this function how URB are updated I mean whether we have to pass the Device Object to Update or what exactly we have to do.
Please Help
neelamw
|
|
|
|

|
Hi,
Very helpful information! Thanks!!
I would like my driver to just wait after a ReadFile and never pass data back to the application.
I know it sounds weird, but it's a long story.
So to try and explain further i want it to work in the following manner:
1, App opens the driver, calls overlapped ReadFile.
2, ReadFile returns with 'Pending'
3, App waits with WaitFor...
4, Waitfor never returns because the event is never triggered.
5, App is eventually closed and driver unloads having never returned data.
So when I process a read can i return straight away with just:
Irp->IoStatus.Status = STATUS_PENDING;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT); //Do I do this or not?
Is any clean up necessary when the driver unloads because of the 'Pending' read?
|
|
|
|

|
Iam getting this error after running the sample..I have installed the driver file by right clicking -> Install..
can any one tell me what am i missing ?
ERROR : Driver couldn't be opened. Error=2
Thanks in advance..
|
|
|
|

|
Hi,
You will definitely need a reboot.
Tamas
|
|
|
|

|
Tamás Károly
Can the same procedure works on Win XP SP2 if I want to read data from Bluetooth devices?
Ajay
|
|
|
|

|
Hi,
This technique works as long as you can handle the IRQ of a device. I don't have much experience with bluettooth devices, but I guess they handle their interrupts themselves. If you want to read data from a bt device, I would recommend writing a filter driver and put it into the device stack on top of the bt's own device. This way you can control the communication between the device and the user mode apps.
I think bt is very similar to serial ports, so maybe the bt driver provides a virtual COM port to access it, in which case you don't even have to write a kernel mode driver.
Tamas Karoly
|
|
|
|

|
How to read data from table of access database (.MDB) created in user-mode?
|
|
|
|

|
You must be joking! Access doesn't even work well in user mode!
Actually, you can access files from a kernel mode driver, but you have to rewrite the whole MS Access to parse the file. Maybe you could use a text file. It is easy to parse, although string functions in the kernel are rather awkward.
Tamas
|
|
|
|

|
hello,
i want to write a program that it controls
the printer in network, for example program give permission
to some users and disallow to some users,
also i want to know that
how many pages a user want to print before giving
him permission or not ?
|
|
|
|

|
I'm afraid I cannot help you. I have no experience with printer drivers, but the DDK docs talk a lot about printer drivers. Have you checked the DDK help?
Tamas
|
|
|
|

|
i have not checked ddk documentation carefully,
also i have no experience any drivers so i try to understand
the concept generally,
Can you give me a advice where to start from?start from ddk doc. from begining
thanks for advice...
oguz
|
|
|
|

|
Hi,
I have serious problem. I'm currently developing application which will protect registry, files, etc. I'm hooking native NT functions in my driver (via KeServiceDescriptorTable).
My user application (server app.) reads some informations (PID, exePath,...) about calling process from driver via DeviceIoControl function (after event from driver [KeSetEvent]).
Now where's the problem. When I start 5 test applications (one application has 5 threads) and each thread is reading registry via our hooked function, when we want to close our "server" and driver, blue-screen appeared with
UNLOADED_WITHOUT_CANCELLING_PENDING_OPERATIONS.
I have IoCsqxxx routines implemented in my driver (from DDK example).
Does anybody know something about this problem? Any articles or suggestions?
Thanks.
|
|
|
|

|
Hi,
Maybe you have already solved the problem, but others may have the same problem.
When you want to unload the driver, you have to make sure of 2 things:
1) No new requests are accepted
2) Already accepted, pending operations are canceled.
From the bugcheck code you get, I think your logic regarding 1) is faulty. What happends I guess is that you cancel IRPs pending in the queue, but by the time your driver unloads, other parts of your code (the read or IO dispatch fn) insert new IRPs into the queue. These IRPs will never get calcelled!
So, you have to make sure that before you start cancelling the IRPs in the queue, you flip a bozo bit that will prevent the inserting of other IRPs into the queue.
I hope it helps.
Tamas Karoly
|
|
|
|

|
How is the IRQ number specified. I want to hook to IRQ 9, but do not know how to do that. Thanks.
Nash22
|
|
|
|

|
Hi, Well, it depends on the type of device you write your driver for. If it's a PCI device, then you'll have to query for the _translated_ resources allocated to your hardware. It's because your device tells the PNP manager that it needs an IRQ, but the actual IRQ number is assigned when the OS boots up. You can retrieve the IRQ number in a dispatch routine, which captures IRP_MN_START_DEVICE (you can capture it by setting the DriverObject->MajorFunction[IRP_MJ_PNP] to your function in the DriverEntry fn.) like this: PIO_STACK_LOCATION stack; PCM_PARTIAL_RESOURCE_LIST PRLTrans; PCM_PARTIAL_RESOURCE_DESCRIPTOR TransRes; stack = IoGetCurrentIrpStackLocation(Irp); if (stack->Parameters.StartDevice.AllocatedResourcesTranslated) { PRLTrans = &stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList; TransRes = &partialResourceListTrans->PartialDescriptors[0]; for (i = 0; i < PRLTrans->Count; i++, TransRes++) { switch (TransRes->Type) { case CmResourceTypePort: int PortNum = TransRes->u.Port.Start.LowPart; break; case CmResourceTypeMemory: void* MemStart; MapMemoryResource(&MemStart, TransRes->u.Memory.Start, TransRes->u.Memory.Length, FALSE); break; case CmResourceTypeInterrupt: ULONG IrqVector = TransRes->u.Interrupt.Vector; KIRQL IrqLevel = (KIRQL)TransRes->u.Interrupt.Level; ULONG IrqAffinity = TransRes->u.Interrupt.Affinity; bool IrqLatched = (TransRes->Flags == CM_RESOURCE_INTERRUPT_LATCHED); bool IrqShared = (TransRes->ShareDisposition == CmResourceShareShared); break; } } } You can connect the IRQ with a handler fn. by calling IoConnectInterrupt. In case of the parallel port, you can retrieve information about the port by using IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO, IOCTL_INTERNAL_GET_MORE_PARALLEL_PORT_INFO and IOCTL_INTERNAL_GET_PARALLEL_PNP_INFO. I hope it helps. If you have any more questions, fell free to write. Tamas
|
|
|
|

|
Tamas,
Thanks for your reply. I am using an ISA card that generates an interrupt (IRQ 9) every 1 millisecond. When this interrupt occurs, I am required to read IO Ports 0x310 to 0x330. OS is Win2K.
Nash
|
|
|
|

|
Nash, I don't have too much experience with ISA cards, so I'm guessing here. I would call the IoReportResourceForDetection fn. to claim resources for your device from the PnP manager. You pass in a CM_RESOURCE_LIST, which describes the resources you would like to allocate. The function returns whether the resources could be allocated. If so, you should call IoReportDetectedDevice to report to the device to PnP manager. You should read the DDK Help, because it seems a complex process. You could also simply call HalGetInterruptVector, but I don't know how it behaves. ULONG MappedVector; KIRQL Irql; KAFFINITY Affinity; MappedVector = HalGetInterruptVector(Isa, 0, DISPATCH_LEVEL + 1, 0x09, &Irql, &Affinity); The DISPATCH_LEVEL + 1 magic ensures that this IRQ is interrupted only by other hardware IRQ's (ans some others) Tamas
|
|
|
|

|
Hello,
I can't build the driver, there is comming an error message:
driver.h file "Csq" syntaxis error.
Can you help me, do I need something special to build your driver.
Best,
Georgi
|
|
|
|

|
Hi Georgi,
Yes, not all versions of the DDK support the cancel-safe queue API. I use DDK 2600.1106 If you compile the driver to win98 or win2000, include the csq.h and add the csq.lib to the make file.
I would suggest that you update your DDK to the latest (free) version.
Regards,
Tamas Karoly
|
|
|
|

|
Why not use ReadFileEx() for async I/O instead of ReadFile()/WaitForSingleObject()
|
|
|
|

|
MSDN says:
>The ReadFileEx function reports its completion status asynchronously, calling a specified >completion routine when reading is completed or canceled and the calling thread is in an alertable >wait state.
and a bit bellow:
>An application uses the MsgWaitForMultipleObjectsEx, WaitForSingleObjectEx, >WaitForMultipleObjectsEx, and SleepEx functions to enter an alertable wait state.
So, you must be in an alertable wait state, otherwise the system won't call the completion routine (the system uses an APC to call it). This function is really the same as the ReadFile + WFSO, the only extra is the completion routine, which I don't use. But yes, I could have used it.
By the way, I use the IOCP functions, which I can only recommend. They allow you to write scalable code.
Thanks for the comment.
Tamas
|
|
|
|

|
Yes, I am aware of alertable wait state condition.
My point is, that using ReadFileEx() will allow the usermode app to run without any threads. In a real application, retrieved data will have to be stored somewhere, which (in multithreaded apps) will rise sync issues.
I believe it worths the effort to write a simple replacement of GetMessage() in order to avoid threads, semaphores, deadlocks and all other fun stuff.
|
|
|
|

|
waleri wrote:
My point is, that using ReadFileEx() will allow the usermode app to run without any threads.
App without any threads?
If you look at the code, I use the ReaderInfo stucture to store the data. Because each completed read operation is handled by exactly one thread (this is the real purpose of GetQueuedCompletionStatus), I don't have to do any synchronization, and there can be no deadlocks.
Of course, at higher levels of the code, when I further process the data, there might be a need to sync access to buffers, but that's a different issue.
Regards,
Tamas
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Describes how to exchange data between a device driver and a user mode application.
| Type | Article |
| Licence | |
| First Posted | 5 Nov 2004 |
| Views | 103,311 |
| Bookmarked | 57 times |
|
|