Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:16:01+00:00 2026-06-14T17:16:01+00:00

A Win32 API was invoked in my DLL, which will be loaded by SYSTEM

  • 0

A Win32 API was invoked in my DLL, which will be loaded by SYSTEM user, and that API returns different results depending on current user, so I cannot get the results corresponding to the current user, how can I invoke that API under current logon user context when the DLL is running in SYSTEM context?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:16:03+00:00Added an answer on June 14, 2026 at 5:16 pm

    I’ve made some research and concluded this (I’m not a Win32 API expert, but I’m really interested in it):

    You can use ImpersonateLoggedOnUser, which asks for a primary or an impersonation token handle (with at least TOKEN_QUERY in both, TOKEN_DUPLICATE on a primary token, or TOKEN_IMPERSONATE on an impersonation token).

    It would be very easy, if you had the current logged on user token, and the right privileges, you’d just use ImpersonateLoggedOnUser, call the API function that you want, and then call RevertToSelf to return to its original owner token.

    But it’s not that easy to get the current logged on user token. You’d have to either use LogonUser specifying the user’s name and password (which doesn’t seem right), or own a Windows service with sufficient privileges to let you call WTSQueryUserToken, which may differ from what type of project you are developing.

    Or, if you are really willing to do this with an ordinary process, you could also explore the Authentication Functions, where you can take advantage of the newly Windows UAC and security contexts, which may be a little complex to work with.

    There is also this method which I’m not sure if it works: Impersonate standard user (getting the token by using OpenProcessToken on explorer.exe).

    Some links I found useful:

    • MSDN – Client Impersonation (Windows)
    • MSDN – Access Tokens (Windows)
    • MSDN – LsaLogonUser function (Windows)
    • A Simple Impersonation Program Example
    • CodeProject – User Impersonation
    • CodeProject – Vista UAC: The Definitive Guide

    I suggest: make sure you really need to impersonate an user when calling the API function you mentioned, before going on. See if there is another path to accomplish what you want.

    You could also specify which API function you are trying to use, which may redirect you to another simpler question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the win32 API CommandLineToArgvW which returns a LPWSTR* and warns me that
What is the Win32 api function that prevents the system from going into standby?
Is there any Win32 API for waking up a system that has been shut
Is there any scalable Win32 API (like IOCP not like select) that gives you
We know that .NET framework class encapsulate the Win32 API, now I am wondering
In Win32 API, there is CopyFile that literally copies a file. However, this API
I now understand that WinRT is an API on top of several implementations (Win32
Which win32 api calls do these functions use (if any)? _itoa_s(), strcat_s()
I am looking for a win32 api function that clears the console, much like
When we want to use Win32 API, we'd specify the import libraries that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.