Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C#] CreateProcess()

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
rump
Expert Cheater
Reputation: 0

Joined: 03 Oct 2007
Posts: 169

PostPosted: Wed Dec 26, 2007 9:00 am    Post subject: [C#] CreateProcess() Reply with quote

Hello again, unfortunatly I suck at understanding how to use the code @ www.msdn.com so when I searched for CreateProcess() and I got this snippet of code I became a bit clueless:

Code:
BOOL WINAPI CreateProcess(
  __in_opt     LPCTSTR lpApplicationName,
  __inout_opt  LPTSTR lpCommandLine,
  __in_opt     LPSECURITY_ATTRIBUTES lpProcessAttributes,
  __in_opt     LPSECURITY_ATTRIBUTES lpThreadAttributes,
  __in         BOOL bInheritHandles,
  __in         DWORD dwCreationFlags,
  __in_opt     LPVOID lpEnvironment,
  __in_opt     LPCTSTR lpCurrentDirectory,
  __in         LPSTARTUPINFO lpStartupInfo,
  __out        LPPROCESS_INFORMATION lpProcessInformation
);


Should I just copy paste it into my clickbutton function and add "my path to my .exe file" after __in_opt LPCTSTR <here>, my usual methods i've used have only required 1 or 2 parameters, thus I've written the calling of those methods like this:
Code:

myMethod(param1, param2);

Is there any difference between that and writing it like this:
Code:
myMethod(
    param1,
    param2,
);


Thanks for reading

_________________
C# boot camp, PM me if you want a simple application made and I'll give it a try!
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Wed Dec 26, 2007 10:58 am    Post subject: Re: [C#] CreateProcess() Reply with quote

rump wrote:
I've written the calling of those methods like this:
Code:

myMethod(param1, param2);

Is there any difference between that and writing it like this:
Code:
myMethod(
    param1,
    param2,
);



no

_________________
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Wed Dec 26, 2007 2:20 pm    Post subject: Reply with quote

You can't just copy down the code and have it work. MSDN documents a WinAPI function. It shows you all the parameters needed to call it, what the function does, and the return values. You need to replace all the parameters with the ones you are going to use in your program.
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Wed Dec 26, 2007 2:25 pm    Post subject: Re: [C#] CreateProcess() Reply with quote

rump wrote:
Hello again, unfortunatly I suck at understanding how to use the code @ www.msdn.com so when I searched for CreateProcess() and I got this snippet of code I became a bit clueless:

Code:
BOOL WINAPI CreateProcess(
  __in_opt     LPCTSTR lpApplicationName,
  __inout_opt  LPTSTR lpCommandLine,
  __in_opt     LPSECURITY_ATTRIBUTES lpProcessAttributes,
  __in_opt     LPSECURITY_ATTRIBUTES lpThreadAttributes,
  __in         BOOL bInheritHandles,
  __in         DWORD dwCreationFlags,
  __in_opt     LPVOID lpEnvironment,
  __in_opt     LPCTSTR lpCurrentDirectory,
  __in         LPSTARTUPINFO lpStartupInfo,
  __out        LPPROCESS_INFORMATION lpProcessInformation
);


Should I just copy paste it into my clickbutton function and add "my path to my .exe file" after __in_opt LPCTSTR <here>, my usual methods i've used have only required 1 or 2 parameters, thus I've written the calling of those methods like this:
Code:

myMethod(param1, param2);

Is there any difference between that and writing it like this:
Code:
myMethod(
    param1,
    param2,
);


Thanks for reading


I Google'd and found this VB.Net code:

Code:

Private Declare Function CreateProcess
Lib _
   "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, _
   ByVal lpCommandLine As String, _ =
   ByVal lpProcessAttributes As Long,_
   ByVal lpThreadAttributes As Long,_
   ByVal bInheritHandles As Long, _ =
   ByVal dwCreationFlags As ProcessCreationFlags, _
   ByVal lpEnvironment As Long, _
   ByVal lpCurrentDirectory As String, _
   lpStartupInfo As STARTUPINFO,_
   lpProcessInformation As PROCESS_INFORMATION) _
As Long

Public Enum ProcessCreationFlags
   DEBUG_PROCESS              = &H1
   DEBUG_ONLY_THIS_PROCESS    = &H2
   CREATE_SUSPENDED           = &H4
   DETACHED_PROCESS           = &H8
   CREATE_NEW_CONSOLE         = &H10
   NORMAL_PRIORITY_CLASS      = &H20
   IDLE_PRIORITY_CLASS        = &H40
   HIGH_PRIORITY_CLASS        = &H80
   REALTIME_PRIORITY_CLASS    = &H100
   CREATE_NEW_PROCESS_GROUP   = &H200
   CREATE_UNICODE_ENVIRONMENT = &H400
   CREATE_SEPARATE_WOW_VDM    = &H800
   CREATE_SHARED_WOW_VDM      = &H1000
   CREATE_FORCEDOS            = &H2000
   CREATE_DEFAULT_ERROR_MODE  = &H4000000
   CREATE_NO_WINDOW           = &H8000000
End Enum


and hand-converted it to C#:

Code:


private static extern long CreateProcessA(
string lpApplicationName,
string lpCommandLine,
long lpProcessAttributes,
long lpThreadAttributes,
long bInheritHandles,
ProcessCreationFlags dwCreationFlags,
long lpEnvironment,
string lpCurrentDirectory,
STARTUPINFO lpStartupInfo,
PROCESSINFORMATION lpProcessInformation);

public enum ProcessCreationFlags
{
DEBUG_PROCESS              = &0x1
   DEBUG_ONLY_THIS_PROCESS    = &0x2
   CREATE_SUSPENDED           = &0x4
   DETACHED_PROCESS           = &0x8
   CREATE_NEW_CONSOLE         = &0x10
   NORMAL_PRIORITY_CLASS      = &0x20
   IDLE_PRIORITY_CLASS        = &0x40
   HIGH_PRIORITY_CLASS        = &0x80
   REALTIME_PRIORITY_CLASS    = &0x100
   CREATE_NEW_PROCESS_GROUP   = &0x200
   CREATE_UNICODE_ENVIRONMENT = &0x400
   CREATE_SEPARATE_WOW_VDM    = &0x800
   CREATE_SHARED_WOW_VDM      = &0x1000
   CREATE_FORCEDOS            = &0x2000
   CREATE_DEFAULT_ERROR_MODE  = &0x4000000
   CREATE_NO_WINDOW           = &0x8000000
}


Here's the link:

http://www.codeguru.com/vb/gen/vb_system/win32/article.php/c7525/

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Wed Dec 26, 2007 2:35 pm    Post subject: Reply with quote

Youre using C# so why not just:
Code:
using System.Diagnostics;
Process engine = Process.Start("C:\\ADDRESSOFEXE.EXE")

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Wed Dec 26, 2007 2:38 pm    Post subject: Reply with quote

the_undead wrote:
Youre using C# so why not just:
Code:
using System.Diagnostics;
Process engine = Process.Start("C:\\ADDRESSOFEXE.EXE")


Good point--I assumed he wanted to make the apicall, but yeah.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
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 cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites