Skip to content

Commit

Permalink
ARM64 support (#32)
Browse files Browse the repository at this point in the history
* Add ARM64 support (#31)

* 1. ARM64 "WDK_COMPILE_DEFINITIONS", same as VS2022
2. Add "Test Sign" to prevent "StartService FAILED 577"

* no mandatory signatures in test mode

---------

Co-authored-by: Sergey Podobry <sergey.podobry@gmail.com>
  • Loading branch information
nblog and SergiusTheBest authored Sep 6, 2024
1 parent 79a45e7 commit 6aaaaf4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/build32
/build64
/samples/build
/samples/out
25 changes: 19 additions & 6 deletions cmake/FindWdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WDK REQUIRED_VARS WDK_LATEST_NTDDK_FILE)

if (NOT WDK_LATEST_NTDDK_FILE)
if(NOT WDK_LATEST_NTDDK_FILE)
return()
endif()

Expand Down Expand Up @@ -105,8 +105,11 @@ set(WDK_COMPILE_DEFINITIONS_DEBUG "MSC_NOOPT;DEPRECATE_DDK_FUNCTIONS=1;DBG=1")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
list(APPEND WDK_COMPILE_DEFINITIONS "_X86_=1;i386=1;STD_CALL")
set(WDK_PLATFORM "x86")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64")
list(APPEND WDK_COMPILE_DEFINITIONS "_ARM64_;ARM64;_USE_DECLSPECS_FOR_SAL=1;STD_CALL")
set(WDK_PLATFORM "arm64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND WDK_COMPILE_DEFINITIONS "_WIN64;_AMD64_;AMD64")
list(APPEND WDK_COMPILE_DEFINITIONS "_AMD64_;AMD64")
set(WDK_PLATFORM "x64")
else()
message(FATAL_ERROR "Unsupported architecture")
Expand All @@ -131,7 +134,7 @@ foreach(LIBRARY IN LISTS WDK_LIBRARIES)
get_filename_component(LIBRARY_NAME ${LIBRARY} NAME_WE)
string(TOUPPER ${LIBRARY_NAME} LIBRARY_NAME)
add_library(WDK::${LIBRARY_NAME} INTERFACE IMPORTED)
set_property(TARGET WDK::${LIBRARY_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LIBRARY})
set_property(TARGET WDK::${LIBRARY_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LIBRARY})
endforeach(LIBRARY)
unset(WDK_LIBRARIES)

Expand All @@ -156,7 +159,17 @@ function(wdk_add_driver _target)
"${WDK_ROOT}/Include/${WDK_INC_VERSION}/km/crt"
)

target_link_libraries(${_target} WDK::NTOSKRNL WDK::HAL WDK::BUFFEROVERFLOWK WDK::WMILIB)
target_link_libraries(${_target} WDK::NTOSKRNL WDK::HAL WDK::WMILIB)

if(WDK::BUFFEROVERFLOWK)
target_link_libraries(${_target} WDK::BUFFEROVERFLOWK) # to support Windows 7 and Vista
else()
target_link_libraries(${_target} WDK::BUFFEROVERFLOWFASTFAILK)
endif()

if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64")
target_link_libraries(${_target} "arm64rt.lib")
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries(${_target} WDK::MEMCMP)
Expand All @@ -171,13 +184,13 @@ function(wdk_add_driver _target)

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:FxDriverEntry@8")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:FxDriverEntry")
endif()
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:GsDriverEntry@8")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:GsDriverEntry")
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion samples/KmdfCppDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ wdk_add_driver(KmdfCppDriver
KMDF 1.15
Main.cpp
)
target_link_libraries(KmdfCppDriver KmdfCppLib)
target_link_libraries(KmdfCppDriver KmdfCppLib)
2 changes: 1 addition & 1 deletion samples/MinifilterCppDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wdk_add_driver(MinifilterCppDriver
Main.cpp
)
target_link_libraries(MinifilterCppDriver WDK::FLTMGR)
target_link_libraries(MinifilterCppDriver WDK::FLTMGR)
2 changes: 1 addition & 1 deletion samples/WdmCppDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wdk_add_driver(WdmCppDriver
Main.cpp
)
target_link_libraries(WdmCppDriver WdmCppLib)
target_link_libraries(WdmCppDriver WdmCppLib)
2 changes: 1 addition & 1 deletion samples/WdmDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wdk_add_driver(WdmDriver
Main.c
)
target_link_libraries(WdmDriver WdmLib)
target_link_libraries(WdmDriver WdmLib)

0 comments on commit 6aaaaf4

Please sign in to comment.