RaMMicHaeL/minhook — pull request #3 by TsudaKageyu (2014-07-16 09:42:40+00:00)
Title: Changes for v1.3

**This pull request is provided for review. Not intended to be merged immediately.**

Major changes
---
- Rewrote in plain C to reduce the footprint and memory usage. (suggested by Andrey Unis)
- Simplified the overall code base to make it more readable and maintainable.
- Changed the license from 3-clause to 2-clause BSD License.

Background
---
This pull request is based on a suggestion by a user named Andrey Unis. He suggested to me to reduce the footprint and memory usage by rewriting MinHook in C. I found that his idea makes sense because the library is mainly used to modify existing processes. The smaller the better for that kind of use.
Additionally, I decided to take this chance to straighten out some issues I have been concerned. For example, overly complicated code (especially, ```trampoline.cpp``` which slows down creating hooks), vulnerable thread locks, lack of readability, etc.
Now I believe it is a success. It performs well. It's more compact, runs faster and consumes less memory than v1.2.2.

For example: Create and remove 500 hooks 100 times: Much faster!
v1.2.2 x86: 810ms, x64: 907ms
This ver. x86: 260ms, x64: 332ms

Enable and disable 500 hooks 100 times: Neither faster nor slower.
v1.2.2 x86: 1807ms, x64: 1725ms
This ver. x86: 1804ms, x64: 1766ms

I hooked a number of functions and did some multi-threaded torture tests. I think that it is as stable as v1.2.2 and it's time to review.

@RaMMicHaeL, you pointed out that some optimizations may spoil the performance, but I found out that some of them are good enough to apply.
Structure with bits: I don't know why but it's rather fast. (presumably, due to the amount of ```memmove```)
"Minimize Size" optimization: As far as I tested, it doesn't slows down the code.