【发布时间】:2012-11-08 15:26:24
【问题描述】:
我有以下用 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 文档,但不了解它的用途。
【问题讨论】:
-
对不起,我编辑了上一个问题,忘记更改标签:s
标签: c windows security winapi token