Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the BUG that functions in intrin.h cannot be used even if it is i… #33

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/FindWdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ set(WDK_COMPILE_FLAGS
"/kernel" # create kernel mode binary
"/FIwarning.h" # disable warnings in WDK headers
"/FI${WDK_ADDITIONAL_FLAGS_FILE}" # include file to disable RTC
"/Oi" # enable intrinsic functions so that you can use functions like _disable or _enable
)

set(WDK_COMPILE_DEFINITIONS "WINNT=1")
Expand Down
3 changes: 2 additions & 1 deletion samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ add_subdirectory(MinifilterCppDriver)
add_subdirectory(WdmCppDriver)
add_subdirectory(WdmCppLib)
add_subdirectory(WdmDriver)
add_subdirectory(WdmLib)
add_subdirectory(WdmLib)
add_subdirectory(WdmIntrinsicFunctions)
4 changes: 4 additions & 0 deletions samples/WdmIntrinsicFunctions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wdk_add_driver(WdmIntrinsicFunctions
Main.cpp
)
target_link_libraries(WdmIntrinsicFunctions WdmCppLib)
25 changes: 25 additions & 0 deletions samples/WdmIntrinsicFunctions/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <wdm.h>
#include <intrin.h>

DRIVER_UNLOAD driverUnload;
VOID driverUnload(_In_ PDRIVER_OBJECT driverObject)
{
UNREFERENCED_PARAMETER(driverObject);

DbgPrint("Driver unloaded\n");
}

EXTERN_C NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT driverObject, _In_ PUNICODE_STRING registryPath)
{
UNREFERENCED_PARAMETER(registryPath);

DbgPrint("Driver loaded\n");

_disable(); //use intrinsic function
ULONG64 cr3 = __readcr3(); //use intrinsic function
_enable(); //use intrinsic function

DbgPrint("CR3: %p\n", cr3);
driverObject->DriverUnload = driverUnload;
return STATUS_SUCCESS;
}
Loading