HoShiMin / HookLib

The functions interception library written on pure C and NativeAPI with UserMode and KernelMode support
MIT License
727 stars 152 forks source link

include <windows.h> to fix undefined identifier #8

Closed rumia-san closed 4 years ago

rumia-san commented 4 years ago

Hi, Александр, I'm using your library in my code. I think it is powerful and easy to use : )

But I found that the HookLib.h uses macros defined in windows headers such as HMODULE, PVOID, etc. without #include <windows.h>

In this case, If I #include HookLib.h in my project, the VS intellisense will complains undefined identifier. 2

If I #include "HookLib.h" before #include <windows.h>, the compiler will complains "E0020 undefined identifier" as well.

Thus, I think it would be better if we add #include <windows.h> to HookLib.h

Best regards, Rumia

HoShiMin commented 4 years ago

Hm, are you sure it would be a good idea to include it in header?

In almost all cases it will be something like this:

include

...

include

And what about kernel? There are no minwindef.h. Should we include wdm.h? Or ntddk, or something else? It's quiet questionable... What are you think about it?

rumia-san commented 4 years ago

Oh, I'm sorry for that I'm just using the user mode and I have no knowledge of the kernel mode programming :facepalm: perhaps we could use conditional compile such as

#ifndef _KERNEL_MODE
#include <windef.h>
#else
#include <wdm.h>
#endif

I'm sorry I have never touched kernel mode programming, thus I am unable to give further suggestions.., What is your opinion?

HoShiMin commented 4 years ago

@rumia-san, it's a variant, but I think it would be better to avoid include windef.h/windows.h/wdm.h in header and include them in place we're including HookLib.h (user should include it himself). And in many cases these headers will be already included. And this approach helps us to avoid multiple headers inclusion. Wouldn't it better?

rumia-san commented 4 years ago

Yeah, There is no concern for me. Thanks for replying .I'm closing this PR.