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:
or B: here:Code:if (GetAsyncKeyState(VK_NUMPAD0)&1) { strideNum +=1; }
Maybe it could have something to do with the conversion of the int to a LPCSTR that can be drawn on the screen.Code:char buffer[20]; _itoa_s(strideNum,buffer,20,2); LPCSTR p = buffer; Draw_Text(p, 200, 5, txtGreen, HeaderFont);
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.
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).Code:if (GetAsyncKeyState(VK_NUMPAD0)&1) { strideNum +=1; }
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.
--
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 : |
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.
--
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.Originally Posted by abuckau907
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:
To:Code:_itoa_s(strideNum,buffer,20,2);
Code:_itoa_s(strideNum,buffer,20,10);
Last edited by Harava; 08-07-2014 at 07:24 AM.
Recent releases:
CSPHv3.2
Can't see me calling, you hatin'?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
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.
--
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!
Recent releases:
CSPHv3.2
Can't see me calling, you hatin'?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