A BYTE is (usually) a typedef for unsigned char.

That code shouldn't compile, there is an extra parenthesis in your call to Detour. If you fix that, it compiles and runs without a crash, so your problem is probably in the unrelated junk.

Identifiers that start with an underscore followed by a capital letter are reserved, so you shouldn't be putting the underscore at the front of your variable names in case they clash with implementation macros. Also, main must specify int as its return value, not bool.