Trying to set OWNER_SECURITY_INFORMATION using FltSetSecurityObject(), returns STATUS_INVALID_OWNER

From some posts, I learnt that we need to restore the priviliges of the thread before setting an owner.
I followed http://www.osronline.com/article.cfm^article=23.htm to restore the privileges. But I am seeing STATUS_ACCESS_VIOLATION for routine NtAdjustPrivilegesToken().

So my question is

  1. Is restoring the privileges is the solution to owner to security object?
    2 ) If yes, how do I achieve that? Because I am seeing STATUS_ACCESS_VIOLATION for the routine NtAdjustPrivilegesToken()

Just posting in case someone comes across this very issue.

This needs to be done in the context of system worker thread. FltAllocateGenericWorkItem, FltQueueGenericWorkItem etc. family of functions are your friends.