Results 1 to 9 of 9
  1. #1
    Phot0n's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    North America
    Posts
    3
    Reputation
    10
    Thanks
    16
    My Mood
    Happy

    Cool Don't always PushToConsole

    I'm fairly new here and just got some of my own initial hacks working with help from the amazing source of information I've found in the forums. One thing I'm noticing a lot are unnecessary PTC in while loops so I thought I'd call it out since I noticed my CA would crash/exit until I fixed it.

    Example of what not to do:

    Code:
    while(true) {
       PushToConsole("...");
    }
    Some of this can be mitigated by detecting if the Console shell exists before pushing a command to the LTC. This type of checking is always good:

    Code:
    void __cdecl PushToConsole( const char* szCmd )
    {
    	DWORD dwCShell = (DWORD)GetModuleHandleA("CShell.dll");
    	if( dwCShell != NULL )
    	...

    Another case of the never-ending pushes that I see floating around the forums are when you set a flag based on a key-event (or whatever), and then either always push the command to be active or inactive:

    Code:
       bool chams = false;
    
       while(true) {
    	// Chams
    	if(GetAsyncKeyState(VK_NUMPAD1)&1) {
    		chams = !chams;
            }
            ...
    	if(chams) {
    		PushToConsole("SkelModelStencil 0");
    	} else {
    		PushToConsole("SkelModelStencil 1");
    	}
    	Sleep(100);
            ...
    }
    Those "Sleep" commands can only do so much, but you are essentially constantly pushing commands (either chams-on or chams-off) all the time. Rather, if you want something simple, then just do the command push and flag update on the key event:

    Code:
    while(true) {
    		// Chams
    		if(GetAsyncKeyState(VK_NUMPAD1)&1)
    		{
    			if(chams) {
    				PushToConsole("SkelModelStencil 0");
    			} else {
    				PushToConsole("SkelModelStencil 1");
    			}
    			chams = !chams;
    			Sleep(100);
    		}
         ...
    }
    So far I've seen better hack success and less CA exit/crashes.

    On a slight side note, I'm also seeing less exits when doing "Release" quality builds from VS2008 and packing the DLL through UPX.

    Anyways, I hope this helps. If not, then... well... hello.

    Regards,
    --Phot0n

  2. The Following 8 Users Say Thank You to Phot0n For This Useful Post:

    cosconub (09-02-2010),fvestrgenrl (09-01-2010),Gordon` (09-01-2010),lucky7 (10-03-2010),rob7601 (09-01-2010),swatfx (09-01-2010),tempta43 (09-02-2010),treeham (09-01-2010)

  3. #2
    Fabolous's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    192.168.1.01
    Posts
    2,704
    Reputation
    261
    Thanks
    682
    My Mood
    Paranoid
    Great Contribution Bro..

    +Rep
    +Thanks

  4. #3
    rob7601's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Posts
    335
    Reputation
    4
    Thanks
    226
    My Mood
    Lurking
    very very good post
    [IMG]https://i727.photobucke*****m/albums/ww279/rob7601/aig-1.jpg[/IMG]
    [IMG]https://i727.photobucke*****m/albums/ww279/rob7601/Crossfire50.jpg[/IMG]


    ..::GOALS::..
    GET HACKS XDONE!
    GET XM8 xDONE!
    [ 50 ] POSTS xDONE!
    [ 100 ] POSTS xDONE!
    [ 250 ] POSTS xDONE!
    [ 500 ] POSTS
    { 100 } THANKS xDONE
    { 500 } THANKS
    { 1000 } THANKS
    GET 100/0 SCORE
    BECOME A MINION
    MAKE MY OWN HACKS

  5. #4
    swatfx's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Posts
    659
    Reputation
    20
    Thanks
    108
    My Mood
    Mellow
    nice.. good thing to know

    /thanked

  6. #5
    Evolution92's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    11
    Reputation
    10
    Thanks
    0
    Yes, this is great for reducing lag in hotkey hacks. But how would you do it with a menu? I've been thinking about it for awhile I just haven't quite figured out how to code it.

  7. #6
    Gordon`'s Avatar
    Join Date
    Dec 2007
    Gender
    male
    Posts
    283
    Reputation
    24
    Thanks
    325
    I posted some code some time ago. You might find it when you search for my posts.


  8. #7
    LightzOut's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    185
    Reputation
    11
    Thanks
    25

  9. #8
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by Phot0n View Post

    Code:
    while(true) {
    		// Chams
    		if(GetAsyncKeyState(VK_NUMPAD1)&1)
    		{
    			if(chams) {
    				PushToConsole("SkelModelStencil 0");
    			} else {
    				PushToConsole("SkelModelStencil 1");
    			}
    			chams = !chams;
    			Sleep(100);
    		}
         ...
    }
    First of all, let me say, nice post mate. Really concise, detailed and above all, logical.

    Also, I was under the impression everyone wrote their hotkeys as you have done above, I didn't realise so many people used a hotkey just to toggle the boolean variable and then continually push the commands.

    Also, with this:

    Code:
    void __cdecl PushToConsole( const char* szCmd )
    {
    	DWORD dwCShell = (DWORD)GetModuleHandleA("CShell.dll");
    	if( dwCShell != NULL )
    	...
    Correct me if I'm wrong, I'm also a beginner in C++ but doesn't the "while(true)" in "void main()" come from the "IsGameReadyForHook" boolean? that procedure already checks whether the ModuleHandle of Cshell is NULL and returns true/false accordingly.

    Again, I really liked the post, good work!

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  10. #9
    LightzOut's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Posts
    185
    Reputation
    11
    Thanks
    25
    Quote Originally Posted by J-Deezy View Post


    First of all, let me say, nice post mate. Really concise, detailed and above all, logical.

    Also, I was under the impression everyone wrote their hotkeys as you have done above, I didn't realise so many people used a hotkey just to toggle the boolean variable and then continually push the commands.

    Also, with this:

    Code:
    void __cdecl PushToConsole( const char* szCmd )
    {
    	DWORD dwCShell = (DWORD)GetModuleHandleA("CShell.dll");
    	if( dwCShell != NULL )
    	...
    Correct me if I'm wrong, I'm also a beginner in C++ but doesn't the "while(true)" in "void main()" come from the "IsGameReadyForHook" boolean? that procedure already checks whether the ModuleHandle of Cshell is NULL and returns true/false accordingly.

    Again, I really liked the post, good work!
    Um no.. The while(true) is just a way of writing an infinate loop. You could also write it like:
    while(1)
    for( ; ; )
    It doesn't really matter, it is just a loop that never ends (until you end the program). The IsGameReadyForHook method checks if all the modules are loaded and returns true when they are. Then in dwHackThread or whatever you call yours it only calls the main thread once IsGameReadyForHook returns true, so maybe thats what your thinking of. And the reason that is in the PushToConsole method is because it is a way of making that method undetected.

Similar Threads

  1. [Solved] =.= i always have a problem don't I
    By Wolfzero in forum CrossFire Help
    Replies: 39
    Last Post: 10-21-2011, 05:59 PM
  2. For those who don't have playspan code. ( always update )
    By Osama_Farooq in forum CrossFire Tutorials
    Replies: 8
    Last Post: 08-07-2010, 01:20 AM
  3. Replies: 6
    Last Post: 12-08-2008, 12:57 PM
  4. [Release] Instantkill/Always headshot
    By hjerherjdsd in forum WarRock - International Hacks
    Replies: 171
    Last Post: 12-10-2006, 07:49 AM