Results 1 to 10 of 10
  1. #1
    wara286's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Location
    At my computer
    Posts
    62
    Reputation
    10
    Thanks
    188
    My Mood
    Psychedelic

    C++ int += 1 increases by 10 or more

    Hello,
    I got a problem:
    I am currently writing a dll for COD MW3 and I'm trying to do a wallhack.
    For that i need the correct stride number and to find that out I increase an int every time I type the NUM1 key on my keyboard.
    The current int is displayed on the screen.
    My problem is that the number displayed on the screen increases by one the first time I type NUM1, but the second time it increases by 10 and then by one agin, the third time it increases by 89 so I am at 100.
    I think that the problem could be
    A: here:
    Code:
    	
    if (GetAsyncKeyState(VK_NUMPAD0)&1) 
    { 
    	strideNum +=1;
    }
    or B: here:
    Code:
            char buffer[20];
    	_itoa_s(strideNum,buffer,20,2);
    	LPCSTR p = buffer;
    	Draw_Text(p, 200, 5, txtGreen, HeaderFont);
    Maybe it could have something to do with the conversion of the int to a LPCSTR that can be drawn on the screen.

    I hope that there will be some good answers soon

    EDIT:
    Maybe I should mention that if I decrease the number it decreases in exactly the same steps that it increased before.
    Last edited by wara286; 08-06-2014 at 04:18 PM.

  2. #2
    somewhatpro's Avatar
    Join Date
    May 2014
    Gender
    male
    Posts
    317
    Reputation
    38
    Thanks
    29
    My Mood
    Daring
    Quote Originally Posted by wara286 View Post
    Hello,
    I got a problem:
    I am currently writing a dll for COD MW3 and I'm trying to do a wallhack.
    For that i need the correct stride number and to find that out I increase an int every time I type the NUM1 key on my keyboard.
    The current int is displayed on the screen.
    My problem is that the number displayed on the screen increases by one the first time I type NUM1, but the second time it increases by 10 and then by one agin, the third time it increases by 89 so I am at 100.
    I think that the problem could be
    A: here:
    Code:
    	
    if (GetAsyncKeyState(VK_NUMPAD0)&1) 
    { 
    	strideNum +=1;
    }
    or B: here:
    Code:
            char buffer[20];
    	_itoa_s(strideNum,buffer,20,2);
    	LPCSTR p = buffer;
    	Draw_Text(p, 200, 5, txtGreen, HeaderFont);
    Maybe it could have something to do with the conversion of the int to a LPCSTR that can be drawn on the screen.

    I hope that there will be some good answers soon

    EDIT:
    Maybe I should mention that if I decrease the number it decreases in exactly the same steps that it increased before.
    add a little sleep to slow it down.

    Code:
    if (GetAsyncKeyState(VK_NUMPAD0)&1) 
    { 
    	strideNum++;
            Sleep(100);
    }
    btw it's better to use sprintf :
    Code:
    char buffer[32];
    sprintf(buffer, "strideNum : %d", strideNum);
    Last edited by somewhatpro; 08-06-2014 at 07:45 PM.

  3. #3
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Code:
    if (GetAsyncKeyState(VK_NUMPAD0)&1) 
    { 
    	strideNum +=1;
    }
    Apparently that code is running MANY times per second. You think you're pressing and releasing the key quickly, but to the computer it was pressed down for a long time (it's doing..~3 billion operations a second..so even 1/10 of a second is a LONG time to the cpu..and it can run your loop code a lot of times -- somewhere near 100 as you say).

    1. Detect that the key is down
    2. Don't run the "+1 code" until the key is up again (ie. action occurs on key RELEASE, not "any time the key is down", like it is now)

    Or use Sleep() as mentioned by user above -- depends how you want the program to act.
    The sleep() will still let the code run 5-10 times a second which might be what you want, or do it only on key-release and only perform the +1 each time the key is pressed and then released.

    edit: I'd post a link, but I expect you to search..and the logic isn't exactly 'complicated.'
    Last edited by abuckau907; 08-06-2014 at 08:12 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  4. #4
    somewhatpro's Avatar
    Join Date
    May 2014
    Gender
    male
    Posts
    317
    Reputation
    38
    Thanks
    29
    My Mood
    Daring
    Quote Originally Posted by abuckau907 View Post
    Code:
    if (GetAsyncKeyState(VK_NUMPAD0)&1) 
    { 
    	strideNum +=1;
    }
    Apparently that code is running MANY times per second. You think you're pressing and releasing the key quickly.
    true, and they think by adding the bitwise AND 1 will make it on a "key_pressed one time" state lol

  5. #5
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Quote Originally Posted by somewhatpro View Post
    ...
    I basically thought the same thing the first time I read the msdn for it...but after testing I figured it out pretty quickly..

    10-30 minutes of testing the function should be enough to learn how to use it..apparently it's too complicated...so why is OP making a wallhack? OP isn't, we (anyone who 'helps') are : |

     

    I'm all for helping people with code (check my post history..), but this ish is getting annoying.

    "I wanna make wallhack, but can't handle the logic behind key presses"
    kind of like
    "I wanna make rocket and go to space, but don't know which end of a hammer is for hammering"


    it just doesn't make sense..you're doing it wrong.
    Last edited by abuckau907; 08-06-2014 at 08:59 PM. Reason: couple edits, per usual. sry.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  6. #6
    wara286's Avatar
    Join Date
    Aug 2014
    Gender
    male
    Location
    At my computer
    Posts
    62
    Reputation
    10
    Thanks
    188
    My Mood
    Psychedelic

    Sleep() is not the problem...

    Quote Originally Posted by abuckau907
    Apparently that code is running MANY times per second. You think you're pressing and releasing the key quickly, but to the computer it was pressed down for a long time (it's doing..~3 billion operations a second..so even 1/10 of a second is a LONG time to the cpu..and it can run your loop code a lot of times -- somewhere near 100 as you say).

    1. Detect that the key is down
    2. Don't run the "+1 code" until the key is up again (ie. action occurs on key RELEASE, not "any time the key is down", like it is now)

    Or use Sleep() as mentioned by user above -- depends how you want the program to act.
    The sleep() will still let the code run 5-10 times a second which might be what you want, or do it only on key-release and only perform the +1 each time the key is pressed and then released.
    I added a sleep time of 1 sec but there is still no success... it looks like it still increases not by one... but I figured out that it increases by 1 every time and is displayed in binary... 0, 1, 10, 11, 100, 101, 111 etc. So i think that my problem is at the conversion of int to LPCSTR.

  7. #7
    Harava's Avatar
    Join Date
    Sep 2013
    Gender
    male
    Posts
    114
    Reputation
    10
    Thanks
    2,990
    You are using a radix of 2 for itoa, thats why it converts it to binary. I'm guessing you meant to use 10.

    _itoa_s

    So change:
    Code:
    _itoa_s(strideNum,buffer,20,2);
    To:
    Code:
    _itoa_s(strideNum,buffer,20,10);
    Last edited by Harava; 08-07-2014 at 07:24 AM.
    Recent releases:
    CSPHv3.2




    Code:
    00F38C0E     B8 0610F300    MOV EAX, 00F31006
    00F38C13     C700 208CF300  MOV DWORD PTR DS:[EAX], 00F38C20
    00F38C19     EB FF          JMP SHORT 00F38C1A
    00F38C1B     90             NOP
    00F38C1C     0000           ADD BYTE PTR DS:[EAX],AL
    00F38C1E     0000           ADD BYTE PTR DS:[EAX],AL
    00F38C20     58             POP EAX
    00F38C21    ^EB EB          JMP SHORT 00F38C0E
    Can't see me calling, you hatin'?

  8. #8
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    hehe oops..the last argument to the _itoa_s() function.

    'radix' , is the base you want to convert to, not the length of the buffer. Should be 10, not 2.
    Change to = _itoa(int,buff,new_base);

    edit: nvm, thanks @ Harava - I was double-checking the code before telling OP something wrong and you posted in that time.
    Last edited by abuckau907; 08-07-2014 at 07:38 AM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  9. #9
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,321
    My Mood
    Cheeky
    This method of stride logging is terribly inefficient and time consuming.

    Consider doing the following:
    int min_stride = 0;
    int max_stride = 10000;
    int cur_stride = (max_stride+min_stride)/2;

    stridenum >= min_stride and < cur_stride -> color blue
    stridenum > cur_stride and <= max_stride -> color red
    stridenum == cur_stride -> color green.

    if it's too high, set max_s to cur_s, and cur_s to half of max+min.
    if it's too low, set min_s to cur_s, and cur_s to half of max+min.
    if it's correct: log the stride and reset min/max/cur.

    log(n)/log(2) where n is the maximum stride number.
    for stride 0 to a 10000 it takes a max of 14 steps.
    for stride 0 to 1000000 it takes a max of 21 steps.
    Ah we-a blaze the fyah, make it bun dem!

  10. #10
    Harava's Avatar
    Join Date
    Sep 2013
    Gender
    male
    Posts
    114
    Reputation
    10
    Thanks
    2,990
    Quote Originally Posted by Hell_Demon View Post
    This method of stride logging is terribly inefficient and time consuming.

    Making a gui for the logger saves a lot of time aswell:

    Recent releases:
    CSPHv3.2




    Code:
    00F38C0E     B8 0610F300    MOV EAX, 00F31006
    00F38C13     C700 208CF300  MOV DWORD PTR DS:[EAX], 00F38C20
    00F38C19     EB FF          JMP SHORT 00F38C1A
    00F38C1B     90             NOP
    00F38C1C     0000           ADD BYTE PTR DS:[EAX],AL
    00F38C1E     0000           ADD BYTE PTR DS:[EAX],AL
    00F38C20     58             POP EAX
    00F38C21    ^EB EB          JMP SHORT 00F38C0E
    Can't see me calling, you hatin'?

Similar Threads

  1. [Preview] Decrease your ping - Increase Download - Upload | 3 Ways and more
    By Rajesh32 in forum Battlefield 3 (BF3) Hacks & Cheats
    Replies: 16
    Last Post: 07-20-2013, 05:23 AM
  2. [Release] Decrease your ping - Increase Download - Upload | 3 Ways and more..
    By Frought in forum Alliance of Valiant Arms (AVA) Hacks & Cheats
    Replies: 37
    Last Post: 01-16-2013, 05:35 AM
  3. Does more ram increase processor GHz?
    By mrkiller2011 in forum General
    Replies: 9
    Last Post: 06-20-2011, 09:07 AM
  4. Increased price on various mats, I wish I stocked up more :(
    By minus4 in forum Vindictus Discussions
    Replies: 4
    Last Post: 06-16-2011, 12:41 AM
  5. Do you want more RoF increased mods?
    By InCognito in forum Combat Arms Mod Discussion
    Replies: 29
    Last Post: 06-23-2010, 04:21 AM

Tags for this Thread