Click here to Skip to main content
15,918,050 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: pfmon.exe tool Pin
George_George19-Jan-08 1:14
George_George19-Jan-08 1:14 
GeneralRe: pfmon.exe tool Pin
Hamid_RT19-Jan-08 7:37
Hamid_RT19-Jan-08 7:37 
GeneralRe: pfmon.exe tool Pin
George_George19-Jan-08 22:18
George_George19-Jan-08 22:18 
GeneralRe: pfmon.exe tool Pin
Hamid_RT20-Jan-08 3:59
Hamid_RT20-Jan-08 3:59 
GeneralRe: pfmon.exe tool Pin
George_George20-Jan-08 4:07
George_George20-Jan-08 4:07 
GeneralRe: pfmon.exe tool Pin
Hamid_RT20-Jan-08 7:24
Hamid_RT20-Jan-08 7:24 
GeneralRe: pfmon.exe tool Pin
George_George20-Jan-08 16:22
George_George20-Jan-08 16:22 
GeneralCreateProcessAsUser Pin
dilip.kamalia17-Jan-08 3:33
dilip.kamalia17-Jan-08 3:33 
hi all,

I want to run .exe from service program in vista, which have run in user session insted of service session as session0.

I tried following code, but it fails at 'WTSQueryUserToken' function giving error : error number1314: A required privilege is not held by the client.

In MSDN I see that what I'm getting is the errorERROR_PRIVILEGE_NOT_HELD which means:The caller does not have theSE_TCB_NAME privilege. How can I set this previledge?



Here is my source:



HANDLE hTokenNew = NULL, hTokenDup = NULL;
HMODULE hmod = LoadLibrary("kernel32.dll");

PVOID proc = GetProcAddress(hmod, "WTSGetActiveConsoleSessionId");
DWORD dwSessionId = WTSGetActiveConsoleSessionId();



f(!WTSQueryUserToken(dwSessionId, &hTokenNew)){
ErrorExit("WTSQueryUserToken");
}

DuplicateTokenEx(hTokenNew,MAXIMUM_ALLOWED,NULL,SecurityIdentification,TokenPrimary,&hTokenDup);
WriteToFile("Calling lpfnCreateEnvironmentBlock");


ZeroMemory( &si, sizeof( STARTUPINFO ) );
si.cb = sizeof( STARTUPINFO );
si.lpDesktop = "winsta0\\default";



LPVOID pEnv = NULL;
DWORD dwCreationFlag = NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE;
HMODULE hModule = LoadLibrary("Userenv.dll");
if(hModule )
{

PVOID _imp_CreateEnvironmentBlock = GetProcAddress( hModule, "CreateEnvironmentBlock" );
if( _imp_CreateEnvironmentBlock != NULL )
{

if(CreateEnvironmentBlock(&pEnv, hTokenDup, FALSE))
{
WriteToFile("CreateEnvironmentBlock Ok");
dwCreationFlag |= CREATE_UNICODE_ENVIRONMENT;
}
else
{
pEnv = NULL;
}
}
}

ZeroMemory( &pi,sizeof(pi));

if ( !CreateProcessAsUser(
hTokenDup,
NULL,
"E:\\example.exe",
NULL,
NULL,
FALSE,
dwCreationFlag,
pEnv,
NULL,
&si,
&pi
) )
{
ErrorExit("CreareProcessAsUser");
return FALSE;
//goto RESTORE;
}



Please reply,

thanks in advance
QuestionRe: CreateProcessAsUser Pin
Mark Salsbery17-Jan-08 7:34
Mark Salsbery17-Jan-08 7:34 
GeneralRe: CreateProcessAsUser Pin
dilip.kamalia17-Jan-08 18:56
dilip.kamalia17-Jan-08 18:56 
GeneralRe: CreateProcessAsUser Pin
Mark Salsbery18-Jan-08 8:01
Mark Salsbery18-Jan-08 8:01 
Generalchanging background color DFC_CAPTION, DFCS_CAPTIONCLOSE Pin
hari prasad sathpadi17-Jan-08 3:24
hari prasad sathpadi17-Jan-08 3:24 
GeneralRe: changing background color DFC_CAPTION, DFCS_CAPTIONCLOSE Pin
James R. Twine17-Jan-08 4:18
James R. Twine17-Jan-08 4:18 
Generalmy code to prove working set larger than virtual bytes Pin
George_George17-Jan-08 3:22
George_George17-Jan-08 3:22 
GeneralDisplaying line numbers Pin
Sanjay K17-Jan-08 1:08
Sanjay K17-Jan-08 1:08 
GeneralRe: Displaying line numbers Pin
Iain Clarke, Warrior Programmer17-Jan-08 2:04
Iain Clarke, Warrior Programmer17-Jan-08 2:04 
QuestionRe: Displaying line numbers Pin
David Crow17-Jan-08 2:29
David Crow17-Jan-08 2:29 
GeneralRe: Displaying line numbers Pin
Hamid_RT17-Jan-08 18:08
Hamid_RT17-Jan-08 18:08 
QuestionHow to use libwww Pin
ktm TechMan17-Jan-08 0:35
ktm TechMan17-Jan-08 0:35 
GeneralError handling - a best way Pin
CodingLover16-Jan-08 22:23
CodingLover16-Jan-08 22:23 
GeneralRe: Error handling - a best way Pin
CPallini16-Jan-08 23:21
mveCPallini16-Jan-08 23:21 
GeneralRe: Error handling - a best way Pin
CodingLover16-Jan-08 23:38
CodingLover16-Jan-08 23:38 
GeneralRe: Error handling - a best way Pin
CPallini17-Jan-08 0:22
mveCPallini17-Jan-08 0:22 
GeneralRe: Error handling - a best way Pin
CodingLover17-Jan-08 0:42
CodingLover17-Jan-08 0:42 
QuestionRe: Error handling - a best way Pin
David Crow17-Jan-08 2:31
David Crow17-Jan-08 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.