 |
|
|
 |
|
 |
Hello
Is it possible to have some snippets of your firewall code? I think a real example would be much complete than only a notification example...
For example, how can you pause the analysis of a paquet while the user hasn't approved or rejected the paquet (with userland app)?
Thanks
|
|
|
|
 |
|
 |
Hi
First of all, sorry for my english.
I don't know how I can to communicate with my apllication when an event happen in the driver. For example, I want to display something in a C# application when the driver detect an interrupt.
Thank you so much
And sorry again
|
|
|
|
 |
|
 |
hi,
if i know how to install this driver, it will be very helpful for me
thanks
|
|
|
|
 |
|
 |
Let us assume the driver file name is SampleDriver.sys and we are running 32 bit windows. Copy the sys file to [System32\drivers] folder. Create a file named setup.reg with content, run it and restart the system.
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SampleDriver]
"ErrorControl"=dword:00000001
#
# When to start the driver:
# At boot: Start=1
# Manually: Start=3
#
"Start"=dword:00000001
"Type"=dword:00000001
|
|
|
|
 |
|
 |
Hi lizhiwei,
The article you provide is really good. But i could not find any help reagarding HOW TO BUILD IT? Similar queries were there but no answer . I could build it only through DDK build enviornment. It would be great help if you can explain little how to build it thru VC++ IDE.
Regards..
Dhirendra.
Dhirendra Pratap Singh
|
|
|
|
 |
|
 |
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 in advance.
Marun
|
|
|
|
 |
|
 |
Hello,
I have a problem with using DeviceIoControl. It always fails and the error I get is "ERROR_INVALID_FUNCTION".
I am using DeviceIoControl to establish a connection to my keyboard filter driver (modifed from "kbfiltr" in the DDK). I have fully checked to make sure the parameters that I pass to DeviceIoControl are infact correct?
Does anyone have any idea what I am doing wrong?
Thanks,
Bob
|
|
|
|
 |
|
 |
Hello there. I am having the exact same problem. I get an error each time I call deviceiocontrol. Does anyone have any ideea why. have succeded in doing anything ?
gabby
|
|
|
|
 |
|
 |
How do I have to procced to install the driver ? Do I Need to create a .inf file ?
Claire
|
|
|
|
 |
|
 |
Hi,
You did a good job on this article.
I think we could even use WMI for event notification. WMI is an important feature as far as WDM drivers are concerned.
What do u think about this?
Cheers!
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
(My COM Blog - http://lovecom.blogspot.com)
|
|
|
|
 |
|
 |
I am trying to create a user mode application to talk to the devices from other vender.
What is the easiest way to find out the GUID interface for a PnP device? I tried the regedt32 but couldn't find it.
Also, I connect several of this outside vender's devices to several virtual COM port (COM3, COM5, COM7, etc). How do I talk to those devices separately (mainly stop the device so I can safely unplug it)?
Thank you for your advice.
|
|
|
|
 |
|
 |
When I run the .exe and try to open the device event it asks me to install the device driver.
Is there a .inf for it or do I just need to copy the device driver to the appropriate Windows directory?
Cheers.
|
|
|
|
 |
|
 |
I am using two USB video cameras of the same manufacturer and having same driver. But i want to detect them seperately that camera1 is found at that Port1 and Camera2 is found at Port2. I want to ask from you that is there any way at Driver Information level that we can detect these cameras seperately or is their any structure provided by Microsoft which gives us information about the device attached to a USB ports..? problem we are facing that the window didnt generate two diferent driver Index for two cameras. Please suggest me what should I do.
Muhammad Talha
|
|
|
|
 |
|
 |
How to communicate revers, from Driver (for exmpl interrupt in ISR and u wanna send some message to Application) to App
|
|
|
|
 |
|
|
 |
|
 |
I'm writing personal firewall and I need to receive some data from driver .
I know how to send data to driver, but I dont now how to read data from driver.
Can you show me how to do this.
For example how to send string-"hello" from driver to GUI application.
If You know how to do this please email me firstx@o2.pl (source code or some projects will be very usefull)
Thanks.
(sorry for my english )
|
|
|
|
 |
|
 |
Hi!
I'm working on a virtual soundcard, based on the "MSVAD" example contained in the Windows DDK. Microphone and speaker will be emulated by software. Realtime problems should be handled with an appropiate buffer. In general this is a minor problem for my project.
The question is, how to exchange stream data every 10 milliseconds between driver and user-mode application. I tried to use IRP-messages for I/O like it is done in multiple simple examples. Unfortunately it was either possible to initialize the sound or (XOR!) the access from an application. Having sound and access at the same time was not possible.
The application tries to connect to the driver with "CreateFile", but the resulting handle is invalid. I haven't found a way to tell the driver, how to open the device properly.
The second approach was a second device (with GUID) created in the driver. This device has the same structure as the I/O-Example. After some codechanges the driver started, but the "CreateFile" always called the sounddevice, resulting in a broken handle.
|
|
|
|
 |
|
 |
Is there any way to dynamically load a kernel-mode DLL? Some kernel-mode routines similiar to LoadLibrary?
Or should i just use kernel32.dll's LoadLibrary in kernel-mode?
Or should kernel-mode DLLs be linked only statically ?
Thank you,
phoCus.
|
|
|
|
 |
|
 |
You can use LdrLoadDll from ntdll.dll ( i think )
the functions prototype is:
NTSYSAPI
NTSTATUS
NTAPI
LdrLoadDll(
IN PWCHAR PathToFile OPTIONAL,
IN ULONG Flags OPTIONAL,
IN PUNICODE_STRING ModuleFileName,
OUT PHANDLE ModuleHandle );
By the way ... You can't user kernel32.dll or any other usermode dll's in ring0.
If you have any more questions about this topic, just drop me a mail.
If there is any interest for it, i can write a paper on function-hooking and hooking of the kernels service table in kernel-mode.
As i said, just drop me a mail.
Ketil Jensen
minpost2@start.no
|
|
|
|
 |
|
 |
when i develop a personal firewall ,i create the named event in the driver.
and when i want to set the event to non-signal ,i use API DeviceIoControl to
call the driver to do the thing that Reset the event. i think this method is more secure.
I am a willing boy..
|
|
|
|
 |
|
 |
Hi,
I'm doing the same thing in my driver, except that I call KeSetEvent() from an ISR routine. Here is the client side:
while(!bExit)
{
IRQCnt++;
tmp = WaitForMultipleObjects(2, hEvents, FALSE, INFINITE);
switch(tmp)
{
case WAIT_OBJECT_0:
bExit = TRUE;
break;
case WAIT_OBJECT_0 + 1:
ReadPortByte(BaseAddress, &Data);
ResetEvent(hEvents[1]);
IRQCnt++;
break;
}
}
And here is the ISR:
if (KeReadStateEvent(deviceExtension->UserNotificationEvent))
{
KdPrint(("Byte lost.\n"));
InterlockedIncrement(&deviceExtension->LostBytes);
}
else
{
KeSetEvent(deviceExtension->UserNotificationEvent, 0, FALSE);
}
My problem is that even at very slow IRQ freq. (2Hz!) I get this "Byte lost" message, which means that the client had no time to call ResetEvent() and another IRQ has already came in. The strange thing is that if I fire IRQs at highter freqs. tghe number of lost bytes doesn't increase proportionally (it doesn't increase at all).
Any ideas? I heard that this is the standard way of notifying user-mode apps, but I just can't believe that it's this slow.
Thanks.
Tamas
|
|
|
|
 |
|
 |
I think your problem is that interrupt is not caused by eadge ,and you do not release the reason for the ISR. What I mean is that when you get a new byte a flag is set and each time while the flag is set you get new ISR about the same byte. the solution is to relase the flag in the client.
DavidR
|
|
|
|
 |
|
 |
Thank you David!
Long time passed since I asked this question. Since then I figured out many things about kernel-mode drivers. I wrote 2 drivers (PCI, parallel port) and completely left out this kind of user notification technique. I think it's a bad solution most of the time, because it always takes considerable amount of time to switch between user mode and kernel mode. The proper way of doing it is to handle the IRQ within the driver and have the user call ReadFile() to get data from the driver. Both of my drivers were used in time critical scenarios and it could handle 20kHz IRQ rate fine, without burning much CPU resources.
Anyway, thanks for the help!
Tamas
|
|
|
|
 |
|
 |
I'm sending this to Richard Marcel, for some reason his eamil address was rejected by my smtp server:
Once you can handle the IRQ, the rest is a piece of cake.
Ok, so, here is how I do it:
In user mode:
1. Open the driver with CreateFile() - (Remember that you have to call IoCreateSymbolicLink() in your driver somewhere (most probably in the DriverEntry routine) to be able to access the driver this way. Also, you must pass in the OPEN_EXISTING and the FILE_FLAG_OVERLAPPED flags)
2. Call ReadFile() asynchronously and pass it a buffer. (ie. use an OVERLAPPED structure)
3. Call WaitForSingleObject() or use GetQueuedCompletionStatus()
4. You have the data in the buffer!
In kernel mode:
1. Have a dispatch Read function in your driver (DriverObject->MajorFunction[IRP_MJ_READ] = )
2. Create a queue by the InitializeListHead() function in your DriverEntry routine.
3. Init the CS queue (Cancel-safe queue) with IoCsqInitialize() in your DriverEntry routine. (the DDK help has a complete sample)
4. In your dispatch Read function, queue the IRP into a CSQ.
a. Call IoCsqInsertIrp() to queue the IRP.
b. return STATUS_PENDING from your dispatch routine.
At this stage the ReadFile() function returns with STATUS_PENDING in the user mode code and step 3. starts.
5. When an IRQ arrives, queue your DPC routine with KeInsertQueueDpc()
6. In your DPC routine:
a. Call IoCsqRemoveNextIrp() to get the IRP you queued in the Read dispatch routine.
b. Get access to the user buffer by something like this:
PUCHAR p = (PUCHAR)MmGetSystemAddressForMdl(Irp->MdlAddress);
c. Fill the buffer with any data you like.
7. Call KeFlushIoBuffers(Irp->MdlAddress, TRUE, FALSE);
8. Call IoCompleteRequest(Irp, ...) to complete the IRP.
When 8. completes, step 3 in the user code returns and you have the data in your buffer!
Of course, you may skip 7 and 8 and fill the buffer step by step in more than one IRQ and call them when the buffer is full.
So, it's as simple as that! I hope it helps. Drop me a mail if you have any more questions.
Regards,
Tamas Karoly
|
|
|
|
 |