I’m attempting to impersonate the system account in my application by calling the following functions: OpenProcess() to winlogon.exe, OpenProcessToken(), DuplicateTokenEx(), and ImpersonateLoggedOnUser(). However, when I execute this code, I encounter error 1314.
Interestingly, when I run my application with psexec -s, which executes the program as the system account without the need for impersonation, everything works smoothly.
Why am I encountering error 1314 when attempting to impersonate the system account, and how can I successfully impersonate the system account in my application?