Thank you
Sean
One more help please. Have I wrapped it right?
Code:
GetCommandLine( PID ) { ; by Sean www.autohotkey.com/forum/viewtopic.php?t=16575
Static pFunc
If ! ( hProcess := DllCall( "OpenProcess", UInt,0x043A, Int,0, UInt, PID ) )
Return
If pFunc=
pFunc := DllCall( "GetProcAddress", UInt
, DllCall( "GetModuleHandle", Str,"kernel32.dll" ), Str,"GetCommandLineA" )
hThrd := DllCall( "CreateRemoteThread", UInt,hProcess, UInt,0, UInt,0, UInt,pFunc, UInt,0
, UInt,0, UInt,0 ), DllCall( "WaitForSingleObject", UInt,hThrd, UInt,0xFFFFFFFF )
DllCall( "GetExitCodeThread", UInt,hThrd, UIntP,pcl ), VarSetCapacity( sCmdLine,512 )
DllCall( "ReadProcessMemory", UInt,hProcess, UInt,pcl, Str,sCmdLine, UInt,512, UInt,0 )
DllCall( "CloseHandle", UInt,hThrd ), DllCall( "CloseHandle", UInt,hProcess )
Return sCmdLine
}
SetDebugPrivilege() {
;PROCESS_QUERY_INFORMATION=0x400, TOKEN_ADJUST_PRIVILEGES=0x20, SE_PRIVILEGE_ENABLED:=0x2
hProcess := DllCall( "OpenProcess", UInt,0x400,Int,0,UInt,DllCall("GetCurrentProcessId"))
DllCall( "Advapi32.dll\LookupPrivilegeValueA", UInt,0, Str,"SeDebugPrivilege", UIntP,lu )
; TOKEN_PRIVILEGES Structure : www.msdn.microsoft.com/en-us/library/aa379630(VS.85).aspx
VarSetCapacity( TP,16,0), NumPut( 1,TP,0,4 ), NumPut( lu,TP,4,8 ), NumPut( 0x2,TP,12,4 )
DllCall( "Advapi32.dll\OpenProcessToken", UInt,hProcess, UInt,0x20, UIntP,hToken )
Result := DllCall( "Advapi32.dll\AdjustTokenPrivileges"
, UInt,hToken, UInt,0, UInt,&TP, UInt,0, UInt,0, UInt,0 )
DllCall( "CloseHandle", UInt,hProcess ), DllCall( "CloseHandle", UInt,hToken )
Return Result
}
SetDebugPrivilege()
MsgBox, % GetCommandLine( DllCall( "GetCurrentProcessId" ) )
Process, Exist, svchost.exe
MsgBox,0, %errorLevel%, % GetCommandLine( errorLevel )
Edit 2009-06-22: Added
DelimitParameters() The following function can convert the obtained command line into pipe delimited string to ease
Loop, Parse or
StringSplitCode:
DelimitParameters( CommandLine,D="|" ) { ; Supplementary function for GetCommandLine()
tempVar := CommandLine ; www.autohotkey.com/forum/viewtopic.php?p=232199#232199
Loop {
StringReplace,tempVar,tempVar,%Param%
CommandLine := DllCall( "shlwapi\PathGetArgsA", Str,CommandLine,Str )
StringReplace,Param,tempVar,%CommandLine%
DllCall( "shlwapi\PathUnquoteSpacesA", Str,Param )
IfEqual,Param,,Return SubStr(DelimitedString,2)
DelimitedString = %DelimitedString%%D%%Param%
}}