HookAPI crashes without calling InitializeMadCHook
HookAPI crashes without calling InitializeMadCHook
Is it possible to just fail and return FALSE instead of producing Access Violation when HookAPI is called without InitializeMadCHook ?
Re: HookAPI crashes without calling InitializeMadCHook
It's difficult, especially when using the Delphi LIB, because if you don't call InitializeMadCHook(), the whole Delphi RTL is not even initialized at all.
It would not be difficult to make HookAPI() not crash, it's just one API, but I'd have to add the same check to each and every exported function, and in Delphi that's a lot more than madCHook.h contains. So a lot of work and added code, just to protect against incorrect usage? Not sure if I like that...
It would not be difficult to make HookAPI() not crash, it's just one API, but I'd have to add the same check to each and every exported function, and in Delphi that's a lot more than madCHook.h contains. So a lot of work and added code, just to protect against incorrect usage? Not sure if I like that...
Re: HookAPI crashes without calling InitializeMadCHook
You can add it inline in the header if you don't want to touch Delphi source.
I understand it is incorrect usage, but I spent several minutes trying to understand why I have crash in some irrelevant address.
I understand it is incorrect usage, but I spent several minutes trying to understand why I have crash in some irrelevant address.
Re: HookAPI crashes without calling InitializeMadCHook
Well, FWIW, I always recommend to use one of the demo projects as the starting point for your own projects. That way you already have the basic framework set up correctly, including compiler and linker settings etc.
Re: HookAPI crashes without calling InitializeMadCHook
This discussion goes to direction who is responsible to check the caller or the callee.
My opinion that callee will do as much checks as possible, while you say it is not really necessary.
I already made a class which does this automatically, so I won't forget
Btw, perhaps you need some C++ API on top of your header which will take care of all this initializations.
Is it something that you would accept as patch ?
My opinion that callee will do as much checks as possible, while you say it is not really necessary.
I already made a class which does this automatically, so I won't forget
Btw, perhaps you need some C++ API on top of your header which will take care of all this initializations.
Is it something that you would accept as patch ?
Re: HookAPI crashes without calling InitializeMadCHook
I'm not sure if I'd like a C++ API. I like a simple and short API. And if I distribute your C++ API, I also become responsible for maintaining it and fixing bugs in it. And if I add or change APIs, I also have to do all that in the C++ API files in addition to the current C header.
Anyway, how complicated is your C++ API? Does it fit into a single e.g. *.h file?
Anyway, how complicated is your C++ API? Does it fit into a single e.g. *.h file?
Re: HookAPI crashes without calling InitializeMadCHook
Currently I removed all wrappers since the code is very simple.
Maybe in the future I'll do wrapping which will initialize madCodeHook automatically on first call if wasn't initialized before or smth like that.
Maybe in the future I'll do wrapping which will initialize madCodeHook automatically on first call if wasn't initialized before or smth like that.