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:
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:while(true) { PushToConsole("..."); }
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:
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:bool chams = false; while(true) { // Chams if(GetAsyncKeyState(VK_NUMPAD1)&1) { chams = !chams; } ... if(chams) { PushToConsole("SkelModelStencil 0"); } else { PushToConsole("SkelModelStencil 1"); } Sleep(100); ... }
So far I've seen better hack success and less CA exit/crashes.Code:while(true) { // Chams if(GetAsyncKeyState(VK_NUMPAD1)&1) { if(chams) { PushToConsole("SkelModelStencil 0"); } else { PushToConsole("SkelModelStencil 1"); } chams = !chams; Sleep(100); } ... }
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
Great Contribution Bro..
+Rep
+Thanks
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
nice.. good thing to know
/thanked
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.
I posted some code some time ago. You might find it when you search for my posts.
https://www.mpgh.net/forum/207-combat...ml#post2262596
Would it be that post? :P
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:
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.Code:void __cdecl PushToConsole( const char* szCmd ) { DWORD dwCShell = (DWORD)GetModuleHandleA("CShell.dll"); if( dwCShell != NULL ) ...
Again, I really liked the post, good work!
You can win the rat race,Originally Posted by Jeremy S. Anderson
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)
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.