我用C写的下面的程序:获取令牌信息
#include "stdafx.h"
#include <Windows.h>
void main()
{
char buffer[1000];
int size = sizeof(buffer);
PDWORD required_size;
printf("----Application Privileges----\n\n");
printf("In this program, we are going to obtain information about the application privileges\n\n");
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);
printf("Press enter to exit the program");
getchar();
}
现在,我是比较新的使用令牌。当我尝试执行该程序时,出现以下错误:
运行时检查失败#3 - 正在使用变量'required_size'而未初始化。
请问我该如何解决这个问题?我想要做的是向用户显示有关当前进程的令牌权限的信息。
我不确切知道GetTokenInformation方法中的最后一个变量(ReturnLength [out])是什么。我尝试阅读msdn文档,但不明白它的用法。
对不起,我编辑的前一个问题,忘了更改标签:■ – Matthew
尝试初始化它! – CCoder