ReactOS 0.4.16-dev-1946-g52006dd
wdfdriverentry.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS KMDF: driver initialization static library
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Main file
5 * COPYRIGHT: Copyright 2021 Max Korostil <mrmks04@yandex.ru>
6 */
7
8#include <ntddk.h>
9#include <windef.h>
10#include <fxldr.h>
11#include "wdf.h"
12
13
14#define WDFENTRY_TAG 'EFDW'
15
16// supplied by the driver this library is linked into
17extern
23
27{
28 .Size = sizeof(BindInfo),
29 .Component = L"KmdfLibrary",
30 .Version.Major = __WDF_MAJOR_VERSION,
31 .Version.Minor = __WDF_MINOR_VERSION,
32 .Version.Build = __WDF_BUILD_NUMBER,
33 .FuncCount = WdfFunctionTableNumEntries,
34 .FuncTable = (WDFFUNC *)&WdfFunctions
35};
38
39static
40VOID
42{
44}
45
46VOID
50{
51 if (pOriginalUnload != NULL)
52 {
54 }
56}
57
63{
65
66 if (DriverObject == NULL)
67 {
69 }
70
71 // Copy registry path
76
78 {
80 }
81
83
84 // Bind wdf driver to framework
87 &BindInfo,
89
90 if (!NT_SUCCESS(status))
91 {
92 return status;
93 }
94
95 // Call original entry point
97 if (!NT_SUCCESS(status))
98 {
100 return status;
101 }
102
104 {
105 pOriginalUnload = DriverObject->DriverUnload;
106 DriverObject->DriverUnload = FxDriverUnload;
107 }
108 return STATUS_SUCCESS;
109}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define L(x)
Definition: resources.c:13
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define _In_
Definition: no_sal2.h:158
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define UNICODE_NULL
#define STATUS_SUCCESS
Definition: shellext.h:65
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG Size
Definition: fxldr.h:131
BOOLEAN DisplaceDriverUnload
Definition: wdfglobals.h:70
Definition: ps.c:97
#define NTAPI
Definition: typedefs.h:36
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID(NTAPI * WDFFUNC)(VOID)
Definition: wdf.h:68
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
const WDFFUNC * WdfFunctions
#define WDFENTRY_TAG
NTSTATUS NTAPI FxDriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
PWDF_DRIVER_GLOBALS WdfDriverGlobals
UNICODE_STRING gRegistryPath
PDRIVER_UNLOAD pOriginalUnload
static VOID FxDriverUnloadCommon(VOID)
WDF_BIND_INFO BindInfo
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE _In_ USHORT _In_ USHORT Version
Definition: wdffdo.h:469
@ WdfFunctionTableNumEntries
Definition: wdffuncenum.h:469
NTSTATUS NTAPI WdfVersionBind(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath, _Inout_ PWDF_BIND_INFO BindInfo, _Out_ PWDF_COMPONENT_GLOBALS *ComponentGlobals)
Bind client driver with framework.
Definition: wdfldr.c:411
NTSTATUS NTAPI WdfVersionUnbind(_In_ PUNICODE_STRING RegistryPath, _In_ PWDF_BIND_INFO BindInfo, _In_ PWDF_COMPONENT_GLOBALS ComponentGlobals)
Unbind client driver from framework.
Definition: wdfldr.c:519
DRIVER_UNLOAD * PDRIVER_UNLOAD
Definition: iotypes.h:2255
_In_ ULONG Component
Definition: potypes.h:499