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
Initial Kernel Shim Engine groundwork #2872
Open
learn-more
wants to merge
6
commits into
reactos:master
Choose a base branch
from
learn-more:kshim
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bbd5c13
[APPCOMPAT] Add some tags required for the drvmain database
learn-more cf65694
[XML2SDB] Simplify the code, add support for drvmain database
learn-more 1dc58d2
[SDK] Add the drvmain driver compatibility database
learn-more 36e7b86
[NTOSKRNL][NDK] Export InitSafeBootMode
learn-more 23cf0bf
[NTOSKRNL] Add initial skeleton for KSE
hpoussin 5fc930c
[NTOS:KSE] Add DriverScope shim
hpoussin File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
|
||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sysmain.sdb | ||
COMMAND native-xml2sdb -i ${CMAKE_CURRENT_SOURCE_DIR}/sysmain.xml -o ${CMAKE_CURRENT_BINARY_DIR}/sysmain.sdb | ||
set(SYSMAIN_SDB ${CMAKE_CURRENT_BINARY_DIR}/sysmain.sdb) | ||
set(DRVMAIN_SDB ${CMAKE_CURRENT_BINARY_DIR}/drvmain.sdb) | ||
|
||
add_custom_command(OUTPUT ${SYSMAIN_SDB} | ||
COMMAND native-xml2sdb -i ${CMAKE_CURRENT_SOURCE_DIR}/sysmain.xml -o ${SYSMAIN_SDB} | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sysmain.xml native-xml2sdb) | ||
|
||
add_custom_target(compatdb DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sysmain.sdb) | ||
add_cd_file(TARGET compatdb FILE ${CMAKE_CURRENT_BINARY_DIR}/sysmain.sdb DESTINATION reactos/AppPatch FOR all) | ||
|
||
add_custom_command(OUTPUT ${DRVMAIN_SDB} | ||
COMMAND native-xml2sdb -i ${CMAKE_CURRENT_SOURCE_DIR}/drvmain.xml -o ${DRVMAIN_SDB} | ||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/drvmain.xml native-xml2sdb) | ||
|
||
add_custom_target(compatdb DEPENDS | ||
${SYSMAIN_SDB} | ||
${DRVMAIN_SDB} | ||
) | ||
add_cd_file(TARGET compatdb FILE ${SYSMAIN_SDB} ${DRVMAIN_SDB} DESTINATION reactos/AppPatch FOR all) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<SDB> | ||
<DATABASE> | ||
<NAME>ReactOS driver compatibility database</NAME> | ||
<OS_PLATFORM >1</OS_PLATFORM><!-- 2 --> | ||
<DATABASE_ID>{f9ab2228-3312-4a73-b6f9-936d70e112ef}</DATABASE_ID> | ||
|
||
<!-- APPHELP blocking is not supported yet! --> | ||
<EXE NAME="something.sys" APP_NAME="BuggyDriver" VENDOR="ACME"> | ||
<APPHELP>...</APPHELP> | ||
<MATCHING_FILE NAME="*" /> | ||
</EXE> | ||
|
||
<!-- --> | ||
<KDRIVER NAME="beep.sys" APP_NAME="Beep driver" VENDOR="ACME"> | ||
<KSHIM_REF NAME="SkipDriverUnload" /> | ||
</KDRIVER> | ||
|
||
<!-- KDEVICE is not supported yet! --> | ||
<KDEVICE NAME="USB:USB\VID_0000&PID_0000"> | ||
<FLAG NAME="USB"> | ||
<FLAG_MASK_KERNEL>1024</FLAG_MASK_KERNEL> | ||
</FLAG> | ||
</KDEVICE> | ||
|
||
<KSHIM NAME="driverscope"> | ||
<MODULE>NT kernel component</MODULE> | ||
</KSHIM> | ||
|
||
<KSHIM NAME="KmWin7VersionLie"> | ||
<MODULE>NT kernel component</MODULE> | ||
</KSHIM> | ||
|
||
<KSHIM NAME="KmWin8VersionLie"> | ||
<MODULE>NT kernel component</MODULE> | ||
</KSHIM> | ||
|
||
<KSHIM NAME="KmWin81VersionLie"> | ||
<MODULE>NT kernel component</MODULE> | ||
</KSHIM> | ||
|
||
<KSHIM NAME="SkipDriverUnload"> | ||
<MODULE>NT kernel component</MODULE> | ||
</KSHIM> | ||
</DATABASE> | ||
</SDB> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
* PROJECT: ReactOS Kernel | ||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) | ||
* PURPOSE: Kernel Shim Engine types | ||
* COPYRIGHT: Copyright 2020 Herv� Poussineau (hpoussin@reactos.org) | ||
* COPYRIGHT: Copyright 2020 Mark Jansen (mark.jansen@reactos.org) | ||
*/ | ||
|
||
|
||
#define KseHookFunction 0 | ||
#define KseHookIRPCallback 1 | ||
#define KseHookInvalid 2 | ||
|
||
#define KseHookCallbackDriverInit 1 | ||
#define KseHookCallbackDriverStartIo 2 | ||
#define KseHookCallbackDriverUnload 3 | ||
#define KseHookCallbackAddDevice 4 | ||
#define KseHookCallbackMajorFunction 100 | ||
|
||
typedef struct _KSE_HOOK | ||
{ | ||
ULONG Type; | ||
union | ||
{ | ||
PCHAR FunctionName; // if Type == KseHookFunction | ||
ULONG CallbackId; // if Type == KseHookIRPCallback, KseHookCallback.. | ||
}; | ||
PVOID HookFunction; | ||
PVOID OriginalFunction; // if Type == KseHookFunction | ||
} KSE_HOOK, *PKSE_HOOK; | ||
|
||
|
||
#define KseCollectionNtExport 0 | ||
#define KseCollectionHalExport 1 | ||
#define KseCollectionDriverExport 2 | ||
#define KseCollectionCallback 3 | ||
#define KseCollectionInvalid 4 | ||
|
||
typedef struct _KSE_HOOK_COLLECTION | ||
{ | ||
ULONG Type; | ||
PWCHAR ExportDriverName; // if Type == KseCollectionDriverExport | ||
PKSE_HOOK HookArray; | ||
} KSE_HOOK_COLLECTION, *PKSE_HOOK_COLLECTION; | ||
|
||
|
||
typedef VOID | ||
(NTAPI *PKSE_HOOK_DRIVER_TARGETED)( | ||
IN PUNICODE_STRING BaseName, | ||
IN PVOID BaseAddress, | ||
IN ULONG SizeOfImage, | ||
IN ULONG TimeDateStamp, | ||
IN ULONG CheckSum); | ||
|
||
typedef VOID | ||
(NTAPI *PKSE_HOOK_DRIVER_UNTARGETED)( | ||
IN PVOID BaseAddress); | ||
|
||
|
||
typedef struct _KSE_DRIVER_IO_CALLBACKS | ||
{ | ||
PDRIVER_INITIALIZE DriverInit; | ||
PDRIVER_STARTIO DriverStartIo; | ||
PDRIVER_UNLOAD DriverUnload; | ||
PDRIVER_ADD_DEVICE AddDevice; | ||
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; | ||
} KSE_DRIVER_IO_CALLBACKS, *PKSE_DRIVER_IO_CALLBACKS; | ||
|
||
|
||
typedef PKSE_DRIVER_IO_CALLBACKS | ||
(NTAPI KSE_GET_IO_CALLBACKS)( | ||
IN PDRIVER_OBJECT DriverObject); | ||
typedef KSE_GET_IO_CALLBACKS *PKSE_GET_IO_CALLBACKS; | ||
|
||
typedef NTSTATUS | ||
(NTAPI KSE_SET_COMPLETION_HOOK)( | ||
IN PDEVICE_OBJECT DeviceObject, | ||
IN PIRP Irp, | ||
IN PIO_COMPLETION_ROUTINE CompletionRoutine, | ||
IN PVOID Context); | ||
typedef KSE_SET_COMPLETION_HOOK *PKSE_SET_COMPLETION_HOOK; | ||
|
||
|
||
typedef struct _KSE_CALLBACK_ROUTINES | ||
{ | ||
PKSE_GET_IO_CALLBACKS KseGetIoCallbacksRoutine; | ||
PKSE_SET_COMPLETION_HOOK KseSetCompletionHookRoutine; | ||
} KSE_CALLBACK_ROUTINES, *PKSE_CALLBACK_ROUTINES; | ||
|
||
typedef struct _KSE_SHIM | ||
{ | ||
ULONG Size; | ||
const GUID* ShimGuid; | ||
PWCHAR ShimName; | ||
PKSE_CALLBACK_ROUTINES KseCallbackRoutines; | ||
PKSE_HOOK_DRIVER_TARGETED ShimmedDriverTargetedNotification; | ||
PKSE_HOOK_DRIVER_UNTARGETED ShimmedDriverUntargetedNotification; | ||
PKSE_HOOK_COLLECTION HookCollectionsArray; | ||
} *PKSE_SHIM, KSE_SHIM; | ||
|
||
|
||
/* Exported functions */ | ||
//KseQueryDeviceData | ||
//KseQueryDeviceDataList | ||
//KseQueryDeviceFlags | ||
//KseSetDeviceFlags | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseRegisterShim( | ||
IN PKSE_SHIM Shim, | ||
IN PVOID Unknown, | ||
IN ULONG Flags); | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseRegisterShimEx( | ||
IN PKSE_SHIM Shim, | ||
IN PVOID Unknown, | ||
IN ULONG Flags, | ||
IN PVOID DriverObject OPTIONAL); | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseUnregisterShim( | ||
IN PKSE_SHIM Shim, | ||
IN PVOID Unknown1, | ||
IN PVOID Unknown2); | ||
|
||
/******************************************************* PRIVATE STUFF *****************************************/ | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseInitialize( | ||
IN ULONG BootPhase, | ||
IN PLOADER_PARAMETER_BLOCK LoaderBlock); | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseShimDriverIoCallbacks( | ||
IN PDRIVER_OBJECT DriverObject); | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseDriverLoadImage( | ||
IN PLDR_DATA_TABLE_ENTRY LdrEntry); | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseVersionLieInitialize(VOID); | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseDriverScopeInitialize(VOID); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* PROJECT: ReactOS Kernel | ||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) | ||
* PURPOSE: KSE 'DriverScope' shim implementation | ||
* COPYRIGHT: Copyright 2020 Herv� Poussineau (hpoussin@reactos.org) | ||
*/ | ||
|
||
#include <ntoskrnl.h> | ||
|
||
//#define NDEBUG | ||
#include <debug.h> | ||
|
||
NTSTATUS | ||
NTAPI | ||
KseDriverScopeInitialize() | ||
{ | ||
UNIMPLEMENTED_ONCE; | ||
|
||
return STATUS_SUCCESS; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use enums for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly following existing style