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] Console to WIN32 GUI Application

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

Joined: 11 May 2007
Posts: 51
Location: 0x0600

PostPosted: Sun Feb 03, 2008 10:10 am    Post subject: [C] Console to WIN32 GUI Application Reply with quote

Hey,
Is there a way to create a console window into existing WIN32 GUI application (jaac is a good example). I tried AllocConsole() but it didn't even open the console window. Any suggestions/tips?
Thank you~

_________________
printf("You just ate a %X!!\n",3735928559);
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sun Feb 03, 2008 10:57 am    Post subject: Reply with quote

I know in CodeBLocks if you select console application it will show the command line by default. I never tried it in VS
_________________
Back to top
View user's profile Send private message
iCucco
Advanced Cheater
Reputation: 0

Joined: 11 May 2007
Posts: 51
Location: 0x0600

PostPosted: Sun Feb 03, 2008 11:00 am    Post subject: Reply with quote

The point is to make DLL that can be injected with BOOL APPENTRY DllMain().
Then DllMain() will create a thread that will allocate console with AllocConsole(). This is the point I'm stuck with.

_________________
printf("You just ate a %X!!\n",3735928559);
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Feb 03, 2008 11:10 am    Post subject: Reply with quote

read and learn from this

http://www.halcyon.com/~ast/dload/guicon.htm

(yes, its old, try to focus on the console coding, like GetStdHandle and such)

just in Dll you have to create a thread in the DLL_PROCESS_ATTACH and then u can code everything from there.

_________________


Last edited by lurc on Sun Feb 03, 2008 11:12 am; edited 1 time in total
Back to top
View user's profile Send private message
iCucco
Advanced Cheater
Reputation: 0

Joined: 11 May 2007
Posts: 51
Location: 0x0600

PostPosted: Sun Feb 03, 2008 11:12 am    Post subject: Reply with quote

Exactly... That was my source for the first attempt. Opened the console window but didn't display any output / input.
_________________
printf("You just ate a %X!!\n",3735928559);
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Feb 03, 2008 11:14 am    Post subject: Reply with quote

you can also use CreateProcess with CREATE_NEW_CONSOLE

http://msdn2.microsoft.com/en-us/library/ms682528.aspx

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

Joined: 11 May 2007
Posts: 51
Location: 0x0600

PostPosted: Sun Feb 03, 2008 11:27 am    Post subject: Reply with quote

Woo! Found a way.
Code:

DWORD dwBytesWritten;
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
WriteFile(handle, "test", strlen("test"), &dwBytesWritten, NULL);
_getch();
FreeConsole();


Though usage of WriteFile is complicated, I'm glad that I even managed to get the output to console.

_________________
printf("You just ate a %X!!\n",3735928559);
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Sun Feb 03, 2008 2:02 pm    Post subject: Reply with quote

Exclamation Better use WriteFile - it allows you to dump your output to text files(batch files\cmd often use that).
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