From c6a43d3aad9a76d1ba702e4cabd394082ce4f70a Mon Sep 17 00:00:00 2001 From: Peihsun Yeh Date: Tue, 14 Aug 2018 12:16:17 -0700 Subject: Added driver project, but it is not building yet --- .../SimpleMediaSourceDriver/Device.c | 115 ++++++++++ .../SimpleMediaSourceDriver/Device.h | 46 ++++ .../SimpleMediaSourceDriver/Driver.c | 167 +++++++++++++++ .../SimpleMediaSourceDriver/Driver.h | 37 ++++ .../SimpleMediaSourceDriver/Public.h | 24 +++ .../SimpleMediaSourceDriver/Queue.c | 193 +++++++++++++++++ .../SimpleMediaSourceDriver/Queue.h | 42 ++++ .../SimpleMediaSourceDriver/ReadMe.txt | 33 +++ .../SimpleMediaSourceDriver.inf | Bin 0 -> 8500 bytes .../SimpleMediaSourceDriver.vcxproj | 238 +++++++++++++++++++++ .../SimpleMediaSourceDriver.vcxproj.filters | 57 +++++ .../SimpleMediaSourceDriver/Trace.h | 62 ++++++ 12 files changed, 1014 insertions(+) create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Device.h create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.c create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.h create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Public.h create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.c create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.h create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/ReadMe.txt create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.inf create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj.filters create mode 100644 general/SimpleMediaSource/SimpleMediaSourceDriver/Trace.h (limited to 'general/SimpleMediaSource/SimpleMediaSourceDriver') diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c new file mode 100644 index 00000000..0cf7979e --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c @@ -0,0 +1,115 @@ +/*++ + +Module Name: + + device.c - Device handling events for example driver. + +Abstract: + + This file contains the device entry points and callbacks. + +Environment: + + User-mode Driver Framework 2 + +--*/ + +#include "driver.h" +#include "device.tmh" + +GUID CAMERA_CATEGORY = { STATIC_KSCATEGORY_VIDEO_CAMERA }; +GUID CAPTURE_CATEGORY = { STATIC_KSCATEGORY_CAPTURE }; +GUID VIDEO_CATEGORY = { STATIC_KSCATEGORY_VIDEO }; + +NTSTATUS +SimpleMediaSourceDriverCreateDevice( + _Inout_ PWDFDEVICE_INIT DeviceInit + ) +/*++ + +Routine Description: + + Worker routine called to create a device and its software resources. + +Arguments: + + DeviceInit - Pointer to an opaque init structure. Memory for this + structure will be freed by the framework when the WdfDeviceCreate + succeeds. So don't access the structure after that point. + +Return Value: + + NTSTATUS + +--*/ +{ + WDF_OBJECT_ATTRIBUTES deviceAttributes; + PDEVICE_CONTEXT deviceContext; + WDFDEVICE device; + NTSTATUS status; + + WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&deviceAttributes, DEVICE_CONTEXT); + + status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); + + if (NT_SUCCESS(status)) { + // + // Get a pointer to the device context structure that we just associated + // with the device object. We define this structure in the device.h + // header file. DeviceGetContext is an inline function generated by + // using the WDF_DECLARE_CONTEXT_TYPE_WITH_NAME macro in device.h. + // This function will do the type checking and return the device context. + // If you pass a wrong object handle it will return NULL and assert if + // run under framework verifier mode. + // + deviceContext = DeviceGetContext(device); + + // + // Initialize the context. + // + deviceContext->PrivateDeviceData = 0; + + // + // Create a device interface so that applications can find and talk + // to us. + // + status = WdfDeviceCreateDeviceInterface( + device, + &GUID_DEVINTERFACE_SimpleMediaSourceDriver, + NULL // ReferenceString + ); + + if (NT_SUCCESS(status)) { + // + // Create a device interface so that application can find and talk + // to us. + // + status = WdfDeviceCreateDeviceInterface( + device, + &CAPTURE_CATEGORY, + NULL // ReferenceString + ); + } + + if (NT_SUCCESS(status)) { + // + // Create a device interface so that application can find and talk + // to us. + // + status = WdfDeviceCreateDeviceInterface( + device, + &VIDEO_CATEGORY, + NULL // ReferenceString + ); + } + + if (NT_SUCCESS(status)) { + // + // Initialize the I/O Package and any Queues + // + status = SimpleMediaSourceDriverQueueInitialize(device); + } + } + + return status; +} diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.h b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.h new file mode 100644 index 00000000..6c2da5e4 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.h @@ -0,0 +1,46 @@ +/*++ + +Module Name: + + device.h + +Abstract: + + This file contains the device definitions. + +Environment: + + User-mode Driver Framework 2 + +--*/ + +#include "public.h" + +EXTERN_C_START + +// +// The device context performs the same job as +// a WDM device extension in the driver frameworks +// +typedef struct _DEVICE_CONTEXT +{ + ULONG PrivateDeviceData; // just a placeholder + +} DEVICE_CONTEXT, *PDEVICE_CONTEXT; + +// +// This macro will generate an inline function called DeviceGetContext +// which will be used to get a pointer to the device context memory +// in a type safe manner. +// +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, DeviceGetContext) + +// +// Function to initialize the device and its callbacks +// +NTSTATUS +SimpleMediaSourceDriverCreateDevice( + _Inout_ PWDFDEVICE_INIT DeviceInit + ); + +EXTERN_C_END diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.c b/general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.c new file mode 100644 index 00000000..94ee0fa9 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.c @@ -0,0 +1,167 @@ +/*++ + +Module Name: + + driver.c + +Abstract: + + This file contains the driver entry points and callbacks. + +Environment: + + User-mode Driver Framework 2 + +--*/ + +#include "driver.h" +#include "driver.tmh" + +NTSTATUS +DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath + ) +/*++ + +Routine Description: + DriverEntry initializes the driver and is the first routine called by the + system after the driver is loaded. DriverEntry specifies the other entry + points in the function driver, such as EvtDevice and DriverUnload. + +Parameters Description: + + DriverObject - represents the instance of the function driver that is loaded + into memory. DriverEntry must initialize members of DriverObject before it + returns to the caller. DriverObject is allocated by the system before the + driver is loaded, and it is released by the system after the system unloads + the function driver from memory. + + RegistryPath - represents the driver specific path in the Registry. + The function driver can use the path to store driver related data between + reboots. The path does not store hardware instance specific data. + +Return Value: + + STATUS_SUCCESS if successful, + STATUS_UNSUCCESSFUL otherwise. + +--*/ +{ + WDF_DRIVER_CONFIG config; + NTSTATUS status; + WDF_OBJECT_ATTRIBUTES attributes; + + // + // Initialize WPP Tracing + // +#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"); + + // + // Register a cleanup callback so that we can call WPP_CLEANUP when + // the framework driver object is deleted during driver unload. + // + WDF_OBJECT_ATTRIBUTES_INIT(&attributes); + attributes.EvtCleanupCallback = SimpleMediaSourceDriverEvtDriverContextCleanup; + + WDF_DRIVER_CONFIG_INIT(&config, + SimpleMediaSourceDriverEvtDeviceAdd + ); + + 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 +SimpleMediaSourceDriverEvtDeviceAdd( + _In_ WDFDRIVER Driver, + _Inout_ PWDFDEVICE_INIT DeviceInit + ) +/*++ +Routine Description: + + EvtDeviceAdd is called by the framework in response to AddDevice + call from the PnP manager. We create and initialize a device object to + represent a new instance of the device. + +Arguments: + + Driver - Handle to a framework driver object created in DriverEntry + + DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure. + +Return Value: + + NTSTATUS + +--*/ +{ + NTSTATUS status; + + UNREFERENCED_PARAMETER(Driver); + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); + + status = SimpleMediaSourceDriverCreateDevice(DeviceInit); + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit"); + + return status; +} + +VOID +SimpleMediaSourceDriverEvtDriverContextCleanup( + _In_ WDFOBJECT DriverObject + ) +/*++ +Routine Description: + + Free all the resources allocated in DriverEntry. + +Arguments: + + DriverObject - handle to a WDF Driver object. + +Return Value: + + VOID. + +--*/ +{ + UNREFERENCED_PARAMETER(DriverObject); + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); + + // + // Stop WPP Tracing + // +#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0 + WPP_CLEANUP(); +#else + WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject)); +#endif +} diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.h b/general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.h new file mode 100644 index 00000000..1e19eec9 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Driver.h @@ -0,0 +1,37 @@ +/*++ + +Module Name: + + driver.h + +Abstract: + + This file contains the driver definitions. + +Environment: + + User-mode Driver Framework 2 + +--*/ + +#include +#include +#include +#include +#include + +#include "device.h" +#include "queue.h" +#include "trace.h" + +EXTERN_C_START + +// +// WDFDRIVER Events +// + +DRIVER_INITIALIZE DriverEntry; +EVT_WDF_DRIVER_DEVICE_ADD SimpleMediaSourceDriverEvtDeviceAdd; +EVT_WDF_OBJECT_CONTEXT_CLEANUP SimpleMediaSourceDriverEvtDriverContextCleanup; + +EXTERN_C_END diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Public.h b/general/SimpleMediaSource/SimpleMediaSourceDriver/Public.h new file mode 100644 index 00000000..f3d4964b --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Public.h @@ -0,0 +1,24 @@ +/*++ + +Module Name: + + public.h + +Abstract: + + This module contains the common declarations shared by driver + and user applications. + +Environment: + + driver and application + +--*/ + +// +// Define an Interface Guid so that apps can find the device and talk to it. +// + +DEFINE_GUID (GUID_DEVINTERFACE_SimpleMediaSourceDriver, + 0xb5036295,0xf041,0x4506,0x88,0xdc,0xcb,0x16,0x5c,0x4d,0x67,0x8c); +// {b5036295-f041-4506-88dc-cb165c4d678c} diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.c b/general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.c new file mode 100644 index 00000000..6ea51781 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.c @@ -0,0 +1,193 @@ +/*++ + +Module Name: + + queue.c + +Abstract: + + This file contains the queue entry points and callbacks. + +Environment: + + User-mode Driver Framework 2 + +--*/ + +#include "driver.h" +#include "queue.tmh" + +NTSTATUS +SimpleMediaSourceDriverQueueInitialize( + _In_ WDFDEVICE Device + ) +/*++ + +Routine Description: + + The I/O dispatch callbacks for the frameworks device object + are configured in this function. + + A single default I/O Queue is configured for parallel request + processing, and a driver context memory allocation is created + to hold our structure QUEUE_CONTEXT. + +Arguments: + + Device - Handle to a framework device object. + +Return Value: + + VOID + +--*/ +{ + WDFQUEUE queue; + NTSTATUS status; + WDF_IO_QUEUE_CONFIG queueConfig; + + // + // Configure a default queue so that requests that are not + // configure-fowarded using WdfDeviceConfigureRequestDispatching to goto + // other queues get dispatched here. + // + WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE( + &queueConfig, + WdfIoQueueDispatchParallel + ); + + queueConfig.EvtIoDeviceControl = SimpleMediaSourceDriverEvtIoDeviceControl; + queueConfig.EvtIoStop = SimpleMediaSourceDriverEvtIoStop; + + status = WdfIoQueueCreate( + Device, + &queueConfig, + WDF_NO_OBJECT_ATTRIBUTES, + &queue + ); + + if(!NT_SUCCESS(status)) { + TraceEvents(TRACE_LEVEL_ERROR, TRACE_QUEUE, "WdfIoQueueCreate failed %!STATUS!", status); + return status; + } + + return status; +} + +VOID +SimpleMediaSourceDriverEvtIoDeviceControl( + _In_ WDFQUEUE Queue, + _In_ WDFREQUEST Request, + _In_ size_t OutputBufferLength, + _In_ size_t InputBufferLength, + _In_ ULONG IoControlCode + ) +/*++ + +Routine Description: + + This event is invoked when the framework receives IRP_MJ_DEVICE_CONTROL request. + +Arguments: + + Queue - Handle to the framework queue object that is associated with the + I/O request. + + Request - Handle to a framework request object. + + OutputBufferLength - Size of the output buffer in bytes + + InputBufferLength - Size of the input buffer in bytes + + IoControlCode - I/O control code. + +Return Value: + + VOID + +--*/ +{ + TraceEvents(TRACE_LEVEL_INFORMATION, + TRACE_QUEUE, + "%!FUNC! Queue 0x%p, Request 0x%p OutputBufferLength %d InputBufferLength %d IoControlCode %d", + Queue, Request, (int) OutputBufferLength, (int) InputBufferLength, IoControlCode); + + WdfRequestComplete(Request, STATUS_SUCCESS); + + return; +} + +VOID +SimpleMediaSourceDriverEvtIoStop( + _In_ WDFQUEUE Queue, + _In_ WDFREQUEST Request, + _In_ ULONG ActionFlags +) +/*++ + +Routine Description: + + This event is invoked for a power-managed queue before the device leaves the working state (D0). + +Arguments: + + Queue - Handle to the framework queue object that is associated with the + I/O request. + + Request - Handle to a framework request object. + + ActionFlags - A bitwise OR of one or more WDF_REQUEST_STOP_ACTION_FLAGS-typed flags + that identify the reason that the callback function is being called + and whether the request is cancelable. + +Return Value: + + VOID + +--*/ +{ + TraceEvents(TRACE_LEVEL_INFORMATION, + TRACE_QUEUE, + "%!FUNC! Queue 0x%p, Request 0x%p ActionFlags %d", + Queue, Request, ActionFlags); + + // + // In most cases, the EvtIoStop callback function completes, cancels, or postpones + // further processing of the I/O request. + // + // Typically, the driver uses the following rules: + // + // - If the driver owns the I/O request, it calls WdfRequestUnmarkCancelable + // (if the request is cancelable) and either calls WdfRequestStopAcknowledge + // with a Requeue value of TRUE, or it calls WdfRequestComplete with a + // completion status value of STATUS_SUCCESS or STATUS_CANCELLED. + // + // Before it can call these methods safely, the driver must make sure that + // its implementation of EvtIoStop has exclusive access to the request. + // + // In order to do that, the driver must synchronize access to the request + // to prevent other threads from manipulating the request concurrently. + // The synchronization method you choose will depend on your driver's design. + // + // For example, if the request is held in a shared context, the EvtIoStop callback + // might acquire an internal driver lock, take the request from the shared context, + // and then release the lock. At this point, the EvtIoStop callback owns the request + // and can safely complete or requeue the request. + // + // - If the driver has forwarded the I/O request to an I/O target, it either calls + // WdfRequestCancelSentRequest to attempt to cancel the request, or it postpones + // further processing of the request and calls WdfRequestStopAcknowledge with + // a Requeue value of FALSE. + // + // A driver might choose to take no action in EvtIoStop for requests that are + // guaranteed to complete in a small amount of time. + // + // In this case, the framework waits until the specified request is complete + // before moving the device (or system) to a lower power state or removing the device. + // Potentially, this inaction can prevent a system from entering its hibernation state + // or another low system power state. In extreme cases, it can cause the system + // to crash with bugcheck code 9F. + // + + return; +} diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.h b/general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.h new file mode 100644 index 00000000..e0c01283 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Queue.h @@ -0,0 +1,42 @@ +/*++ + +Module Name: + + queue.h + +Abstract: + + This file contains the queue definitions. + +Environment: + + User-mode Driver Framework 2 + +--*/ + +EXTERN_C_START + +// +// This is the context that can be placed per queue +// and would contain per queue information. +// +typedef struct _QUEUE_CONTEXT { + + ULONG PrivateDeviceData; // just a placeholder + +} QUEUE_CONTEXT, *PQUEUE_CONTEXT; + +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(QUEUE_CONTEXT, QueueGetContext) + +NTSTATUS +SimpleMediaSourceDriverQueueInitialize( + _In_ WDFDEVICE Device + ); + +// +// Events from the IoQueue object +// +EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL SimpleMediaSourceDriverEvtIoDeviceControl; +EVT_WDF_IO_QUEUE_IO_STOP SimpleMediaSourceDriverEvtIoStop; + +EXTERN_C_END diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/ReadMe.txt b/general/SimpleMediaSource/SimpleMediaSourceDriver/ReadMe.txt new file mode 100644 index 00000000..55d9dadd --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + SimpleMediaSourceDriver Project Overview +======================================================================== + +This file contains a summary of what you will find in each of the files that make up your project. + +SimpleMediaSourceDriver.vcxproj + This is the main project file for projects generated using an Application Wizard. + It contains information about the version of the product that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +SimpleMediaSourceDriver.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +Public.h + Header file to be shared with applications. + +Driver.c & Driver.h + DriverEntry and WDFDRIVER related functionality and callbacks. + +Device.c & Device.h + WDFDEVICE related functionality and callbacks. + +Queue.c & Queue.h + WDFQUEUE related functionality and callbacks. + +Trace.h + Definitions for WPP tracing. diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.inf b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.inf new file mode 100644 index 00000000..dabb3237 Binary files /dev/null and b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.inf differ diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj new file mode 100644 index 00000000..c3afadf5 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj @@ -0,0 +1,238 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + + + + + + + + + + + + + + + + + + + + {3098C6BF-E96E-4793-A70E-FB09B741580A} + {32909489-7be5-497b-aafa-db6669d9b44b} + v4.5 + 12.0 + Debug + Win32 + SimpleMediaSourceDriver + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + WindowsUserModeDriver10.0 + DynamicLibrary + Universal + + + + Windows10 + true + 2 + + + Windows10 + false + 2 + + + Windows10 + true + 2 + + + Windows10 + false + 2 + + + Windows10 + true + 2 + + + Windows10 + false + 2 + + + Windows10 + true + 2 + + + Windows10 + false + 2 + + + + + + + + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + DbgengRemoteDebugger + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + true + true + trace.h + + + + + + + + + \ No newline at end of file diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj.filters b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj.filters new file mode 100644 index 00000000..6f2263ef --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj.filters @@ -0,0 +1,57 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {8E41214B-6785-4CFE-B992-037D68949A14} + inf;inv;inx;mof;mc; + + + + + + + + Driver Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Trace.h b/general/SimpleMediaSource/SimpleMediaSourceDriver/Trace.h new file mode 100644 index 00000000..0180b817 --- /dev/null +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Trace.h @@ -0,0 +1,62 @@ +/*++ + +Module Name: + + Internal.h + +Abstract: + + This module contains the local type definitions for the + driver. + +Environment: + + Windows User-Mode Driver Framework 2 + +--*/ + +// +// Define the tracing flags. +// +// Tracing GUID - a9ae54d8-0a84-4b05-b9ae-faff98267b7e +// + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + MyDriver1TraceGuid, (a9ae54d8,0a84,4b05,b9ae,faff98267b7e), \ + \ + WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \ + WPP_DEFINE_BIT(TRACE_DRIVER) \ + WPP_DEFINE_BIT(TRACE_DEVICE) \ + WPP_DEFINE_BIT(TRACE_QUEUE) \ + ) + +#define WPP_FLAG_LEVEL_LOGGER(flag, level) \ + WPP_LEVEL_LOGGER(flag) + +#define WPP_FLAG_LEVEL_ENABLED(flag, level) \ + (WPP_LEVEL_ENABLED(flag) && \ + WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) + +#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ + WPP_LEVEL_LOGGER(flags) + +#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ + (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) + +// +// This comment block is scanned by the trace preprocessor to define our +// Trace function. +// +// begin_wpp config +// FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); +// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); +// end_wpp + +// +// +// Driver specific #defines +// +#if UMDF_VERSION_MAJOR == 2 && UMDF_VERSION_MINOR == 0 + #define MYDRIVER_TRACING_ID L"Microsoft\\UMDF2.0\\SimpleMediaSourceDriver V1.0" +#endif \ No newline at end of file -- cgit v1.3.1 From 2649a6ac6d3edbe2eea9a9e4b6a0168da6609b3a Mon Sep 17 00:00:00 2001 From: Peihsun Yeh Date: Wed, 15 Aug 2018 15:15:19 -0700 Subject: adding entry code for media source --- general/SimpleMediaSource/MediaSource/MediaSource.vcxproj | 9 +++++++++ .../SimpleMediaSource/MediaSource/MediaSource.vcxproj.filters | 3 +++ general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'general/SimpleMediaSource/SimpleMediaSourceDriver') diff --git a/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj b/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj index ea726a92..15e2b6c8 100644 --- a/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj +++ b/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj @@ -80,6 +80,8 @@ mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + $(SolutionDir)MediaSource\module.def @@ -91,6 +93,8 @@ mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + $(SolutionDir)MediaSource\module.def + %(IgnoreSpecificDefaultLibraries) @@ -106,6 +110,8 @@ true true mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + $(SolutionDir)MediaSource\module.def @@ -121,12 +127,15 @@ true true mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + %(IgnoreSpecificDefaultLibraries) + $(SolutionDir)MediaSource\module.def + diff --git a/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj.filters b/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj.filters index ce4a1433..ffcc9853 100644 --- a/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj.filters +++ b/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj.filters @@ -29,6 +29,9 @@ Source Files + + Source Files + diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c index 0cf7979e..2fa03bb9 100644 --- a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c @@ -75,7 +75,7 @@ Return Value: // status = WdfDeviceCreateDeviceInterface( device, - &GUID_DEVINTERFACE_SimpleMediaSourceDriver, + &CAMERA_CATEGORY, NULL // ReferenceString ); -- cgit v1.3.1 From 039691b8fcc20ff71815ebae5848a0c0da8aaa75 Mon Sep 17 00:00:00 2001 From: Joel Corley Date: Fri, 17 Aug 2018 17:23:35 -0700 Subject: Fix the solution and project so everything builds. Note: The DLLs are still not being signed. The driver package will install, but won't start because of it. --- .../MediaSource/MediaSource.vcxproj | 200 +++++++++++++++++++-- general/SimpleMediaSource/SimpleMediaSource.sln | 8 +- .../SimpleMediaSourceDriver.vcxproj | 50 +++++- 3 files changed, 242 insertions(+), 16 deletions(-) (limited to 'general/SimpleMediaSource/SimpleMediaSourceDriver') diff --git a/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj b/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj index 15e2b6c8..47562ff7 100644 --- a/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj +++ b/general/SimpleMediaSource/MediaSource/MediaSource.vcxproj @@ -1,10 +1,26 @@ + + Debug + ARM + + + Debug + ARM64 + Debug Win32 + + Release + ARM + + + Release + ARM64 + Release Win32 @@ -22,35 +38,69 @@ 15.0 {43AD9BF7-E765-48FE-9826-71A8F2CB12DD} MediaSource - 10.0.17134.0 + $(LatestTargetPlatformVersion) SimpleMediaSource DynamicLibrary true - v141 + WindowsApplicationForDrivers10.0 + MultiByte + Universal + + + DynamicLibrary + true + WindowsApplicationForDrivers10.0 MultiByte + Universal DynamicLibrary false - v141 + WindowsApplicationForDrivers10.0 true MultiByte + Universal + + + DynamicLibrary + false + WindowsApplicationForDrivers10.0 + true + MultiByte + Universal DynamicLibrary true - v141 + WindowsApplicationForDrivers10.0 + MultiByte + Universal + + + DynamicLibrary + true + WindowsApplicationForDrivers10.0 MultiByte + Universal DynamicLibrary false - v141 + WindowsApplicationForDrivers10.0 true MultiByte + Universal + + + DynamicLibrary + false + WindowsApplicationForDrivers10.0 + true + MultiByte + Universal @@ -60,26 +110,88 @@ + + + + + + + + + + + + - + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + + + NativeRecommendedRules.ruleset + false + Level3 Disabled true true + false + false + MultiThreadedDebugDLL + + + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib + %(IgnoreSpecificDefaultLibraries) + $(SolutionDir)MediaSource\module.def + + + + + Level3 + Disabled + true + true + false + false + MultiThreadedDebugDLL - mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib %(IgnoreSpecificDefaultLibraries) $(SolutionDir)MediaSource\module.def @@ -90,9 +202,28 @@ Disabled true true + false + false + MultiThreadedDebugDLL + + + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib + $(SolutionDir)MediaSource\module.def + %(IgnoreSpecificDefaultLibraries) + + + + + Level3 + Disabled + true + true + false + false + MultiThreadedDebugDLL - mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib $(SolutionDir)MediaSource\module.def %(IgnoreSpecificDefaultLibraries) @@ -105,13 +236,39 @@ true true true + false + false + MultiThreadedDLL true true - mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib %(IgnoreSpecificDefaultLibraries) $(SolutionDir)MediaSource\module.def + + + + + + Level3 + MaxSpeed + true + true + true + true + false + false + MultiThreadedDLL + + + true + true + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib + %(IgnoreSpecificDefaultLibraries) + $(SolutionDir)MediaSource\module.def + + @@ -122,11 +279,34 @@ true true true + false + MultiThreadedDLL + false + + + true + true + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib + %(IgnoreSpecificDefaultLibraries) + $(SolutionDir)MediaSource\module.def + + + + + Level3 + MaxSpeed + true + true + true + true + false + MultiThreadedDLL + false true true - mfplat.lib;RuntimeObject.lib;Mfsensorgroup.lib;%(AdditionalDependencies) + mfplat.lib;Mfsensorgroup.lib;%(AdditionalDependencies);OneCoreUAP.lib %(IgnoreSpecificDefaultLibraries) $(SolutionDir)MediaSource\module.def diff --git a/general/SimpleMediaSource/SimpleMediaSource.sln b/general/SimpleMediaSource/SimpleMediaSource.sln index c7b0e366..c93b8c42 100644 --- a/general/SimpleMediaSource/SimpleMediaSource.sln +++ b/general/SimpleMediaSource/SimpleMediaSource.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27703.2026 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaSource", "MediaSource\MediaSource.vcxproj", "{43AD9BF7-E765-48FE-9826-71A8F2CB12DD}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleMediaSource", "MediaSource\MediaSource.vcxproj", "{43AD9BF7-E765-48FE-9826-71A8F2CB12DD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleMediaSourceDriver", "SimpleMediaSourceDriver\SimpleMediaSourceDriver.vcxproj", "{3098C6BF-E96E-4793-A70E-FB09B741580A}" EndProject @@ -25,8 +25,10 @@ Global {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Debug|x64.Build.0 = Debug|x64 {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Debug|x86.ActiveCfg = Debug|Win32 {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Debug|x86.Build.0 = Debug|Win32 - {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|ARM.ActiveCfg = Release|Win32 - {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|ARM64.ActiveCfg = Release|Win32 + {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|ARM.ActiveCfg = Release|ARM + {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|ARM.Build.0 = Release|ARM + {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|ARM64.ActiveCfg = Release|ARM64 + {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|ARM64.Build.0 = Release|ARM64 {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|x64.ActiveCfg = Release|x64 {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|x64.Build.0 = Release|x64 {43AD9BF7-E765-48FE-9826-71A8F2CB12DD}.Release|x86.ActiveCfg = Release|Win32 diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj index c3afadf5..38e21ccd 100644 --- a/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/SimpleMediaSourceDriver.vcxproj @@ -52,6 +52,21 @@ + + + + + + + + + + + + + {43ad9bf7-e765-48fe-9826-71a8f2cb12dd} + + {3098C6BF-E96E-4793-A70E-FB09B741580A} {32909489-7be5-497b-aafa-db6669d9b44b} @@ -163,15 +178,23 @@ DbgengRemoteDebugger + false + + DbgengRemoteDebugger + false + + DbgengRemoteDebugger + Server10_$(DDKPlatform) DbgengRemoteDebugger + Server10_$(DDKPlatform) @@ -179,6 +202,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -186,6 +212,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -193,6 +222,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -200,6 +232,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -207,6 +242,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -214,6 +252,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -221,6 +262,9 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + @@ -228,10 +272,10 @@ true trace.h + + %(AdditionalDependencies);$(SDK_LIB_PATH)\OneCoreUAP.lib + - - - -- cgit v1.3.1 From 6930fc413a7a19ce04fb61fab5db7e71729fde18 Mon Sep 17 00:00:00 2001 From: Peihsun Yeh Date: Fri, 24 Aug 2018 14:58:59 -0700 Subject: added mising referencestring --- general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'general/SimpleMediaSource/SimpleMediaSourceDriver') diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c index 2fa03bb9..133d55eb 100644 --- a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c @@ -47,6 +47,8 @@ Return Value: PDEVICE_CONTEXT deviceContext; WDFDEVICE device; NTSTATUS status; + UNICODE_STRING szReference; + RtlInitUnicodeString(&szReference, L"CustomCameraSource"); WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&deviceAttributes, DEVICE_CONTEXT); @@ -76,7 +78,7 @@ Return Value: status = WdfDeviceCreateDeviceInterface( device, &CAMERA_CATEGORY, - NULL // ReferenceString + &szReference // ReferenceString ); if (NT_SUCCESS(status)) { @@ -87,7 +89,7 @@ Return Value: status = WdfDeviceCreateDeviceInterface( device, &CAPTURE_CATEGORY, - NULL // ReferenceString + &szReference // ReferenceString ); } @@ -99,7 +101,7 @@ Return Value: status = WdfDeviceCreateDeviceInterface( device, &VIDEO_CATEGORY, - NULL // ReferenceString + &szReference // ReferenceString ); } -- cgit v1.3.1 From 28c11cc0153286544abdb66eac22c760b73a4155 Mon Sep 17 00:00:00 2001 From: Peihsun Yeh Date: Mon, 27 Aug 2018 11:13:03 -0700 Subject: clarifying comments, removing some also --- general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'general/SimpleMediaSource/SimpleMediaSourceDriver') diff --git a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c index 133d55eb..083cf3c7 100644 --- a/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c +++ b/general/SimpleMediaSource/SimpleMediaSourceDriver/Device.c @@ -48,7 +48,7 @@ Return Value: WDFDEVICE device; NTSTATUS status; UNICODE_STRING szReference; - RtlInitUnicodeString(&szReference, L"CustomCameraSource"); + RtlInitUnicodeString(&szReference, L"CustomCameraSource"); // Needs to match the ReferenceString in INF WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&deviceAttributes, DEVICE_CONTEXT); @@ -82,10 +82,6 @@ Return Value: ); if (NT_SUCCESS(status)) { - // - // Create a device interface so that application can find and talk - // to us. - // status = WdfDeviceCreateDeviceInterface( device, &CAPTURE_CATEGORY, @@ -94,10 +90,6 @@ Return Value: } if (NT_SUCCESS(status)) { - // - // Create a device interface so that application can find and talk - // to us. - // status = WdfDeviceCreateDeviceInterface( device, &VIDEO_CATEGORY, -- cgit v1.3.1