Hello everybody,
I am working at a little bigger project called the GHF (Gamehacking Foundation).
It is a (hopefully soon) big compilation of classes that are usefull for gamehacking (detours, memory writing, botting, etc...)
It is written in C++ with Visual Studio 2010 (because I want to make well designed classes, I could need some guys with a good programming style); it should be completly object oriented.
There are also a few little (easy to make) Makros and defines to make programming in general easier.
If you know at least the basics of object oriented programming in C++ (better is a good knowledge) and you are interested, it would be very nice, if you post here.
Atm, the GHF only consists of the GHF Base and a almost-done Detours class.
I know, some design decisions are not very good, but I had no better idea. So please, give me feedback
And I also know, that it is not commented very well, this will follow, too.
*/
#ifndef GHF_H
#define GHF_H
#if defined (_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "GHF_Detour.h"
#include "GHF_Process.h"
#endif
I hope, you will download the source and give me some feedback
For ex. instead of calling setHookType and getHookType, you would add a public variable that will call them, looks like this:
Code:
__declspec(property(get = getHookType, put = setHookType)) int HookType;
Where using the var as follows:
Code:
GHFHook.HookType = 1;
int Type = GHFHook.HookType;
Will call the get/put functions and return/update the private variables.
lol and where exactly is the sense?
i dont see any reason, why i should make a new variable, so the return goes over 3 points (variable -> function -> return)
and i didnt know, that the propperty keyword is also available in c++
Quote:
Provide facts please.
they provide access to the implementation
but i think, Detour is one of the situations, in which getters/setters are unavoidable. it is not really an implementation detail, but an important information for the user (how should i hook without access to the target?)
getters/setters are supposed to be replaced by methods that let the object do the work itself (at the website, the example is a GUI system and a getter called getAttribute (of course, if the drawing method is in the object, a getter is not necessary)), but a detour cant set the target itself.
lol and where exactly is the sense?
i dont see any reason, why i should make a new variable, so the return goes over 3 points (variable -> function -> return)
I'm not 100% sure about the mechanism but from what i learned is that the variable used is nothing but an image to the getters/setters, so it doesn't really go variable -> function -> private variable(the compiler kind of translates it to a function call, it's only used for increasing the readability of the code which is - according to my beliefs - vital.)
EDIT: Actually after reading the documentation, it is correct that any reference to a property is translated to a function call, reason why it can be used is 1 line above :P.
Quote:
Originally Posted by MrSm!th
and i didnt know, that the propperty keyword is also available in c++
It's only supported in MSVS.
Quote:
Originally Posted by MrSm!th
they provide access to the implementation
I don't really see why getters/setters shouldn't be used in this case, since using getters/setters would actually help a lot in this case, since you can simply change code implementation inside the getter/setter without worrying about other classes that might as well use the variables.
However when refreshing the private variable comes at expensive costs, using public variables would be the only solution, and setters would be merely for refreshing the variable.
Also I don't see the logic behind sticking to the rule and accept it as a holy rule that should be followed at all costs, people forget about the intentions behind this rule.
I'm not 100% sure about the mechanism but from what i learned is that the variable used is nothing but an image to the getters/setters, so it doesn't really go variable -> function -> private variable(the compiler kind of translates it to a function call, it's only used for increasing the readability of the code)
hm, ok, this is your opinion.
i find it more difficult to read
Quote:
I suppose only in MSVS, didn't have any luck with Dev-C++
ah ok
Quote:
I don't really see why getters/setters shouldn't be used in this case, since using getters/setters would actually help a lot in this case, since you can simply change code implementation inside the getter/setter without worrying about other classes that might as well use the variables.
However when refreshing the private variable comes at expensive costs, using public variables would be the only solution, and setters would be merely for refreshing the variable.
Also I don't see the logic behind sticking to the rule and accept it as a holy rule that should be followed at all costs, people forget about the intentions behind this rule.
That's what I said In this case, at least the setters are unavoidable!
hm, ok, this is your opinion.
i find it more difficult to read
I guess it is just a matter of opinions here since style isn't really affected .
Again, good luck with the project. I will be willing to help with anything i can help with.
You should use an enum for your hook types instead of those #define macros, one should avoid using macros if possible.
And your class design is somewhat wacky, do you think creating a class instance for every new hook is a good idea? Wouldn't it be a much better approach to create a singleton class that keeps all your hooks in a container?
And btw, the whole if defined MSVC stuff is pretty pointless since you're already using an #ifdefined macro to prevent multiple includes of your header.
You should use an enum for your hook types instead of those #define macros, one should avoid using macros if possible.
Yeah, thought that also
These defines were my first idea, in my new version, it is an enumaration.
Quote:
And your class design is somewhat wacky, do you think creating a class instance for every new hook is a good idea? Wouldn't it be a much better approach to create a singleton class that keeps all your hooks in a container?
I thought about that, too.
Maybe I will add this, first a GHF_Detour object should represent one hook.
Quote:
And btw, the whole if defined MSVC stuff is pretty pointless since you're already using an #ifdefined macro to prevent multiple includes of your header.
1. pragma once makes the compiler open the file only once (files with include guards are always opened), so the process of compilation takes less time
2. I tried to use Include Guards only already, but they didn't work.... I just read about that and it seems that it worked, but I had an error in reasoning and so it just didn't work like I had expected it.
But there is still reason 1
Hmm....maybe I will delete pragma once again, but this little thing is not very important atm.
Make sure that you can unhook without deleting the detours instructions. It annoys me that with ms detours you cannot remove a detour inside the detour because it removes the instructions.