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++] Help with CreateProcess

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 29, 2008 3:27 pm    Post subject: [C++] Help with CreateProcess Reply with quote

hii..
i'm trying to open notepad with CreateProcess according to the book that i'm studing with it goes like this:
Code:

STARTUPINFO sui;
PROCESS_INFORMATION pi;
ZeroMemory(&sui,sizeof(STARTUPINFO));
sui.cb = sizeof(STARTUPINFO);
CreateProcess(NULL,L"C:\\WINDOWS\\Notepad.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&sui,&pi);


but when i active that code the window crushes . . huh o.O ?!?!

_________________
Stylo
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Sun Jun 29, 2008 3:33 pm    Post subject: Reply with quote

Code:
    int OpenProcess( LPTSTR process_name )
    {
    STARTUPINFO sui;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(sui) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    int retval = CreateProcess( process_name,
    NULL,NULL,NULL,FALSE, NULL, //change your creation flag to suit your need.
    NULL,NULL,&sui,&pi);

    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    //returns ZERO if failed. returns NON-ZERO if succeeded.
    return retval;
    }


Credits: The_Undead
Back to top
View user's profile Send private message MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun Jun 29, 2008 3:39 pm    Post subject: Reply with quote

Switch the first to parameters. You're giving the path as the command line.
_________________
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sun Jun 29, 2008 5:27 pm    Post subject: Reply with quote

Code:
#include <windows.h>

char target[] = "\\test.exe";
char path[MAX_PATH];
STARTUPINFO         si = { 0 };
PROCESS_INFORMATION pi;

int main(){
   si.cb = sizeof(STARTUPINFO);
   GetCurrentDirectory((MAX_PATH - sizeof(target)), (LPSTR)&path);
   lstrcat((LPSTR)&path, (LPSTR)&target);
   CreateProcess((LPSTR)&path, NULL, NULL, NULL, FALSE,
              NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
}
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Sun Jun 29, 2008 8:53 pm    Post subject: Reply with quote

oh thx HalfPrime all i needed was to switch the first two parameters
thx to other guys that help too

_________________
Stylo
Back to top
View user's profile Send private message
systat
Advanced Cheater
Reputation: 0

Joined: 15 Feb 2008
Posts: 54

PostPosted: Mon Jun 30, 2008 2:04 am    Post subject: Reply with quote

Overload wrote:
Code:
    int OpenProcess( LPTSTR process_name )
    {
    STARTUPINFO sui;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(sui) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    int retval = CreateProcess( process_name,
    NULL,NULL,NULL,FALSE, NULL, //change your creation flag to suit your need.
    NULL,NULL,&sui,&pi);

    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    //returns ZERO if failed. returns NON-ZERO if succeeded.
    return retval;
    }


Credits: The_Undead


Hey pal
Code:
si.cb = sizeof(si);

si isn't declared!!!!!!!!!!

_________________
uuuuuuuuuuuuu
Back to top
View user's profile Send private message
Overload
Master Cheater
Reputation: 0

Joined: 08 Feb 2008
Posts: 293

PostPosted: Mon Jun 30, 2008 2:41 am    Post subject: Reply with quote

systat wrote:
Overload wrote:
Code:
    int OpenProcess( LPTSTR process_name )
    {
    STARTUPINFO sui;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(sui) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    int retval = CreateProcess( process_name,
    NULL,NULL,NULL,FALSE, NULL, //change your creation flag to suit your need.
    NULL,NULL,&sui,&pi);

    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    //returns ZERO if failed. returns NON-ZERO if succeeded.
    return retval;
    }


Credits: The_Undead


Hey pal
Code:
si.cb = sizeof(si);

si isn't declared!!!!!!!!!!


if you can't fix that, you dont deserve to be on this forum...lol
it was just a typing error =/
Back to top
View user's profile Send private message MSN Messenger
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