我用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