Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results
The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.
Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/
I'm writing a kernel-mode dll hash table. And I want to use data_segment to share data between two filter drivers.
There is a file system filter and a volume filter. When the file system driver get an important irp, it will put the
irp pointer into the shared hash table. The volume filter will check if the irp it filtered is in the hash table, if
it is, volume filter will delete it from table.
To keep it safe, I used a spin_lock like below:
#pragma data_seg("SharedHashSet") HashSet set; KSPIN_LOCK PLock; #pragma data_seg
And the operation method for hash table is like this:
//Node typedef struct _ENTRY { PIRP key; struct _ENTRY* next; }Entry , *PEntry; //Node array typedef struct _HASHSET { PEntry bucket[BUCKETCAPICITY]; }HashSet, *PHashSet; void insertValue(PIRP key) { KIRQL irql; KeAcquireSpinLock(&PLock, &irql); PEntry mEntry; INT i = getLocation(key); PEntry entry = set.bucket[i]; //head insert if (entry == NULL) { mEntry = newEntry(key, NULL); } else { mEntry = newEntry(key, entry); } set.bucket[i] = mEntry; KeReleaseSpinLock(&PLock, irql);
}
Now two filter drivers share a table and a lock. But, I find that volume filter may not find the irp
which file system filter already put into the table sometimes.
Could somebody tell me what is the problem?
Upcoming OSR Seminars | ||
---|---|---|
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead! | ||
Writing WDF Drivers | 12 September 2022 | Live, Online |
Internals & Software Drivers | 23 October 2022 | Live, Online |
Kernel Debugging | 14 November 2022 | Live, Online |
Developing Minifilters | 5 December 2022 | Live, Online |
Comments
Hmmmm... You have a bug in your code??
Just guessin'
Peter
Peter Viscarola
OSR
@OSRDrivers
I've solved this problem. It's not the problem of my code, but I didn't realize that
some Irp will complete in file system because they are written in page buffer and a new
Irp will be created later. That's the reason why I can not catch the Irp that I have put
int the table.