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 working on a callout driver, and one of its features is to intercept network connection events. I have a callout at the
FWPS_LAYER_ALE_FLOW_ESTABLISHED_V4 layer. This layer has a fixed data field
FWPS_FIELD_ALE_FLOW_ESTABLISHED_V4_ALE_USER_ID, which contains a
TOKEN_ACCESS_INFORMATION pointer that provides the SID of the user account that owns the connection. My goal is to copy this SID to a buffer and pass it to user-mode for further processing. My question is: what is the correct way to copy this SID to the buffer?
I was going to use standard Sid functions, but the documentation is quite clear:
IRQL <= DISPATCH_LEVEL.
RtlLengthSid(), which are needed to allocate the buffer and copy the sid, must be called at
IRQL <= APC_LEVEL.
This means that we can only use the Sid functions to copy the user's SID when the callout's classify function is called at
IRQL < DISPATCH_LEVEL, but this never actually happens. So we can't use Sid functions at all, if I'm not missing something.
My other approach was to convert the SID to a Unicode String (
RtlConvertSidToUnicodeString()) and pass that string to user mode. And this approach works. But as I know it's not recommended to use unicode at the
DISPATCH_LEVEL, because unicode charactes code pages memory may be paged and in this case the driver will crash.
So what is the correct way to copy user's SID in this case?
Thank you in advance,
|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!
|13-17 May 2024
|1-5 Apr 2024
|Internals & Software Drivers
|11-15 Mar 2024
|Writing WDF Drivers
|20-24 May 2024