私は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 のドキュメントを読んでみましたが、その使い方がわかりませんでした。