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 8801433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:49:57+00:00 2026-06-14T00:49:57+00:00

I have the following code snippet written in C which is supposed to retrieve

  • 0

I have the following code snippet written in C which is supposed to retrieve token information about the program privileges:

char buffer[1000]; //Declaring the buffer where the token information will be stored
int size = sizeof(buffer); //Storing the size of the buffer
DWORD required_size; //A variable storing return information from the GetTokenInformation() method

HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, GetCurrentProcessId()); //Opening the current process
HANDLE token; //Creating a handle for the token
OpenProcessToken(process, TOKEN_ADJUST_PRIVILEGES, &token); //Opening the process token

GetTokenInformation(token, TokenPrivileges, buffer, size, &required_size); //Obtaining the token information
printf("The following information was obtained with regards to the token privileges: \n\n");
printf("%s\n\n", buffer);

The main problem is that when I try to print the contents of ‘buffer’, only rubbish information is printed on the screen :s How can I solve this please?

  • 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-14T00:50:00+00:00Added an answer on June 14, 2026 at 12:50 am

    It’s printing rubbish because the data you haven’t isn’t a C string, it’s just raw binary data. In the case of TokenPrivileges, the data is really a TOKEN_PRIVILEGES structure.

    So, you should cast the byte buffer into a pointer to a TOKEN_PRIVILEGES structure. Note that it ends with a flexible array member — the Privileges array will contain a variable number of array elements, which is why you have to query the total size and use a large enough byte buffer instead of just allocating a TOKEN_PRIVILEGES on the stack, which wouldn’t be large enough to hold more than one entry.

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

Sidebar

Related Questions

i have the following code snippet in my ANT File which compiles my project
i have the following code snippet. in which i just want to return PartyName
I have the following snippet of code written in C#: openFileDialog1.InitialDirectory = \\\\fwm-storage\\users\\ +
I have written the following code which will does not work but the second
I have a program written in C. The following is a snippet of the
I have written the following code snippet to read data from the database :
I have written a code snippet which i definitely feel its not written a
I have the following code snippet in which I'm trying to print some statements
I have in my project(written by others) handlebars template the following code snippet {{view
I have following code snippet that i use to compile class at the run

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.