The WDK documentation describes FltSetStreamContext as follows:
“After calling FltSetStreamContext, the caller must call FltReleaseContext to decrement the reference count on NewContext, even if the call to FltSetStreamContext was unsuccessful. If the call was successful, or if FltSetStreamContext returned an error code (such as STATUS_FLT_CONTEXT_ALREADY_DEFINED), the caller must also call FltReleaseContext for OldContext if OldContext is not NULL and does not point to NULL_CONTEXT.”
What makes me confused is the last statement: “if OldContext is not NULL and does not point to NULL_CONTEXT.”
Given NULL_CONTEXT was defined as NULL, and OldContext was defined as PVOID, I have written code like this:
PFLT_CONTEXT old_ctx = 0;
FltSetStreamContext(…, &old_ctx);
if (old_ctx && *old_ctx != NULL_CONTEXT) // Oops! this line is illegal to compile!
{}
My question is:
How should I check the returned value of OldContext?
Any help will be highly appreciated! Thanks in advance.