| View previous topic :: View next topic |
| Author |
Message |
geicsge Newbie
Joined: 27 Feb 2009 Posts: 19
|
Posted: Sat Mar 14, 2009 2:14 am Post subject: OpenProcess + GetCommandLineW -> kernel32 API calls |
|
|
I want to open a specific process via a kernel32.dll API call. to obtain some details, for example the process' PATH or the process' priority etc...
I receive "The parameter is incorrect" for the OpenProcess API call...
Please help me with the correct code... I tried many combinations...
Plus, after the correct API call of the OpenProcess function, please help me with the GetCommandLineW function, to get the command line argumments of the specific process...
| Code: |
loadlib kernel32.dll
#DEFINE FUNCTION,GETLASTERROR
rem For example, 1672 is the PID
%%PID =1672
%a =@binary(DWORD,%%PID)
rem PROCESS_QUERY_INFORMATION = $0400
%%openProcess =@LIB(kernel32,OpenProcess,INT:$0400,BOOL:,@addr("%a"))
%%tmp1 =@getlasterror(kernel32)
rem %%currProcess =@LIB(kernel32,CloseHandle,%%openProcess)
rem %%tmp1 =@getlasterror(kernel32)
freelib kernel32.dll
stop
:GetLastError
# The GetLastError will return the last-error code value
# Parameters:
# dllname
#
# Syntax: %A = @GetLastError(<dllname>)
%%tmp1 =@lib(KERNEL32,GetLastError,INT:)
# Test for the first parameter. If NULL use the KERNEL32.DLL
If %1
%%tmp2 =@lib(KERNEL32,GetModuleHandleA,INT:,STR:%1.dll)
Else
%%tmp2 =@lib(KERNEL32,GetModuleHandleA,INT:,STR:kernel32.dll)
End
%x =@fill(256,,Z)
%%tmp3 =@lib(KERNEL32,FormatMessageA,INT:,INT:$0800,%%tmp2,INT:%%tmp1,INT:0,@ADDR("%x"),INT:255,INT:0)
warn API call error: %%tmp1 "(0x"@hex(%%tmp1)")"@cr()@adjust(%x)
exit
|
|
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Mar 14, 2009 12:48 pm Post subject: |
|
|
I don't think that is going to get you what you want..
| Quote: |
The GetCommandLine function retrieves the command-line string for the current process.
LPTSTR GetCommandLine(void);
|
Meaning it will get the command-ling string for the process that calls the function(your app).
Unless that is what you are after, then you wouldn't need the OpenProcess and all that.. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
geicsge Newbie
Joined: 27 Feb 2009 Posts: 19
|
Posted: Sat Mar 14, 2009 2:45 pm Post subject: |
|
|
| Ok. I think you are right... So, how can I get the command line argumments of a specific process already started? |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat Mar 14, 2009 3:38 pm Post subject: |
|
|
I really don't know sorry.. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|