我有以下用 C 编写的代码片段,它应该检索有关程序权限的令牌信息:
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);
主要问题是当我尝试打印“缓冲区”的内容时,屏幕上只打印垃圾信息:s 请问我该如何解决这个问题?