forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


OpenProcess + GetCommandLineW -> kernel32 API calls

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
geicsge
Newbie


Joined: 27 Feb 2009
Posts: 19

PostPosted: Sat Mar 14, 2009 2:14 am    Post subject: OpenProcess + GetCommandLineW -> kernel32 API calls Reply with quote

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
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sat Mar 14, 2009 12:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
geicsge
Newbie


Joined: 27 Feb 2009
Posts: 19

PostPosted: Sat Mar 14, 2009 2:45 pm    Post subject: Reply with quote

Ok. I think you are right... So, how can I get the command line argumments of a specific process already started?
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Sat Mar 14, 2009 3:38 pm    Post subject: Reply with quote

I really don't know sorry..
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group