[Release]Small Weapon Pixel-Bot

08/12/2010 23:08 critical1235#46
Also icj krieg nen overflow error...
08/12/2010 23:31 Wardog315#47
I don't speak any other language but English, so I apologize if this has been answered already.

When I click the bot, either as admin or not, I get an error. I can choose to continue, but I highly doubt if I choose to continue it won't work.

Any suggestions?

I tried running the set up, sadly, it didn't solve my problem.
08/12/2010 23:46 Neku!#48
Wenn man Visual Studio 2010 hat und es selbst kompiliert dann sollte es gehen. Hatte früher auch immer dieses Problem und glaube mich zu erinnern das es an der Kompilierung liegt.
Es gibt ja den Debugger und den Release Ordner. Das sind zwei verschiedene Kompilierungsvarianten. Wenn man sein Projekt veröffentlichen will, dann sollte man die Release Kompilierung benutzen.

Ich gebe dir ein Thanks wegen der Source, daraus kann ich eventuell etwas lernen.
08/13/2010 01:16 Ezio_Auditore_da_Firenze#49
bei mir gehts aba wirklich was bringen tuts net für die normalen weps da bin ich ohne besser xD
08/13/2010 02:32 clericxx#50
Not to bash your work or anything, but just a few things to point out:

1. I noticed you are using GetPixel(), this API call is blocked by XTrap when trying to call it on the device context of S4's window. To get around this, I noticed you create a DC for the whole display, and from there GetPixel() that device context with the intent of capturing S4's window's pixels. This results in a situation requiring that S4's window is not overlapped by any other windows, or this will flat-out read the wrong pixel, and fail. I do not believe you mentioned this.

2. Your bot extremely lacks error checking. You have a few checks here and there, but you could perform a lot more in places which would be beneficial, should an error occur.

3. You attempt to find S4's window an perform a few other actions upon the loading of your bot's form. Not only is this not needed, seeing as the Find Window, etc buttons are there on the form already, this was coded strangely in that if S4's window handle is not found, an Overflow Exception occurs within a GetWindowRect() call you have made in your S4 information finding function. The error occurs because of this little snippet of code:
Code:
Private Sub S4InfosFinden()
        If S4Found = True Then
            ''Informationen finden
            If GetWindowRect(S4.Handle, S4.WRect) = 0 Then
                MsgBox("Error 1")
                End
            End If
The GetWindowRect() function overflows because you have not checked if the handle is valid before performing the operation. Another note, the value of the handle does not seem to be returning 0 when finding the handle has failed. This is not default behavior, at least not in my experience of using FindWindow() in C++. I think you are peforming improper actions on this handle variable, or otherwise performing call(s) wrong for such a strange outcome.

Again, these are just some observations, and please do not take this as a personal attack, or any form of insulting your coding abilities. Please just try to further bug-check a beta application before releasing.

EDIT: You also seem to be creating and destroying the device context you create in every call to your GetPixelColor() function. It would be very beneficial to create the device context on form load, and to destroy it when your app closes, as opposed to creating and destroying it each time the function is called.

Also, where is your changelog? Version 1.0 and 4.0 don't look all that different, and you're not supposed to increment whole version numbers that fast.

As for the hotkeys, look into the API call RegisterHotKey():
[Only registered and activated users can see links. Click Here To Register...]
08/13/2010 03:22 waldi_#51
Quote:
Originally Posted by clericxx View Post
1. I noticed you are using GetPixel(), this API call is blocked by XTrap when trying to call it on the device context of S4's window. To get around this, I noticed you create a DC for the whole display, and from there GetPixel() that device context with the intent of capturing S4's window's pixels. This results in a situation requiring that S4's window is not overlapped by any other windows, or this will flat-out read the wrong pixel, and fail. I do not believe you mentioned this.
Of cource, i know that :) but, seriously, who plays with a window in the middle of s4 screen? :D
Quote:
2. Your bot extremely lacks error checking. You have a few checks here and there, but you could perform a lot more in places which would be beneficial, should an error occur.
Yes, that's true xD
Quote:
3. You attempt to find S4's window an perform a few other actions upon the loading of your bot's form. Not only is this not needed, seeing as the Find Window, etc buttons are there on the form already, this was coded strangely in that if S4's window handle is not found, an Overflow Exception occurs within a GetWindowRect() call you have made in your S4 information finding function. The error occurs because of this little snippet of code:
Code:
Private Sub S4InfosFinden()
        If S4Found = True Then
            ''Informationen finden
            If GetWindowRect(S4.Handle, S4.WRect) = 0 Then
                MsgBox("Error 1")
                End
            End If
The GetWindowRect() function overflows because you have not checked if the handle is valid before performing the operation.
Another note, the value of the handle does not seem to be returning 0 when finding the handle has failed. This is not default behavior, at least not in my experience of using FindWindow() in C++. I think you are peforming improper actions on this handle variable, or otherwise performing call(s) wrong for such a strange outcome.
Mhm.. but why occures a overflow exception and not my msgbox? the description of the api was that if the action has failed GetWindowRect == 0
and how could i check if handle is the right?

Edit: And another Question, why doesn't it found the right handle? *confused*
Quote:
EDIT: You also seem to be creating and destroying the device context you create in every call to your GetPixelColor() function. It would be very beneficial to create the device context on form load, and to destroy it when your app closes, as opposed to creating and destroying it each time the function is called.
I will try :D thank you
Quote:
Also, where is your changelog? Version 1.0 and 4.0 don't look all that different, and you're not supposed to increment whole version numbers that fast.
no, no.. this is the first version :D i called it sniper bot 4.0 at first.. but then i decided to make a weapon bot^^
this is the version 0.1 of the bot :D

Thank you very much for the Tips ! :D I'm not so experienced in debugging programms... i will save all in my little brain ^_^
08/13/2010 03:33 clericxx#52
You are correct, if GetWindowRect() fails, the return value is 0, however, it is trying to get the coordinates of a window handle which is invalid, and that is the part that is causing it to fail, not the return of the function.

I have taken a look at your code, and determined the solution to the problem, it is because you are attempting to store the return value of FindWindow as a long instead of what it should be, an IntPtr. The following revisions should fix this crash:
Code:
    Public Structure Window
        [COLOR="Red"]Public Handle As IntPtr[/COLOR]
        Public WRect As Rect
        Public Position As Point
        Public Size As Point
        Public Innersize As Point
        Public InnerPos As Point
    End Structure

and

Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As[COLOR="Red"] IntPtr[/COLOR]
Try compiling it now without S4 running, instead of crashing it should pop up with your error message stating S4's window has not been found.
08/13/2010 03:42 waldi_#53
But i doesn't crash with Long as Type..
It does all work fine for me.. that's my problem xD

And there is still another question, why does it crash if S4 is opened.. ?(not on my pc) Shouldn't be the handle right?
08/13/2010 03:59 clericxx#54
It would most likely be the handle. It would be trying to acquire it as the type long while it's really an IntPtr and it would crash. I'm not sure why it doesn't crash on your computer set as a long... The real way to define it is as an IntPtr, as FindWindow normally returns an HWND, which is really a HANDLE, which is really a void* (pointer to a void). That is not equivalent to a long value, which is why it crashes.

(If you want to get technical, HWND is a struct, I know)
08/13/2010 04:06 waldi_#55
could it be, because I have 64-bit and my friend 32 bit?
08/13/2010 04:23 clericxx#56
Well, I have 32-bit as well, so I suppose the reason it doesn't crash for you may be because you're on 64-bit. But, as I said, the solution is switching the type from long to IntPtr and it should work for both types of operating systems fine.
08/13/2010 04:31 waldi_#57
Quote:
Originally Posted by clericxx View Post
Well, I have 32-bit as well, so I suppose the reason it doesn't crash for you may be because you're on 64-bit. But, as I said, the solution is switching the type from long to IntPtr and it should work for both types of operating systems fine.
yes, it works on 64
and long doesn't worked on my 32-bit virtual maschine, so i think we have the solution, thanks (:
i will upload a new version tomorrow
08/13/2010 06:50 ikian#58
great ^^! thanks you alot cleric! i will wait for the new version +w+! and thanks waldi, for don't give up and try to fix it ^^!
08/13/2010 11:46 Illidansklinge#59
@waldi weisst du schon worran der Fehler liegt?
08/13/2010 13:04 critical1235#60
Iwie hab ich nwn overfflow, vlt is mein PC scheisse.