demuelli
October 20th, 2004, 09:45 AM
I try to open a threadtoken in a thread and set its privileges:
With starting the thread like that:
SECURITY_ATTRIBUTES sa;
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = NULL;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
hWorkerThread = CreateThread(
&sa,
0,
CreateWorkerThread,
&UInf,
0,
&dwLoginThreadId);
And trying to open the token like that:
if(!OpenThreadToken(
GetCurrentThread(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
TRUE,
&hToken
))
{
printf("Unable to open thread token.\n");
dwLastError = GetLastError();
printf("OpenThreadToken: dwLastError: %0.8x[%d]\n",dwLastError,dwLastError);
return 0;
}
I'm getting the follwing error: 1008 -> An attempt was made to reference a token that does not exist. ERROR_NO_TOKEN.
Any suggestions why this happened and how it can be fixed ?
With starting the thread like that:
SECURITY_ATTRIBUTES sa;
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = NULL;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
hWorkerThread = CreateThread(
&sa,
0,
CreateWorkerThread,
&UInf,
0,
&dwLoginThreadId);
And trying to open the token like that:
if(!OpenThreadToken(
GetCurrentThread(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
TRUE,
&hToken
))
{
printf("Unable to open thread token.\n");
dwLastError = GetLastError();
printf("OpenThreadToken: dwLastError: %0.8x[%d]\n",dwLastError,dwLastError);
return 0;
}
I'm getting the follwing error: 1008 -> An attempt was made to reference a token that does not exist. ERROR_NO_TOKEN.
Any suggestions why this happened and how it can be fixed ?