windows - CreateProcess hook to add CommandLine -
i have project adding specific flags (command lines) chrome browser, problem doing creating new chrome shortcut, flags want execute.
in last days solution became superficial, , requested more 'deeper'. looking on windows registry, didn't found solution always add flags when run chrome, started thinking hook createprocess explorer, , check if process run chrome, add flags in lpcommandline attribute.
i know hook explorer pretty 'intrusive' solution, became helpful because have other achieves putting off on project, , hooking me them done.
i got hook working, tried many ways add command lines when chrome found, no success... right (and tried @ least 8 different solutions) detour function is:
function interceptcreateprocess(lpapplicationname: pchar; lpcommandline: pchar; lpprocessattributes, lpthreadattributes: psecurityattributes; binherithandles: bool; dwcreationflags: dword; lpenvironment: pointer; lpcurrentdirectory: pchar; const lpstartupinfo: startupinfo; var lpprocessinformation: process_information): bool; stdcall; var cmd: string; begin result:= createprocessnext(lpapplicationname, lpcommandline, lpprocessattributes, lpthreadattributes, binherithandles, dwcreationflags, lpenvironment, lpcurrentdirectory, lpstartupinfo, lpprocessinformation); if (pos(chrome, uppercase(string(lpapplicationname))) > 0) begin cmd:= ' --show-fps-counter'; lpcommandline:= pchar(widestring(lpcommandline + cmd)); showmessage(lpcommandline); end; end;
the "--show-fps-counter" command line i'm trying add without success.
my delphi version xe4.
ok, pretty obvious thing... need add parameter before calling createprocessnext (original function)! so, doing:
if (pos(chrome, uppercase(string(lpapplicationname))) > 0) begin lpcommandline:= pchar(lpcommandline + ' --show-fps-counter'); end; result:= createprocessnext(lpapplicationname, lpcommandline, lpprocessattributes, lpthreadattributes, binherithandles, dwcreationflags, lpenvironment, lpcurrentdirectory, lpstartupinfo, lpprocessinformation);
works... note inverted order change lpcommandline. thank's participants , i'll still consider said here.
Comments
Post a Comment