Skip to content
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
12 changes: 0 additions & 12 deletions Dmf/Framework/DmfContainer.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ Return Value:
}
#pragma code_seg()

#pragma code_seg("PAGE")
_Use_decl_annotations_
NTSTATUS
DmfContainerEvtDeviceSelfManagedIoSuspend(
Expand All @@ -823,8 +822,6 @@ Return Value:

FuncEntry(DMF_TRACE);

PAGED_CODE();

dmfDeviceContext = DmfDeviceContextGet(Device);
DmfAssert(dmfDeviceContext != NULL);

Expand All @@ -836,9 +833,7 @@ Return Value:

return ntStatus;
}
#pragma code_seg()

#pragma code_seg("PAGE")
_Use_decl_annotations_
NTSTATUS
DmfContainerEvtDeviceSelfManagedIoRestart(
Expand All @@ -865,8 +860,6 @@ Return Value:

FuncEntry(DMF_TRACE);

PAGED_CODE();

dmfDeviceContext = DmfDeviceContextGet(Device);
DmfAssert(dmfDeviceContext != NULL);

Expand All @@ -878,9 +871,7 @@ Return Value:

return ntStatus;
}
#pragma code_seg()

#pragma code_seg("PAGE")
_Use_decl_annotations_
VOID
DmfContainerEvtDeviceSurpriseRemoval(
Expand All @@ -906,8 +897,6 @@ Return Value:

FuncEntry(DMF_TRACE);

PAGED_CODE();

dmfDeviceContext = DmfDeviceContextGet(Device);
DmfAssert(dmfDeviceContext != NULL);

Expand All @@ -917,7 +906,6 @@ Return Value:

FuncExitVoid(DMF_TRACE);
}
#pragma code_seg()

#pragma code_seg("PAGE")
_Use_decl_annotations_
Expand Down
88 changes: 16 additions & 72 deletions Dmf/Framework/DmfDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,16 @@ typedef struct _DMF_PORTABLE_RUNDOWN
#endif // !defined(DMF_USER_MODE)
} DMF_PORTABLE_RUNDOWN_REF;

// Definitions used to determine OS version to determine
// availability of some OS features.
//
#define DMF_VERSIONCHECK_BUILD_NUMBER_RS2 15063
#define DMF_VERSIONCHECK_BUILD_NUMBER_RS3 16299
#define DMF_VERSIONCHECK_BUILD_NUMBER_RS4 17134
#define DMF_VERSIONCHECK_BUILD_NUMBER_RS5 17763
#define DMF_VERSIONCHECK_BUILD_NUMBER_19H1 18362
#define DMF_VERSIONCHECK_BUILD_NUMBER_20H1 19041

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Portable_EventCreate(
Expand Down Expand Up @@ -1362,6 +1372,12 @@ DMF_Portable_Rundown_Completed(
_Inout_ DMF_PORTABLE_RUNDOWN_REF* RundownRef
);

BOOLEAN
DMF_Portable_VersionCheck(
_In_ ULONG MinimumOsVersion,
_Out_ BOOLEAN* IsOsEqualOrGreater
);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// "Invoke" API prototypes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1466,78 +1482,6 @@ DMF_Utility_LogEmitString(
...
);

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Utility_EventLogEntryWriteDriverObject(
_In_ PDRIVER_OBJECT DriverObject,
_In_ NTSTATUS ErrorCode,
_In_ NTSTATUS FinalNtStatus,
_In_ ULONG UniqueId,
_In_ ULONG TextLength,
_In_opt_ PCWSTR Text,
_In_ INT NumberOfFormatStrings,
_In_opt_ PWCHAR* FormatStrings,
_In_ INT NumberOfInsertionStrings,
...
);

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Utility_EventLogEntryWriteDriver(
_In_ WDFDRIVER Driver,
_In_ NTSTATUS ErrorCode,
_In_ NTSTATUS Status,
_In_ ULONG UniqueId,
_In_ ULONG TextLength,
_In_opt_ PCWSTR Text,
_In_ INT NumberOfFormatStrings,
_In_opt_ PWCHAR* FormatStrings,
_In_ INT NumberOfInsertionStrings,
...
);

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Utility_EventLogEntryWriteDevice(
_In_ WDFDEVICE Device,
_In_ NTSTATUS ErrorCode,
_In_ NTSTATUS Status,
_In_ ULONG UniqueId,
_In_ ULONG TextLength,
_In_opt_ PCWSTR Text,
_In_ INT NumberOfFormatStrings,
_In_opt_ PWCHAR* FormatStrings,
_In_ INT NumberOfInsertionStrings,
...
);

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Utility_EventLogEntryWriteDmfModule(
_In_ DMFMODULE DmfModule,
_In_ NTSTATUS ErrorCode,
_In_ NTSTATUS Status,
_In_ ULONG UniqueId,
_In_ ULONG TextLength,
_In_opt_ PCWSTR Text,
_In_ INT NumberOfFormatStrings,
_In_opt_ PWCHAR* FormatStrings,
_In_ INT NumberOfInsertionStrings,
...
);

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Utility_EventLogEntryWriteUserMode(
_In_ PWSTR Provider,
_In_ WORD EventType,
_In_ DWORD EventID,
_In_ INT NumberOfFormatStrings,
_In_opt_ PWCHAR* FormatStrings,
_In_ INT NumberOfInsertionStrings,
...
);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// LIST_ENTRY functions for User-Mode. (These are copied as-is from Wdm.h.
Expand Down
20 changes: 6 additions & 14 deletions Dmf/Framework/DmfModuleCollection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,6 @@ Return Value:
}
#pragma code_seg()

#pragma code_seg("PAGE")
_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
DMF_ModuleCollectionSelfManagedIoSuspend(
Expand All @@ -1743,8 +1742,6 @@ Return Value:
{
NTSTATUS ntStatus;

PAGED_CODE();

FuncEntryArguments(DMF_TRACE, "DmfCollection=0x%p", DmfCollection);

DMF_MODULE_COLLECTION* moduleCollectionHandle = DMF_CollectionToHandle(DmfCollection);
Expand Down Expand Up @@ -1772,9 +1769,7 @@ Return Value:

return ntStatus;
}
#pragma code_seg()

#pragma code_seg("PAGE")
_IRQL_requires_max_(PASSIVE_LEVEL)
NTSTATUS
DMF_ModuleCollectionSelfManagedIoRestart(
Expand All @@ -1800,8 +1795,6 @@ Return Value:
{
NTSTATUS ntStatus;

PAGED_CODE();

FuncEntryArguments(DMF_TRACE, "DmfCollection=0x%p", DmfCollection);

DMF_MODULE_COLLECTION* moduleCollectionHandle = DMF_CollectionToHandle(DmfCollection);
Expand Down Expand Up @@ -1829,9 +1822,7 @@ Return Value:

return ntStatus;
}
#pragma code_seg()

#pragma code_seg("PAGE")
_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_ModuleCollectionSurpriseRemoval(
Expand All @@ -1854,8 +1845,6 @@ Return Value:

--*/
{
PAGED_CODE();

FuncEntryArguments(DMF_TRACE, "DmfCollection=0x%p", DmfCollection);

DMF_MODULE_COLLECTION* moduleCollectionHandle = DMF_CollectionToHandle(DmfCollection);
Expand All @@ -1880,7 +1869,6 @@ Return Value:

FuncExit(DMF_TRACE, "DmfCollection=0x%p", DmfCollection);
}
#pragma code_seg()

#pragma code_seg("PAGE")
_IRQL_requires_max_(PASSIVE_LEVEL)
Expand Down Expand Up @@ -3906,6 +3894,11 @@ Return Value:
goto Exit;
}

// Store the collection in Container Context.
// Do this as soon as possible because DmfCollection may be needed during DMF_ModuleCollectionPostCreate().
//
dmfDeviceContext->DmfCollection = dmfCollection;

// Open or register for notification for OPEN_Create or NOTIFY_Create Modules.
//
ntStatus = DMF_ModuleCollectionPostCreate(&moduleCollectionConfig,
Expand All @@ -3916,9 +3909,8 @@ Return Value:
goto Exit;
}

// Store the collection in Container Context.
// Remember if the Client supports DeviceAdd.
//
dmfDeviceContext->DmfCollection = dmfCollection;
dmfDeviceContext->ClientImplementsEvtWdfDriverDeviceAdd = DMF_DmfDeviceInitClientImplementsDeviceAdd(dmfDeviceInit);

// Store information needed to automatically call DMF_Invoke_DeviceCallbacksDestroy() when the
Expand Down
98 changes: 98 additions & 0 deletions Dmf/Framework/DmfPortable.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Module Name:
#include "DmfPortable.tmh"
#endif

#define MAJOR_VERSION_WINDOWS_10 10
#define MINOR_VERSION_WINDOWS_10 0

_IRQL_requires_max_(PASSIVE_LEVEL)
VOID
DMF_Portable_EventCreate(
Expand Down Expand Up @@ -786,5 +789,100 @@ Return Value:
#endif // defined(DMF_KERNEL_MODE)
}

BOOLEAN
DMF_Portable_VersionCheck(
_In_ ULONG MinimumOsVersion,
_Out_ BOOLEAN *IsOsEqualOrGreater
)
/*++

Routine Description:

Read the Windows 10 OS version to check for feature availability.

Arguments:

MinimumOsVersion - The minimum OS version to check for.
IsOsEqualOrGreater - Flag to indicate if the running OS is greater
than or equal to the minimum passed in.

Return Value:

TRUE if able to read the OS version.

--*/
{
BOOLEAN returnStatus;
static ULONG s_OsBuildNumber = 0;

returnStatus = FALSE;
*IsOsEqualOrGreater = FALSE;

if (s_OsBuildNumber == 0)
{
#if defined(DMF_KERNEL_MODE)
NTSTATUS ntStatus;
RTL_OSVERSIONINFOW versionInfo;

versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
ntStatus = RtlGetVersion(&versionInfo);
if (NT_SUCCESS(ntStatus))
{
if (versionInfo.dwMajorVersion >= MAJOR_VERSION_WINDOWS_10 &&
versionInfo.dwMinorVersion == MINOR_VERSION_WINDOWS_10)
{
s_OsBuildNumber = versionInfo.dwBuildNumber;
}
}
#else
OSVERSIONINFOEXW versionInfo = { 0 };
LONG status = 0;

typedef LONG(WINAPI* PFN_RTL_GET_VERSION)(OSVERSIONINFOEXW*);
PFN_RTL_GET_VERSION functionRtlGetVersion = NULL;

versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);

HMODULE ntDll = GetModuleHandleW(L"ntdll.dll");
if (ntDll != NULL)
{
functionRtlGetVersion = (PFN_RTL_GET_VERSION)GetProcAddress(ntDll,
"RtlGetVersion");
if (functionRtlGetVersion)
{
status = functionRtlGetVersion(&versionInfo);
if (status == S_OK)
{
// Expecting major version 10 and minor version 0.
// Otherwise, unknown or unsupported os version.
//
if (versionInfo.dwMajorVersion >= MAJOR_VERSION_WINDOWS_10 &&
versionInfo.dwMinorVersion == MINOR_VERSION_WINDOWS_10)
{
// Everything worked, so store the os build number.
//
s_OsBuildNumber = versionInfo.dwBuildNumber;
}
}
}
}
#endif // defined(DMF_KERNEL_MODE)
}

// 0 is an unsupported OS build version. It is overloaded here to
// indicate an error in retrieving the OS version.
//
if (s_OsBuildNumber != 0)
{
returnStatus = TRUE;
if (s_OsBuildNumber >= MinimumOsVersion)
{
*IsOsEqualOrGreater = TRUE;
}
}

return returnStatus;
}

// eof: DmfPortable.c
//
Loading