2023-10-20 04:36:34 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2024-02-01 06:16:31 +00:00
|
|
|
* Copyright © 2017-2024 The Looking Glass Authors
|
2023-10-20 04:36:34 +00:00
|
|
|
* https://looking-glass.io
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2023-04-09 02:16:33 +00:00
|
|
|
#include "driver.h"
|
|
|
|
#include "driver.tmh"
|
|
|
|
|
2023-04-10 04:02:47 +00:00
|
|
|
#include "CPlatformInfo.h"
|
|
|
|
|
2023-04-09 02:16:33 +00:00
|
|
|
NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
|
|
|
|
{
|
|
|
|
WDF_DRIVER_CONFIG config;
|
|
|
|
NTSTATUS status;
|
|
|
|
WDF_OBJECT_ATTRIBUTES attributes;
|
|
|
|
|
|
|
|
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
|
|
|
|
WPP_INIT_TRACING(MYDRIVER_TRACING_ID);
|
|
|
|
#else
|
|
|
|
WPP_INIT_TRACING(DriverObject, RegistryPath);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
|
|
|
|
|
|
|
|
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
|
|
|
|
attributes.EvtCleanupCallback = LGIddEvtDriverContextCleanup;
|
|
|
|
WDF_DRIVER_CONFIG_INIT(&config, LGIddEvtDeviceAdd);
|
|
|
|
|
2023-04-10 04:02:47 +00:00
|
|
|
CPlatformInfo::Init();
|
2023-04-09 02:16:33 +00:00
|
|
|
status = WdfDriverCreate(DriverObject, RegistryPath, &attributes, &config, WDF_NO_HANDLE);
|
|
|
|
if (!NT_SUCCESS(status))
|
|
|
|
{
|
|
|
|
TraceEvents(TRACE_LEVEL_ERROR, TRACE_DRIVER, "WdfDriverCreate failed %!STATUS!", status);
|
|
|
|
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
|
|
|
|
WPP_CLEANUP();
|
|
|
|
#else
|
|
|
|
WPP_CLEANUP(DriverObject);
|
|
|
|
#endif
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit");
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS LGIddEvtDeviceAdd(_In_ WDFDRIVER Driver, _Inout_ PWDFDEVICE_INIT DeviceInit)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
UNREFERENCED_PARAMETER(Driver);
|
|
|
|
|
|
|
|
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
|
|
|
|
status = LGIddCreateDevice(DeviceInit);
|
|
|
|
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit");
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID LGIddEvtDriverContextCleanup(_In_ WDFOBJECT DriverObject)
|
|
|
|
{
|
|
|
|
UNREFERENCED_PARAMETER(DriverObject);
|
|
|
|
|
|
|
|
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
|
|
|
|
|
|
|
|
#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0
|
|
|
|
WPP_CLEANUP();
|
|
|
|
#else
|
|
|
|
WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject));
|
|
|
|
#endif
|
|
|
|
}
|