[
  {
    "path": ".gitignore",
    "content": "## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n##\n## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore\n\n# User-specific files\n*.rsuser\n*.suo\n*.user\n*.userosscache\n*.sln.docstates\n\n# User-specific files (MonoDevelop/Xamarin Studio)\n*.userprefs\n\n# Mono auto generated files\nmono_crash.*\n\n# Build results\n[Dd]ebug/\n[Dd]ebugPublic/\n[Rr]elease/\n[Rr]eleases/\nx64/\nx86/\n[Aa][Rr][Mm]/\n[Aa][Rr][Mm]64/\nbld/\n[Bb]in/\n[Oo]bj/\n[Ll]og/\n[Ll]ogs/\n\n# Visual Studio 2015/2017 cache/options directory\n.vs/\n# Uncomment if you have tasks that create the project's static files in wwwroot\n#wwwroot/\n\n# Visual Studio 2017 auto generated files\nGenerated\\ Files/\n\n# MSTest test Results\n[Tt]est[Rr]esult*/\n[Bb]uild[Ll]og.*\n\n# NUnit\n*.VisualState.xml\nTestResult.xml\nnunit-*.xml\n\n# Build Results of an ATL Project\n[Dd]ebugPS/\n[Rr]eleasePS/\ndlldata.c\n\n# Benchmark Results\nBenchmarkDotNet.Artifacts/\n\n# .NET Core\nproject.lock.json\nproject.fragment.lock.json\nartifacts/\n\n# StyleCop\nStyleCopReport.xml\n\n# Files built by Visual Studio\n*_i.c\n*_p.c\n*_h.h\n*.ilk\n*.meta\n*.obj\n*.iobj\n*.pch\n*.pdb\n*.ipdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.tmp_proj\n*_wpftmp.csproj\n*.log\n*.vspscc\n*.vssscc\n.builds\n*.pidb\n*.svclog\n*.scc\n\n# Chutzpah Test files\n_Chutzpah*\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opendb\n*.opensdf\n*.sdf\n*.cachefile\n*.VC.db\n*.VC.VC.opendb\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n*.sap\n\n# Visual Studio Trace Files\n*.e2e\n\n# TFS 2012 Local Workspace\n$tf/\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*/\n*.[Rr]e[Ss]harper\n*.DotSettings.user\n\n# TeamCity is a build add-in\n_TeamCity*\n\n# DotCover is a Code Coverage Tool\n*.dotCover\n\n# AxoCover is a Code Coverage Tool\n.axoCover/*\n!.axoCover/settings.json\n\n# Visual Studio code coverage results\n*.coverage\n*.coveragexml\n\n# NCrunch\n_NCrunch_*\n.*crunch*.local.xml\nnCrunchTemp_*\n\n# MightyMoose\n*.mm.*\nAutoTest.Net/\n\n# Web workbench (sass)\n.sass-cache/\n\n# Installshield output folder\n[Ee]xpress/\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish/\n\n# Publish Web Output\n*.[Pp]ublish.xml\n*.azurePubxml\n# Note: Comment the next line if you want to checkin your web deploy settings,\n# but database connection strings (with potential passwords) will be unencrypted\n*.pubxml\n*.publishproj\n\n# Microsoft Azure Web App publish settings. Comment the next line if you want to\n# checkin your Azure Web App publish settings, but sensitive information contained\n# in these scripts will be unencrypted\nPublishScripts/\n\n# NuGet Packages\n*.nupkg\n# NuGet Symbol Packages\n*.snupkg\n# The packages folder can be ignored because of Package Restore\n**/[Pp]ackages/*\n# except build/, which is used as an MSBuild target.\n!**/[Pp]ackages/build/\n# Uncomment if necessary however generally it will be regenerated when needed\n#!**/[Pp]ackages/repositories.config\n# NuGet v3's project.json files produces more ignorable files\n*.nuget.props\n*.nuget.targets\n\n# Microsoft Azure Build Output\ncsx/\n*.build.csdef\n\n# Microsoft Azure Emulator\necf/\nrcf/\n\n# Windows Store app package directories and files\nAppPackages/\nBundleArtifacts/\nPackage.StoreAssociation.xml\n_pkginfo.txt\n*.appx\n*.appxbundle\n*.appxupload\n\n# Visual Studio cache files\n# files ending in .cache can be ignored\n*.[Cc]ache\n# but keep track of directories ending in .cache\n!?*.[Cc]ache/\n\n# Others\nClientBin/\n~$*\n*~\n*.dbmdl\n*.dbproj.schemaview\n*.jfm\n*.pfx\n*.publishsettings\norleans.codegen.cs\n\n# Including strong name files can present a security risk\n# (https://github.com/github/gitignore/pull/2483#issue-259490424)\n#*.snk\n\n# Since there are multiple workflows, uncomment next line to ignore bower_components\n# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)\n#bower_components/\n\n# RIA/Silverlight projects\nGenerated_Code/\n\n# Backup & report files from converting an old project file\n# to a newer Visual Studio version. Backup files are not needed,\n# because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\nUpgradeLog*.htm\nServiceFabricBackup/\n*.rptproj.bak\n\n# SQL Server files\n*.mdf\n*.ldf\n*.ndf\n\n# Business Intelligence projects\n*.rdl.data\n*.bim.layout\n*.bim_*.settings\n*.rptproj.rsuser\n*- [Bb]ackup.rdl\n*- [Bb]ackup ([0-9]).rdl\n*- [Bb]ackup ([0-9][0-9]).rdl\n\n# Microsoft Fakes\nFakesAssemblies/\n\n# GhostDoc plugin setting file\n*.GhostDoc.xml\n\n# Node.js Tools for Visual Studio\n.ntvs_analysis.dat\nnode_modules/\n\n# Visual Studio 6 build log\n*.plg\n\n# Visual Studio 6 workspace options file\n*.opt\n\n# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)\n*.vbw\n\n# Visual Studio LightSwitch build output\n**/*.HTMLClient/GeneratedArtifacts\n**/*.DesktopClient/GeneratedArtifacts\n**/*.DesktopClient/ModelManifest.xml\n**/*.Server/GeneratedArtifacts\n**/*.Server/ModelManifest.xml\n_Pvt_Extensions\n\n# Paket dependency manager\n.paket/paket.exe\npaket-files/\n\n# FAKE - F# Make\n.fake/\n\n# CodeRush personal settings\n.cr/personal\n\n# Python Tools for Visual Studio (PTVS)\n__pycache__/\n*.pyc\n\n# Cake - Uncomment if you are using it\n# tools/**\n# !tools/packages.config\n\n# Tabs Studio\n*.tss\n\n# Telerik's JustMock configuration file\n*.jmconfig\n\n# BizTalk build output\n*.btp.cs\n*.btm.cs\n*.odx.cs\n*.xsd.cs\n\n# OpenCover UI analysis results\nOpenCover/\n\n# Azure Stream Analytics local run output\nASALocalRun/\n\n# MSBuild Binary and Structured Log\n*.binlog\n\n# NVidia Nsight GPU debugger configuration file\n*.nvuser\n\n# MFractors (Xamarin productivity tool) working folder\n.mfractor/\n\n# Local History for Visual Studio\n.localhistory/\n\n# BeatPulse healthcheck temp database\nhealthchecksdb\n\n# Backup folder for Package Reference Convert tool in Visual Studio 2017\nMigrationBackup/\n\n# Ionide (cross platform F# VS Code tools) working folder\n.ionide/\n"
  },
  {
    "path": "Driver/avshws/README.md",
    "content": "---\npage_type: sample\ndescription: \"A simulated hardware sample driver providing a pin-centric capture driver to simulate AV capture hardware.\"\nlanguages:\n- cpp\nproducts:\n- windows\n- windows-wdk\n---\n\n# AVStream simulated hardware sample driver (Avshws)\n\nThe AVStream simulated hardware sample driver (Avshws) provides a pin-centric [AVStream](https://docs.microsoft.com/windows-hardware/drivers/stream/avstream-overview) capture driver for a simulated piece of hardware. This streaming media driver performs video captures at 320 x 240 pixels in either RGB24 or YUV422 format using direct memory access (DMA) into capture buffers. The purpose of the sample is to demonstrate how to write a pin-centric AVStream minidriver. The sample also shows how to implement DMA by using the related functionality provided by the AVStream class driver.\n\nThis sample features enhanced parameter validation and overflow detection.\n\n## Provision a target computer\n\nAfter you've installed the sample on your host computer, run Visual Studio, and from the **File** menu, select **Open**, then **Project/Solution...**, navigate to the directory where you've copied the Avshws sample, then to the C++ folder, and select **avshws.vcxproj** (the VC++ Project).\n\nIn the **Solution Explorer** pane in Visual Studio, at the top is **Solution 'avshws'**. Right-click this and select **Configuration Manager**. Follow the instructions in [Building a Driver with Visual Studio and the WDK](https://docs.microsoft.com/windows-hardware/drivers/develop/building-a-driver) to set the platform, operating system, and debug configuration you want to use, and to build the sample. This sample project will automatically sign the driver package.\n\nProvision your target computer using instructions in, for example, [Provision a computer for driver deployment and testing](https://docs.microsoft.com/windows-hardware/drivers/gettingstarted/provision-a-target-computer-wdk-8-1). Ensure that in the **Network and Sharing Center** control panel your target computer has **Network Discovery** and **File and Printer Sharing** enabled.\n\n## Deploy the driver to the target computer\n\nNow you can deploy the Avshws driver that you've just built to the target computer, using guidance in [Deploying a Driver to a Test Computer](https://docs.microsoft.com/windows-hardware/drivers/develop/deploying-a-driver-to-a-test-computer). Specifically, find the package file under the **Package** folder in the Avshws solution. Right-click **package** and select **Properties**. Under Configuration Properties, click **Driver install** and then **Deployment**. Here you must click the check box for **Enable deployment**, and then click the button to the right of **\\<Configure Computer...\\>**. In the next dialog you enter the **Target Computer Name** and can let the host computer automatically provision the target computer and set up debugger options.\n\nFinally, in Visual Studio, from the **Build** menu select **Deploy Solution** to deploy the sample to the target computer. On the target computer, you can see the deployed package in the **%Systemdrive%\\\\drivertest\\\\drivers** folder.\n\n## Install the driver\n\nOn the target computer, open Device Manager, and follow these steps:\n\n1. In the **Action** menu, click **Add Legacy Hardware**, and the **Add Hardware Wizard** appears. Click **Next** and then **Next** again.\n\n1. In the **Add Hardware** window, select **Show All Devices**.\n\n1. In the **Manufacturer** list in the left pane, click **Microsoft**.\n\n1. You should see the **AVStream Simulated Hardware Sample** in the **Model** pane on the right. Click this and then click **Next**.\n\n1. Click **Next** again to install the driver, and then click **Finish** to exit the wizard.\n\nThe sample driver now appears in the Device Manager console tree under **Sound, video and game controllers**. The Avshws INF file will be on the system drive at, for example, **...windows\\\\System32\\\\DriverStore\\\\FileRepository\\\\**.\n\n## Sample code hierarchy\n\n[**DriverEntry**](https://docs.microsoft.com/previous-versions//ff558717(v=vs.85)) in Device.cpp is the initial point of entry into the driver. This routine passes control to AVStream by calling the [**KsInitializeDriver**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/nf-ks-ksinitializedriver) function. In this call, the minidriver passes the device descriptor, an AVStream structure that recursively defines the AVStream object hierarchy for a driver. This is common behavior for an AVStream minidriver.\n\nAt device start time, a simulated piece of capture hardware is created (the **CHardwareSimulation** class), and a DMA adapter is acquired from the operating system and is registered with AVStream by calling the [**KsDeviceRegisterAdapterObject**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/nf-ks-ksdeviceregisteradapterobject) function. This call is required for a sample that performs DMA access directly into the capture buffers, instead of using DMA access to write to a common buffer. The driver creates the [KS Filter](https://docs.microsoft.com/windows-hardware/drivers/stream/ks-filters) for this device dynamically by calling the [**KsCreateFilterFactory**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/nf-ks-kscreatefilterfactory) function.\n\nFilter.cpp is where the sample lays out the [**KSPIN\\_DESCRIPTOR\\_EX**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/ns-ks-_kspin_descriptor_ex) structure for the single video pin. In addition, a [**KSFILTER\\_DISPATCH**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/ns-ks-_ksfilter_dispatch) structure and a [**KSFILTER\\_DESCRIPTOR**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/ns-ks-_ksfilter_descriptor) structure are provided in this source file. The filter dispatch provides only a create dispatch, a routine that is included in Filter.cpp. The process dispatch is provided on the pin because this is a pin-centric sample.\n\nCapture.cpp contains source for the video capture pin on the capture filter. This is where the [**KSPIN\\_DISPATCH**](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/ks/ns-ks-_kspin_dispatch) structure for the unique pin is provided. This dispatch structure specifies a *Process* callback routine, also defined in this source file. This routine is where stream pointer manipulation and cloning occurs.\n\nThe process callback is one of two routines of interest in Capture.cpp that demonstrate how to perform DMA transfers with AVStream functionality. The other is the **CCapturePin::CompleteMappings** method. These two methods show how to use the queue, obtain clone pointers, use scatter/gather lists, and perform other DMA-related tasks.\n\nFor more information, see the comments in all .cpp files.\n\n## Run the sample\n\nFollow these steps to see how the sample driver functions:\n\n1. After installation has completed, access the driver through the Graphedt tool. Graphedt.exe is available in the *tools* directory of the WDK.\n\n1. Before running GraphEdit, use the regsvr32 utility to register the proppage.dll DLL and to enable GraphEdit to display property pages for some of the built-in Microsoft DirectShow filters. Open an elevated command window with Administrator privileges, and navigate to the WDK or SDK *tools* directory that contains proppage.dll.\n\n1. On the command line, type regsvr32 proppage.dll. If the registration succeeds, you'll get a message, \"DllRegisterServer in proppage.dll succeeded.\" Click OK.\n\n1. In the Graphedt tool, click the **Graph** menu and click **Insert Filters**. The sample appears under \"WDM Streaming Capture Devices\" as \"avshws Source.\"\n\n1. Click **Insert Filter**. The sample appears in the graph as a single filter labeled, \"avshws Source.\" There is one output pin, which is the video capture pin. This pin emits video in YUY2 format.\n\n1. Attach this filter to either a DirectShow Video Renderer or to the VMR default video renderer. Then click **Play**.\n\nThe output that is produced by the sample is a 320 x 240 pixel image of standard EIA-189-A color bars. In the middle of the image near the bottom, a clock appears over the image. This clock displays the elapsed time since the graph was introduced into the run state following the last stop. The clock display format is MINUTES:SECONDS.HUNDREDTHS.\n\nIn the upper-left corner of the image, a counter counts the number of frames that have been dropped since the graph was introduced into the run state after the last stop.\n\n## File manifest\n\n| File | Description |\n| --- | --- |\n| Avshws.h | Main header file for the sample |\n| Avshws.inf | Sample installation file |\n"
  },
  {
    "path": "Driver/avshws/avshws.h",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        avshws.h\n\n    Abstract:\n\n        AVStream Simulated Hardware Sample header file.  This is the \n        main header.\n\n    History:\n\n        created 3/12/2001\n\n**************************************************************************/\n\n/*************************************************\n\n    Standard Includes\n\n*************************************************/\n\n#ifndef _avshws_h_\n#define _avshws_h_\n\nextern \"C\" {\n#include <wdm.h>\n}\n\n#include <windef.h>\n#include <stdio.h>\n#include <ntstrsafe.h>\n#include <stdlib.h>\n#include <windef.h>\n#define NOBITMAP\n#include <mmreg.h>\n#undef NOBITMAP\n#include <unknown.h>\n#include <ks.h>\n#include <ksmedia.h>\n\n#include \"customprops.h\"\n\n/*************************************************\n\n    Misc Definitions\n\n*************************************************/\n#pragma warning (disable : 4100 4127 4131 4189 4701 4706)\n#define STR_MODULENAME \"avshws: \"\n#define DEBUGLVL_VERBOSE 2\n#define DEBUGLVL_TERSE 1\n#define DEBUGLVL_ERROR 0\n\nconst DebugLevel = DEBUGLVL_TERSE;\n\n#if (DBG)\n#define _DbgPrintF(lvl, strings) \\\n{ \\\n    if (lvl <= DebugLevel) {\\\n        DbgPrint(STR_MODULENAME);\\\n        DbgPrint##strings;\\\n        DbgPrint(\"\\n\");\\\n        if ((lvl) == DEBUGLVL_ERROR) {\\\n            NT_ASSERT(0);\\\n        } \\\n    }\\\n}\n#else // !DBG\n   #define _DbgPrintF(lvl, strings)\n#endif // !DBG\n\n#define ABS(x) ((x) < 0 ? (-(x)) : (x))\n\n#ifndef mmioFOURCC    \n#define mmioFOURCC( ch0, ch1, ch2, ch3 )                \\\n        ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) |    \\\n        ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )\n#endif\n\n#define FOURCC_YUY2         mmioFOURCC('Y', 'U', 'Y', '2')\n//\n// CAPTURE_PIN_DATA_RANGE_COUNT:\n//\n// The number of ranges supported on the capture pin.\n//\n#define CAPTURE_PIN_DATA_RANGE_COUNT 1 // 2\n\n//\n// CAPTURE_FILTER_PIN_COUNT:\n//\n// The number of pins on the capture filter.\n//\n#define CAPTURE_FILTER_PIN_COUNT 1\n\n//\n// CAPTURE_FILTER_CATEGORIES_COUNT:\n//\n// The number of categories for the capture filter.\n//\n#define CAPTURE_FILTER_CATEGORIES_COUNT 3\n\n#define AVSHWS_POOLTAG 'hSVA'\n\n/*************************************************\n\n    Externed information\n\n*************************************************/\n//\n// filter.cpp externs:\n//\nextern\nconst\nKSFILTER_DISPATCH\nCaptureFilterDispatch;\n\nextern\nconst\nKSFILTER_DESCRIPTOR\nCaptureFilterDescriptor;\n\nextern\nconst\nKSPIN_DESCRIPTOR_EX\nCaptureFilterPinDescriptors [CAPTURE_FILTER_PIN_COUNT];\n\nextern\nconst\nGUID\nCaptureFilterCategories [CAPTURE_FILTER_CATEGORIES_COUNT];\n\n//\n// capture.cpp externs:\n//\nextern \nconst\nKSALLOCATOR_FRAMING_EX\nCapturePinAllocatorFraming;\n\nextern \nconst\nKSPIN_DISPATCH\nCapturePinDispatch;\n\nextern\nconst\nPKSDATARANGE\nCapturePinDataRanges [CAPTURE_PIN_DATA_RANGE_COUNT];\n\n/*************************************************\n\n    Enums / Typedefs\n\n*************************************************/\n\ntypedef enum _HARDWARE_STATE {\n\n    HardwareStopped = 0,\n    HardwarePaused,\n    HardwareRunning\n\n} HARDWARE_STATE, *PHARDWARE_STATE;\n\n/*************************************************\n\n    Class Definitions\n\n*************************************************/\n\n//\n// IHardwareSink:\n//\n// This interface is used by the hardware simulation to fake interrupt\n// service routines.  The Interrupt method is called at DPC as a fake\n// interrupt.\n//\nclass IHardwareSink {\n\npublic:\n\n    virtual\n    void\n    Interrupt (\n        ) = 0;\n\n};\n\n//\n// ICaptureSink:\n//\n// This is a capture sink interface.  The device level calls back the\n// CompleteMappings method passing the number of completed mappings for\n// the capture pin.  This method is called during the device DPC.\n//\nclass ICaptureSink {\n\npublic:\n\n    virtual\n    void\n    CompleteMappings (\n        IN ULONG NumMappings\n        ) = 0;\n\n};\n\n\n\n/*************************************************\n\n    Global Functions\n\n*************************************************/\n#ifndef _NEW_DELETE_OPERATORS_\n#define _NEW_DELETE_OPERATORS_\n\n/*************************************************\n\n    Add definitions that are missing for C++14.\n\n*************************************************/\n\nPVOID operator new\n(\n    size_t          iSize,\n    _When_((poolType & NonPagedPoolMustSucceed) != 0,\n       __drv_reportError(\"Must succeed pool allocations are forbidden. \"\n             \"Allocation failures cause a system crash\"))\n    POOL_TYPE       poolType\n);\n\nPVOID operator new\n(\n    size_t          iSize,\n    _When_((poolType & NonPagedPoolMustSucceed) != 0,\n       __drv_reportError(\"Must succeed pool allocations are forbidden. \"\n             \"Allocation failures cause a system crash\"))\n    POOL_TYPE       poolType,\n    ULONG           tag\n);\n\n/*++\n\nRoutine Description:\n\n    Array new() operator for creating objects with a specified allocation tag.\n\nArguments:\n\n    iSize -\n        The size of the entire allocation.\n\n    poolType -\n        The type of allocation.  Ex: PagedPool or NonPagedPoolNx\n\n    tag -\n        A 4-byte allocation identifier.\n\nReturn Value:\n\n    None\n\n--*/\nPVOID \noperator new[](\n    size_t          iSize,\n    _When_((poolType & NonPagedPoolMustSucceed) != 0,\n        __drv_reportError(\"Must succeed pool allocations are forbidden. \"\n            \"Allocation failures cause a system crash\"))\n    POOL_TYPE       poolType,\n    ULONG           tag\n);\n\n/*++\n\nRoutine Description:\n\n    Array delete() operator.\n\nArguments:\n\n    pVoid -\n        The memory to free.\n\nReturn Value:\n\n    None\n\n--*/\nvoid \n__cdecl \noperator delete[](\n    PVOID pVoid\n);\n\n/*++\n\nRoutine Description:\n\n    Sized delete() operator.\n\nArguments:\n\n    pVoid -\n        The memory to free.\n\n    size -\n        The size of the memory to free.\n\nReturn Value:\n\n    None\n\n--*/\nvoid __cdecl operator delete\n(\n    void *pVoid,\n    size_t /*size*/\n);\n\n/*++\n\nRoutine Description:\n\n    Sized delete[]() operator.\n\nArguments:\n\n    pVoid -\n        The memory to free.\n\n    size -\n        The size of the memory to free.\n\nReturn Value:\n\n    None\n\n--*/\nvoid __cdecl operator delete[]\n(\n    void *pVoid,\n    size_t /*size*/\n);\n\n#endif // _NEW_DELETE_OPERATORS_\n\n\n\n\n/*************************************************\n\n    Internal Includes\n\n*************************************************/\n\n#include \"image.h\"\n#include \"hwsim.h\"\n#include \"device.h\"\n#include \"filter.h\"\n#include \"capture.h\"\n#include <uuids.h>\n#endif //_avshws_h_"
  },
  {
    "path": "Driver/avshws/avshws.inf",
    "content": ";/*++\n;\n;Copyright (c) Microsoft Corporation.  All rights reserved.\n;\n;    THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF ANY\n;    KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\n;    IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR\n;    PURPOSE.\n;\n;Module Name:\n;\n;    AVSHWS.INF\n;\n;Abstract:\n;\n;\n;AVStream pin centric sample mini driver (AVSHWS.sys) installation file. \n;Supports x86, amd64, arm and arm64 platforms\n;\n;--*/\n\n[Version]\nsignature=\"$WINDOWS NT$\"\nClass=Camera\nClassGuid={ca3e7ab9-b4c3-4ae6-8251-579ef933890f}\nProvider=%ProviderName%\nCatalogfile=avshws.cat\nDriverVer=01/01/2020,6.0.5600.0\n\n[SourceDisksNames]\n1000=%cdname%,,,\n\n[SourceDisksFiles]\navshws.sys=1000\n\n[DestinationDirs]\nDefaultDestDir=12\navshws.CopyFiles=12\n\n[avshws.CopyFiles]\navshws.sys\n\n[Manufacturer]\n%ManufacturerName%=Standard,NTx86,NTamd64,ntarm,ntarm64\n\n[Standard.NTx86]\n%avshws.DeviceDesc%=avshws.NTx86,AVSHWS\n\n[Standard.NTamd64]\n%avshws.DeviceDesc%=avshws.NTamd64,AVSHWS\n\n[Standard.NTarm]\n%avshws.DeviceDesc%=avshws.NTarm,AVSHWS\n\n[Standard.NTarm64]\n%avshws.DeviceDesc%=avshws.NTarm64,AVSHWS\n\n;---------------------------------------------------------------\n;                x 86  D D I n s t a l l\n;---------------------------------------------------------------\n\n[avshws.NTx86]\nInclude=ks.inf, KSCAPTUR.inf\nNeeds=KS.Registration,KSCAPTUR.Registration.NT\nCopyFiles=avshws.CopyFiles\n\n;---------------------------------------------------------------\n;                A M D 64  D D I n s t a l l\n;---------------------------------------------------------------\n\n[avshws.NTamd64]\nInclude=ks.inf,KSCAPTUR.inf\nNeeds=KS.Registration,KSCAPTUR.Registration.NT\nCopyFiles=avshws.CopyFiles\n\n;---------------------------------------------------------------\n;                A R M  D D I n s t a l l\n;---------------------------------------------------------------\n\n[avshws.NTarm]\nInclude=ks.inf,KSCAPTUR.inf\nNeeds=KS.Registration,KSCAPTUR.Registration.NT\nCopyFiles=avshws.CopyFiles\n\n;---------------------------------------------------------------\n;                A R M 64  D D I n s t a l l\n;---------------------------------------------------------------\n\n[avshws.NTarm64]\nInclude=ks.inf,KSCAPTUR.inf\nNeeds=KS.Registration,KSCAPTUR.Registration.NT\nCopyFiles=avshws.CopyFiles\n\n;---------------------------------------------------------------\n;                I n t e r f a c e s\n;---------------------------------------------------------------\n\n[avshws.NTx86.Interfaces]\nAddInterface=%KSCATEGORY_CAPTURE%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO_CAMERA%,\"GLOBAL\",CaptureInterface.NT,0\n\n[avshws.NTamd64.Interfaces]\nAddInterface=%KSCATEGORY_CAPTURE%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO_CAMERA%,\"GLOBAL\",CaptureInterface.NT,0\n\n[avshws.NTarm.Interfaces]\nAddInterface=%KSCATEGORY_CAPTURE%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO_CAMERA%,\"GLOBAL\",CaptureInterface.NT,0\n\n[avshws.NTarm64.Interfaces]\nAddInterface=%KSCATEGORY_CAPTURE%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO%,\"GLOBAL\",CaptureInterface.NT,0\nAddInterface=%KSCATEGORY_VIDEO_CAMERA%,\"GLOBAL\",CaptureInterface.NT,0\n\n[CaptureInterface.NT]\nAddReg=avshws.Reader.AddReg\n\n;---------------------------------------------------------------\n;                A d d R e g\n;---------------------------------------------------------------\n\n[avshws.Reader.AddReg]\nHKR,,CLSID,,%Proxy.CLSID%\nHKR,,FriendlyName,,%avshws.Reader.FriendlyName%\n\n;---------------------------------------------------------------\n;                S e r v i c e s  \n;---------------------------------------------------------------\n\n[avshws.NTx86.Services]\nAddService=avshws, 0x00000002, avshws.ServiceInstall\n\n[avshws.NTamd64.Services]\nAddService=avshws, 0x00000002, avshws.ServiceInstall\n\n[avshws.NTarm.Services]\nAddService=avshws, 0x00000002, avshws.ServiceInstall\n\n[avshws.NTarm64.Services]\nAddService=avshws, 0x00000002, avshws.ServiceInstall\n\n[avshws.ServiceInstall]\nDisplayName=%avshws.DeviceDesc%\nServiceType=%SERVICE_KERNEL_DRIVER%\nStartType=%SERVICE_DEMAND_START%\nErrorControl=%SERVICE_ERROR_NORMAL%\nServiceBinary=%12%\\avshws.sys\n\n;---------------------------------------------------------------\n;                S t r i n g s\n;---------------------------------------------------------------\n\n[Strings]\n; non-localizable\nProxy.CLSID=\"{17CCA71B-ECD7-11D0-B908-00A0C9223196}\"\nKSCATEGORY_CAPTURE=\"{65E8773D-8F56-11D0-A3B9-00A0C9223196}\"\nKSCATEGORY_VIDEO=\"{6994AD05-93EF-11D0-A3CC-00A0C9223196}\"\nKSCATEGORY_VIDEO_CAMERA=\"{E5323777-F976-4f5b-9B55-B94699C46E44}\"\n\nSERVICE_KERNEL_DRIVER=1\nSERVICE_DEMAND_START=3\nSERVICE_ERROR_NORMAL=1\nREG_DWORD=0x00010001\n\n;localizable\nProviderName=\"TODO-Set-Provider\"\nManufacturerName=\"TODO-Set-Manufacturer\"\navshws.DeviceDesc=\"AVStream Simulated Hardware Sample\"\navshws.Reader.FriendlyName=\"avshws Source\"\ncdname=\"AVSHWS Installation Disk\""
  },
  {
    "path": "Driver/avshws/avshws.rc",
    "content": "//+-------------------------------------------------------------------------\n//\n//  Microsoft Windows\n//\n//  Copyright (C) Microsoft Corporation, 1999 - 1999\n//\n//  File:       captst.rc\n//\n//--------------------------------------------------------------------------\n\n#include <windows.h>\n\n#include <ntverp.h>\n\n#define VER_FILETYPE                VFT_DRV\n#define VER_FILESUBTYPE             VFT2_UNKNOWN\n#define VER_FILEDESCRIPTION_STR     \"AVStream Simulated Hardware Sample\"\n#define VER_INTERNALNAME_STR        \"avshws.sys\"\n#define VER_ORIGINALFILENAME_STR    \"avshws.sys\"\n\n#include \"common.ver\"\n\n"
  },
  {
    "path": "Driver/avshws/avshws.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 15\nVisualStudioVersion = 15.0.28307.136\nMinimumVisualStudioVersion = 12.0\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"avshws\", \"avshws.vcxproj\", \"{77FA53EC-3637-411C-B708-C8EED64543A4}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|ARM = Debug|ARM\n\t\tDebug|ARM64 = Debug|ARM64\n\t\tDebug|Win32 = Debug|Win32\n\t\tDebug|x64 = Debug|x64\n\t\tRelease|ARM = Release|ARM\n\t\tRelease|ARM64 = Release|ARM64\n\t\tRelease|Win32 = Release|Win32\n\t\tRelease|x64 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|ARM.ActiveCfg = Debug|ARM\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|ARM.Build.0 = Debug|ARM\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|ARM.Deploy.0 = Debug|ARM\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|ARM64.ActiveCfg = Debug|ARM64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|ARM64.Build.0 = Debug|ARM64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|ARM64.Deploy.0 = Debug|ARM64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Debug|x64.Build.0 = Debug|x64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|ARM.ActiveCfg = Release|ARM\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|ARM.Build.0 = Release|ARM\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|ARM.Deploy.0 = Release|ARM\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|ARM64.ActiveCfg = Release|ARM64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|ARM64.Build.0 = Release|ARM64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|ARM64.Deploy.0 = Release|ARM64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|Win32.Build.0 = Release|Win32\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|x64.ActiveCfg = Release|x64\n\t\t{77FA53EC-3637-411C-B708-C8EED64543A4}.Release|x64.Build.0 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {5EBC439F-EC31-448F-B129-434D42485011}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "Driver/avshws/avshws.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|ARM\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|ARM64\">\n      <Configuration>Debug</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|ARM64\">\n      <Configuration>Release</Configuration>\n      <Platform>ARM64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{77FA53EC-3637-411C-B708-C8EED64543A4}</ProjectGuid>\n    <RootNamespace>$(MSBuildProjectName)</RootNamespace>\n    <Configuration Condition=\"'$(Configuration)' == ''\">Debug</Configuration>\n    <Platform Condition=\"'$(Platform)' == ''\">Win32</Platform>\n    <SampleGuid>{555099C6-5354-4C50-A241-A09CDD72299D}</SampleGuid>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>False</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>True</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>False</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>False</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>False</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>True</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>True</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\" Label=\"Configuration\">\n    <TargetVersion>Windows10</TargetVersion>\n    <UseDebugLibraries>True</UseDebugLibraries>\n    <DriverTargetPlatform>Universal</DriverTargetPlatform>\n    <DriverType>WDM</DriverType>\n    <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>\n    <ConfigurationType>Driver</ConfigurationType>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <PropertyGroup>\n    <OutDir>$(IntDir)</OutDir>\n  </PropertyGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\" Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" />\n  </ImportGroup>\n  <ItemGroup Label=\"WrappedTaskItems\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <TargetName>avshws</TargetName>\n    <Inf2CatUseLocalTime>true</Inf2CatUseLocalTime>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\n    <TargetName>avshws</TargetName>\n  </PropertyGroup>\n  <ItemDefinitionGroup>\n    <Link>\n      <AdditionalDependencies>%(AdditionalDependencies);$(DDK_LIB_PATH)\\ks.lib;$(DDK_LIB_PATH)\\ntoskrnl.lib</AdditionalDependencies>\n      <AdditionalOptions>%(AdditionalOptions)  -merge:PAGECONST=PAGE</AdditionalOptions>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|ARM64'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|ARM64'\">\n    <ResourceCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </ResourceCompile>\n    <ClCompile>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <TreatWarningAsError>true</TreatWarningAsError>\n      <WarningLevel>Level4</WarningLevel>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n      <ExceptionHandling>\n      </ExceptionHandling>\n    </ClCompile>\n    <Midl>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(DDK_INC_PATH)</AdditionalIncludeDirectories>\n      <PreprocessorDefinitions>%(PreprocessorDefinitions);UNICODE;_UNICODE;DEBUG_LEVEL=DEBUGLVL_BLAB;_WIN2K_COMPAT_SLIST_USAGE;_NO_SYS_GUID_OPERATOR_EQ_</PreprocessorDefinitions>\n    </Midl>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"capture.cpp\" />\n    <ClCompile Include=\"device.cpp\" />\n    <ClCompile Include=\"filter.cpp\" />\n    <ClCompile Include=\"hwsim.cpp\" />\n    <ClCompile Include=\"image.cpp\" />\n    <ClCompile Include=\"purecall.c\" />\n    <ResourceCompile Include=\"avshws.rc\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Inf Exclude=\"@(Inf)\" Include=\"*.inf\" />\n    <FilesToPackage Include=\"$(TargetPath)\" Condition=\"'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'\" />\n  </ItemGroup>\n  <ItemGroup>\n    <None Exclude=\"@(None)\" Include=\"*.txt;*.htm;*.html\" />\n    <None Exclude=\"@(None)\" Include=\"*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2\" />\n    <None Exclude=\"@(None)\" Include=\"*.def;*.bat;*.hpj;*.asmx\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"avshws.h\" />\n    <ClInclude Include=\"capture.h\" />\n    <ClInclude Exclude=\"@(ClInclude)\" Include=\"customprops.h\" />\n    <ClInclude Include=\"device.h\" />\n    <ClInclude Include=\"filter.h\" />\n    <ClInclude Include=\"hwsim.h\" />\n    <ClInclude Include=\"image.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n</Project>"
  },
  {
    "path": "Driver/avshws/avshws.vcxproj.Filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;*</Extensions>\n      <UniqueIdentifier>{124F9628-D980-4A5F-BCB3-C73BBF85F98E}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n      <UniqueIdentifier>{53840AE7-57A9-46F8-8D16-B52859B4C272}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml</Extensions>\n      <UniqueIdentifier>{1156F063-8F29-4654-8347-0519BE2E0418}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Driver Files\">\n      <Extensions>inf;inv;inx;mof;mc;</Extensions>\n      <UniqueIdentifier>{77087805-4D7E-4591-B71F-4ABA9576DD2A}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"capture.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"device.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"filter.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"hwsim.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"purecall.c\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"image.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"avshws.rc\">\n      <Filter>Resource Files</Filter>\n    </ResourceCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"capture.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"customprops.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"device.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"filter.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"hwsim.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"image.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"customprops.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"avshws.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"capture.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"device.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"filter.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"hwsim.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"image.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <Inf Include=\"*.inf\">\n      <Filter>Driver Files</Filter>\n    </Inf>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"*.txt;*.htm;*.html\" />\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "Driver/avshws/capture.cpp",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        capture.cpp\n\n    Abstract:\n\n        This file contains source for the video capture pin on the capture\n        filter.  The capture sample performs \"fake\" DMA directly into\n        the capture buffers.  Common buffer DMA will work slightly differently.\n\n        For common buffer DMA, the general technique would be DPC schedules\n        processing with KsPinAttemptProcessing.  The processing routine grabs\n        the leading edge, copies data out of the common buffer and advances.\n        Cloning would not be necessary with this technique.  It would be \n        similiar to the way \"AVSSamp\" works, but it would be pin-centric.\n\n    History:\n\n        created 3/8/2001\n\n**************************************************************************/\n\n#include \"avshws.h\"\n#include <ksmedia.h>\n#include <ntintsafe.h>\n\n/**************************************************************************\n\n    PAGEABLE CODE\n\n**************************************************************************/\n\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg(\"PAGE\")\n#endif // ALLOC_PRAGMA\n\n//OG: 320x240\n#define DMAX_X 1280\n#define DMAX_Y 720\n#define D_X 1280\n#define D_Y 720\n\nCCapturePin::\nCCapturePin (\n    IN PKSPIN Pin\n    ) :\n    m_Pin (Pin)\n    ,m_PresentationTime (0)\n\n/*++\n\nRoutine Description:\n\n    Construct a new capture pin.\n\nArguments:\n\n    Pin -\n        The AVStream pin object corresponding to the capture pin\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    PKSDEVICE Device = KsPinGetDevice (Pin);\n\n    //\n    // Set up our device pointer.  This gives us access to \"hardware I/O\"\n    // during the capture routines.\n    //\n    m_Device = reinterpret_cast <CCaptureDevice *> (Device -> Context);\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCapturePin::\nDispatchCreate (\n    IN PKSPIN Pin,\n    IN PIRP Irp\n    )\n\n/*++\n\nRoutine Description:\n\n    Create a new capture pin.  This is the creation dispatch for\n    the video capture pin.\n\nArguments:\n\n    Pin -\n        The pin being created\n\n    Irp -\n        The creation Irp\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_SUCCESS;\n\n    CCapturePin *CapPin = new (NonPagedPoolNx, 'niPC') CCapturePin (Pin);\n\n    if (!CapPin) {\n        //\n        // Return failure if we couldn't create the pin.\n        //\n        Status = STATUS_INSUFFICIENT_RESOURCES;\n\n    } else {\n        //\n        // Add the item to the object bag if we we were successful. \n        // Whenever the pin closes, the bag is cleaned up and we will be\n        // freed.\n        //\n        Status = KsAddItemToObjectBag (\n            Pin -> Bag,\n            reinterpret_cast <PVOID> (CapPin),\n            reinterpret_cast <PFNKSFREE> (CCapturePin::Cleanup)\n            );\n\n        if (!NT_SUCCESS (Status)) {\n            delete CapPin;\n        } else {\n            Pin -> Context = reinterpret_cast <PVOID> (CapPin);\n        }\n\n    }\n\n    //\n    // If we succeeded so far, stash the video info header away and change\n    // our allocator framing to reflect the fact that only now do we know\n    // the framing requirements based on the connection format.\n    //\n    PKS_VIDEOINFOHEADER VideoInfoHeader = NULL;\n\n    if (NT_SUCCESS (Status)) {\n\n        VideoInfoHeader = CapPin -> CaptureVideoInfoHeader ();\n        if (!VideoInfoHeader) {\n            Status = STATUS_INSUFFICIENT_RESOURCES;\n        }\n    }\n\n    if (NT_SUCCESS(Status)) {\n        //\n        // We need to edit the descriptor to ensure we don't mess up any other\n        // pins using the descriptor or touch read-only memory.\n        //\n        Status = KsEdit (\n            Pin, \n            &Pin -> Descriptor, \n            AVSHWS_POOLTAG);\n\n        if (NT_SUCCESS (Status)) { \n\n            //\n            // If the edits proceeded without running out of memory, adjust \n            // the framing based on the video info header.\n            //\n            Status = KsEdit (\n                Pin, \n                &Pin -> Descriptor -> AllocatorFraming, \n                AVSHWS_POOLTAG);\n\n            if (NT_SUCCESS (Status)) {\n\n                //\n                // We've KsEdit'ed this...  I'm safe to cast away constness as\n                // long as the edit succeeded.\n                //\n                PKSALLOCATOR_FRAMING_EX Framing =\n                    const_cast <PKSALLOCATOR_FRAMING_EX> (\n                        Pin -> Descriptor -> AllocatorFraming\n                        );\n\n                Framing -> FramingItem [0].Frames = 2;\n\n                //\n                // The physical and optimal ranges must be biSizeImage.  We only\n                // support one frame size, precisely the size of each capture\n                // image.\n                //\n                Framing -> FramingItem [0].PhysicalRange.MinFrameSize =\n                    Framing -> FramingItem [0].PhysicalRange.MaxFrameSize =\n                    Framing -> FramingItem [0].FramingRange.Range.MinFrameSize =\n                    Framing -> FramingItem [0].FramingRange.Range.MaxFrameSize =\n                    VideoInfoHeader -> bmiHeader.biSizeImage;\n\n                Framing -> FramingItem [0].PhysicalRange.Stepping = \n                    Framing -> FramingItem [0].FramingRange.Range.Stepping =\n                    0;\n\n            }\n\n        }\n    }\n\n    if (NT_SUCCESS (Status)) {\n        //\n        // Adjust the stream header size.  The video packets have extended\n        // header info (KS_FRAME_INFO).\n        //\n        Pin -> StreamHeaderSize = sizeof (KSSTREAM_HEADER) +\n            sizeof (KS_FRAME_INFO);\n\n    }\n    return Status;\n}\n\n/*************************************************/\n\n\f\nPKS_VIDEOINFOHEADER \nCCapturePin::\nCaptureVideoInfoHeader (\n    )\n\n/*++\n\nRoutine Description:\n\n    Capture the video info header out of the connection format.  This\n    is what we use to base synthesized images off.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    The captured video info header or NULL if there is insufficient\n    memory.\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    PKS_VIDEOINFOHEADER ConnectionHeader =\n        &((reinterpret_cast <PKS_DATAFORMAT_VIDEOINFOHEADER> \n            (m_Pin -> ConnectionFormat)) -> \n            VideoInfoHeader);\n\n    m_VideoInfoHeader = reinterpret_cast <PKS_VIDEOINFOHEADER> (\n        ExAllocatePoolWithTag (\n            NonPagedPoolNx,\n            KS_SIZE_VIDEOHEADER (ConnectionHeader),\n            AVSHWS_POOLTAG\n            )\n        );\n\n    if (!m_VideoInfoHeader)\n        return NULL;\n\n    //\n    // Bag the newly allocated header space.  This will get cleaned up\n    // automatically when the pin closes.\n    //\n    NTSTATUS Status =\n        KsAddItemToObjectBag (\n            m_Pin -> Bag,\n            reinterpret_cast <PVOID> (m_VideoInfoHeader),\n            NULL\n            );\n\n    if (!NT_SUCCESS (Status)) {\n\n        ExFreePool (m_VideoInfoHeader);\n        return NULL;\n\n    } else {\n\n        //\n        // Copy the connection format video info header into the newly \n        // allocated \"captured\" video info header.\n        //\n        RtlCopyMemory (\n            m_VideoInfoHeader,\n            ConnectionHeader,\n            KS_SIZE_VIDEOHEADER (ConnectionHeader)\n            );\n\n    }\n\n    return m_VideoInfoHeader;\n\n}\n\n\f\nNTSTATUS\nCCapturePin::\nProcess (\n    )\n\n/*++\n\nRoutine Description:\n\n    The process dispatch for the pin bridges to this location.\n    We handle setting up scatter gather mappings, etc...\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_SUCCESS;\n    PKSSTREAM_POINTER Leading;\n\n    _DbgPrintF(DEBUGLVL_VERBOSE, (\"Process\"));\n\n    Leading = KsPinGetLeadingEdgeStreamPointer (\n        m_Pin,\n        KSSTREAM_POINTER_STATE_LOCKED\n        );\n\n    while (NT_SUCCESS (Status) && Leading) {\n\n        PKSSTREAM_POINTER ClonePointer;\n        PSTREAM_POINTER_CONTEXT SPContext = NULL;\n\n        //\n        // If no data is present in the Leading edge stream pointer, just \n        // move on to the next frame\n        //\n        if ( NULL == Leading -> StreamHeader -> Data ) {\n            Status = KsStreamPointerAdvance(Leading);\n            continue;\n        }\n        //\n        // For optimization sake in this particular sample, I will only keep\n        // one clone stream pointer per frame.  This complicates the logic\n        // here but simplifies the completions.\n        //\n        // I'm also choosing to do this since I need to keep track of the\n        // virtual addresses corresponding to each mapping since I'm faking\n        // DMA.  It simplifies that too.\n        //\n        if (!m_PreviousStreamPointer) {\n            //\n            // First thing we need to do is clone the leading edge.  This allows\n            // us to keep reference on the frames while they're in DMA.\n            //\n            Status = KsStreamPointerClone (\n                Leading,\n                NULL,\n                sizeof (STREAM_POINTER_CONTEXT),\n                &ClonePointer\n                );\n\n            //\n            // I use this for easy chunking of the buffer.  We're not really\n            // dealing with physical addresses.  This keeps track of what \n            // virtual address in the buffer the current scatter / gather \n            // mapping corresponds to for the fake hardware.\n            //\n            if (NT_SUCCESS (Status)) {\n\n                //\n                // Set the stream header data used to 0.  We update this \n                // in the DMA completions.  For queues with DMA, we must\n                // update this field ourselves.\n                //\n                ClonePointer -> StreamHeader -> DataUsed = 0;\n\n                SPContext = reinterpret_cast <PSTREAM_POINTER_CONTEXT> \n                    (ClonePointer -> Context);\n\n                SPContext -> BufferVirtual = \n                    reinterpret_cast <PUCHAR> (\n                        ClonePointer -> StreamHeader -> Data\n                        );\n            }\n\n        } else {\n\n            ClonePointer = m_PreviousStreamPointer;\n            SPContext = reinterpret_cast <PSTREAM_POINTER_CONTEXT> \n                (ClonePointer -> Context);\n            Status = STATUS_SUCCESS;\n        }\n\n        //\n        // If the clone failed, likely we're out of resources.  Break out\n        // of the loop for now.  We may end up starving DMA.\n        //\n        if (!NT_SUCCESS (Status)) {\n            KsStreamPointerUnlock (Leading, FALSE);\n            break;\n        }\n\n        //\n        // Program the fake hardware.  I would use Clone -> OffsetOut.*, but\n        // because of the optimization of one stream pointer per frame, it\n        // doesn't make complete sense.\n        //\n        ULONG MappingsUsed =\n            m_Device -> ProgramScatterGatherMappings (\n                ClonePointer,\n                &(SPContext -> BufferVirtual),\n                Leading -> OffsetOut.Mappings,\n                Leading -> OffsetOut.Remaining\n                );\n\n        //\n        // In order to keep one clone per frame and simplify the fake DMA\n        // logic, make a check to see if we completely used the mappings in\n        // the leading edge.  Set a flag.\n        //\n        if (MappingsUsed == Leading -> OffsetOut.Remaining) {\n            m_PreviousStreamPointer = NULL;\n        } else {\n            m_PreviousStreamPointer = ClonePointer;\n        }\n\n        if (MappingsUsed) {\n            //\n            // If any mappings were added to scatter / gather queues, \n            // advance the leading edge by that number of mappings.  If \n            // we run off the end of the queue, Status will be \n            // STATUS_DEVICE_NOT_READY.  Otherwise, the leading edge will\n            // point to a new frame.  The previous one will not have been\n            // dismissed (unless \"DMA\" completed) since there's a clone\n            // pointer referencing the frames.\n            //\n            Status =\n                KsStreamPointerAdvanceOffsets (\n                    Leading,\n                    0,\n                    MappingsUsed,\n                    FALSE\n                    );\n        } else {\n\n            //\n            // The hardware was incapable of adding more entries.  The S/G\n            // table is full.\n            //\n            Status = STATUS_PENDING;\n            break;\n\n        }\n\n    }\n\n    //\n    // If the leading edge failed to lock (this is always possible, remember\n    // that locking CAN occassionally fail), don't blow up passing NULL\n    // into KsStreamPointerUnlock.  Also, set m_PendIo to kick us later...\n    //\n    if (!Leading) {\n\n        m_PendIo = TRUE;\n\n        //\n        // If the lock failed, there's no point in getting called back \n        // immediately.  The lock could fail due to insufficient memory,\n        // etc...  In this case, we don't want to get called back immediately.\n        // Return pending.  The m_PendIo flag will cause us to get kicked\n        // later.\n        //\n        Status = STATUS_PENDING;\n    }\n\n    //\n    // If we didn't run the leading edge off the end of the queue, unlock it.\n    //\n    if (NT_SUCCESS (Status) && Leading) {\n        KsStreamPointerUnlock (Leading, FALSE);\n    } else {\n        //\n        // DEVICE_NOT_READY indicates that the advancement ran off the end\n        // of the queue.  We couldn't lock the leading edge.\n        //\n        if (Status == STATUS_DEVICE_NOT_READY) Status = STATUS_SUCCESS;\n    }\n\n    //\n    // If we failed with something that requires pending, set the pending I/O\n    // flag so we know we need to start it again in a completion DPC.\n    //\n    if (!NT_SUCCESS (Status) || Status == STATUS_PENDING) {\n        m_PendIo = TRUE;\n    }\n\n    _DbgPrintF(DEBUGLVL_VERBOSE, (\"Leaving Process...\"));\n    return Status;\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCapturePin::\nCleanupReferences (\n    )\n\n/*++\n\nRoutine Description:\n\n    Clean up any references we're holding on frames after we abruptly\n    stop the hardware.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    PKSSTREAM_POINTER Clone = KsPinGetFirstCloneStreamPointer (m_Pin);\n    PKSSTREAM_POINTER NextClone = NULL;\n\n    //\n    // Walk through the clones, deleting them, and setting DataUsed to\n    // zero since we didn't use any data!\n    //\n    while (Clone) {\n\n        NextClone = KsStreamPointerGetNextClone (Clone);\n\n        Clone -> StreamHeader -> DataUsed = 0;\n        KsStreamPointerDelete (Clone);\n\n        Clone = NextClone;\n\n    }\n\n    return STATUS_SUCCESS;\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCapturePin::\nSetState (\n    IN KSSTATE ToState,\n    IN KSSTATE FromState\n    )\n\n/*++\n\nRoutine Description:\n\n    This is called when the caputre pin transitions state.  The routine\n    attempts to acquire / release any hardware resources and start up\n    or shut down capture based on the states we are transitioning to\n    and away from.\n\nArguments:\n\n    ToState -\n        The state we're transitioning to\n\n    FromState -\n        The state we're transitioning away from\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_SUCCESS;\n\n    switch (ToState) {\n\n        case KSSTATE_STOP:\n\n            //\n            // First, stop the hardware if we actually did anything to it.\n            //\n            if (m_HardwareState != HardwareStopped) {\n                Status = m_Device -> Stop ();\n                NT_ASSERT (NT_SUCCESS (Status));\n\n                m_HardwareState = HardwareStopped;\n            }\n\n            //\n            // We've stopped the \"fake hardware\".  It has cleared out\n            // it's scatter / gather tables and will no longer be \n            // completing clones.  We had locks on some frames that were,\n            // however, in hardware.  This will clean them up.  An\n            // alternative location would be in the reset dispatch.\n            // Note, however, that the reset dispatch can occur in any\n            // state and this should be understood.\n            //\n            // Some hardware may fill all S/G mappings before stopping...\n            // in this case, you may not have to do this.  The \n            // \"fake hardware\" here simply stops filling mappings and \n            // cleans its scatter / gather tables out on the Stop call.\n            //\n            Status = CleanupReferences ();\n\n            //\n            // Release any hardware resources related to this pin.\n            //\n            if (m_AcquiredResources) {\n                //\n                // If we got an interface to the clock, we must release it.\n                //\n                if (m_Clock) {\n                    m_Clock -> Release ();\n                    m_Clock = NULL;\n                }\n\n                m_Device -> ReleaseHardwareResources (\n                    );\n\n                m_AcquiredResources = FALSE;\n            }\n\n            break;\n\n        case KSSTATE_ACQUIRE:\n            //\n            // Acquire any hardware resources related to this pin.  We should\n            // only acquire them here -- **NOT** at filter create time. \n            // This means we do not fail creation of a filter because of\n            // limited hardware resources.\n            //\n            if (FromState == KSSTATE_STOP) {\n                Status = m_Device -> AcquireHardwareResources (\n                    this,\n                    m_VideoInfoHeader\n                    );\n\n                if (NT_SUCCESS (Status)) {\n                    m_AcquiredResources = TRUE;\n\n                    //\n                    // Attempt to get an interface to the master clock.\n                    // This will fail if one has not been assigned.  Since\n                    // one must be assigned while the pin is still in \n                    // KSSTATE_STOP, this is a guranteed method of getting\n                    // the clock should one be assigned.\n                    //\n                    if (!NT_SUCCESS (\n                        KsPinGetReferenceClockInterface (\n                            m_Pin,\n                            &m_Clock\n                            )\n                        )) {\n\n                        //\n                        // If we could not get an interface to the clock,\n                        // don't use one.  \n                        //\n                        m_Clock = NULL;\n\n                    }\n\n                } else {\n                    m_AcquiredResources = FALSE;\n                }\n\n            } else {\n                //\n                // Standard transport pins will always receive transitions in\n                // +/- 1 manner.  This means we'll always see a PAUSE->ACQUIRE\n                // transition before stopping the pin.  \n                //\n                // The below is done because on DirectX 8.0, when the pin gets\n                // a message to stop, the queue is inaccessible.  The reset \n                // which comes on every stop happens after this (at which time\n                // the queue is inaccessible also).  So, for compatibility with\n                // DirectX 8.0, I am stopping the \"fake\" hardware at this\n                // point and cleaning up all references we have on frames.  See\n                // the comments above regarding the CleanupReferences call.\n                //\n                // If this sample were targeting XP only, the below code would\n                // not be here.  Again, I only do this so the sample does not\n                // hang when it is stopped running on a configuration such as\n                // Win2K + DX8. \n                //\n                if (m_HardwareState != HardwareStopped) {\n                    Status = m_Device -> Stop ();\n                    NT_ASSERT (NT_SUCCESS (Status));\n\n                    m_HardwareState = HardwareStopped;\n                }\n\n                Status = CleanupReferences ();\n            }\n\n            m_FrameNumber   = 0;\n            m_DroppedFrames = 0;\n            break;\n\n        case KSSTATE_PAUSE:\n            //\n            // Stop the hardware simulation if we're coming down from run.\n            //\n            if (FromState == KSSTATE_RUN) {\n\n                m_PresentationTime = 0;\n                Status = m_Device -> Pause (TRUE);\n\n                if (NT_SUCCESS (Status)) {\n                    m_HardwareState = HardwarePaused;\n                }\n\n            }\n            m_FrameNumber   = 0;\n            break;\n\n        case KSSTATE_RUN:\n            //\n            // Start the hardware simulation or unpause it depending on\n            // whether we're initially running or we've paused and restarted.\n            //\n            if (m_HardwareState == HardwarePaused) {\n                Status = m_Device -> Pause (FALSE);\n            } else {\n                Status = m_Device -> Start ();\n            }\n\n            if (NT_SUCCESS (Status)) {\n                m_HardwareState = HardwareRunning;\n            }\n\n            break;\n\n    }\n\n    return Status;\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCapturePin::\nIntersectHandler (\n    IN PKSFILTER Filter,\n    IN PIRP Irp,\n    IN PKSP_PIN PinInstance,\n    IN PKSDATARANGE CallerDataRange,\n    IN PKSDATARANGE DescriptorDataRange,\n    IN ULONG BufferSize,\n    OUT PVOID Data OPTIONAL,\n    OUT PULONG DataSize\n    )\n\n/*++\n\nRoutine Description:\n\n    This routine handles video pin intersection queries by determining the\n    intersection between two data ranges.\n\nArguments:\n\n    Filter -\n        Contains a void pointer to the  filter structure.\n\n    Irp -\n        Contains a pointer to the data intersection property request.\n\n    PinInstance -\n        Contains a pointer to a structure indicating the pin in question.\n\n    CallerDataRange -\n        Contains a pointer to one of the data ranges supplied by the client\n        in the data intersection request.  The format type, subtype and\n        specifier are compatible with the DescriptorDataRange.\n\n    DescriptorDataRange -\n        Contains a pointer to one of the data ranges from the pin descriptor\n        for the pin in question.  The format type, subtype and specifier are\n        compatible with the CallerDataRange.\n\n    BufferSize -\n        Contains the size in bytes of the buffer pointed to by the Data\n        argument.  For size queries, this value will be zero.\n\n    Data -\n        Optionally contains a pointer to the buffer to contain the data \n        format structure representing the best format in the intersection \n        of the two data ranges.  For size queries, this pointer will be \n        NULL.\n\n    DataSize -\n        Contains a pointer to the location at which to deposit the size \n        of the data format.  This information is supplied by the function \n        when the format is actually delivered and in response to size \n        queries.\n\nReturn Value:\n\n    STATUS_SUCCESS if there is an intersection and it fits in the supplied\n    buffer, STATUS_BUFFER_OVERFLOW for successful size queries, \n    STATUS_NO_MATCH if the intersection is empty, or \n    STATUS_BUFFER_TOO_SMALL if the supplied buffer is too small.\n\n--*/\n\n{\n    PAGED_CODE();\n\n    const GUID VideoInfoSpecifier = \n        {STATICGUIDOF(KSDATAFORMAT_SPECIFIER_VIDEOINFO)};\n    \n    NT_ASSERT(Filter);\n    NT_ASSERT(Irp);\n    NT_ASSERT(PinInstance);\n    NT_ASSERT(CallerDataRange);\n    NT_ASSERT(DescriptorDataRange);\n    NT_ASSERT(DataSize);\n    \n    ULONG DataFormatSize;\n    \n    //\n    // Specifier FORMAT_VideoInfo for VIDEOINFOHEADER\n    //\n    if (IsEqualGUID(CallerDataRange->Specifier, VideoInfoSpecifier) &&\n        CallerDataRange -> FormatSize >= sizeof (KS_DATARANGE_VIDEO)) {\n            \n        PKS_DATARANGE_VIDEO callerDataRange = \n            reinterpret_cast <PKS_DATARANGE_VIDEO> (CallerDataRange);\n\n        PKS_DATARANGE_VIDEO descriptorDataRange = \n            reinterpret_cast <PKS_DATARANGE_VIDEO> (DescriptorDataRange);\n\n        PKS_DATAFORMAT_VIDEOINFOHEADER FormatVideoInfoHeader;\n\n        //\n        // Check that the other fields match\n        //\n        if ((callerDataRange->bFixedSizeSamples != \n                descriptorDataRange->bFixedSizeSamples) ||\n            (callerDataRange->bTemporalCompression != \n                descriptorDataRange->bTemporalCompression) ||\n            (callerDataRange->StreamDescriptionFlags != \n                descriptorDataRange->StreamDescriptionFlags) ||\n            (callerDataRange->MemoryAllocationFlags != \n                descriptorDataRange->MemoryAllocationFlags) ||\n            (RtlCompareMemory (&callerDataRange->ConfigCaps,\n                    &descriptorDataRange->ConfigCaps,\n                    sizeof (KS_VIDEO_STREAM_CONFIG_CAPS)) != \n                    sizeof (KS_VIDEO_STREAM_CONFIG_CAPS))) \n        {\n            return STATUS_NO_MATCH;\n        }\n\n        //\n        // KS_SIZE_VIDEOHEADER() below is relying on bmiHeader.biSize from\n        // the caller's data range.  This **MUST** be validated; the\n        // extended bmiHeader size (biSize) must not extend past the end\n        // of the range buffer.  Possible arithmetic overflow is also\n        // checked for.\n        //\n        {\n            ULONG VideoHeaderSize = KS_SIZE_VIDEOHEADER (\n                &callerDataRange->VideoInfoHeader\n                );\n\n            ULONG DataRangeSize = \n                FIELD_OFFSET (KS_DATARANGE_VIDEO, VideoInfoHeader) +\n                VideoHeaderSize;\n\n            //\n            // Check that biSize does not extend past the buffer.  The \n            // first two checks are for arithmetic overflow on the \n            // operations to compute the alleged size.  (On unsigned\n            // math, a+b < a iff an arithmetic overflow occurred).\n            //\n            if (\n                VideoHeaderSize < callerDataRange->\n                    VideoInfoHeader.bmiHeader.biSize ||\n                DataRangeSize < VideoHeaderSize ||\n                DataRangeSize > callerDataRange -> DataRange.FormatSize\n                ) {\n\n                return STATUS_INVALID_PARAMETER;\n\n            }\n\n        }\n\n        DataFormatSize = \n            sizeof (KSDATAFORMAT) + \n            KS_SIZE_VIDEOHEADER (&callerDataRange->VideoInfoHeader);\n\n            \n        //\n        // If the passed buffer size is 0, it indicates that this is a size\n        // only query.  Return the size of the intersecting data format and\n        // pass back STATUS_BUFFER_OVERFLOW.\n        //\n        if (BufferSize == 0) {\n\n            *DataSize = DataFormatSize;\n            return STATUS_BUFFER_OVERFLOW;\n\n        }\n        \n        //\n        // Verify that the provided structure is large enough to\n        // accept the result.\n        //\n        if (BufferSize < DataFormatSize) \n        {\n            return STATUS_BUFFER_TOO_SMALL;\n        }\n\n        //\n        // Copy over the KSDATAFORMAT, followed by the actual VideoInfoHeader\n        //\n        *DataSize = DataFormatSize;\n            \n        FormatVideoInfoHeader = PKS_DATAFORMAT_VIDEOINFOHEADER( Data );\n\n        //\n        // Copy over the KSDATAFORMAT.  This is precisely the same as the\n        // KSDATARANGE (it's just the GUIDs, etc...  not the format information\n        // following any data format.\n        // \n        RtlCopyMemory (\n            &FormatVideoInfoHeader->DataFormat, \n            DescriptorDataRange, \n            sizeof (KSDATAFORMAT));\n\n        FormatVideoInfoHeader->DataFormat.FormatSize = DataFormatSize;\n\n        //\n        // Copy over the callers requested VIDEOINFOHEADER\n        //\n\n        RtlCopyMemory (\n            &FormatVideoInfoHeader->VideoInfoHeader, \n            &callerDataRange->VideoInfoHeader,\n            KS_SIZE_VIDEOHEADER (&callerDataRange->VideoInfoHeader) \n            );\n\n        //\n        // Calculate biSizeImage for this request, and put the result in both\n        // the biSizeImage field of the bmiHeader AND in the SampleSize field\n        // of the DataFormat.\n        //\n        // Note that for compressed sizes, this calculation will probably not\n        // be just width * height * bitdepth\n        //\n        FormatVideoInfoHeader->VideoInfoHeader.bmiHeader.biSizeImage =\n            FormatVideoInfoHeader->DataFormat.SampleSize = \n            KS_DIBSIZE (FormatVideoInfoHeader->VideoInfoHeader.bmiHeader);\n\n        //\n        // REVIEW - Perform other validation such as cropping and scaling checks\n        // \n        \n        return STATUS_SUCCESS;\n        \n    } // End of VIDEOINFOHEADER specifier\n    \n    return STATUS_NO_MATCH;\n}\n\n/*************************************************/\n\nBOOL\nMultiplyCheckOverflow (\n    ULONG a,\n    ULONG b,\n    ULONG *pab\n    )\n\n/*++\n\nRoutine Description:\n\n    Perform a 32 bit unsigned multiplication and check for arithmetic overflow.\n\nArguments:\n\n    a -\n        First operand\n\n    b -\n        Second operand\n\n    pab -\n        Result\n\nReturn Value:\n\n    TRUE -\n        no overflow\n\n    FALSE -\n        overflow occurred\n\n--*/\n\n{\n    PAGED_CODE();\n\n    *pab = a * b;\n    if ((a == 0) || (((*pab) / a) == b)) {\n        return TRUE;\n    }\n    return FALSE;\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCapturePin::\nDispatchSetFormat (\n    IN PKSPIN Pin,\n    IN PKSDATAFORMAT OldFormat OPTIONAL,\n    IN PKSMULTIPLE_ITEM OldAttributeList OPTIONAL,\n    IN const KSDATARANGE *DataRange,\n    IN const KSATTRIBUTE_LIST *AttributeRange OPTIONAL\n    )\n\n/*++\n\nRoutine Description:\n\n    This is the set data format dispatch for the capture pin.  It is called\n    in two circumstances.\n\n        1: before Pin's creation dispatch has been made to verify that\n           Pin -> ConnectionFormat is an acceptable format for the range\n           DataRange.  In this case OldFormat is NULL.\n\n        2: after Pin's creation dispatch has been made and an initial format\n           selected in order to change the format for the pin.  In this case,\n           OldFormat will not be NULL.\n\n    Validate that the format is acceptable and perform the actions necessary\n    to change format if appropriate.\n\nArguments:\n\n    Pin -\n        The pin this format is being set on.  The format itself will be in\n        Pin -> ConnectionFormat.\n\n    OldFormat -\n        The previous format used on this pin.  If this is NULL, it is an\n        indication that Pin's creation dispatch has not yet been made and\n        that this is a request to validate the initial format and not to\n        change formats.\n\n    OldAttributeList -\n        The old attribute list for the prior format\n\n    DataRange -\n        A range out of our list of data ranges which was determined to be\n        at least a partial match for Pin -> ConnectionFormat.  If the format\n        there is unacceptable for the range, STATUS_NO_MATCH should be\n        returned.\n\n    AttributeRange -\n        The attribute range\n\nReturn Value:\n\n    Success / Failure\n\n        STATUS_SUCCESS -\n            The format is acceptable / the format has been changed\n\n        STATUS_NO_MATCH -\n            The format is not-acceptable / the format has not been changed\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_NO_MATCH;\n\n    const GUID VideoInfoSpecifier = \n        {STATICGUIDOF(KSDATAFORMAT_SPECIFIER_VIDEOINFO)};\n\n    CCapturePin *CapPin = NULL;\n\n    //\n    // Find the pin, if it exists yet.  OldFormat will be an indication of \n    // this.  If we're changing formats, OldFormat will be non-NULL.\n    //\n    // You cannot use Pin -> Context to make the determination.  AVStream\n    // preinitializes this to the filter's context.\n    //\n    if (OldFormat) {\n        CapPin = reinterpret_cast <CCapturePin *> (Pin -> Context);\n    }\n\n    if (IsEqualGUID (Pin -> ConnectionFormat -> Specifier,\n            VideoInfoSpecifier) &&\n        Pin -> ConnectionFormat -> FormatSize >=\n            sizeof (KS_DATAFORMAT_VIDEOINFOHEADER)) {\n\n        PKS_DATAFORMAT_VIDEOINFOHEADER ConnectionFormat =\n            reinterpret_cast <PKS_DATAFORMAT_VIDEOINFOHEADER> \n                (Pin -> ConnectionFormat);\n\n        //\n        // DataRange comes out of OUR data range list.  I know the range\n        // is valid as such.\n        //\n        const KS_DATARANGE_VIDEO *VIRange =\n            reinterpret_cast <const KS_DATARANGE_VIDEO *>\n                (DataRange);\n\n        //\n        // Check that bmiHeader.biSize is valid since we use it later.\n        //\n        ULONG VideoHeaderSize = KS_SIZE_VIDEOHEADER (\n            &ConnectionFormat -> VideoInfoHeader\n            );\n\n        ULONG DataFormatSize = FIELD_OFFSET (\n            KS_DATAFORMAT_VIDEOINFOHEADER, VideoInfoHeader\n            ) + VideoHeaderSize;\n\n        if (\n            VideoHeaderSize < ConnectionFormat->\n                VideoInfoHeader.bmiHeader.biSize ||\n            DataFormatSize < VideoHeaderSize ||\n            DataFormatSize > ConnectionFormat -> DataFormat.FormatSize\n            ) {\n\n            Status = STATUS_INVALID_PARAMETER;\n\n        }\n\n        //\n        // Check that the format is a match for the selected range. \n        //\n        else if (\n            (ConnectionFormat -> VideoInfoHeader.bmiHeader.biWidth !=\n                VIRange -> VideoInfoHeader.bmiHeader.biWidth) ||\n\n            (ConnectionFormat -> VideoInfoHeader.bmiHeader.biHeight !=\n                VIRange -> VideoInfoHeader.bmiHeader.biHeight) ||\n\n            (ConnectionFormat -> VideoInfoHeader.bmiHeader.biCompression !=\n                VIRange -> VideoInfoHeader.bmiHeader.biCompression) \n\n            ) {\n\n            Status = STATUS_NO_MATCH;\n\n        } else {\n\n            //\n            // Compute the minimum size of our buffers to validate against.\n            // The image synthesis routines synthesize |biHeight| rows of\n            // biWidth pixels in either RGB24 or UYVY.  In order to ensure\n            // safe synthesis into the buffer, we need to know how large an\n            // image this will produce.\n            //\n            // I do this explicitly because of the method that the data is\n            // synthesized.  A variation of this may or may not be necessary\n            // depending on the mechanism the driver in question fills the \n            // capture buffers.  The important thing is to ensure that they\n            // aren't overrun during capture.\n            //\n            ULONG ImageSize;\n\n            if (!MultiplyCheckOverflow (\n                (ULONG)ConnectionFormat->VideoInfoHeader.bmiHeader.biWidth,\n                (ULONG)abs (ConnectionFormat->\n                    VideoInfoHeader.bmiHeader.biHeight),\n                &ImageSize\n                )) {\n\n                Status = STATUS_INVALID_PARAMETER;\n            }\n\n            //\n            // We only support KS_BI_RGB (24) and KS_BI_YUV422 (16), so\n            // this is valid for those formats.\n            //\n            else if (!MultiplyCheckOverflow (\n                ImageSize,\n                (ULONG)(ConnectionFormat->\n                    VideoInfoHeader.bmiHeader.biBitCount / 8),\n                &ImageSize\n                )) {\n\n                Status = STATUS_INVALID_PARAMETER;\n\n            }\n\n            //\n            // Valid for the formats we use.  Otherwise, this would be\n            // checked later.\n            //\n            else if (ConnectionFormat->VideoInfoHeader.bmiHeader.biSizeImage <\n                    ImageSize) {\n\n                Status = STATUS_INVALID_PARAMETER;\n\n            } else {\n\n                //\n                // We can accept the format. \n                //\n                Status = STATUS_SUCCESS;\n\n                //\n                // OldFormat is an indication that this is a format change.  \n                // Since I do not implement the \n                // KSPROPERTY_CONNECTION_PROPOSEDATAFORMAT, by default, I do \n                // not handle dynamic format changes.\n                //\n                // If something changes while we're in the stop state, we're \n                // fine to handle it since we haven't \"configured the hardware\"\n                // yet.\n                //\n                if (OldFormat) {\n                    //\n                    // If we're in the stop state, we can handle just about any\n                    // change.  We don't support dynamic format changes. \n                    //\n                    if (Pin -> DeviceState == KSSTATE_STOP) {\n                        if (!CapPin -> CaptureVideoInfoHeader ()) {\n                            Status = STATUS_INSUFFICIENT_RESOURCES;\n                        }\n                    } else {\n                        //\n                        // Because we don't accept dynamic format changes, we\n                        // should never get here.  Just being over-protective.\n                        //\n                        Status = STATUS_INVALID_DEVICE_STATE;\n                    }\n                }\n\n            }\n\n        }\n\n    }\n    return Status;\n}\n\n/**************************************************************************\n\n    LOCKED CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg()\n#endif // ALLOC_PRAGMA\n\nvoid\nCCapturePin::\nCompleteMappings (\n    IN ULONG NumMappings\n    )\n\n/*++\n\nRoutine Description:\n\n    Called to notify the pin that a given number of scatter / gather\n    mappings have completed.  Let the buffers go if possible.\n    We're called at DPC.\n\nArguments:\n\n    NumMappings -\n        The number of mappings that have completed.\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    ULONG MappingsRemaining = NumMappings;\n\n    //\n    // Walk through the clones list and delete clones whose time has come.\n    // The list is guaranteed to be kept in the order they were cloned.\n    //\n    PKSSTREAM_POINTER Clone = KsPinGetFirstCloneStreamPointer (m_Pin);\n\n    while (MappingsRemaining && Clone) {\n\n        PKSSTREAM_POINTER NextClone = KsStreamPointerGetNextClone (Clone);\n\n        // \n        // If we have completed all remaining mappings in this clone, it\n        // is an indication that the clone is ready to be deleted and the\n        // buffer released.  Set anything required in the stream header which\n        // has not yet been set.  If we have a clock, we can timestamp the\n        // sample.\n        //\n        if (Clone -> StreamHeader -> DataUsed >= Clone -> OffsetOut.Remaining) {\n            Clone -> StreamHeader -> Duration =\n                m_VideoInfoHeader -> AvgTimePerFrame;\n\n            Clone -> StreamHeader -> PresentationTime.Numerator =\n                Clone -> StreamHeader -> PresentationTime.Denominator = 1;\n\n            //\n            // If a clock has been assigned, timestamp the packets with the\n            // time shown on the clock. \n            //\n            if (m_Clock) {\n\n                LONGLONG ClockTime = m_Clock -> GetTime ();\n\n                Clone -> StreamHeader -> PresentationTime.Time = ClockTime;\n\n                Clone -> StreamHeader -> OptionsFlags =\n                    KSSTREAM_HEADER_OPTIONSF_TIMEVALID |\n                    KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;\n\n            } else {\n\t      //\n\t      // If there is no clock, don't time stamp the packets.\n\t      //\n\t      Clone -> StreamHeader -> PresentationTime.Time = 0;\n\t      \n            }\n\n            //\n            // Increment the frame number.  This is the total count of frames which\n            // have attempted capture.\n            //\n            m_FrameNumber++;\n\n            //\n            // Double check the Stream Header size.  AVStream makes no guarantee\n            // that because StreamHeaderSize is set to a specific size that you\n            // will get that size.  If the proper data type handlers are not \n            // installed, the stream header will be of default size.\n            //\n            if ( Clone -> StreamHeader -> Size >= sizeof (KSSTREAM_HEADER) +\n                sizeof (KS_FRAME_INFO)) {\n\n                PKS_FRAME_INFO FrameInfo = reinterpret_cast <PKS_FRAME_INFO> (\n                    Clone -> StreamHeader + 1\n                    );\n    \n                FrameInfo -> ExtendedHeaderSize = sizeof (KS_FRAME_INFO);\n                FrameInfo -> dwFrameFlags       = KS_VIDEO_FLAG_FRAME;\n                FrameInfo -> PictureNumber      = (LONGLONG)m_FrameNumber;\n\n                // I don't really have a way to tell if the device has dropped a frame \n                // or was not able to send a frame on time.\n                FrameInfo -> DropCount = (LONGLONG)m_DroppedFrames;\n            }\n\n\n            //\n            // If all of the mappings in this clone have been completed,\n            // delete the clone.  We've already updated DataUsed above.\n            //\n\n            MappingsRemaining--;\n            KsStreamPointerDelete (Clone);\n\n        } else {\n            //\n            // If only part of the mappings in this clone have been completed,\n            // update the pointers.  Since we're guaranteed this won't advance\n            // to a new frame by the check above, it won't fail.\n            //\n            (void)KsStreamPointerAdvanceOffsets (\n                Clone,\n                0,\n                Clone -> StreamHeader -> DataUsed,\n                FALSE\n                );\n\n            MappingsRemaining = 0;\n\n        }\n\n        //\n        // Go to the next clone.\n        //\n        Clone = NextClone;\n\n    }\n\n    //\n    // If we've used all the mappings in hardware and pended, we can kick\n    // processing to happen again if we've completed mappings.\n    //\n    if (m_PendIo) {\n        m_PendIo = TRUE;\n        KsPinAttemptProcessing (m_Pin, TRUE);\n    }\n\n}\n\n/**************************************************************************\n\n    DISPATCH AND DESCRIPTOR LAYOUT\n\n**************************************************************************/\n\n//\n// FormatRGB24Bpp_Capture:\n//\n// This is the data range description of the RGB24 capture format we support.\n//\nconst \nKS_DATARANGE_VIDEO \nFormatRGB24Bpp_Capture = {\n\n    //\n    // KSDATARANGE\n    //\n    {   \n        sizeof (KS_DATARANGE_VIDEO),                // FormatSize\n        0,                                          // Flags\n        D_X * D_Y * 3,                              // SampleSize\n        0,                                          // Reserved\n\n        STATICGUIDOF (KSDATAFORMAT_TYPE_VIDEO),     // aka. MEDIATYPE_Video\n        0xe436eb7d, 0x524f, 0x11ce, 0x9f, 0x53, 0x00, 0x20, \n            0xaf, 0x0b, 0xa7, 0x70,                 // aka. MEDIASUBTYPE_RGB24,\n        STATICGUIDOF (KSDATAFORMAT_SPECIFIER_VIDEOINFO) // aka. FORMAT_VideoInfo\n    },\n\n    TRUE,               // BOOL,  bFixedSizeSamples (all samples same size?)\n    FALSE,              // BOOL,  bTemporalCompression (all I frames?)\n    0,                  // Reserved (was StreamDescriptionFlags)\n    0,                  // Reserved (was MemoryAllocationFlags   \n                        //           (KS_VIDEO_ALLOC_*))\n    //\n    // _KS_VIDEO_STREAM_CONFIG_CAPS  \n    //\n    {\n        STATICGUIDOF( KSDATAFORMAT_SPECIFIER_VIDEOINFO ), // GUID\n        KS_AnalogVideo_None,                            // AnalogVideoStandard\n        D_X,D_Y,        // InputSize, (the inherent size of the incoming signal\n                        //             with every digitized pixel unique)\n        D_X,D_Y,        // MinCroppingSize, smallest rcSrc cropping rect allowed\n        D_X,D_Y,        // MaxCroppingSize, largest  rcSrc cropping rect allowed\n        8,              // CropGranularityX, granularity of cropping size\n        1,              // CropGranularityY\n        8,              // CropAlignX, alignment of cropping rect \n        1,              // CropAlignY;\n        D_X, D_Y,       // MinOutputSize, smallest bitmap stream can produce\n        D_X, D_Y,       // MaxOutputSize, largest  bitmap stream can produce\n        8,              // OutputGranularityX, granularity of output bitmap size\n        1,              // OutputGranularityY;\n        0,              // StretchTapsX  (0 no stretch, 1 pix dup, 2 interp...)\n        0,              // StretchTapsY\n        0,              // ShrinkTapsX \n        0,              // ShrinkTapsY \n        333667,         // MinFrameInterval, 100 nS units\n        640000000,      // MaxFrameInterval, 100 nS units\n        8 * 3 * 30 * D_X * D_Y,  // MinBitsPerSecond;\n        8 * 3 * 30 * D_X * D_Y   // MaxBitsPerSecond;\n    }, \n        \n    //\n    // KS_VIDEOINFOHEADER (default format)\n    //\n    {\n        0,0,0,0,                            // RECT  rcSource; \n        0,0,0,0,                            // RECT  rcTarget; \n        D_X * D_Y * 3 * 8 * 30,             // DWORD dwBitRate;\n        0L,                                 // DWORD dwBitErrorRate; \n        333667,                             // REFERENCE_TIME  AvgTimePerFrame;   \n        sizeof (KS_BITMAPINFOHEADER),       // DWORD biSize;\n        D_X,                                // LONG  biWidth;\n        D_Y,                                // LONG  biHeight;\n        1,                                  // WORD  biPlanes;\n        24,                                 // WORD  biBitCount;\n        KS_BI_RGB,                          // DWORD biCompression;\n        D_X * D_Y * 3,                      // DWORD biSizeImage;\n        0,                                  // LONG  biXPelsPerMeter;\n        0,                                  // LONG  biYPelsPerMeter;\n        0,                                  // DWORD biClrUsed;\n        0                                   // DWORD biClrImportant;\n    }\n}; \n\n//\n// FormatYUY2_Capture:\n//\n// This is the data range description of the YUY2 format we support.\n//\nconst \nKS_DATARANGE_VIDEO \nFormatYUY2_Capture = {\n\n    //\n    // KSDATARANGE\n    //\n    {   \n        sizeof (KS_DATARANGE_VIDEO),            // FormatSize\n        0,                                      // Flags\n        DMAX_X * DMAX_Y * 2,                    // SampleSize\n        0,                                      // Reserved\n        STATICGUIDOF (KSDATAFORMAT_TYPE_VIDEO), // aka. MEDIATYPE_Video\n        0x32595559, 0x0000, 0x0010, 0x80, 0x00, \n        0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71,     //aka. MEDIASUBTYPE_YUY2,\n        STATICGUIDOF (KSDATAFORMAT_SPECIFIER_VIDEOINFO) // aka. FORMAT_VideoInfo\n    },\n\n    TRUE,               // BOOL,  bFixedSizeSamples (all samples same size?)\n    FALSE,              // BOOL,  bTemporalCompression (all I frames?)\n    0,                  // Reserved (was StreamDescriptionFlags)\n    0,                  // Reserved (was MemoryAllocationFlags   \n                        //           (KS_VIDEO_ALLOC_*))\n\n    //\n    // _KS_VIDEO_STREAM_CONFIG_CAPS  \n    //\n    {\n        STATICGUIDOF( KSDATAFORMAT_SPECIFIER_VIDEOINFO ), // GUID\n        KS_AnalogVideo_None,                            // AnalogVideoStandard\n        DMAX_X, DMAX_Y, // InputSize, (the inherent size of the incoming signal\n                        //             with every digitized pixel unique)\n        D_X,D_Y,        // MinCroppingSize, smallest rcSrc cropping rect allowed\n        DMAX_X, DMAX_Y, // MaxCroppingSize, largest  rcSrc cropping rect allowed\n        8,              // CropGranularityX, granularity of cropping size\n        1,              // CropGranularityY\n        8,              // CropAlignX, alignment of cropping rect \n        1,              // CropAlignY;\n        D_X, D_Y,       // MinOutputSize, smallest bitmap stream can produce\n        DMAX_X, DMAX_Y, // MaxOutputSize, largest  bitmap stream can produce\n        8,              // OutputGranularityX, granularity of output bitmap size\n        1,              // OutputGranularityY;\n        0,              // StretchTapsX  (0 no stretch, 1 pix dup, 2 interp...)\n        0,              // StretchTapsY\n        0,              // ShrinkTapsX \n        0,              // ShrinkTapsY \n        333667,         // MinFrameInterval, 100 nS units\n        640000000,      // MaxFrameInterval, 100 nS units\n        8 * 2 * 30 * D_X * D_Y,  // MinBitsPerSecond;\n        8 * 2 * 30 * DMAX_X * DMAX_Y,   // MaxBitsPerSecond;\n    }, \n        \n    //\n    // KS_VIDEOINFOHEADER (default format)\n    //\n    {\n        0, 0, 0, 0,                         // RECT  rcSource; \n        0, 0, 0, 0,                         // RECT  rcTarget; \n        DMAX_X * DMAX_Y * 2 * 8 * 30,       // DWORD dwBitRate;\n        0L,                                 // DWORD dwBitErrorRate; \n        333667,                             // REFERENCE_TIME  AvgTimePerFrame;   \n        sizeof (KS_BITMAPINFOHEADER),       // DWORD biSize;\n        DMAX_X,                             // LONG  biWidth;\n        DMAX_Y,                             // LONG  biHeight;\n        1,                                  // WORD  biPlanes;\n        16,                                 // WORD  biBitCount;\n        FOURCC_YUY2,                        // DWORD biCompression;\n        DMAX_X * DMAX_Y * 2,                // DWORD biSizeImage;\n        0,                                  // LONG  biXPelsPerMeter;\n        0,                                  // LONG  biYPelsPerMeter;\n        0,                                  // DWORD biClrUsed;\n        0                                   // DWORD biClrImportant;\n    }\n}; \n\n//\n// CapturePinDispatch:\n//\n// This is the dispatch table for the capture pin.  It provides notifications\n// about creation, closure, processing, data formats, etc...\n//\nconst\nKSPIN_DISPATCH\nCapturePinDispatch = {\n    CCapturePin::DispatchCreate,            // Pin Create\n    NULL,                                   // Pin Close\n    CCapturePin::DispatchProcess,           // Pin Process\n    NULL,                                   // Pin Reset\n    CCapturePin::DispatchSetFormat,         // Pin Set Data Format\n    CCapturePin::DispatchSetState,          // Pin Set Device State\n    NULL,                                   // Pin Connect\n    NULL,                                   // Pin Disconnect\n    NULL,                                   // Clock Dispatch\n    NULL                                    // Allocator Dispatch\n};\n\n//\n// CapturePinAllocatorFraming:\n//\n// This is the simple framing structure for the capture pin.  Note that this\n// will be modified via KsEdit when the actual capture format is determined.\n//\nDECLARE_SIMPLE_FRAMING_EX (\n    CapturePinAllocatorFraming,\n    STATICGUIDOF (KSMEMORY_TYPE_KERNEL_NONPAGED),\n    KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY |\n        KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY,\n    2,\n    0,\n    2 * PAGE_SIZE,\n    2 * PAGE_SIZE\n    );\n\n//\n// CapturePinDataRanges:\n//\n// This is the list of data ranges supported on the capture pin.  We support\n// two: one RGB24, and one YUY2.\n//\nconst \nPKSDATARANGE \nCapturePinDataRanges [CAPTURE_PIN_DATA_RANGE_COUNT] = {\n    //(PKSDATARANGE) &FormatYUY2_Capture,\n    (PKSDATARANGE) &FormatRGB24Bpp_Capture\n    };\n"
  },
  {
    "path": "Driver/avshws/capture.h",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        capture.h\n\n    Abstract:\n\n        This file contains header for the video capture pin on the capture\n        filter.  The capture sample performs \"fake\" DMA directly into\n        the capture buffers.  Common buffer DMA will work slightly differently.\n\n        For common buffer DMA, the general technique would be DPC schedules\n        processing with KsPinAttemptProcessing.  The processing routine grabs\n        the leading edge, copies data out of the common buffer and advances.\n        Cloning would not be necessary with this technique.  It would be \n        similiar to the way \"AVSSamp\" works, but it would be pin-centric.\n\n    History:\n\n        created 3/8/2001\n\n**************************************************************************/\n#include <initguid.h>\n//\n// STREAM_POINTER_CONTEXT:\n//\n// This is the context structure we associate with all clone stream pointers.\n// It allows the mapping code to rip apart the buffer into chunks the same\n// size as the scatter/gather mappings in order to fake scatter / gather\n// bus-master DMA.\n//\ntypedef struct _STREAM_POINTER_CONTEXT {\n    \n    PUCHAR BufferVirtual;\n\n} STREAM_POINTER_CONTEXT, *PSTREAM_POINTER_CONTEXT;\n\n//\n// CCapturePin:\n//\n// The video capture pin class.\n//\nclass CCapturePin :\n    public ICaptureSink {\n\nprivate:\n\n    //\n    // The AVStream pin we're associated with.\n    //\n    PKSPIN m_Pin;\n\n    //\n    // Pointer to the internal device object for our capture device.\n    // We access the \"fake\" hardware through this object.\n    //\n    CCaptureDevice *m_Device;\n    \n    //\n    // The state we've put the hardware into.  This allows us to keep track\n    // of whether to do things like unpausing or restarting.\n    //\n    HARDWARE_STATE m_HardwareState;\n\n    //\n    // The clock we've been assigned.  As with other capture filters, we do\n    // not expose a clock.  If one has been assigned, we will use it to\n    // time stamp packets (plus a reasonable delta to work the capture stream\n    // in a preview graph).\n    //\n    PIKSREFERENCECLOCK m_Clock;\n\n    //\n    // The captured video info header.  The settings for \"fake\" hardware will be\n    // programmed via this video info header.\n    //\n    PKS_VIDEOINFOHEADER m_VideoInfoHeader;\n\n    //\n    // If we are unable to insert all of the mappings in a stream pointer into\n    // the \"fake\" hardware's scatter / gather table, we set this to the\n    // stream pointer that's incomplete.  This is done both to make the \n    // relasing easier and to make it easier to fake the scatter / gather\n    // hardware.\n    //\n    PKSSTREAM_POINTER m_PreviousStreamPointer;\n\n    //\n    // An indication of whether or not we pended I/O for some reason.  If this\n    // is set, the DPC will resume I/O when any mappings are completed.\n    //\n    BOOLEAN m_PendIo;\n\n    //\n    // An indication of whether or not this pin has acquired the necessary\n    // hardware resources to operate.  When the pin reaches KSSTATE_ACQUIRE,\n    // we attempt to acquire the hardware.  This flag will be set based on\n    // our success / failure.\n    //\n    BOOLEAN m_AcquiredResources;\n    \n    //\n    // Presentation time for the sample\n    //\n    LONGLONG m_PresentationTime;\n\n    LONGLONG m_FrameNumber;\n    LONGLONG m_DroppedFrames;\n\n    //\n    // CleanupReferences():\n    //\n    // Clean up any references we hold on frames in the queue.  This is called\n    // when we abruptly stop the fake hardware.\n    //\n    NTSTATUS\n    CleanupReferences (\n        );\n\n    //\n    // SetState():\n    //\n    // This is the state transition handler for the capture pin.  It attempts\n    // to acquire resources for the capture pin (or releasing them if\n    // necessary) and starts and stops the hardware as required.\n    //\n    NTSTATUS\n    SetState (\n        IN KSSTATE ToState,\n        IN KSSTATE FromState\n        );\n\n    //\n    // Process():\n    //\n    // This is the processing dispatch for the capture pin.  It handles\n    // programming the scatter / gather tables for the hardware as buffers\n    // become available.  This processing routine is designed for a direct\n    // into the capture buffers kind of DMA as opposed to common-buffer\n    // and copy strategies.\n    //\n    NTSTATUS\n    Process (\n        );\n    //\n    // CaptureVideoInfoHeader():\n    //\n    // This routine stashes the video info header set on the pin connection\n    // in the CCapturePin object.  This is used to base hardware settings.\n    //\n    PKS_VIDEOINFOHEADER\n    CaptureVideoInfoHeader (\n        );\n\n    //\n    // Cleanup():\n    //\n    // This is the free callback from the bagged item (CCapturePin).  If we\n    // do not provide a callback when we bag the CCapturePin, ExFreePool\n    // would be called.  This is not desirable for C++ constructed objects.\n    // We merely delete the object here.\n    //\n    static\n    void\n    Cleanup (\n        IN CCapturePin *Pin\n        )\n    {\n        delete Pin;\n    }\n\npublic:\n    //\n    // CCapturePin():\n    //\n    // The capture pin's constructor.  Initialize any non-0, non-NULL fields\n    // (since new will have zero'ed the memory anyway) and set up our\n    // device level pointers for access during capture routines.\n    //\n    CCapturePin (\n        IN PKSPIN Pin\n        );\n\n    //\n    // ~CCapturePin():\n    //\n    // The capture pin's destructor.\n    //\n    ~CCapturePin (\n        )\n    {\n    }\n\n    //\n    // ICaptureSink::CompleteMappings()\n    //\n    // This is the capture sink notification mechanism for mapping completion.\n    // When the device DPC detects that a given number of mappings have been\n    // completed by the fake hardware, it signals the capture sink of this\n    // through this method.\n    //\n    virtual\n    void\n    CompleteMappings (\n        IN ULONG NumMappings\n        );\n\n    /*************************************************\n\n        Dispatch Routines\n\n    *************************************************/\n\n    //\n    // DispatchCreate():\n    //\n    // This is the creation dispatch for the capture pin.  It creates\n    // the CCapturePin object and associates it with the AVStream object\n    // bagging it in the process.\n    //\n    static\n    NTSTATUS\n    DispatchCreate (\n        IN PKSPIN Pin,\n        IN PIRP Irp\n        );\n\n    //\n    // DispatchSetState():\n    //\n    // This is the set device state dispatch for the pin.  The routine bridges\n    // to SetState() in the context of the CCapturePin.\n    //\n    static\n    NTSTATUS\n    DispatchSetState (\n        IN PKSPIN Pin,\n        IN KSSTATE ToState,\n        IN KSSTATE FromState\n        )\n    {\n        return \n            (reinterpret_cast <CCapturePin *> (Pin -> Context)) ->\n                SetState (ToState, FromState);\n    }\n\n    //\n    // DispatchSetFormat():\n    //\n    // This is the set data format dispatch for the pin.  This will be called\n    // BEFORE pin creation to validate that a data format selected is a match\n    // for the range pulled out of our range list.  It will also be called\n    // for format changes.\n    //\n    // If OldFormat is NULL, this is an indication that it's the initial\n    // call and not a format change.  Even fixed format pins get this call\n    // once.\n    //\n    static\n    NTSTATUS\n    DispatchSetFormat (\n        IN PKSPIN Pin,\n        IN PKSDATAFORMAT OldFormat OPTIONAL,\n        IN PKSMULTIPLE_ITEM OldAttributeList OPTIONAL,\n        IN const KSDATARANGE *DataRange,\n        IN const KSATTRIBUTE_LIST *AttributeRange OPTIONAL\n        );\n\n    //\n    // DispatchProcess():\n    //\n    // This is the processing dispatch for the capture pin.  The routine \n    // bridges to Process() in the context of the CCapturePin.\n    //\n    static \n    NTSTATUS\n    DispatchProcess (\n        IN PKSPIN Pin\n        )\n    {\n        return \n            (reinterpret_cast <CCapturePin *> (Pin -> Context)) ->\n               Process ();\n            \n    }\n\n    //\n    // IntersectHandler():\n    //\n    // This is the data intersection handler for the capture pin.  This \n    // determines an optimal format in the intersection of two ranges,\n    // one local and one possibly foreign.  If there is no compatible format,\n    // STATUS_NO_MATCH is returned.\n    //\n    static\n    NTSTATUS\n    IntersectHandler (\n        IN PKSFILTER Filter,\n        IN PIRP Irp,\n        IN PKSP_PIN PinInstance,\n        IN PKSDATARANGE CallerDataRange,\n        IN PKSDATARANGE DescriptorDataRange,\n        IN ULONG BufferSize,\n        OUT PVOID Data OPTIONAL,\n        OUT PULONG DataSize\n        );\n\n};"
  },
  {
    "path": "Driver/avshws/customprops.h",
    "content": "#pragma once\n\n\n#define DEFINE_STD_PROPERTY_SET(SET, PROPERTIES)    \\\n    DEFINE_KSPROPERTY_SET(                          \\\n        &SET,                                       \\\n        SIZEOF_ARRAY(PROPERTIES),                   \\\n        PROPERTIES,                                 \\\n        0,                                          \\\n        NULL)\n\n#define DEFINE_PROP_ITEM_WITH_VALUES( T, ctrl, type, name, values )     \\\n    DEFINE_KSPROPERTY_ITEM(                                             \\\n        ctrl,                                                           \\\n        (&T::Prop<type, T, &T::Get##name>),                             \\\n        sizeof(KSPROPERTY),                                             \\\n        0,                                                              \\\n        (&T::Prop<type, T, &T::Set##name>),                             \\\n        values, 0, NULL, NULL, 0                                        \\\n        )\n\n\n#define DEFINE_PROP_ITEM( T, ctrl, type, name )                         \\\n    DEFINE_PROP_ITEM_WITH_VALUES( T, ctrl, type, name, NULL )\n\n\n//  Declare a property's GET handler.\n#define DECLARE_PROPERTY_GET_HANDLER( name )      \\\n    static NTSTATUS                                            \\\n    Get##name(                                          \\\n        _In_ PIRP Irp, _In_ PKSIDENTIFIER Request, _Inout_ PVOID Data  \\\n        );\n\n//  Declare a property's SET handler.\n#define DECLARE_PROPERTY_SET_HANDLER( name )      \\\n    static NTSTATUS                                            \\\n    Set##name(                                          \\\n        _In_ PIRP Irp, _In_ PKSIDENTIFIER Request, _Inout_ PVOID Data  \\\n        );\n\n//  Declare a property's GET and SET handlers.\n#define DECLARE_PROPERTY_HANDLERS( name )         \\\nDECLARE_PROPERTY_GET_HANDLER( name )              \\\nDECLARE_PROPERTY_SET_HANDLER( name )\n\n// {CB043957-7B35-456E-9B61-5513930F4D8E}\n#define STATIC_PROPSETID_VIDCAP_CUSTOMCONTROL 0xcb043957, 0x7b35, 0x456e, 0x9b, 0x61, 0x55, 0x13, 0x93, 0xf, 0x4d, 0x8e\nDEFINE_GUIDSTRUCT(\"CB043957-7B35-456E-9B61-5513930F4D8E\", PROPSETID_VIDCAP_CUSTOMCONTROL);\n#define PROPSETID_VIDCAP_CUSTOMCONTROL DEFINE_GUIDNAMED(PROPSETID_VIDCAP_CUSTOMCONTROL )\n\n\nenum\n{\n\tKSPROPERTY_CUSTOMCONTROL_DUMMY\n};"
  },
  {
    "path": "Driver/avshws/device.cpp",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        device.cpp\n\n    Abstract:\n\n        This file contains the device level implementation of the AVStream\n        hardware sample.  Note that this is not the \"fake\" hardware.  The\n        \"fake\" hardware is in hwsim.cpp.\n\n    History:\n\n        created 3/9/2001\n\n**************************************************************************/\n\n#include \"avshws.h\"\n\nPVOID operator new\n(\n    size_t          iSize,\n    _When_((poolType & NonPagedPoolMustSucceed) != 0,\n       __drv_reportError(\"Must succeed pool allocations are forbidden. \"\n             \"Allocation failures cause a system crash\"))\n    POOL_TYPE       poolType\n)\n{\n    PVOID result = ExAllocatePoolWithTag(poolType,iSize,'wNCK');\n\n    if (result) {\n        RtlZeroMemory(result,iSize);\n    }\n\n    return result;\n}\n\nPVOID operator new\n(\n    size_t          iSize,\n    _When_((poolType & NonPagedPoolMustSucceed) != 0,\n       __drv_reportError(\"Must succeed pool allocations are forbidden. \"\n             \"Allocation failures cause a system crash\"))\n    POOL_TYPE       poolType,\n    ULONG           tag\n)\n{\n    PVOID result = ExAllocatePoolWithTag(poolType,iSize,tag);\n\n    if (result) {\n        RtlZeroMemory(result,iSize);\n    }\n\n    return result;\n}\n\nPVOID \noperator new[](\n    size_t          iSize,\n    _When_((poolType & NonPagedPoolMustSucceed) != 0,\n        __drv_reportError(\"Must succeed pool allocations are forbidden. \"\n            \"Allocation failures cause a system crash\"))\n    POOL_TYPE       poolType,\n    ULONG           tag\n)\n{\n    PVOID result = ExAllocatePoolWithTag(poolType, iSize, tag);\n\n    if (result)\n    {\n        RtlZeroMemory(result, iSize);\n    }\n\n    return result;\n}\n\n/*++\n\nRoutine Description:\n\n    Array delete() operator.\n\nArguments:\n\n    pVoid -\n        The memory to free.\n\nReturn Value:\n\n    None\n\n--*/\nvoid \n__cdecl \noperator delete[](\n    PVOID pVoid\n)\n{\n    if (pVoid)\n    {\n        ExFreePool(pVoid);\n    }\n}\n\n/*++\n\nRoutine Description:\n\n    Sized delete() operator.\n\nArguments:\n\n    pVoid -\n        The memory to free.\n\n    size -\n        The size of the memory to free.\n\nReturn Value:\n\n    None\n\n--*/\nvoid __cdecl operator delete\n(\n    void *pVoid,\n    size_t /*size*/\n)\n{\n    if (pVoid)\n    {\n        ExFreePool(pVoid);\n    }\n}\n\n/*++\n\nRoutine Description:\n\n    Sized delete[]() operator.\n\nArguments:\n\n    pVoid -\n        The memory to free.\n\n    size -\n        The size of the memory to free.\n\nReturn Value:\n\n    None\n\n--*/\nvoid __cdecl operator delete[]\n(\n    void *pVoid,\n    size_t /*size*/\n)\n{\n    if (pVoid)\n    {\n        ExFreePool(pVoid);\n    }\n}\n\nvoid __cdecl operator delete\n(\n    PVOID pVoid\n    )\n{\n    if (pVoid) {\n        ExFreePool(pVoid);\n    }\n}\n\n/**************************************************************************\n\n    PAGEABLE CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg(\"PAGE\")\n#endif // ALLOC_PRAGMA\n\nNTSTATUS\nCCaptureDevice::\nDispatchCreate (\n    IN PKSDEVICE Device\n    )\n\n/*++\n\nRoutine Description:\n\n    Create the capture device.  This is the creation dispatch for the\n    capture device.\n\nArguments:\n\n    Device -\n        The AVStream device being created.\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status;\n\n    CCaptureDevice *CapDevice = new (NonPagedPoolNx, 'veDC') CCaptureDevice (Device);\n\n    if (!CapDevice) {\n        //\n        // Return failure if we couldn't create the pin.\n        //\n        Status = STATUS_INSUFFICIENT_RESOURCES;\n\n    } else {\n\n        //\n        // Add the item to the object bag if we were successful.\n        // Whenever the device goes away, the bag is cleaned up and\n        // we will be freed.\n        //\n        // For backwards compatibility with DirectX 8.0, we must grab\n        // the device mutex before doing this.  For Windows XP, this is\n        // not required, but it is still safe.\n        //\n        KsAcquireDevice (Device);\n        Status = KsAddItemToObjectBag (\n            Device -> Bag,\n            reinterpret_cast <PVOID> (CapDevice),\n            reinterpret_cast <PFNKSFREE> (CCaptureDevice::Cleanup)\n            );\n        KsReleaseDevice (Device);\n\n        if (!NT_SUCCESS (Status)) {\n            delete CapDevice;\n        } else {\n            Device -> Context = reinterpret_cast <PVOID> (CapDevice);\n        }\n\n    }\n\n    return Status;\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCaptureDevice::\nPnpStart (\n    IN PCM_RESOURCE_LIST TranslatedResourceList,\n    IN PCM_RESOURCE_LIST UntranslatedResourceList\n    )\n\n/*++\n\nRoutine Description:\n\n    Called at Pnp start.  We start up our virtual hardware simulation.\n\nArguments:\n\n    TranslatedResourceList -\n        The translated resource list from Pnp\n\n    UntranslatedResourceList -\n        The untranslated resource list from Pnp\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    //\n    // Normally, we'd do things here like parsing the resource lists and\n    // connecting our interrupt.  Since this is a simulation, there isn't\n    // much to parse.  The parsing and connection should be the same as\n    // any WDM driver.  The sections that will differ are illustrated below\n    // in setting up a simulated DMA.\n    //\n\n    NTSTATUS Status = STATUS_SUCCESS;\n\n    if (!m_Device -> Started) {\n        // Create the Filter for the device\n        KsAcquireDevice(m_Device);\n        Status = KsCreateFilterFactory( m_Device->FunctionalDeviceObject,\n                                        &CaptureFilterDescriptor,\n                                        L\"GLOBAL\",\n                                        NULL,\n                                        KSCREATE_ITEM_FREEONSTOP,\n                                        NULL,\n                                        NULL,\n                                        NULL );\n        KsReleaseDevice(m_Device);\n\n    }\n    //\n    // By PnP, it's possible to receive multiple starts without an intervening\n    // stop (to reevaluate resources, for example).  Thus, we only perform\n    // creations of the simulation on the initial start and ignore any \n    // subsequent start.  Hardware drivers with resources should evaluate\n    // resources and make changes on 2nd start.\n    //\n    if (NT_SUCCESS(Status) && (!m_Device -> Started)) {\n\n        m_HardwareSimulation = new (NonPagedPoolNx, 'miSH') CHardwareSimulation (this);\n        if (!m_HardwareSimulation) {\n            //\n            // If we couldn't create the hardware simulation, fail.\n            //\n            Status = STATUS_INSUFFICIENT_RESOURCES;\n    \n        } else {\n            Status = KsAddItemToObjectBag (\n                m_Device -> Bag,\n                reinterpret_cast <PVOID> (m_HardwareSimulation),\n                reinterpret_cast <PFNKSFREE> (CHardwareSimulation::Cleanup)\n                );\n\n            if (!NT_SUCCESS (Status)) {\n                delete m_HardwareSimulation;\n            }\n        }\n    }\n    \n    return Status;\n\n}\n\n/*************************************************/\n\n\f\nvoid\nCCaptureDevice::\nPnpStop (\n    )\n\n/*++\n\nRoutine Description:\n\n    This is the pnp stop dispatch for the capture device.  It releases any\n    adapter object previously allocated by IoGetDmaAdapter during Pnp Start.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    if (m_DmaAdapterObject) {\n        //\n        // Return the DMA adapter back to the system.\n        //\n        m_DmaAdapterObject -> DmaOperations -> \n            PutDmaAdapter (m_DmaAdapterObject);\n\n        m_DmaAdapterObject = NULL;\n    }\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCaptureDevice::\nAcquireHardwareResources (\n    IN ICaptureSink *CaptureSink,\n    IN PKS_VIDEOINFOHEADER VideoInfoHeader\n    )\n\n/*++\n\nRoutine Description:\n\n    Acquire hardware resources for the capture hardware.  If the \n    resources are already acquired, this will return an error.\n    The hardware configuration must be passed as a VideoInfoHeader.\n\nArguments:\n\n    CaptureSink -\n        The capture sink attempting to acquire resources.  When scatter /\n        gather mappings are completed, the capture sink specified here is\n        what is notified of the completions.\n\n    VideoInfoHeader -\n        Information about the capture stream.  This **MUST** remain\n        stable until the caller releases hardware resources.  Note\n        that this could also be guaranteed by bagging it in the device\n        object bag as well.\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_SUCCESS;\n\n    //\n    // If we're the first pin to go into acquire (remember we can have\n    // a filter in another graph going simultaneously), grab the resources.\n    //\n    if (InterlockedCompareExchange (\n        &m_PinsWithResources,\n        1,\n        0) == 0) {\n\n        m_VideoInfoHeader = VideoInfoHeader;\n\n        //\n        // If there's an old hardware simulation sitting around for some\n        // reason, blow it away.\n        //\n        if (m_ImageSynth) {\n            delete m_ImageSynth;\n            m_ImageSynth = NULL;\n        }\n    \n        //\n        // Create the necessary type of image synthesizer.\n        //\n        if (m_VideoInfoHeader -> bmiHeader.biBitCount == 24 &&\n            m_VideoInfoHeader -> bmiHeader.biCompression == KS_BI_RGB) {\n    \n            //\n            // If we're RGB24, create a new RGB24 synth.  RGB24 surfaces\n            // can be in either orientation.  The origin is lower left if\n            // height < 0.  Otherwise, it's upper left.\n            //\n            m_ImageSynth = new (NonPagedPoolNx, 'RysI') \n                CRGB24Synthesizer (\n                    m_VideoInfoHeader -> bmiHeader.biHeight >= 0\n                    );\n    \n        } else\n        if (m_VideoInfoHeader -> bmiHeader.biBitCount == 16 &&\n           (m_VideoInfoHeader -> bmiHeader.biCompression == FOURCC_YUY2)) {\n    \n            //\n            // If we're UYVY, create the YUV synth.\n            //\n            m_ImageSynth = new(NonPagedPoolNx, 'YysI') CYUVSynthesizer;\n    \n        }\n        else\n            //\n            // We don't synthesize anything but RGB 24 and UYVY.\n            //\n            Status = STATUS_INVALID_PARAMETER;\n    \n        if (NT_SUCCESS (Status) && !m_ImageSynth) {\n    \n            Status = STATUS_INSUFFICIENT_RESOURCES;\n    \n        } \n\n        if (NT_SUCCESS (Status)) {\n            //\n            // If everything has succeeded thus far, set the capture sink.\n            //\n            m_CaptureSink = CaptureSink;\n\n        } else {\n            //\n            // If anything failed in here, we release the resources we've\n            // acquired.\n            //\n            ReleaseHardwareResources ();\n        }\n    \n    } else {\n\n        //\n        // TODO: Better status code?\n        //\n        Status = STATUS_SHARING_VIOLATION;\n\n    }\n\n    return Status;\n\n}\n\n/*************************************************/\n\n\f\nvoid\nCCaptureDevice::\nReleaseHardwareResources (\n    )\n\n/*++\n\nRoutine Description:\n\n    Release hardware resources.  This should only be called by\n    an object which has acquired them.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    //\n    // Blow away the image synth.\n    //\n    if (m_ImageSynth) {\n        delete m_ImageSynth;\n        m_ImageSynth = NULL;\n\n    }\n\n    m_VideoInfoHeader = NULL;\n    m_CaptureSink = NULL;\n\n    //\n    // Release our \"lock\" on hardware resources.  This will allow another\n    // pin (perhaps in another graph) to acquire them.\n    //\n    InterlockedExchange (\n        &m_PinsWithResources,\n        0\n        );\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCaptureDevice::\nStart (\n    )\n\n/*++\n\nRoutine Description:\n\n    Start the capture device based on the video info header we were told\n    about when resources were acquired.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    m_LastMappingsCompleted = 0;\n    m_InterruptTime = 0;\n\n    return\n        m_HardwareSimulation -> Start (\n            m_ImageSynth,\n            m_VideoInfoHeader -> AvgTimePerFrame,\n            m_VideoInfoHeader -> bmiHeader.biWidth,\n            ABS (m_VideoInfoHeader -> bmiHeader.biHeight),\n            m_VideoInfoHeader -> bmiHeader.biSizeImage\n            );\n\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCaptureDevice::\nPause (\n    IN BOOLEAN Pausing\n    )\n\n/*++\n\nRoutine Description:\n\n    Pause or unpause the hardware simulation.  This is an effective start\n    or stop without resetting counters and formats.  Note that this can\n    only be called to transition from started -> paused -> started.  Calling\n    this without starting the hardware with Start() does nothing.\n\nArguments:\n\n    Pausing -\n        An indicatation of whether we are pausing or unpausing\n\n        TRUE -\n            Pause the hardware simulation\n\n        FALSE -\n            Unpause the hardware simulation\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    return\n        m_HardwareSimulation -> Pause (\n            Pausing\n            );\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCCaptureDevice::\nStop (\n    )\n\n/*++\n\nRoutine Description:\n\n    Stop the capture device.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    return\n        m_HardwareSimulation -> Stop ();\n\n}\n\n/*************************************************/\n\n\f\nULONG\nCCaptureDevice::\nProgramScatterGatherMappings (\n    IN PKSSTREAM_POINTER Clone,\n    IN PUCHAR *Buffer,\n    IN PKSMAPPING Mappings,\n    IN ULONG MappingsCount\n    )\n\n/*++\n\nRoutine Description:\n\n    Program the scatter / gather mappings for the \"fake\" hardware.\n\nArguments:\n\n    Buffer -\n        Points to a pointer to the virtual address of the topmost\n        scatter / gather chunk.  The pointer will be updated as the\n        device \"programs\" mappings.  Reason for this is that we get\n        the physical addresses and sizes, but must calculate the virtual\n        addresses...  This is used as scratch space for that.\n\n    Mappings -\n        An array of mappings to program\n\n    MappingsCount -\n        The count of mappings in the array\n\nReturn Value:\n\n    The number of mappings successfully programmed\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    \n\n    return \n        m_HardwareSimulation -> ProgramScatterGatherMappings (\n            Clone,\n            Buffer,\n            Mappings,\n            MappingsCount,\n            sizeof (KSMAPPING)\n            );\n\n}\n\n/*************************************************************************\n\n    LOCKED CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg()\n#endif // ALLOC_PRAGMA\n\n\f\nULONG\nCCaptureDevice::\nQueryInterruptTime (\n    )\n\n/*++\n\nRoutine Description:\n\n    Return the number of frame intervals that have elapsed since the\n    start of the device.  This will be the frame number.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    The interrupt time of the device (the number of frame intervals that\n    have elapsed since the start of the device).\n\n--*/\n\n{\n\n    return m_InterruptTime;\n\n}\n\n/*************************************************/\n\n\f\nvoid\nCCaptureDevice::\nInterrupt (\n    )\n\n/*++\n\nRoutine Description:\n\n    This is the \"faked\" interrupt service routine for this device.  It\n    is called at dispatch level by the hardware simulation.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    m_InterruptTime++;\n\n    //\n    // Realistically, we'd do some hardware manipulation here and then queue\n    // a DPC.  Since this is fake hardware, we do what's necessary here.  This\n    // is pretty much what the DPC would look like short of the access\n    // of hardware registers (ReadNumberOfMappingsCompleted) which would likely\n    // be done in the ISR.\n    //\n    ULONG NumMappingsCompleted = \n        m_HardwareSimulation -> ReadNumberOfMappingsCompleted ();\n\n    //\n    // Inform the capture sink that a given number of scatter / gather\n    // mappings have completed.\n    //\n    m_CaptureSink -> CompleteMappings (\n        NumMappingsCompleted - m_LastMappingsCompleted\n        );\n\n    m_LastMappingsCompleted = NumMappingsCompleted;\n\n}\n\n/**************************************************************************\n\n    DESCRIPTOR AND DISPATCH LAYOUT\n\n**************************************************************************/\n\n//\n// CaptureFilterDescriptor:\n//\n// The filter descriptor for the capture device.\nDEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) { \n    &CaptureFilterDescriptor\n};\n\n//\n// CaptureDeviceDispatch:\n//\n// This is the dispatch table for the capture device.  Plug and play\n// notifications as well as power management notifications are dispatched\n// through this table.\n//\nconst\nKSDEVICE_DISPATCH\nCaptureDeviceDispatch = {\n    CCaptureDevice::DispatchCreate,         // Pnp Add Device\n    CCaptureDevice::DispatchPnpStart,       // Pnp Start\n    NULL,                                   // Post-Start\n    NULL,                                   // Pnp Query Stop\n    NULL,                                   // Pnp Cancel Stop\n    CCaptureDevice::DispatchPnpStop,        // Pnp Stop\n    NULL,                                   // Pnp Query Remove\n    NULL,                                   // Pnp Cancel Remove\n    NULL,                                   // Pnp Remove\n    NULL,                                   // Pnp Query Capabilities\n    NULL,                                   // Pnp Surprise Removal\n    NULL,                                   // Power Query Power\n    NULL,                                   // Power Set Power\n    NULL                                    // Pnp Query Interface\n};\n\n//\n// CaptureDeviceDescriptor:\n//\n// This is the device descriptor for the capture device.  It points to the\n// dispatch table and contains a list of filter descriptors that describe\n// filter-types that this device supports.  Note that the filter-descriptors\n// can be created dynamically and the factories created via \n// KsCreateFilterFactory as well.  \n//\nconst\nKSDEVICE_DESCRIPTOR\nCaptureDeviceDescriptor = {\n    &CaptureDeviceDispatch,\n    0,\n    NULL\n};\n\n/**************************************************************************\n\n    INITIALIZATION CODE\n\n**************************************************************************/\n\nextern \"C\" DRIVER_INITIALIZE DriverEntry;\n\nextern \"C\"\nNTSTATUS\nDriverEntry (\n    IN PDRIVER_OBJECT DriverObject,\n    IN PUNICODE_STRING RegistryPath\n    )\n\n/*++\n\nRoutine Description:\n\n    Driver entry point.  Pass off control to the AVStream initialization\n    function (KsInitializeDriver) and return the status code from it.\n\nArguments:\n\n    DriverObject -\n        The WDM driver object for our driver\n\n    RegistryPath -\n        The registry path for our registry info\n\nReturn Value:\n\n    As from KsInitializeDriver\n\n--*/\n\n{\n    //\n    // Simply pass the device descriptor and parameters off to AVStream\n    // to initialize us.  This will cause filter factories to be set up\n    // at add & start.  Everything is done based on the descriptors passed\n    // here.\n    //\n\treturn\n        KsInitializeDriver (\n            DriverObject,\n            RegistryPath,\n            &CaptureDeviceDescriptor\n            );\n}\n\nvoid CCaptureDevice::SetData(PVOID data, ULONG dataLength)\n{\n\tm_HardwareSimulation->SetData(data, dataLength);\n}"
  },
  {
    "path": "Driver/avshws/device.h",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        device.h\n\n    Abstract:\n\n        The header for the device level of the simulated hardware.  This is\n        not actually the hardware simulation itself.  The hardware simulation\n        is contained in hwsim.*, image.*.\n        \n    History:\n\n        created 3/9/2001\n\n**************************************************************************/\n\nclass CCaptureDevice :\n    public IHardwareSink {\n\nprivate:\n\n    //\n    // The AVStream device we're associated with.\n    //\n    PKSDEVICE m_Device;\n\n    //\n    // Number of pins with resources acquired.  This is used as a locking\n    // mechanism for resource acquisition on the device.\n    //\n    LONG m_PinsWithResources;\n\n    //\n    // Since we don't have physical hardware, this provides the hardware\n    // simulation.  m_HardwareSimulation provides the fake ISR, fake DPC,\n    // etc...  m_ImageSynth provides RGB24 and UYVY image synthesis and\n    // overlay in software.\n    //\n    CHardwareSimulation *m_HardwareSimulation;\n    CImageSynthesizer *m_ImageSynth;\n\n    //\n    // The number of ISR's that have occurred since capture started.\n    //\n    ULONG m_InterruptTime;\n\n    //\n    // The last reading of mappings completed.\n    //\n    ULONG m_LastMappingsCompleted;\n\n    //\n    // The Dma adapter object we acquired through IoGetDmaAdapter() during\n    // Pnp start.  This must be initialized with AVStream in order to perform\n    // Dma directly into the capture buffers.\n    //\n    PADAPTER_OBJECT m_DmaAdapterObject;\n\n    //\n    // The number of map registers returned from IoGetDmaAdapter().\n    //\n    ULONG m_NumberOfMapRegisters;\n\n    //\n    // The capture sink.  When we complete scatter / gather mappings, we\n    // notify the capture sink.\n    //\n    ICaptureSink *m_CaptureSink;\n\n    //\n    // The video info header we're basing hardware settings on.  The pin\n    // provides this to us when acquiring resources and must guarantee its\n    // stability until resources are released.\n    //\n    PKS_VIDEOINFOHEADER m_VideoInfoHeader;\n\n    //\n    // Cleanup():\n    //\n    // This is the free callback for the bagged capture device.  Not providing\n    // one will call ExFreePool, which is not what we want for a constructed\n    // C++ object.  This simply deletes the capture device.\n    //\n    static\n    void\n    Cleanup (\n        IN CCaptureDevice *CapDevice\n        )\n    {\n        delete CapDevice;\n    }\n\n    //\n    // PnpStart():\n    //\n    // This is the Pnp start routine for our simulated hardware.  Note that\n    // DispatchStart bridges to here in the context of the CCaptureDevice.\n    //\n    NTSTATUS\n    PnpStart (\n        IN PCM_RESOURCE_LIST TranslatedResourceList,\n        IN PCM_RESOURCE_LIST UntranslatedResourceList\n        );\n\n    //\n    // PnpStop():\n    //\n    // This is the Pnp stop routine for our simulated hardware.  Note that\n    // DispatchStop bridges to here in the context of the CCaptureDevice.\n    //\n    void\n    PnpStop (\n        );\n\npublic:\n\n    //\n    // CCaptureDevice():\n    //\n    // The capture device class constructor.  Since everything should have\n    // been zero'ed by the new operator, don't bother setting anything to\n    // zero or NULL.  Only initialize non-NULL, non-0 fields.\n    //\n    CCaptureDevice (\n        IN PKSDEVICE Device\n        ) :\n        m_Device (Device)\n    {\n    }\n\n    //\n    // ~CCaptureDevice():\n    //\n    // The capture device destructor.\n    //\n    ~CCaptureDevice (\n        )\n    {\n    }\n\n    //\n    // DispatchCreate():\n    //\n    // This is the Add Device dispatch for the capture device.  It creates\n    // the CCaptureDevice and associates it with the device via the bag.\n    //\n    static\n    NTSTATUS\n    DispatchCreate (\n        IN PKSDEVICE Device\n        );\n    //\n    // DispatchPnpStart():\n    //\n    // This is the Pnp Start dispatch for the capture device.  It simply\n    // bridges to PnpStart() in the context of the CCaptureDevice.\n    //\n    static\n    NTSTATUS\n    DispatchPnpStart (\n        IN PKSDEVICE Device,\n        IN PIRP Irp,\n        IN PCM_RESOURCE_LIST TranslatedResourceList,\n        IN PCM_RESOURCE_LIST UntranslatedResourceList\n        )\n    {\n        return \n            (reinterpret_cast <CCaptureDevice *> (Device -> Context)) ->\n            PnpStart (\n                TranslatedResourceList,\n                UntranslatedResourceList\n                );\n    }\n\n    //\n    // DispatchPnpStop():\n    //\n    // This is the Pnp stop dispatch for the capture device.  It simply\n    // bridges to PnpStop() in the context of the CCaptureDevice.\n    //\n    static\n    void\n    DispatchPnpStop (\n        IN PKSDEVICE Device,\n        IN PIRP Irp\n        )\n    {\n        return\n            (reinterpret_cast <CCaptureDevice *> (Device -> Context)) ->\n            PnpStop (\n                );\n    }\n\n    //\n    // AcquireHardwareResources():\n    //\n    // Called to acquire hardware resources for the device based on a given\n    // video info header.  This will fail if another object has already\n    // acquired hardware resources since we emulate a single capture\n    // device.\n    //\n    NTSTATUS\n    AcquireHardwareResources (\n        IN ICaptureSink *CaptureSink,\n        IN PKS_VIDEOINFOHEADER VideoInfoHeader\n        );\n\n    //\n    // ReleaseHardwareResources():\n    //\n    // Called to release hardware resources for the device.\n    //\n    void\n    ReleaseHardwareResources (\n        );\n\n    //\n    // Start():\n    //\n    // Called to start the hardware simulation.  This causes us to simulate\n    // interrupts, simulate filling buffers with synthesized data, etc...\n    //\n    NTSTATUS\n    Start (\n        );\n\n    //\n    // Pause():\n    //\n    // Called to pause or unpause the hardware simulation.  This will be\n    // indentical to a start or stop but it will not reset formats and \n    // counters.\n    //\n    NTSTATUS\n    Pause (\n        IN BOOLEAN Pausing\n        );\n\n    //\n    // Stop():\n    //\n    // Called to stop the hardware simulation.  This causes interrupts to\n    // stop issuing.  When this call returns, the \"fake\" hardware has\n    // stopped accessing all s/g buffers, etc...\n    //\n    NTSTATUS\n    Stop (\n        );\n\n    //\n    // ProgramScatterGatherMappings():\n    //\n    // Called to program the hardware simulation's scatter / gather table.\n    // This synchronizes with the \"fake\" ISR and hardware simulation via\n    // a spinlock.\n    //\n    ULONG\n    ProgramScatterGatherMappings (\n        IN PKSSTREAM_POINTER Clone,\n        IN PUCHAR *Buffer,\n        IN PKSMAPPING Mappings,\n        IN ULONG MappingsCount\n        );\n\n    //\n    // QueryInterruptTime():\n    //\n    // Determine the frame number that this frame corresponds to.  \n    //\n    ULONG\n    QueryInterruptTime (\n        );\n\n    //\n    // IHardwareSink::Interrupt():\n    //\n    // The interrupt service routine as called through the hardware sink\n    // interface.  The \"fake\" hardware uses this method to inform the device\n    // of a \"fake\" ISR.  The routine is called at dispatch level and must\n    // be in locked code.\n    //\n    virtual\n    void\n    Interrupt (\n        );\n\n    LONG GetDroppedFrameCount(){return m_HardwareSimulation->GetSkippedFrameCount();};\n\n\n\npublic:\n\t//\n\t//  Recast():\n\t//\n\t//  Helper function.  Used to convert from a PKSDEVICE to a CCaptureDevice *\n\t//\n\tstatic\n\t\tinline\n\t\tCCaptureDevice *\n\t\tRecast(\n\t\t\t_In_ PKSDEVICE Device\n\t\t)\n\t{\n\t\treturn reinterpret_cast <CCaptureDevice *> (Device->Context);\n\t}\n\n\t//\n\t// SetData();\n\t//\n\t// Sets the virtual frame buffer of the device.\n\t//\n\tvoid SetData(PVOID data, ULONG dataLength);\n};\n"
  },
  {
    "path": "Driver/avshws/filter.cpp",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        filter.cpp\n\n    Abstract:\n\n        This file contains the filter level implementation for the \n        capture filter.\n\n    History:\n\n        created 3/12/2001\n\n**************************************************************************/\n\n#include \"avshws.h\"\n\n/**************************************************************************\n\n    PAGEABLE CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg(\"PAGE\")\n#endif // ALLOC_PRAGMA\n\n\f\nNTSTATUS\nCCaptureFilter::\nDispatchCreate (\n    IN PKSFILTER Filter,\n    IN PIRP Irp\n    )\n\n/*++\n\nRoutine Description:\n\n    This is the creation dispatch for the capture filter.  It creates\n    the CCaptureFilter object, associates it with the AVStream filter\n    object, and bag the CCaptureFilter for later cleanup.\n\nArguments:\n\n    Filter -\n        The AVStream filter being created\n\n    Irp -\n        The creation Irp\n\nReturn Value:\n    \n    Success / failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_SUCCESS;\n\n    CCaptureFilter *CapFilter = new (NonPagedPoolNx, 'liFC') CCaptureFilter (Filter);\n\n    if (!CapFilter) {\n        //\n        // Return failure if we couldn't create the filter.\n        //\n        Status = STATUS_INSUFFICIENT_RESOURCES;\n\n    } else {\n        //\n        // Add the item to the object bag if we we were successful. \n        // Whenever the filter closes, the bag is cleaned up and we will be\n        // freed.\n        //\n        Status = KsAddItemToObjectBag (\n            Filter -> Bag,\n            reinterpret_cast <PVOID> (CapFilter),\n            reinterpret_cast <PFNKSFREE> (CCaptureFilter::Cleanup)\n            );\n\n        if (!NT_SUCCESS (Status)) {\n            delete CapFilter;\n        } else {\n            Filter -> Context = reinterpret_cast <PVOID> (CapFilter);\n        }\n\n    }\n\n    return Status;\n\n}\n\n//  Get KSPROPERTY_CUSTOMCONTROL_DUMMY.\nNTSTATUS\nCCaptureFilter::\nGetData(\n\t_In_ PIRP Irp,\n\t_In_ PKSIDENTIFIER Request,\n\t_Inout_ PVOID Data\n)\n{\n\tPAGED_CODE();\n\n\tPDWORD dataPtr = (PDWORD)Data;\n\n\t*dataPtr = 0xAA77AA77;\n\tIrp->IoStatus.Information = sizeof(DWORD);\n\n\treturn STATUS_SUCCESS;\n}\n\n//  Set KSPROPERTY_CUSTOMCONTROL_DUMMY.\nNTSTATUS\nCCaptureFilter::\nSetData(\n\t_In_ PIRP Irp,\n\t_In_ PKSIDENTIFIER Request,\n\t_Inout_ PVOID Data\n)\n{\n\tPAGED_CODE();\n\n\tCCaptureFilter* filter = reinterpret_cast<CCaptureFilter*>(KsGetFilterFromIrp(Irp)->Context);\n\n\tPIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(Irp);\n\tULONG bufferLength = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength;\n\n\tif (bufferLength == 0 || Data == NULL) {\n\t\treturn STATUS_SUCCESS;\n\t}\n\n\tCCaptureDevice* device = CCaptureDevice::Recast(KsFilterGetDevice(filter->m_Filter));\n\tdevice->SetData(Data, bufferLength);\n\n\treturn STATUS_SUCCESS;\n}\n\n/**************************************************************************\n\n\tPROPERTY TABLE STUFF\n\n**************************************************************************/\n\nDEFINE_KSPROPERTY_TABLE(CustomPropertyTable)\n{\n\t{\n\t\t0,\t\t\t\t\t\t\t\t\t\t\t//PropertyId\n\t\t(PFNKSHANDLER)&CCaptureFilter::GetData,\t\t//GetPropertyHandler\n\t\t(ULONG)sizeof(KSPROPERTY),\t\t\t\t\t//MinProperty\n\t\t(ULONG)0,\t\t\t\t\t\t\t\t//MinData\n\t\t(PFNKSHANDLER)&CCaptureFilter::SetData,\t\t//SetPropertyHandler\n\t\t(PKSPROPERTY_VALUES)NULL,\t\t\t\t\t//Values\n\t\t0,\t\t\t\t\t\t\t\t\t\t\t//RelationsCount\n\t\t(PKSPROPERTY)NULL,\t\t\t\t\t\t\t//Relations\n\t\t(PFNKSHANDLER)NULL,\t\t\t\t\t\t\t//SupportHandler\n\t\t(ULONG)0\t\t\t\t\t\t\t\t\t//SerializedSize\n\t}\n};\n\nDEFINE_KSPROPERTY_SET_TABLE(PropertySetTable)\n{\n\tDEFINE_STD_PROPERTY_SET(PROPSETID_VIDCAP_CUSTOMCONTROL, CustomPropertyTable)\n};\n\n\nDEFINE_KSAUTOMATION_TABLE(AvsFilterAutomationTable)\n{\n\tDEFINE_KSAUTOMATION_PROPERTIES(PropertySetTable),\n\tDEFINE_KSAUTOMATION_METHODS_NULL,\n\tDEFINE_KSAUTOMATION_EVENTS_NULL\n};\n\n/**************************************************************************\n\n    DESCRIPTOR AND DISPATCH LAYOUT\n\n**************************************************************************/\n\nGUID g_PINNAME_VIDEO_CAPTURE = {STATIC_PINNAME_VIDEO_CAPTURE};\n\n//\n// CaptureFilterCategories:\n//\n// The list of category GUIDs for the capture filter.\n//\nconst\nGUID\nCaptureFilterCategories [CAPTURE_FILTER_CATEGORIES_COUNT] = {\n    STATICGUIDOF (KSCATEGORY_VIDEO),\n    STATICGUIDOF (KSCATEGORY_CAPTURE),\n    STATICGUIDOF (KSCATEGORY_VIDEO_CAMERA)\n};\n\n//\n// CaptureFilterPinDescriptors:\n//\n// The list of pin descriptors on the capture filter.  \n//\nconst \nKSPIN_DESCRIPTOR_EX\nCaptureFilterPinDescriptors [CAPTURE_FILTER_PIN_COUNT] = {\n    //\n    // Video Capture Pin\n    //\n    {\n        &CapturePinDispatch,\n        NULL,             \n        {\n            0,                              // Interfaces (NULL, 0 == default)\n            NULL,\n            0,                              // Mediums (NULL, 0 == default)\n            NULL,\n            SIZEOF_ARRAY(CapturePinDataRanges),// Range Count\n            CapturePinDataRanges,           // Ranges\n            KSPIN_DATAFLOW_OUT,             // Dataflow\n            KSPIN_COMMUNICATION_BOTH,       // Communication\n            &PIN_CATEGORY_CAPTURE,          // Category\n            &g_PINNAME_VIDEO_CAPTURE,       // Name\n            0                               // Reserved\n        },\n        KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,// Pin Flags\n        1,                                  // Instances Possible\n        1,                                  // Instances Necessary\n        &CapturePinAllocatorFraming,        // Allocator Framing\n        reinterpret_cast <PFNKSINTERSECTHANDLEREX> \n            (CCapturePin::IntersectHandler)\n    }\n};\n\n//\n// CaptureFilterDispatch:\n//\n// This is the dispatch table for the capture filter.  It provides notification\n// of creation, closure, processing (for filter-centrics, not for the capture\n// filter), and resets (for filter-centrics, not for the capture filter).\n//\nconst \nKSFILTER_DISPATCH\nCaptureFilterDispatch = {\n    CCaptureFilter::DispatchCreate,         // Filter Create\n    NULL,                                   // Filter Close\n    NULL,                                   // Filter Process\n    NULL                                    // Filter Reset\n};\n\n\n//\n// CaptureFilterDescription:\n//\n// The descriptor for the capture filter.  We don't specify any topology\n// since there's only one pin on the filter.  Realistically, there would\n// be some topological relationships here because there would be input \n// pins from crossbars and the like.\n//\nconst \nKSFILTER_DESCRIPTOR \nCaptureFilterDescriptor = {\n    &CaptureFilterDispatch,                 // Dispatch Table\n    &AvsFilterAutomationTable,              // Automation Table\n    KSFILTER_DESCRIPTOR_VERSION,            // Version\n    0,                                      // Flags\n    &KSNAME_Filter,                         // Reference GUID\n    DEFINE_KSFILTER_PIN_DESCRIPTORS (CaptureFilterPinDescriptors),\n    DEFINE_KSFILTER_CATEGORIES (CaptureFilterCategories),\n    0,\n    sizeof (KSNODE_DESCRIPTOR),\n    NULL,\n    0,\n    NULL,\n    NULL                                    // Component ID\n};"
  },
  {
    "path": "Driver/avshws/filter.h",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        filter.h\n\n    Abstract:\n\n        This file contains the filter level header for the capture filter.\n\n    History:\n\n        created 3/12/2001\n\n**************************************************************************/\n\nclass CCaptureFilter {\n\nprivate:\n\n    //\n    // The AVStream filter object associated with this CCaptureFilter.\n    //\n    PKSFILTER m_Filter;\n   \n    //\n    // Cleanup():\n    //\n    // This is the bag cleanup callback for the CCaptureFilter.  Not providing\n    // one would cause ExFreePool to be used.  This is not good for C++\n    // constructed objects.  We simply delete the object here.\n    //\n    static\n    void\n    Cleanup (\n        IN CCaptureFilter *CapFilter\n        )\n    {\n        delete CapFilter;\n    }\n\npublic:\n\n    //\n    // CCaptureFilter():\n    //\n    // The capture filter object constructor.  Since the new operator will\n    // have zeroed the memory, do not bother initializing any NULL or 0\n    // fields.  Only initialize non-NULL, non-0 fields.\n    //\n    CCaptureFilter (\n        IN PKSFILTER Filter\n        ) :\n        m_Filter (Filter)\n    {\n    }\n\n    //\n    // ~CCaptureFilter():\n    //\n    // The capture filter destructor.\n    //\n    ~CCaptureFilter (\n        )\n    {\n    }\n\n    //\n    // DispatchCreate():\n    //\n    // This is the filter creation dispatch for the capture filter.  It\n    // creates the CCaptureFilter object, associates it with the AVStream\n    // object, and bags it for easy cleanup later.\n    //\n    static\n    NTSTATUS\n    DispatchCreate (\n        IN PKSFILTER Filter,\n        IN PIRP Irp\n        );\n\n\n\t//  Example of adding a new, custom property.\n\tDECLARE_PROPERTY_HANDLERS(Data)\n\n};\n\n\n"
  },
  {
    "path": "Driver/avshws/hwsim.cpp",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        hwsim.cpp\n\n    Abstract:\n        \n        This file contains the hardware simulation.  It fakes \"DMA\" transfers,\n        scatter gather mapping handling, ISR's, etc...  The ISR routine in\n        here will be called when an ISR would be generated by the fake hardware\n        and it will directly call into the device level ISR for more accurate\n        simulation.\n\n    History:\n\n        created 3/9/2001\n\n**************************************************************************/\n\n#include \"avshws.h\"\n\n\n/*************************************************/\nKDEFERRED_ROUTINE SimulatedInterrupt;\n\nvoid\nSimulatedInterrupt (\n    IN PKDPC Dpc,\n    IN PVOID DeferredContext,\n    IN PVOID SystemArg1,\n    IN PVOID SystemArg2\n    )\n{\n    CHardwareSimulation* HardwareSim = (CHardwareSimulation*)DeferredContext;\n    \n    if (HardwareSim)\n    {\n        HardwareSim -> FakeHardware ();\n    }\n}\n\n\n/**************************************************************************\n\n    PAGEABLE CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg(\"PAGE\")\n#endif // ALLOC_PRAGMA\n\n\n\f\nCHardwareSimulation::\nCHardwareSimulation (\n    IN IHardwareSink *HardwareSink\n    ) :\n    m_HardwareSink (HardwareSink),\n    m_ScatterGatherMappingsMax (SCATTER_GATHER_MAPPINGS_MAX)\n\n/*++\n\nRoutine Description:\n\n    Construct a hardware simulation\n\nArguments:\n\n    HardwareSink -\n        The hardware sink interface.  This is used to trigger\n        fake interrupt service routines from.\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    //\n    // Initialize the DPC's, timer's, and locks necessary to simulate\n    // this capture hardware.\n    //\n    KeInitializeDpc (\n        &m_IsrFakeDpc, \n        SimulatedInterrupt, \n        this\n        );\n\n    KeInitializeEvent (\n        &m_HardwareEvent,\n        SynchronizationEvent,\n        FALSE\n        );\n\n    KeInitializeTimer (&m_IsrTimer);\n\n    KeInitializeSpinLock (&m_ListLock);\n\n}\n\n/*************************************************/\n\n\f\nCHardwareSimulation *\nCHardwareSimulation::\nInitialize (\n    IN KSOBJECT_BAG Bag,\n    IN IHardwareSink *HardwareSink\n    )\n\n/*++\n\nRoutine Description:\n\n    Initialize the hardware simulation\n\nArguments:\n\n    HardwareSink -\n        The hardware sink interface.  This is what ISR's will be\n        triggered through.\n\nReturn Value:\n\n    A fully initialized hardware simulation or NULL if the simulation\n    could not be initialized.\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    CHardwareSimulation *HwSim = \n        new (NonPagedPoolNx, 'miSH') CHardwareSimulation (HardwareSink);\n\n    return HwSim;\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCHardwareSimulation::\nStart (\n    IN CImageSynthesizer *ImageSynth,\n    IN LONGLONG TimePerFrame,\n    IN ULONG Width,\n    IN ULONG Height,\n    IN ULONG ImageSize\n    )\n\n/*++\n\nRoutine Description:\n\n    Start the hardware simulation.  This will kick the interrupts on,\n    begin issuing DPC's, filling in capture information, etc...\n    We keep track of starvation starting at this point.\n\nArguments:\n\n    ImageSynth -\n        The image synthesizer to use to generate pictures to display\n        on the capture buffer.\n\n    TimePerFrame -\n        The time per frame...  we issue interrupts this often.\n\n    Width -\n        The image width\n\n    Height -\n        The image height\n\n    ImageSize - \n        The size of the image.  We allocate a temporary scratch buffer\n        based on this size to fake hardware.\n\nReturn Value:\n\n    Success / Failure (typical failure will be out of memory on the \n    scratch buffer, etc...)\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    NTSTATUS Status = STATUS_SUCCESS;\n\n    m_ImageSynth = ImageSynth;\n    m_TimePerFrame = TimePerFrame;\n    m_ImageSize = ImageSize;\n    m_Height = Height;\n    m_Width = Width;\n\n    InitializeListHead (&m_ScatterGatherMappings);\n    m_NumMappingsCompleted = 0;\n    m_ScatterGatherMappingsQueued = 0;\n    m_NumFramesSkipped = 0;\n    m_InterruptTime = 0;\n\n    KeQuerySystemTime (&m_StartTime);\n\n    //\n    // Allocate a scratch buffer for the synthesizer.\n    //\n    m_SynthesisBuffer = reinterpret_cast <PUCHAR> (\n        ExAllocatePoolWithTag (\n            NonPagedPoolNx,\n            m_ImageSize,\n            AVSHWS_POOLTAG\n            )\n        );\n\n    if (!m_SynthesisBuffer) {\n        Status = STATUS_INSUFFICIENT_RESOURCES;\n    }\n\n\t//\n\t// Allocate a temporary frame buffer;\n\t//\n\tm_TemporaryBuffer = reinterpret_cast <PUCHAR> (\n\t\tExAllocatePoolWithTag(\n\t\t\tNonPagedPoolNx,\n\t\t\tm_ImageSize,\n\t\t\tAVSHWS_POOLTAG\n\t\t\t)\n\t\t);\n\n\tif (!m_TemporaryBuffer) {\n\t\tStatus = STATUS_INSUFFICIENT_RESOURCES;\n\t}\n\n\tRtlZeroMemory(m_TemporaryBuffer, m_ImageSize);\n\t\n    //\n    // If everything is ok, start issuing interrupts.\n    //\n    if (NT_SUCCESS (Status)) {\n\n        //\n        // Initialize the entry lookaside.\n        //\n        ExInitializeNPagedLookasideList (\n            &m_ScatterGatherLookaside,\n            NULL,\n            NULL,\n            POOL_NX_ALLOCATION,\n            sizeof (SCATTER_GATHER_ENTRY),\n            'nEGS',\n            0\n            );\n\n        //\n        // Set up the synthesizer with the width, height, and scratch buffer.\n        //\n        m_ImageSynth -> SetImageSize (m_Width, m_Height);\n        m_ImageSynth -> SetBuffer (m_SynthesisBuffer);\n\n        LARGE_INTEGER NextTime;\n        NextTime.QuadPart = m_StartTime.QuadPart + m_TimePerFrame;\n\n        m_HardwareState = HardwareRunning;\n        KeSetTimer (&m_IsrTimer, NextTime, &m_IsrFakeDpc);\n\n    }\n\n    return Status;\n        \n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCHardwareSimulation::\nPause (\n    BOOLEAN Pausing\n    )\n\n/*++\n\nRoutine Description:\n\n    Pause the hardware simulation...  When the hardware simulation is told\n    to pause, it stops issuing interrupts, etc...  but it does not reset\n    the counters \n\nArguments:\n\n    Pausing -\n        Indicates whether the hardware is pausing or not. \n\n        TRUE -\n            Pause the hardware\n\n        FALSE -\n            Unpause the hardware from a previous pause\n\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    PAGED_CODE();\n\n    if (Pausing && m_HardwareState == HardwareRunning) {\n        //\n        // If we were running, stop completing mappings, etc...\n        //\n        m_StopHardware = TRUE;\n    \n        KeWaitForSingleObject (\n            &m_HardwareEvent,\n            Suspended,\n            KernelMode,\n            FALSE,\n            NULL\n            );\n\n        NT_ASSERT (m_StopHardware == FALSE);\n\n        m_HardwareState = HardwarePaused; \n\n    } else if (!Pausing && m_HardwareState == HardwarePaused) {\n\n        //\n        // For unpausing the hardware, we need to compute the relative time\n        // and restart interrupts.\n        //\n        LARGE_INTEGER UnpauseTime;\n\n        KeQuerySystemTime (&UnpauseTime);\n        m_InterruptTime = (ULONG) (\n            (UnpauseTime.QuadPart - m_StartTime.QuadPart) /\n            m_TimePerFrame\n            );\n\n        UnpauseTime.QuadPart = m_StartTime.QuadPart +\n            (m_InterruptTime + 1) * m_TimePerFrame;\n\n        m_HardwareState = HardwareRunning;\n        KeSetTimer (&m_IsrTimer, UnpauseTime, &m_IsrFakeDpc);\n\n    }\n\n    return STATUS_SUCCESS;\n\n}\n\n/**************************************************************************\n\n    LOCKED CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg()\n#endif // ALLOC_PRAGMA\n\f\nNTSTATUS\nCHardwareSimulation::\nStop (\n    )\n\n/*++\n\nRoutine Description:\n\n    Stop the hardware simulation....  Wait until the hardware simulation\n    has successfully stopped and then return.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n    KIRQL Irql;\n    //\n    // If the hardware is told to stop while it's running, we need to\n    // halt the interrupts first.  If we're already paused, this has\n    // already been done.\n    //\n    if (m_HardwareState == HardwareRunning) {\n    \n        m_StopHardware = TRUE;\n    \n        KeWaitForSingleObject (\n            &m_HardwareEvent,\n            Suspended,\n            KernelMode,\n            FALSE,\n            NULL\n            );\n    \n        NT_ASSERT (m_StopHardware == FALSE);\n\n    }\n\n    m_HardwareState = HardwareStopped;\n\n    //\n    // The image synthesizer may still be around.  Just for safety's\n    // sake, NULL out the image synthesis buffer and toast it.\n    //\n    m_ImageSynth -> SetBuffer (NULL);\n\n    if (m_SynthesisBuffer) {\n        ExFreePool (m_SynthesisBuffer);\n        m_SynthesisBuffer = NULL;\n    }\n\n\tif (m_TemporaryBuffer) {\n\t\tExFreePool(m_TemporaryBuffer);\n\t\tm_TemporaryBuffer = NULL;\n\t}\n\n    //\n    // Protect the S/G list\n    //\n    KeAcquireSpinLock (&m_ListLock, &Irql);\n    // \n    // Free S/G buffer \n    // \n    // \n    while (m_ScatterGatherMappingsQueued > 0) {\n        LIST_ENTRY *listEntry = RemoveHeadList (&m_ScatterGatherMappings);\n        m_ScatterGatherMappingsQueued--;\n        PSCATTER_GATHER_ENTRY SGEntry =\n            reinterpret_cast <PSCATTER_GATHER_ENTRY> (\n                CONTAINING_RECORD (\n                    listEntry,\n                    SCATTER_GATHER_ENTRY,\n                    ListEntry\n                    )\n                );\n        // \n        // Release the scatter / gather entry back to our lookaside. \n        // \n        ExFreeToNPagedLookasideList (\n            &m_ScatterGatherLookaside,\n            reinterpret_cast <PVOID> (SGEntry)\n            );\n    } \n\n    m_NumMappingsCompleted = 0;\n    m_ScatterGatherBytesQueued = 0;\n    //\n    // Delete the scatter / gather lookaside for this run.\n    //\n    ExDeleteNPagedLookasideList (&m_ScatterGatherLookaside);\n\n    KeReleaseSpinLock (&m_ListLock, Irql);\n\n    return STATUS_SUCCESS;\n\n}\n\n\f\nULONG\nCHardwareSimulation::\nReadNumberOfMappingsCompleted (\n    )\n\n/*++\n\nRoutine Description:\n\n    Read the number of scatter / gather mappings which have been\n    completed (TOTAL NUMBER) since the last reset of the simulated\n    hardware\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Total number of completed mappings.\n\n--*/\n\n{\n\n    //\n    // Don't care if this is being updated this moment in the DPC...  I only\n    // need a number to return which isn't too great (too small is ok).\n    // In real hardware, this wouldn't be done this way anyway.\n    //\n    return m_NumMappingsCompleted;\n\n}\n\n/*************************************************/\n\n\f\nULONG\nCHardwareSimulation::\nProgramScatterGatherMappings (\n    IN PKSSTREAM_POINTER Clone,\n    IN PUCHAR *Buffer,\n    IN PKSMAPPING Mappings,\n    IN ULONG MappingsCount,\n    IN ULONG MappingStride\n    )\n\n/*++\n\nRoutine Description:\n\n    Program the scatter gather mapping list.  This shoves a bunch of \n    entries on a list for access during the fake interrupt.  Note that\n    we have physical addresses here only for simulation.  We really\n    access via the virtual address....  although we chunk it into multiple\n    buffers to more realistically simulate S/G\n\nArguments:\n\n    Buffer -\n        The virtual address of the buffer mapped by the mapping list \n\n    Mappings -\n        The KSMAPPINGS array corresponding to the buffer\n\n    MappingsCount -\n        The number of mappings in the mappings array\n\n    MappingStride -\n        The mapping stride used in initialization of AVStream DMA\n\nReturn Value:\n\n    Number of mappings actually inserted.\n\n--*/\n\n{\n\n    KIRQL Irql;\n\n    ULONG MappingsInserted = 0;\n\n    //\n    // Protect our S/G list with a spinlock.\n    //\n    KeAcquireSpinLock (&m_ListLock, &Irql);\n\n    //\n    // Loop through the scatter / gather list and break the buffer up into\n    // chunks equal to the scatter / gather mappings.  Stuff the virtual\n    // addresses of these chunks on a list somewhere.  We update the buffer\n    // pointer the caller passes as a more convenient way of doing this.\n    //\n    // If I could just remap physical in the list to virtual easily here,\n    // I wouldn't need to do it.\n    //\n    do\n    {\n        PSCATTER_GATHER_ENTRY Entry =\n            reinterpret_cast <PSCATTER_GATHER_ENTRY> (\n                ExAllocateFromNPagedLookasideList (\n                    &m_ScatterGatherLookaside\n                    )\n                );\n\n        if (!Entry) {\n            break;\n        }\n        Entry -> Virtual    = *Buffer;\n        Entry -> ByteCount  = MappingsCount;\n        Entry -> CloneEntry = Clone;\n\n        //\n        // Move forward a specific number of bytes in chunking this into\n        // mapping sized va buffers.\n        //\n        *Buffer += MappingsCount;\n        Mappings = reinterpret_cast <PKSMAPPING> (\n            (reinterpret_cast <PUCHAR> (Mappings) + MappingStride)\n            );\n\n        InsertTailList (&m_ScatterGatherMappings, &(Entry -> ListEntry));\n        MappingsInserted = MappingsCount;\n        m_ScatterGatherMappingsQueued++;\n        m_ScatterGatherBytesQueued += MappingsCount;\n\n   }\n    while(FALSE);\n\n    KeReleaseSpinLock (&m_ListLock, Irql);\n\n    return MappingsInserted;\n\n}\n\n/*************************************************/\n\n\f\nNTSTATUS\nCHardwareSimulation::\nFillScatterGatherBuffers (\n    )\n\n/*++\n\nRoutine Description:\n\n    The hardware has synthesized a buffer in scratch space and we're to\n    fill scatter / gather buffers.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    Success / Failure\n\n--*/\n\n{\n\n    //\n    // We're using this list lock to protect our scatter / gather lists instead\n    // of some hardware mechanism / KeSynchronizeExecution / whatever.\n    //\n    KeAcquireSpinLockAtDpcLevel (&m_ListLock);\n\n    PUCHAR Buffer = reinterpret_cast <PUCHAR> (m_SynthesisBuffer);\n    ULONG BufferRemaining = m_ImageSize;\n\n    //\n    // For simplification, if there aren't enough scatter / gather buffers\n    // queued, we don't partially fill the ones that are available.  We just\n    // skip the frame and consider it starvation.\n    //\n    // This could be enforced by only programming scatter / gather mappings\n    // for a buffer if all of them fit in the table also...\n    //\n    while (BufferRemaining &&\n        m_ScatterGatherMappingsQueued > 0 &&\n        m_ScatterGatherBytesQueued >= BufferRemaining) {\n\n        LIST_ENTRY *listEntry = RemoveHeadList (&m_ScatterGatherMappings);\n        m_ScatterGatherMappingsQueued--;\n\n        PSCATTER_GATHER_ENTRY SGEntry =  \n            reinterpret_cast <PSCATTER_GATHER_ENTRY> (\n                CONTAINING_RECORD (\n                    listEntry,\n                    SCATTER_GATHER_ENTRY,\n                    ListEntry\n                    )\n                );\n\n        //\n        // Since we're software, we'll be accessing this by virtual address...\n        //\n        ULONG BytesToCopy = \n            (BufferRemaining < SGEntry -> ByteCount) ?\n            BufferRemaining :\n            SGEntry -> ByteCount;\n\n        LONG Width = m_Width*(m_ImageSynth->GetBytesPerPixel());\n\n        LONG Stride = Width;\n        if(SGEntry->CloneEntry->StreamHeader->Size >= sizeof(KSSTREAM_HEADER)+sizeof(KS_FRAME_INFO))\n        {\n            PKS_FRAME_INFO FrameInfo = reinterpret_cast <PKS_FRAME_INFO> (SGEntry->CloneEntry->StreamHeader+1);\n            if(FrameInfo->lSurfacePitch != 0)\n            {\n                Stride = FrameInfo->lSurfacePitch;\n                if(FrameInfo->lSurfacePitch < 0)\n                {\n                    Stride = -Stride;\n                }\n            }\n        }\n\n        for(ULONG y = 0; y < m_Height; y++)\n        {\n            RtlCopyMemory((SGEntry->Virtual+(ULONG)Stride*y), Buffer, Width);\n            Buffer += Width;\n            BytesToCopy -= Width;\n            BufferRemaining -= Width;\n        }\n\n        m_NumMappingsCompleted++;\n        m_ScatterGatherBytesQueued -= SGEntry -> ByteCount;\n\n        //\n        // Release the scatter / gather entry back to our lookaside.\n        //\n        ExFreeToNPagedLookasideList (\n            &m_ScatterGatherLookaside,\n            reinterpret_cast <PVOID> (SGEntry)\n            );\n\n    }\n    \n    KeReleaseSpinLockFromDpcLevel (&m_ListLock);\n\n    if (BufferRemaining) return STATUS_INSUFFICIENT_RESOURCES;\n    else return STATUS_SUCCESS;\n    \n}\n\n/*************************************************/\n\n\f\nvoid\nCHardwareSimulation::\nFakeHardware (\n    )\n\n/*++\n\nRoutine Description:\n\n    Simulate an interrupt and what the hardware would have done in the\n    time since the previous interrupt.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    m_InterruptTime++;\n\n\tif (m_HardwareState == HardwareRunning)\n\t{\n\t\tRtlCopyMemory(m_SynthesisBuffer, m_TemporaryBuffer, m_ImageSize);\n\n\t\tif (!NT_SUCCESS(FillScatterGatherBuffers())) {\n\t\t\tInterlockedIncrement(PLONG(&m_NumFramesSkipped));\n\t\t}\n\t}\n\n    //\n    // Issue an interrupt to our hardware sink.  This is a \"fake\" interrupt.\n    // It will occur at DISPATCH_LEVEL.\n    //\n    m_HardwareSink -> Interrupt ();\n\n    //\n    // Reschedule the timer if the hardware isn't being stopped.\n    //\n    if (!m_StopHardware) {\n\n        //\n        // Reschedule the timer for the next interrupt time.\n        //\n        LARGE_INTEGER NextTime;\n        NextTime.QuadPart = m_StartTime.QuadPart + \n            (m_TimePerFrame * (m_InterruptTime + 1));\n\n        KeSetTimer (&m_IsrTimer, NextTime, &m_IsrFakeDpc);\n        \n    } else {\n        //\n        // If someone is waiting on the hardware to stop, raise the stop\n        // event and clear the flag.\n        //\n        m_StopHardware = FALSE;\n        KeSetEvent (&m_HardwareEvent, IO_NO_INCREMENT, FALSE);\n    }\n\n}\n\n\nvoid CHardwareSimulation::SetData(PVOID data, ULONG dataLength)\n{\n\tif (m_HardwareState != HardwareRunning) \n\t{\n\t\treturn;\n\t}\n\n\tif (m_TemporaryBuffer == NULL)\n\t{\n\t\treturn;\n\t}\n\n\tif (dataLength < m_Width * m_Height * 3)\n\t{\n\t\treturn;\n\t}\n\n\tfor (ULONG y = 0; y < m_Height; y++)\n\t{\n\t\tPUCHAR buffer = m_TemporaryBuffer + ((m_Width * 3) * (m_Height - 1 - y));\n\t\tPUCHAR dataLine = (PUCHAR)(data) + ((m_Width * 3) * y);\n\n\t\tRtlCopyMemory(buffer, dataLine, m_Width * 3);\n\t}\n}"
  },
  {
    "path": "Driver/avshws/hwsim.h",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        hwsim.cpp\n\n    Abstract:\n        \n        This file is the hardware simulation header.  \n\n        The simulation fakes \"DMA\" transfers, scatter gather mapping handling, \n        ISR's, etc...  The ISR routine in here will be called when an ISR \n        would be generated by the fake hardware and it will directly call into \n        the device level ISR for more accurate simulation.\n\n    History:\n\n        created 3/9/2001\n\n**************************************************************************/\n\n//\n// SCATTER_GATHER_MAPPINGS_MAX:\n//\n// The maximum number of entries in the hardware's scatter/gather list.  I\n// am making this so large for a few reasons:\n//\n//     1) we're faking this with uncompressed surfaces -- \n//            these are large buffers which will map to a lot of s/g entries\n//     2) the fake hardware implementation requires at least one frame's\n//            worth of s/g entries to generate a frame\n//\n#define SCATTER_GATHER_MAPPINGS_MAX 128\n\n//\n// SCATTER_GATHER_ENTRY:\n//\n// This structure is used to keep the scatter gather table for the fake\n// hardware as a doubly linked list.\n//\ntypedef struct _SCATTER_GATHER_ENTRY {\n\n    LIST_ENTRY ListEntry;\n    PKSSTREAM_POINTER CloneEntry;\n    PUCHAR Virtual;\n    ULONG ByteCount;\n\n} SCATTER_GATHER_ENTRY, *PSCATTER_GATHER_ENTRY;\n\n//\n// CHardwareSimulation:\n//\n// The hardware simulation class.\n//\nclass CHardwareSimulation {\n\nprivate:\n\n    //\n    // The image synthesizer.  This is a piece of code which actually draws\n    // the requested images.\n    //\n    CImageSynthesizer *m_ImageSynth;\n\n    //\n    // The synthesis buffer.  This is a private buffer we use to generate the\n    // capture image in.  The fake \"scatter / gather\" mappings are filled\n    // in from this buffer during each interrupt.\n    //\n    PUCHAR m_SynthesisBuffer;\n\n\t//\n\t// A temporary frame buffer;\n\t//\n\tPUCHAR m_TemporaryBuffer;\n\n    //\n    // Key information regarding the frames we generate.\n    //\n    LONGLONG m_TimePerFrame;\n    ULONG m_Width;\n    ULONG m_Height;\n    ULONG m_ImageSize;\n\n    //\n    // Scatter gather mappings for the simulated hardware.\n    //\n    KSPIN_LOCK m_ListLock;\n    LIST_ENTRY m_ScatterGatherMappings;\n\n    //\n    // Lookaside for memory for the scatter / gather entries on the scatter /\n    // gather list.\n    //\n    NPAGED_LOOKASIDE_LIST m_ScatterGatherLookaside;\n\n    //\n    // The current state of the fake hardware.\n    //\n    HARDWARE_STATE m_HardwareState;\n\n    //\n    // The pause / stop hardware flag and event.\n    //\n    BOOLEAN m_StopHardware;\n    KEVENT m_HardwareEvent;\n\n    //\n    // Maximum number of scatter / gather mappins in the s/g table of the\n    // fake hardware.\n    //\n    ULONG m_ScatterGatherMappingsMax;\n\n    //\n    // Number of scatter / gather mappings that have been completed (total)\n    // since the start of the hardware or any reset.\n    //\n    ULONG m_NumMappingsCompleted;\n\n    //\n    // Number of scatter / gather mappings that are queued for this hardware.\n    //\n    ULONG m_ScatterGatherMappingsQueued;\n    ULONG m_ScatterGatherBytesQueued;\n\n    //\n    // Number of frames skipped due to lack of scatter / gather mappings.\n    //\n    ULONG m_NumFramesSkipped;\n\n    //\n    // The \"Interrupt Time\".  Number of \"fake\" interrupts that have occurred\n    // since the hardware was started.\n    // \n    ULONG m_InterruptTime;\n\n    //\n    // The system time at start.\n    //\n    LARGE_INTEGER m_StartTime;\n    \n    //\n    // The DPC used to \"fake\" ISR\n    //\n    KDPC m_IsrFakeDpc;\n    KTIMER m_IsrTimer;\n\n    //\n    // The hardware sink that will be used for interrupt notifications.\n    //\n    IHardwareSink *m_HardwareSink;\n\n    //\n    // FillScatterGatherBuffers():\n    //\n    // This is called by the hardware simulation to fill a series of scatter /\n    // gather buffers with synthesized data.\n    //\n    NTSTATUS\n    FillScatterGatherBuffers (\n        );\n\npublic:\n\n    LONG GetSkippedFrameCount()\n    {\n        return InterlockedExchange((LONG*)&this->m_NumFramesSkipped, this->m_NumFramesSkipped);\n    }\n    //\n    // CHardwareSimulation():\n    //\n    // The hardware simulation constructor.  Since the new operator will\n    // have zeroed the memory, only initialize non-NULL, non-0 fields. \n    //\n    CHardwareSimulation (\n        IN IHardwareSink *HardwareSink\n        );\n\n    //\n    // ~CHardwareSimulation():\n    //\n    // The hardware simulation destructor.\n    //\n    ~CHardwareSimulation (\n        )\n    {\n    }\n\n    //\n    // Cleanup():\n    //\n    // This is the free callback for the bagged hardware sim.  Not providing\n    // one will call ExFreePool, which is not what we want for a constructed\n    // C++ object.  This simply deletes the simulation.\n    //\n    static\n    void\n    Cleanup (\n        IN CHardwareSimulation *HwSim\n        )\n    {\n        delete HwSim;\n    }\n\n    //\n    // FakeHardware():\n    //\n    // Called from the simulated interrupt.  First we fake the hardware's\n    // actions (at DPC) then we call the \"Interrupt service routine\" on\n    // the hardware sink.\n    //\n    void\n    FakeHardware (\n        );\n\n    //\n    // Start():\n    //\n    // \"Start\" the fake hardware.  This will start issuing interrupts and \n    // DPC's. \n    //\n    // The frame rate, image size, and a synthesizer must be provided.\n    //\n    NTSTATUS\n    Start (\n        CImageSynthesizer *ImageSynth,\n        IN LONGLONG TimePerFrame,\n        IN ULONG Width,\n        IN ULONG Height,\n        IN ULONG ImageSize\n        );\n\n    //\n    // Pause():\n    //\n    // \"Pause\" or \"unpause\" the fake hardware.  This will stop issuing \n    // interrupts or DPC's on a pause and restart them on an unpause.  Note\n    // that this will not reset counters as a Stop() would.\n    //\n    NTSTATUS\n    Pause (\n        IN BOOLEAN Pausing\n        );\n\n    //\n    // Stop():\n    //\n    // \"Stop\" the fake hardware.  This will stop issuing interrupts and\n    // DPC's.\n    //\n    NTSTATUS\n    Stop (\n        );\n\n    //\n    // ProgramScatterGatherMappings():\n    //\n    // Program a series of scatter gather mappings into the fake hardware.\n    //\n    ULONG\n    ProgramScatterGatherMappings (\n        IN PKSSTREAM_POINTER Clone,\n        IN PUCHAR *Buffer,\n        IN PKSMAPPING Mappings,\n        IN ULONG MappingsCount,\n        IN ULONG MappingStride\n        );\n\n    //\n    // Initialize():\n    //\n    // Initialize a piece of simulated hardware.\n    //\n    static \n    CHardwareSimulation *\n    Initialize (\n        IN KSOBJECT_BAG Bag,\n        IN IHardwareSink *HardwareSink\n        );\n\n    //\n    // ReadNumberOfMappingsCompleted():\n    //\n    // Read the number of mappings completed since the last hardware reset.\n    //\n    ULONG\n    ReadNumberOfMappingsCompleted (\n        );\n\n\n\t//\n\t// SetData();\n\t//\n\t// Sets the virtual frame buffer of the simulation.\n\t//\n\tvoid SetData(PVOID data, ULONG dataLength);\n};\n\n"
  },
  {
    "path": "Driver/avshws/image.cpp",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        image.cpp\n\n    Abstract:\n\n        The image synthesis and overlay code.  These objects provide image\n        synthesis (pixel, color-bar, etc...) onto RGB24 and UYVY buffers as\n        well as software string overlay into these buffers.\n\n\tThis entire file, data and all, must be in locked segments.\n\n    History:\n\n        created 1/16/2001\n\n**************************************************************************/\n\n#include \"avshws.h\"\n\n/**************************************************************************\n\n    Constants\n\n**************************************************************************/\n\n//\n// g_FontData:\n//\n// The following is an 8x8 bitmapped font for use in the text overlay\n// code.\n//\nUCHAR g_FontData [256][8] = {\n    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},\n    {0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e},\n    {0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e},\n    {0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00},\n    {0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00},\n    {0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c},\n    {0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c},\n    {0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00},\n    {0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff},\n    {0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00},\n    {0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff},\n    {0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78},\n    {0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18},\n    {0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0},\n    {0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0},\n    {0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99},\n    {0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00},\n    {0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00},\n    {0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18},\n    {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00},\n    {0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00},\n    {0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78},\n    {0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00},\n    {0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff},\n    {0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00},\n    {0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00},\n    {0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00},\n    {0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00},\n    {0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00},\n    {0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00},\n    {0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00},\n    {0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},\n    {0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00},\n    {0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00},\n    {0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00},\n    {0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00},\n    {0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00},\n    {0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00},\n    {0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00},\n    {0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00},\n    {0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00},\n    {0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00},\n    {0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60},\n    {0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00},\n    {0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00},\n    {0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00},\n    {0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00},\n    {0x78, 0xcc, 0x0c, 0x38, 0x60, 0xcc, 0xfc, 0x00},\n    {0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00},\n    {0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00},\n    {0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00},\n    {0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00},\n    {0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00},\n    {0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00},\n    {0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00},\n    {0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00},\n    {0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x60},\n    {0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00},\n    {0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00},\n    {0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00},\n    {0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00},\n    {0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00},\n    {0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00},\n    {0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00},\n    {0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00},\n    {0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00},\n    {0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00},\n    {0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00},\n    {0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00},\n    {0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00},\n    {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00},\n    {0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00},\n    {0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00},\n    {0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00},\n    {0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00},\n    {0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00},\n    {0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00},\n    {0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00},\n    {0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00},\n    {0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00},\n    {0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00},\n    {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00},\n    {0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00},\n    {0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00},\n    {0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00},\n    {0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00},\n    {0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00},\n    {0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00},\n    {0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00},\n    {0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff},\n    {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00},\n    {0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00},\n    {0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00},\n    {0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00},\n    {0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},\n    {0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00},\n    {0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},\n    {0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00},\n    {0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78},\n    {0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00},\n    {0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00},\n    {0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00},\n    {0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00},\n    {0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0},\n    {0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e},\n    {0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00},\n    {0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00},\n    {0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00},\n    {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00},\n    {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00},\n    {0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00},\n    {0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00},\n    {0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},\n    {0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00},\n    {0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00},\n    {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00},\n    {0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00},\n    {0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},\n    {0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00},\n    {0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x18, 0x0c, 0x78},\n    {0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},\n    {0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},\n    {0x7e, 0xc3, 0x3c, 0x06, 0x3e, 0x66, 0x3f, 0x00},\n    {0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},\n    {0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},\n    {0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},\n    {0x00, 0x00, 0x78, 0xc0, 0xc0, 0x78, 0x0c, 0x38},\n    {0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00},\n    {0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},\n    {0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00},\n    {0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0x7c, 0xc6, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00},\n    {0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00},\n    {0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00},\n    {0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00},\n    {0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00},\n    {0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00},\n    {0x78, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},\n    {0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},\n    {0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},\n    {0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},\n    {0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},\n    {0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8},\n    {0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00},\n    {0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00},\n    {0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18},\n    {0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00},\n    {0xcc, 0xcc, 0x78, 0xfc, 0x30, 0xfc, 0x30, 0x30},\n    {0xf8, 0xcc, 0xcc, 0xfa, 0xc6, 0xcf, 0xc6, 0xc7},\n    {0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70},\n    {0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00},\n    {0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00},\n    {0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00},\n    {0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00},\n    {0x00, 0xf8, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0x00},\n    {0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00},\n    {0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00},\n    {0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00},\n    {0x30, 0x00, 0x30, 0x60, 0xc0, 0xcc, 0x78, 0x00},\n    {0x00, 0x00, 0x00, 0xfc, 0xc0, 0xc0, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00},\n    {0xc3, 0xc6, 0xcc, 0xde, 0x33, 0x66, 0xcc, 0x0f},\n    {0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6f, 0xcf, 0x03},\n    {0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00},\n    {0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00},\n    {0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00},\n    {0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88},\n    {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa},\n    {0xdb, 0x77, 0xdb, 0xee, 0xdb, 0x77, 0xdb, 0xee},\n    {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18},\n    {0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36},\n    {0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36},\n    {0x00, 0x00, 0xf8, 0x18, 0xf8, 0x18, 0x18, 0x18},\n    {0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36},\n    {0x00, 0x00, 0xfe, 0x06, 0xf6, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00},\n    {0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00},\n    {0x18, 0x18, 0xf8, 0x18, 0xf8, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00},\n    {0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18},\n    {0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00},\n    {0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18},\n    {0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0xf7, 0x00, 0xff, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36},\n    {0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00},\n    {0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36},\n    {0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00},\n    {0x36, 0x36, 0x36, 0x36, 0xff, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18},\n    {0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0x36, 0x36, 0x3f, 0x00, 0x00, 0x00},\n    {0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18},\n    {0x00, 0x00, 0x00, 0x00, 0x3f, 0x36, 0x36, 0x36},\n    {0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36},\n    {0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18},\n    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},\n    {0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff},\n    {0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0},\n    {0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f},\n    {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x76, 0xdc, 0xc8, 0xdc, 0x76, 0x00},\n    {0x00, 0x78, 0xcc, 0xf8, 0xcc, 0xf8, 0xc0, 0xc0},\n    {0x00, 0xfc, 0xcc, 0xc0, 0xc0, 0xc0, 0xc0, 0x00},\n    {0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00},\n    {0xfc, 0xcc, 0x60, 0x30, 0x60, 0xcc, 0xfc, 0x00},\n    {0x00, 0x00, 0x7e, 0xd8, 0xd8, 0xd8, 0x70, 0x00},\n    {0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0},\n    {0x00, 0x76, 0xdc, 0x18, 0x18, 0x18, 0x18, 0x00},\n    {0xfc, 0x30, 0x78, 0xcc, 0xcc, 0x78, 0x30, 0xfc},\n    {0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x6c, 0x38, 0x00},\n    {0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x6c, 0xee, 0x00},\n    {0x1c, 0x30, 0x18, 0x7c, 0xcc, 0xcc, 0x78, 0x00},\n    {0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00},\n    {0x06, 0x0c, 0x7e, 0xdb, 0xdb, 0x7e, 0x60, 0xc0},\n    {0x38, 0x60, 0xc0, 0xf8, 0xc0, 0x60, 0x38, 0x00},\n    {0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00},\n    {0x00, 0xfc, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0x00},\n    {0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0xfc, 0x00},\n    {0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xfc, 0x00},\n    {0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xfc, 0x00},\n    {0x0e, 0x1b, 0x1b, 0x18, 0x18, 0x18, 0x18, 0x18},\n    {0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70},\n    {0x30, 0x30, 0x00, 0xfc, 0x00, 0x30, 0x30, 0x00},\n    {0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00},\n    {0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00},\n    {0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x1c},\n    {0x78, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00},\n    {0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00},\n    {0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00},\n    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\n};\n\n//\n// Standard definition of EIA-189-A color bars.  The actual color definitions\n// are either in CRGB24Synthesizer or CYUVSynthesizer.\n//\nconst COLOR g_ColorBars[] = \n    {WHITE, YELLOW, CYAN, GREEN, MAGENTA, RED, BLUE, BLACK};\n\nconst UCHAR CRGB24Synthesizer::Colors [MAX_COLOR][3] = {\n    {0, 0, 0},          // BLACK\n    {255, 255, 255},    // WHITE\n    {0, 255, 255},      // YELLOW\n    {255, 255, 0},      // CYAN\n    {0, 255, 0},        // GREEN\n    {255, 0, 255},      // MAGENTA\n    {0, 0, 255},        // RED\n    {255, 0, 0},        // BLUE\n    {128, 128, 128}     // GREY\n};\n\nconst UCHAR CYUVSynthesizer::Colors [MAX_COLOR][3] = {\n    {128, 16, 128},     // BLACK\n    {128, 235, 128},    // WHITE\n    {16, 211, 146},     // YELLOW\n    {166, 170, 16},     // CYAN\n    {54, 145, 34},      // GREEN\n    {202, 106, 222},    // MAGENTA\n    {90, 81, 240},      // RED\n    {240, 41, 109},     // BLUE\n    {128, 125, 128},    // GREY\n};\n\n/**************************************************************************\n\n    LOCKED CODE\n\n**************************************************************************/\n\n#ifdef ALLOC_PRAGMA\n#pragma code_seg()\n#endif // ALLOC_PRAGMA\n\n\f\nvoid\nCImageSynthesizer::\nSynthesizeBars (\n    )\n\n/*++\n\nRoutine Description:\n\n    Synthesize EIA-189-A standard color bars onto the Image.  The image\n    in question is the current synthesis buffer.\n\nArguments:\n\n    None\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n    const COLOR *CurColor = g_ColorBars;\n    ULONG ColorCount = SIZEOF_ARRAY (g_ColorBars);\n\n    //\n    // Set the default cursor...\n    //\n    GetImageLocation (0, 0);\n\n    //\n    // Synthesize a single line.\n    //\n    PUCHAR ImageStart = m_Cursor;\n    for (ULONG x = 0; x < m_Width; x++) \n        PutPixel (g_ColorBars [((x * ColorCount) / m_Width)]);\n\n    PUCHAR ImageEnd = m_Cursor;\n    \n    //\n    // Copy the synthesized line to all subsequent lines.\n    //\n    for (ULONG line = 1; line < m_Height; line++) {\n\n        GetImageLocation (0, line);\n\n        RtlCopyMemory (\n            m_Cursor,\n            ImageStart,\n            ImageEnd - ImageStart\n            );\n    }\n}\n\n/*************************************************/\n\n\f\nvoid \nCImageSynthesizer::\nOverlayText (\n    _In_ ULONG LocX,\n    _In_ ULONG LocY,\n    _In_ ULONG Scaling,\n    _In_ LPSTR Text,\n    _In_ COLOR BgColor,\n    _In_ COLOR FgColor\n    )\n\n/*++\n\nRoutine Description:\n\n    Overlay text onto the synthesized image.  Clip to fit the image\n    if the overlay does not fit.  The image buffer used is the set\n    synthesis buffer.\n\nArguments:\n\n    LocX -\n        The X location on the image to begin the overlay.  This MUST\n        be inside the image.  POSITION_CENTER may be used to indicate\n        horizontal centering.\n\n    LocY -\n        The Y location on the image to begin the overlay.  This MUST\n        be inside the image.  POSITION_CENTER may be used to indicate\n        vertical centering.\n\n    Scaling -\n        Normally, the overlay is done in 8x8 font.  A scaling of\n        2 indicates 16x16, 3 indicates 24x24 and so forth.\n\n    Text -\n        A character string containing the information to overlay\n\n    BgColor -\n        The background color of the overlay window.  For transparency,\n        indicate TRANSPARENT here.\n\n    FgColor -\n        The foreground color for the text overlay.\n\nReturn Value:\n\n    None\n\n--*/\n\n{\n\n    NT_ASSERT ((LocX <= m_Width || LocX == POSITION_CENTER) &&\n            (LocY <= m_Height || LocY == POSITION_CENTER));\n\n    ULONG StrLen = 0;\n    CHAR* CurChar;\n\n    //\n    // Determine the character length of the string.\n    //\n    for (CurChar = Text; CurChar && *CurChar; CurChar++)\n        StrLen++;\n\n    //\n    // Determine the physical size of the string plus border.  There is\n    // a definable NO_CHARACTER_SEPARATION.  If this is defined, there will\n    // be no added space between font characters.  Otherwise, one empty pixel\n    // column is added between characters.\n    //\n    #ifndef NO_CHARACTER_SEPARATION\n        ULONG LenX = (StrLen * (Scaling << 3)) + 1 + StrLen;\n    #else // NO_CHARACTER_SEPARATION\n        ULONG LenX = (StrLen * (Scaling << 3)) + 2;\n    #endif // NO_CHARACTER_SEPARATION\n\n    ULONG LenY = 2 + (Scaling << 3);\n\n    //\n    // Adjust for center overlays.\n    //\n    // NOTE: If the overlay doesn't fit into the synthesis buffer, this\n    // merely left aligns the overlay and clips off the right side.\n    //\n    if (LocX == POSITION_CENTER) {\n        if (LenX >= m_Width) {\n            LocX = 0;\n        } else {\n            LocX = (m_Width >> 1) - (LenX >> 1);\n        }\n    }\n\n    if (LocY == POSITION_CENTER) {\n        if (LenY >= m_Height) {\n            LocY = 0;\n        } else {\n            LocY = (m_Height >> 1) - (LenY >> 1);\n        }\n    }\n\n    //\n    // Determine the amount of space available on the synthesis buffer.\n    // We will clip anything that finds itself outside the synthesis buffer.\n    //\n    ULONG SpaceX = m_Width - LocX;\n    ULONG SpaceY = m_Height - LocY;\n\n    //\n    // Set the default cursor position.\n    //\n    GetImageLocation (LocX, LocY);\n\n    //\n    // Overlay a background color row.\n    //\n    if (BgColor != TRANSPARENT && SpaceY) {\n        for (ULONG x = 0; x < LenX && x < SpaceX; x++) {\n            PutPixel (BgColor);\n        }\n    }\n    LocY++;\n    if (SpaceY) SpaceY--;\n\n    //\n    // Loop across each row of the image.\n    //\n    for (ULONG row = 0; row < 8 && SpaceY; row++) {\n        //\n        // Generate a line.\n        //\n        GetImageLocation (LocX, LocY++);\n\n        PUCHAR ImageStart = m_Cursor;\n\n        ULONG CurSpaceX = SpaceX;\n        if (CurSpaceX) {\n            PutPixel (BgColor);\n            CurSpaceX--;\n        }\n\n        //\n        // Generate the row'th row of the overlay.\n        //\n        CurChar = Text;\n        while (CurChar && *CurChar) {\n            \n            UCHAR CharBase = g_FontData [*CurChar++][row];\n            for (ULONG mask = 0x80; mask && CurSpaceX; mask >>= 1) {\n                for (ULONG scale = 0; scale < Scaling && CurSpaceX; scale++) {\n                    if (CharBase & mask) {\n                        PutPixel (FgColor);\n                    } else {\n                        PutPixel (BgColor);\n                    }\n                    CurSpaceX--;\n                }\n            }\n\n            // \n            // Separate each character by one space.  Account for the border\n            // space at the end by placing the separator after the last \n            // character also.\n            //\n            #ifndef NO_CHARACTER_SEPARATION\n                if (CurSpaceX) {\n                    PutPixel (BgColor);\n                    CurSpaceX--;\n                }\n            #endif // NO_CHARACTER_SEPARATION\n\n        }\n\n        //\n        // If there is no separation character defined, account for the\n        // border.\n        // \n        #ifdef NO_CHARACTER_SEPARATION\n            if (CurSpaceX) {\n                PutPixel (BgColor);\n                CurSpaceX--;\n            }\n        #endif // NO_CHARACTER_SEPARATION\n            \n\n        PUCHAR ImageEnd = m_Cursor;\n        //\n        // Copy the line downward scale times.\n        //\n        for (ULONG scale = 1; scale < Scaling && SpaceY; scale++) {\n            GetImageLocation (LocX, LocY++);\n            RtlCopyMemory (m_Cursor, ImageStart, ImageEnd - ImageStart);\n            SpaceY--;\n        }\n\n    }\n\n    //\n    // Add the bottom section of the overlay.\n    //\n    GetImageLocation (LocX, LocY);\n    if (BgColor != TRANSPARENT && SpaceY) {\n        for (ULONG x = 0; x < LenX && x < SpaceX; x++) {\n            PutPixel (BgColor);\n        }\n    }\n\n}\n\n\nvoid CImageSynthesizer::CopyBuffer(PVOID data, ULONG dataLength)\n{\n\n}"
  },
  {
    "path": "Driver/avshws/image.h",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        image.h\n\n    Abstract:\n\n        The image synthesis and overlay header.  These objects provide image\n        synthesis (pixel, color-bar, etc...) onto RGB24 and UYVY buffers as\n        well as software string overlay into these buffers.\n\n    History:\n\n        created 1/16/2001\n\n**************************************************************************/\n\n/**************************************************************************\n\n    Constants\n\n**************************************************************************/\n\n//\n// COLOR:\n//\n// Pixel color for placement onto the synthesis buffer.\n//\ntypedef enum {\n\n    BLACK = 0,\n    WHITE,\n    YELLOW,\n    CYAN,\n    GREEN,\n    MAGENTA,\n    RED,\n    BLUE,\n    GREY,\n\n    MAX_COLOR,\n    TRANSPARENT,\n\n} COLOR;\n\n//\n// POSITION_CENTER:\n//\n// Only useful for text overlay.  This can be substituted for LocX or LocY\n// in order to center the text screen on the synthesis buffer.\n//\n#define POSITION_CENTER ((ULONG)-1)\n\n/*************************************************\n\n    CImageSynthesizer\n\n    This class synthesizes images in various formats for output from the\n    capture filter.  It is capable of performing various text overlays onto\n    the image surface.\n\n*************************************************/\n\nclass CImageSynthesizer {\n\nprotected:\n\n    //\n    // The width and height the synthesizer is set to. \n    //\n    ULONG m_Width;\n    ULONG m_Height;\n\n    //\n    // The synthesis buffer.  All scan conversion happens in the synthesis\n    // buffer.  This must be set with SetBuffer() before any scan conversion\n    // routines are called.\n    //\n    PUCHAR m_SynthesisBuffer;\n\n    //\n    // The default cursor.  This is a pointer into the synthesis buffer where\n    // a non specific PutPixel will be placed. \n    //\n    PUCHAR m_Cursor;\n\npublic:\n\n    //\n    // PutPixel():\n    //\n    // Place a pixel at the specified image cursor and move right\n    // by one pixel.  No bounds checking...  wrap around occurs.\n    //\n    virtual void\n    PutPixel (\n        PUCHAR *ImageLocation,\n        COLOR Color\n        ) = 0;\n\n    //\n    // PutPixel():\n    //\n    // Place a pixel at the default image cursor and move right\n    // by one pixel.  No bounds checking...  wrap around occurs.\n    //\n    // If the derived class doesn't provide an implementation, provide\n    // one.\n    //\n    virtual void\n    PutPixel (\n        COLOR Color\n        )\n    {\n        PutPixel (&m_Cursor, Color);\n    }\n\n    virtual long\n    GetBytesPerPixel() = 0;\n        \n\n    //\n    // GetImageLocation():\n    //\n    // Get the location into the image buffer for a specific X/Y location.\n    // This also sets the synthesizer's default cursor to the position\n    // LocX, LocY.\n    //\n    virtual PUCHAR\n    GetImageLocation (  \n        ULONG LocX,\n        ULONG LocY\n        ) = 0;\n\n    //\n    // SetImageSize():\n    //\n    // Set the image size of the synthesis buffer.\n    //\n    void\n    SetImageSize (\n        ULONG Width,\n        ULONG Height\n        )\n    {\n        m_Width = Width;\n        m_Height = Height;\n    }\n\n    //\n    // SetBuffer():\n    //\n    // Set the buffer the synthesizer generates images to.\n    //\n    void\n    SetBuffer (\n        PUCHAR SynthesisBuffer\n        )\n    {\n        m_SynthesisBuffer = SynthesisBuffer;\n    }\n\n    //\n    // SynthesizeBars():\n    //\n    // Synthesize EIA-189-A standard color bars.\n    //\n    void\n    SynthesizeBars (\n        );\n\n    //\n    // OverlayText():\n    //\n    // Overlay a text string onto the image.\n    //\n    void\n    OverlayText (\n        _In_ ULONG LocX,\n        _In_ ULONG LocY,\n        _In_ ULONG Scaling,\n        _In_ LPSTR Text,\n        _In_ COLOR BgColor,\n        _In_ COLOR FgColor\n        );\n\n    //\n    // DEFAULT CONSTRUCTOR\n    //\n    CImageSynthesizer (\n        ) :\n        m_Width (0),\n        m_Height (0),\n        m_SynthesisBuffer (NULL)\n    {\n    }\n\n    //\n    // CONSTRUCTOR:\n    //\n    CImageSynthesizer (\n        ULONG Width,\n        ULONG Height\n        ) :\n        m_Width (Width),\n        m_Height (Height),\n        m_SynthesisBuffer (NULL)\n    {\n    }\n\n    //\n    // DESTRUCTOR:\n    //\n    virtual\n    ~CImageSynthesizer (\n        )\n    {\n    }\n\n\n\tvoid\n\t\tCopyBuffer(PVOID data, ULONG dataLength);\n};\n\n/*************************************************\n\n    CRGB24Synthesizer\n\n    Image synthesizer for RGB24 format.\n\n*************************************************/\n\nclass CRGB24Synthesizer : public CImageSynthesizer {\n\nprivate:\n\n    const static UCHAR Colors [MAX_COLOR][3];\n\n    BOOLEAN m_FlipVertical;\n\npublic:\n\n    //\n    // PutPixel():\n    //\n    // Place a pixel at a specific cursor location.  *ImageLocation must\n    // reside within the synthesis buffer.\n    //\n    virtual void\n    PutPixel (\n        PUCHAR *ImageLocation,\n        COLOR Color\n        )\n    {\n        if (Color != TRANSPARENT) {\n            *(*ImageLocation)++ = Colors [(ULONG)Color][0];\n            *(*ImageLocation)++ = Colors [(ULONG)Color][1];\n            *(*ImageLocation)++ = Colors [(ULONG)Color][2];\n        } else {\n            *ImageLocation += 3;\n        }\n    }\n\n    //\n    // PutPixel():\n    //\n    // Place a pixel at the default cursor location.  The cursor location\n    // must be set via GetImageLocation(x, y).\n    // \n    virtual void\n    PutPixel (\n        COLOR Color\n        )\n    {\n        if (Color != TRANSPARENT) {\n            *m_Cursor++ = Colors [(ULONG)Color][0];\n            *m_Cursor++ = Colors [(ULONG)Color][1];\n            *m_Cursor++ = Colors [(ULONG)Color][2];\n        } else {\n            m_Cursor += 3;\n        }\n    }\n\n    virtual long\n    GetBytesPerPixel () \n    {\n        return 3;\n    }\n\n    virtual PUCHAR\n    GetImageLocation (\n        ULONG LocX,\n        ULONG LocY\n        )\n    {\n        if (m_FlipVertical) {\n            return (m_Cursor = \n                (m_SynthesisBuffer + 3 * \n                    (LocX + (m_Height - 1 - LocY) * m_Width))\n                );\n        } else {\n            return (m_Cursor =\n                (m_SynthesisBuffer + 3 * (LocX + LocY * m_Width))\n                );\n        }\n    }\n\n    //\n    // DEFAULT CONSTRUCTOR:\n    //\n    CRGB24Synthesizer (\n        BOOLEAN FlipVertical\n        ) :\n        m_FlipVertical (FlipVertical)\n    {\n    }\n\n    //\n    // CONSTRUCTOR:\n    //\n    CRGB24Synthesizer (\n        BOOLEAN FlipVertical,\n        ULONG Width,\n        ULONG Height\n        ) :\n        CImageSynthesizer (Width, Height),\n        m_FlipVertical (FlipVertical)\n    {\n    }\n\n    //\n    // DESTRUCTOR:\n    //\n    virtual\n    ~CRGB24Synthesizer (\n        )\n    {\n    }\n\n};\n\n/*************************************************\n\n    CYUVSynthesizer\n\n    Image synthesizer for YUV format.\n\n*************************************************/\n\nclass CYUVSynthesizer : public CImageSynthesizer {\n\nprivate:\n\n    const static UCHAR Colors [MAX_COLOR][3];\n\n    BOOLEAN m_Parity;\n\npublic:\n\n    //\n    // PutPixel():\n    //\n    // Place a pixel at a specific cursor location.  *ImageLocation must\n    // reside within the synthesis buffer.\n    //\n    virtual void\n    PutPixel (\n        PUCHAR *ImageLocation,\n        COLOR Color\n        )\n    {\n\n        BOOLEAN Parity = (((*ImageLocation - m_SynthesisBuffer) & 0x2) != 0);\n\n#if DBG\n        //\n        // Check that the current pixel points to a valid start pixel\n        // in the UYVY buffer.\n        //\n        BOOLEAN Odd = (((*ImageLocation - m_SynthesisBuffer) & 0x1) != 0);\n        NT_ASSERT ((m_Parity && Odd) || (!m_Parity && !Odd));\n#endif // DBG\n\n        if (Color != TRANSPARENT) {\n            if (Parity) {\n                *(*ImageLocation)++ = Colors [(ULONG)Color][2];\n            } else {\n                *(*ImageLocation)++ = Colors [(ULONG)Color][1];\n                *(*ImageLocation)++ = Colors [(ULONG)Color][0];\n                *(*ImageLocation)++ = Colors [(ULONG)Color][1];\n            }\n        } else {\n            *ImageLocation += (Parity ? 1 : 3);\n        }\n\n    }\n\n    //\n    // PutPixel():\n    //\n    // Place a pixel at the default cursor location.  The cursor location\n    // must be set via GetImageLocation(x, y).\n    //\n    virtual void\n    PutPixel (\n        COLOR Color\n        )\n\n    {\n\n        if (Color != TRANSPARENT) {\n            if (m_Parity) {\n                *m_Cursor++ = Colors [(ULONG)Color][2];\n            } else {\n                *m_Cursor++ = Colors [(ULONG)Color][1];\n                *m_Cursor++ = Colors [(ULONG)Color][0];\n                *m_Cursor++ = Colors [(ULONG)Color][1];\n            }\n        } else {\n            m_Cursor += (m_Parity ? 1 : 3);\n        }\n\n        m_Parity = !m_Parity;\n\n    }\n\n    virtual long\n    GetBytesPerPixel () \n    {\n        return 2;\n    }\n\n    virtual PUCHAR\n    GetImageLocation (\n        ULONG LocX,\n        ULONG LocY\n        )\n    {\n    \n        m_Cursor = m_SynthesisBuffer + ((LocX + LocY * m_Width) << 1);\n        if (m_Parity = ((LocX & 1) != 0)) \n            m_Cursor++;\n\n        return m_Cursor;\n    }\n\n    //\n    // DEFAULT CONSTRUCTOR:\n    //\n    CYUVSynthesizer (\n        ) \n    {\n    }\n\n    //\n    // CONSTRUCTOR:\n    //\n    CYUVSynthesizer (\n        ULONG Width,\n        ULONG Height\n        ) :\n        CImageSynthesizer (Width, Height)\n    {\n    }\n\n    //\n    // DESTRUCTOR:\n    //\n    virtual\n    ~CYUVSynthesizer (\n        )\n    {\n    }\n\n};\n\n"
  },
  {
    "path": "Driver/avshws/purecall.c",
    "content": "/**************************************************************************\n\n    AVStream Simulated Hardware Sample\n\n    Copyright (c) 2001, Microsoft Corporation.\n\n    File:\n\n        purecall.c\n\n    Abstract:\n\n        This file contains the _purecall stub necessary for virtual function\n        usage in drivers on 98 gold.\n\n    History:\n\n        created 9/16/02\n\n**************************************************************************/\n\n/*************************************************\n\n    Function:\n\n        _purecall\n\n    Description:\n\n        _purecall stub for virtual function usage\n\n    Arguments:\n\n        None\n\n    Return Value:\n\n        0\n\n*************************************************/\n#pragma warning (disable : 4100 4131)\nint __cdecl \n_purecall (\n    VOID\n    ) \n\n{\n    return 0;\n}\n\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2020 Bence\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# VirtualCameraDriver\nWindows virtual camera driver using the AVStream minidriver.\n\nThis project was a challenge for myself. I wanted to create a virtual camera driver for Windows.\n\nThe project has two parts: the *Windows driver* and the *user mode apps* which can push frames to the driver.\n\n## Driver\nThe driver is based on the **avshws** driver example from Microsoft.\n\nThe filter implemented in this driver is extended with a custom property which accepts a buffer (1280x720, RGB), this buffer is then copied to the output buffer.\n\n* *GUID* of the property set: *{CB043957-7B35-456E-9B61-5513930F4D8E}*\n* *ID* of the property: *0*\n\nAccessing this property can be done using DirectShow.\n\n### Driver installation:\nAfter building the driver (Windows SDK and Windows Driver Kit required) the inf can be installed using **hdwwiz.exe** (can be launched in CMD).\n\nTest signing might be required to be enabled for driver installation:\n`bcdedit.exe -set TESTSIGNING ON`\n\n## UserMode apps\nThese applications can push frames to the driver using the property exposed in the filter. The apps are based on the **driver interface library** which handles enumerating devices and setting the value of the property. This is written in VC++.\n\nThere are two example applications:\n* **UserDriverStaticImage**: This app can push static images to the driver.\n* **UserDriverCanon**: This application can push the live view of a Canon EOS camera to the driver, essentially turning it into a webcam. EDSDK not included in this repository!\n"
  },
  {
    "path": "UserLand/.gitignore",
    "content": "EDSDKLib"
  },
  {
    "path": "UserLand/DriverInterface/Common.h",
    "content": "#pragma once\n\n#include <SDKDDKVer.h>\n\n#define WIN32_LEAN_AND_MEAN\n#include <windows.h>\n#include <dshow.h>\n#include <dvdmedia.h>\n\n#include <string>\n\nusing namespace std;\n\n#define EXPORT extern \"C\" __declspec(dllexport)"
  },
  {
    "path": "UserLand/DriverInterface/Device.cpp",
    "content": "#include \"Device.h\"\n\nconst GUID GUID_PROP_CLASS = { PROP_GUID };\n\nDevice::Device(IBaseFilter* filter)\n\t: filter(filter), propertySet(NULL)\n{\n}\n\nDevice::~Device()\n{\n\tif (propertySet != NULL)\n\t{\n\t\tpropertySet->Release();\n\t}\n\n\tfilter->Release();\n}\n\nint Device::Init()\n{\n\tHRESULT hr = filter->QueryInterface(IID_PPV_ARGS(&propertySet));\n\tif (!SUCCEEDED(hr)) \n\t{\n\t\treturn 0;\n\t}\n\n\tDWORD supportFlags = 0;\n\thr = propertySet->QuerySupported(GUID_PROP_CLASS, PROP_DATA_ID, &supportFlags);\n\tif (!SUCCEEDED(hr)) \n\t{\n\t\treturn 0;\n\t}\n\n\tif (supportFlags & KSPROPERTY_SUPPORT_SET != KSPROPERTY_SUPPORT_SET)\n\t{\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}\n\nint Device::SetData(PVOID dataPointer, ULONG dataLength)\n{\n\tif (dataLength != WIDTH * HEIGHT * 3) \n\t{\n\t\treturn -1;\n\t}\n\n\tHRESULT hr = propertySet->Set(GUID_PROP_CLASS, PROP_DATA_ID, NULL, 0, dataPointer, dataLength);\n\n\treturn SUCCEEDED(hr);\n}"
  },
  {
    "path": "UserLand/DriverInterface/Device.h",
    "content": "#pragma once\n\n#include \"Common.h\"\n\n#define PROP_GUID 0xcb043957, 0x7b35, 0x456e, 0x9b, 0x61, 0x55, 0x13, 0x93, 0xf, 0x4d, 0x8e\n#define PROP_DATA_ID 0\n\n#define WIDTH 1280\n#define HEIGHT 720\n\nclass Device\n{\nprivate:\n\tIBaseFilter* filter;\n\tIKsPropertySet* propertySet;\npublic:\n\tDevice(IBaseFilter* filter);\n\t~Device();\n\n\tint Init();\n\n\tint SetData(PVOID dataPointer, ULONG dataLength);\n};\n\n"
  },
  {
    "path": "UserLand/DriverInterface/DeviceEnumeration.cpp",
    "content": "#include \"DeviceEnumeration.h\"\n\nHRESULT EnumerateDevices(REFGUID category, IEnumMoniker **ppEnum)\n{\n\tICreateDevEnum *pDevEnum;\n\tHRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,\n\t\tCLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum));\n\n\tif (SUCCEEDED(hr))\n\t{\n\t\thr = pDevEnum->CreateClassEnumerator(category, ppEnum, 0);\n\t\tif (hr == S_FALSE)\n\t\t{\n\t\t\thr = S_FALSE;\n\t\t}\n\t\tpDevEnum->Release();\n\t}\n\treturn hr;\n}\n\nint EnumerateDevicePaths(string* paths, int maxCount)\n{\n\tint index = 0;\n\n\tIEnumMoniker *pEnum;\n\n\tHRESULT hr = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum);\n\tif (SUCCEEDED(hr))\n\t{\n\t\tIMoniker *pMoniker = NULL;\n\t\twhile (pEnum->Next(1, &pMoniker, NULL) == S_OK && index < maxCount)\n\t\t{\n\t\t\tLPOLESTR str;\n\t\t\tpMoniker->GetDisplayName(0, 0, &str);\n\n\t\t\tsize_t numChars = 0;\n\t\t\tchar cstr[1024];\n\t\t\twcstombs_s(&numChars, cstr, str, 512);\n\n\t\t\tpaths[index].append(cstr);\n\n\t\t\tindex++;\n\t\t}\n\n\t\tpEnum->Release();\n\t}\n\telse\n\t{\n\t\treturn -1;\n\t}\n\n\treturn index;\n}\n\nint GetFilter(string path, IBaseFilter** filter)\n{\n\tbool found = false;\n\n\tIEnumMoniker *pEnum;\n\n\tHRESULT hr = EnumerateDevices(CLSID_VideoInputDeviceCategory, &pEnum);\n\tif (SUCCEEDED(hr))\n\t{\n\t\tIMoniker *pMoniker = NULL;\n\t\twhile (pEnum->Next(1, &pMoniker, NULL) == S_OK)\n\t\t{\n\t\t\tLPOLESTR str;\n\t\t\tpMoniker->GetDisplayName(0, 0, &str);\n\n\t\t\tsize_t numChars = 0;\n\t\t\tchar cstr[1024];\n\t\t\twcstombs_s(&numChars, cstr, str, 512);\n\n\t\t\tif (strcmp(path.c_str(), cstr) == 0)\n\t\t\t{\n\t\t\t\thr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)filter);\n\t\t\t\tif (SUCCEEDED(hr))\n\t\t\t\t{\n\t\t\t\t\tfound = true;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tpEnum->Release();\n\t}\n\t\n\treturn found;\n}"
  },
  {
    "path": "UserLand/DriverInterface/DeviceEnumeration.h",
    "content": "#pragma once\n\n#include \"Common.h\"\n\nint EnumerateDevicePaths(string* paths, int maxCount);\nint GetFilter(string path, IBaseFilter** filter);"
  },
  {
    "path": "UserLand/DriverInterface/DriverInterface.cpp",
    "content": "#include \"Common.h\"\n#include \"DeviceEnumeration.h\"\n#include \"Device.h\"\n\n#define NUM_MAX_PATHS 16\nstatic string cachedPaths[NUM_MAX_PATHS];\nstatic int numDevices;\n\nstatic Device* activeDevice = NULL;\n\n#define TEMPORARY_BUFFER_SIZE (WIDTH * HEIGHT * 3)\nstatic PVOID temporaryBuffer = NULL;\n\nEXPORT int Init()\n{\n\tHRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);\n\tif (!SUCCEEDED(hr))\n\t{\n\t\treturn 0;\n\t}\n\n\tnumDevices = EnumerateDevicePaths(cachedPaths, NUM_MAX_PATHS);\n\tif (numDevices < 0) {\n\t\treturn 0;\n\t}\n\n\ttemporaryBuffer = malloc(TEMPORARY_BUFFER_SIZE);\n\tif (temporaryBuffer == NULL)\n\t{\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}\n\nEXPORT int Free()\n{\n\tif (activeDevice != NULL) \n\t{\n\t\tdelete activeDevice;\n\t}\n\n\tfree(temporaryBuffer);\n\n\tCoUninitialize(); \n\n\treturn 1;\n}\n\nEXPORT int GetNumDevices()\n{\n\treturn numDevices;\n}\n\nEXPORT int GetDevicePath(int index, char* str, int maxLen)\n{\n\tif (index < 0 || index >= numDevices) {\n\t\treturn -1;\n\t}\n\n\tstrcpy_s(str, maxLen, cachedPaths[index].c_str());\n\n\treturn 1;\n}\n\nEXPORT void DestroyDevice()\n{\n\tif (activeDevice != NULL)\n\t{\n\t\tdelete activeDevice;\n\t\tactiveDevice = NULL;\n\t}\n}\n\nEXPORT int SetDevice(char* str, int strLen) \n{\n\tDestroyDevice();\n\n\tIBaseFilter* filter = NULL;\n\tif (!GetFilter(string(str), &filter) || filter == NULL)\n\t{\n\t\treturn 0;\n\t}\n\n\tactiveDevice = new Device(filter);\n\tif (!activeDevice->Init()) \n\t{\n\t\tdelete activeDevice;\n\t\tactiveDevice = NULL;\n\n\t\treturn 0;\n\t}\n\n\treturn 1;\n}\n\nEXPORT int SetBuffer(PVOID data, DWORD stride, DWORD width, DWORD height)\n{\n\tif (activeDevice == NULL) \n\t{\n\t\treturn -1;\n\t}\n\n\tif (width != WIDTH || height != HEIGHT) \n\t{\n\t\treturn -1;\n\t}\n\n\tmemset(temporaryBuffer, 0x00, TEMPORARY_BUFFER_SIZE);\n\n\tPUCHAR inputData = (PUCHAR)data;\n\tPUCHAR buffer = (PUCHAR)temporaryBuffer;\n\tfor (ULONG y = 0; y < height; y++)\n\t{\n\t\tPUCHAR sourceLine = inputData + stride * y;\n\t\tPUCHAR targetLine = buffer + ((WIDTH * 3) * y);\n\t\tmemcpy(targetLine, sourceLine, WIDTH * 3);\n\t}\n\n\tactiveDevice->SetData(temporaryBuffer, TEMPORARY_BUFFER_SIZE);\n\n\treturn 1;\n}"
  },
  {
    "path": "UserLand/DriverInterface/DriverInterface.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <VCProjectVersion>15.0</VCProjectVersion>\n    <ProjectGuid>{4621FE02-0FE3-4810-80CD-6183638C0270}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>DriverInterface</RootNamespace>\n    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v140</PlatformToolset>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v140</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <PlatformToolset>v140</PlatformToolset>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <PlatformToolset>v140</PlatformToolset>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"Shared\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <LinkIncremental>true</LinkIncremental>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <LinkIncremental>true</LinkIncremental>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <LinkIncremental>false</LinkIncremental>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <LinkIncremental>false</LinkIncremental>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\n    <ClCompile>\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>Disabled</Optimization>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>WIN32;_DEBUG;DRIVERINTERFACE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">\n    <ClCompile>\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>Disabled</Optimization>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>_DEBUG;DRIVERINTERFACE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>MaxSpeed</Optimization>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>WIN32;NDEBUG;DRIVERINTERFACE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">\n    <ClCompile>\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n      <WarningLevel>Level3</WarningLevel>\n      <Optimization>MaxSpeed</Optimization>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <SDLCheck>true</SDLCheck>\n      <PreprocessorDefinitions>NDEBUG;DRIVERINTERFACE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <ConformanceMode>true</ConformanceMode>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\n      <OptimizeReferences>true</OptimizeReferences>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n      <AdditionalDependencies>strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"Device.cpp\" />\n    <ClCompile Include=\"DeviceEnumeration.cpp\" />\n    <ClCompile Include=\"dllmain.cpp\" />\n    <ClCompile Include=\"DriverInterface.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"Common.h\" />\n    <ClInclude Include=\"Device.h\" />\n    <ClInclude Include=\"DeviceEnumeration.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "UserLand/DriverInterface/DriverInterface.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"DriverInterface.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dllmain.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DeviceEnumeration.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Device.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"Common.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DeviceEnumeration.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"Device.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "UserLand/DriverInterface/dllmain.cpp",
    "content": "#include <Windows.h>\n\nBOOL APIENTRY DllMain( HMODULE hModule,\n                       DWORD  ul_reason_for_call,\n                       LPVOID lpReserved\n                     )\n{\n    switch (ul_reason_for_call)\n    {\n    case DLL_PROCESS_ATTACH:\n    case DLL_THREAD_ATTACH:\n    case DLL_THREAD_DETACH:\n    case DLL_PROCESS_DETACH:\n        break;\n    }\n    return TRUE;\n}\n\n"
  },
  {
    "path": "UserLand/DriverInterfaceWrapper/DeviceInfo.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace DriverInterfaceWrapper\n{\n    public class DeviceInfo\n    {\n        public string Path\n        {\n            get;\n            private set;\n        }\n\n        internal DeviceInfo(string path)\n        {\n            Path = path;\n        }\n\n        public override string ToString()\n        {\n            return Path;\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/DriverInterfaceWrapper/DriverInterface.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace DriverInterfaceWrapper\n{\n    public class DriverInterface\n    {\n        public const int Width = 1280;\n        public const int Height = 720;\n\n        public static bool Init()\n        {\n            return (Native.Init() != 0);\n        }\n\n        public static void Free()\n        {\n            Native.Free();\n        }\n\n        public static DeviceInfo[] GetDevices()\n        {\n            int count = Native.GetNumDevices();\n            DeviceInfo[] array = new DeviceInfo[count];\n\n            for (int x = 0; x < count; x++)\n            {\n                array[x] = new DeviceInfo(Native.GetDevicePath(x));\n            }\n\n            return array;\n        }\n\n        public static void DestroyDevice()\n        {\n            Native.DestroyDevice();\n        }\n\n        public static bool SelectDevice(string path)\n        {\n            return Native.SetDevice(path);\n        }\n\n        public static bool SetData(IntPtr data, int stride, int width, int height)\n        {\n            return (Native.SetBuffer(data, stride, width, height) > 0); \n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/DriverInterfaceWrapper/DriverInterfaceWrapper.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{6F9843C8-F363-4B39-B40A-6A5814A99442}</ProjectGuid>\n    <OutputType>Library</OutputType>\n    <AppDesignerFolder>Properties</AppDesignerFolder>\n    <RootNamespace>DriverInterfaceWrapper</RootNamespace>\n    <AssemblyName>DriverInterfaceWrapper</AssemblyName>\n    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>\n    <FileAlignment>512</FileAlignment>\n    <Deterministic>true</Deterministic>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <DebugSymbols>true</DebugSymbols>\n    <DebugType>full</DebugType>\n    <Optimize>false</Optimize>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <DebugType>pdbonly</DebugType>\n    <Optimize>true</Optimize>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <DefineConstants>TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n    <Reference Include=\"System.Core\" />\n    <Reference Include=\"System.Xml.Linq\" />\n    <Reference Include=\"System.Data.DataSetExtensions\" />\n    <Reference Include=\"Microsoft.CSharp\" />\n    <Reference Include=\"System.Data\" />\n    <Reference Include=\"System.Net.Http\" />\n    <Reference Include=\"System.Xml\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Compile Include=\"DeviceInfo.cs\" />\n    <Compile Include=\"DriverInterface.cs\" />\n    <Compile Include=\"Native.cs\" />\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\n  </ItemGroup>\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n</Project>"
  },
  {
    "path": "UserLand/DriverInterfaceWrapper/Native.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace DriverInterfaceWrapper\n{\n    class Native\n    {\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        public static extern int Init();\n\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        public static extern int Free();\n\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        public static extern int GetNumDevices();\n\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        static extern int GetDevicePath(int index, StringBuilder str, int maxLen);\n\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        public static extern void DestroyDevice();\n\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        static extern int SetDevice(StringBuilder path, int length);\n\n        [DllImport(\"DriverInterface.dll\", CallingConvention = CallingConvention.Cdecl)]\n        public static extern int SetBuffer(IntPtr data, int stride, int width, int height);\n\n        public static string GetDevicePath(int index)\n        {\n            StringBuilder buffer = new StringBuilder(256);\n\n            GetDevicePath(index, buffer, buffer.Capacity);\n\n            return buffer.ToString();\n        }\n\n        public static bool SetDevice(string path)\n        {\n            StringBuilder buffer = new StringBuilder(path);\n\n            return (SetDevice(buffer, buffer.Capacity) > 0);\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/DriverInterfaceWrapper/Properties/AssemblyInfo.cs",
    "content": "﻿using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following\n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n[assembly: AssemblyTitle(\"DriverInterfaceWrapper\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"DriverInterfaceWrapper\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2020\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible\n// to COM components.  If you need to access a type in this assembly from\n// COM, set the ComVisible attribute to true on that type.\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n[assembly: Guid(\"6f9843c8-f363-4b39-b40a-6a5814a99442\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version\n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers\n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\n"
  },
  {
    "path": "UserLand/UserDriverCanon/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<configuration>\n    <startup> \n        <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.7\" />\n    </startup>\n</configuration>"
  },
  {
    "path": "UserLand/UserDriverCanon/CameraListItem.cs",
    "content": "﻿using EOSDigital.API;\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace UserDriverCanon\n{\n    class CameraListItem\n    {\n        public Camera Camera;\n\n        public CameraListItem(Camera c)\n        {\n            Camera = c;\n        }\n\n        public override string ToString()\n        {\n            return Camera.DeviceName;\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverCanon/FitPictureBox.cs",
    "content": "﻿using System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Linq;\nusing System.Text;\nusing System.Windows.Forms;\n\nnamespace UserDriverCanon\n{\n    public class FitPictureBox : Control\n    {\n        private Image _image;\n        public Image Image\n        {\n            get { return _image; }\n            set { _image = value; }\n        }\n\n        private bool _simpleBorder = false;\n        public bool SimpleBorder \n        {\n            get { return _simpleBorder; }\n            set\n            {\n                _simpleBorder = value;\n            }\n        }\n\n        public object ImageLock = new object();\n\n        public FitPictureBox()\n        {\n            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);\n        }\n\n        protected override void OnPaint(PaintEventArgs e)\n        {\n            e.Graphics.Clear(BackColor);\n\n            if (_image == null)\n                return;\n\n            lock (ImageLock)\n            {\n                float scaleRatio = 1f;\n\n                if (_image.Width > _image.Height && _image.Width > Width)\n                {\n                    float a = (float)_image.Width;\n                    float b = (float)Width;\n\n                    scaleRatio = Math.Min(a, b) / Math.Max(a, b);\n                }\n                if (_image.Width < _image.Height && _image.Height > Height)\n                {\n                    float a = (float)_image.Height;\n                    float b = (float)Height;\n\n                    scaleRatio = Math.Min(a, b) / Math.Max(a, b);\n                }\n\n                int nw = (int)Math.Floor((float)_image.Width * scaleRatio);\n                int nh = (int)Math.Floor((float)_image.Height * scaleRatio);\n\n                e.Graphics.DrawImage(_image, new Rectangle((this.Width / 2) - (nw / 2), (this.Height / 2) - (nh / 2), nw, nh));\n\n                if (SimpleBorder)\n                {\n                    e.Graphics.DrawRectangle(Pens.Black, new Rectangle(0, 0, this.Width - 1, this.Height - 1));\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverCanon/MainForm.Designer.cs",
    "content": "﻿namespace UserDriverCanon\n{\n    partial class MainForm\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.components = new System.ComponentModel.Container();\n            this.label1 = new System.Windows.Forms.Label();\n            this.cbDevices = new System.Windows.Forms.ComboBox();\n            this.groupDevice = new System.Windows.Forms.GroupBox();\n            this.btnDeviceRefresh = new System.Windows.Forms.Button();\n            this.groupBox1 = new System.Windows.Forms.GroupBox();\n            this.btnRefreshCameras = new System.Windows.Forms.Button();\n            this.cbCameras = new System.Windows.Forms.ComboBox();\n            this.label2 = new System.Windows.Forms.Label();\n            this.cameraKeepAlive = new System.Windows.Forms.Timer(this.components);\n            this.groupDevice.SuspendLayout();\n            this.groupBox1.SuspendLayout();\n            this.SuspendLayout();\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(21, 38);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(42, 18);\n            this.label1.TabIndex = 0;\n            this.label1.Text = \"Path:\";\n            // \n            // cbDevices\n            // \n            this.cbDevices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cbDevices.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cbDevices.FormattingEnabled = true;\n            this.cbDevices.Location = new System.Drawing.Point(69, 34);\n            this.cbDevices.Name = \"cbDevices\";\n            this.cbDevices.Size = new System.Drawing.Size(435, 26);\n            this.cbDevices.TabIndex = 1;\n            this.cbDevices.SelectedIndexChanged += new System.EventHandler(this.cbDevices_SelectedIndexChanged);\n            // \n            // groupDevice\n            // \n            this.groupDevice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.groupDevice.Controls.Add(this.btnDeviceRefresh);\n            this.groupDevice.Controls.Add(this.cbDevices);\n            this.groupDevice.Controls.Add(this.label1);\n            this.groupDevice.Location = new System.Drawing.Point(12, 12);\n            this.groupDevice.Name = \"groupDevice\";\n            this.groupDevice.Size = new System.Drawing.Size(648, 88);\n            this.groupDevice.TabIndex = 2;\n            this.groupDevice.TabStop = false;\n            this.groupDevice.Text = \"Device\";\n            // \n            // btnDeviceRefresh\n            // \n            this.btnDeviceRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnDeviceRefresh.Location = new System.Drawing.Point(510, 34);\n            this.btnDeviceRefresh.Name = \"btnDeviceRefresh\";\n            this.btnDeviceRefresh.Size = new System.Drawing.Size(112, 26);\n            this.btnDeviceRefresh.TabIndex = 2;\n            this.btnDeviceRefresh.Text = \"Refresh\";\n            this.btnDeviceRefresh.UseVisualStyleBackColor = true;\n            this.btnDeviceRefresh.Click += new System.EventHandler(this.btnDeviceRefresh_Click);\n            // \n            // groupBox1\n            // \n            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.groupBox1.Controls.Add(this.btnRefreshCameras);\n            this.groupBox1.Controls.Add(this.cbCameras);\n            this.groupBox1.Controls.Add(this.label2);\n            this.groupBox1.Location = new System.Drawing.Point(12, 106);\n            this.groupBox1.Name = \"groupBox1\";\n            this.groupBox1.Size = new System.Drawing.Size(648, 88);\n            this.groupBox1.TabIndex = 3;\n            this.groupBox1.TabStop = false;\n            this.groupBox1.Text = \"Camera\";\n            // \n            // btnRefreshCameras\n            // \n            this.btnRefreshCameras.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnRefreshCameras.Location = new System.Drawing.Point(510, 34);\n            this.btnRefreshCameras.Name = \"btnRefreshCameras\";\n            this.btnRefreshCameras.Size = new System.Drawing.Size(112, 26);\n            this.btnRefreshCameras.TabIndex = 2;\n            this.btnRefreshCameras.Text = \"Refresh\";\n            this.btnRefreshCameras.UseVisualStyleBackColor = true;\n            this.btnRefreshCameras.Click += new System.EventHandler(this.btnRefreshCameras_Click);\n            // \n            // cbCameras\n            // \n            this.cbCameras.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cbCameras.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cbCameras.FormattingEnabled = true;\n            this.cbCameras.Location = new System.Drawing.Point(69, 34);\n            this.cbCameras.Name = \"cbCameras\";\n            this.cbCameras.Size = new System.Drawing.Size(435, 26);\n            this.cbCameras.TabIndex = 1;\n            this.cbCameras.SelectedIndexChanged += new System.EventHandler(this.cbCameras_SelectedIndexChanged);\n            // \n            // label2\n            // \n            this.label2.AutoSize = true;\n            this.label2.Location = new System.Drawing.Point(21, 38);\n            this.label2.Name = \"label2\";\n            this.label2.Size = new System.Drawing.Size(42, 18);\n            this.label2.TabIndex = 0;\n            this.label2.Text = \"Path:\";\n            // \n            // cameraKeepAlive\n            // \n            this.cameraKeepAlive.Enabled = true;\n            this.cameraKeepAlive.Interval = 2000;\n            this.cameraKeepAlive.Tick += new System.EventHandler(this.cameraKeepAlive_Tick);\n            // \n            // MainForm\n            // \n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;\n            this.ClientSize = new System.Drawing.Size(672, 207);\n            this.Controls.Add(this.groupBox1);\n            this.Controls.Add(this.groupDevice);\n            this.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));\n            this.Name = \"MainForm\";\n            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\n            this.Text = \"UserDriverStaticImage\";\n            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);\n            this.Load += new System.EventHandler(this.MainForm_Load);\n            this.groupDevice.ResumeLayout(false);\n            this.groupDevice.PerformLayout();\n            this.groupBox1.ResumeLayout(false);\n            this.groupBox1.PerformLayout();\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cbDevices;\n        private System.Windows.Forms.GroupBox groupDevice;\n        private System.Windows.Forms.Button btnDeviceRefresh;\n        private System.Windows.Forms.GroupBox groupBox1;\n        private System.Windows.Forms.Button btnRefreshCameras;\n        private System.Windows.Forms.ComboBox cbCameras;\n        private System.Windows.Forms.Label label2;\n        private System.Windows.Forms.Timer cameraKeepAlive;\n    }\n}\n\n"
  },
  {
    "path": "UserLand/UserDriverCanon/MainForm.cs",
    "content": "﻿using DriverInterfaceWrapper;\nusing EOSDigital.API;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nusing System.Drawing.Imaging;\nusing System.IO;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace UserDriverCanon\n{\n    public partial class MainForm : Form\n    {\n        private CanonAPI api;\n        private Camera activeCamera;\n\n        private bool hasDevice = false;\n\n        public MainForm()\n        {\n            InitializeComponent();\n        }\n\n        private void MainForm_Load(object sender, EventArgs e)\n        {\n            api = new CanonAPI();\n\n            btnDeviceRefresh_Click(sender, e);\n            btnRefreshCameras_Click(sender, e);\n        }\n\n        private void btnDeviceRefresh_Click(object sender, EventArgs e)\n        {\n            DeviceInfo[] info = DriverInterface.GetDevices();\n\n            cbDevices.Items.Clear();\n            cbDevices.Items.AddRange(info);\n        }\n\n        private void cbDevices_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            hasDevice = false;\n\n            if (!DriverInterface.SelectDevice(((DeviceInfo)cbDevices.SelectedItem).Path))\n            {\n                cbDevices.SelectedIndex = -1;\n                MessageBox.Show(\"Failed to select device!\");\n                return;\n            }\n\n            hasDevice = (cbDevices.SelectedIndex > -1);\n        }\n\n        private void btnRefreshCameras_Click(object sender, EventArgs e)\n        {\n            List<Camera> cameraList = api.GetCameraList();\n            foreach (Camera c in cameraList)\n            {\n                cbCameras.Items.Add(new CameraListItem(c));\n            }\n        }\n\n        private void cbCameras_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            if (activeCamera != null && activeCamera.SessionOpen)\n            {\n                activeCamera.CloseSession();\n                activeCamera = null;\n            }\n\n            if (cbCameras.SelectedIndex > -1)\n            {\n                activeCamera = ((CameraListItem)cbCameras.SelectedItem).Camera;\n\n                activeCamera.LiveViewUpdated += ActiveCamera_LiveViewUpdated;\n\n                activeCamera.OpenSession();\n\n                //activeCamera.StartLiveView();\n                activeCamera.SetSetting(EOSDigital.SDK.PropertyID.Evf_OutputDevice, (int)EOSDigital.SDK.EvfOutputDevice.Filming);\n            }\n        }\n\n        private void ActiveCamera_LiveViewUpdated(Camera sender, Stream img)\n        {\n            if (!hasDevice)\n                return;\n\n            using (Bitmap rawInput = new Bitmap(img))\n            {\n                Bitmap videoBuffer = null;\n\n                if (rawInput.Width != DriverInterface.Width || rawInput.Height != DriverInterface.Height)\n                {\n                    videoBuffer = new Bitmap(DriverInterface.Width, DriverInterface.Height);\n                    Graphics gfx = Graphics.FromImage(videoBuffer);\n\n                    float scaleX = 1.0f;\n                    if (rawInput.Width != DriverInterface.Width)\n                    {\n                        scaleX = DriverInterface.Width / (float)rawInput.Width;\n                    }\n\n                    float scaleY = 1.0f;\n                    if (rawInput.Height != DriverInterface.Height)\n                    {\n                        scaleY = DriverInterface.Height / (float)rawInput.Height;\n                    }\n\n                    float scale = Math.Min(scaleX, scaleY);\n\n                    int newWidth = (int)Math.Floor(scale * rawInput.Width);\n                    int newHeight = (int)Math.Floor(scale * rawInput.Height);\n\n                    gfx.Clear(Color.Black);\n                    gfx.DrawImage(rawInput, new Rectangle((videoBuffer.Width / 2) - (newWidth / 2), (videoBuffer.Height / 2) - (newHeight / 2), newWidth, newHeight));\n\n                    gfx.Dispose();\n                }\n                else\n                {\n                    videoBuffer = rawInput;\n                }\n\n                BitmapData imageLock = videoBuffer.LockBits(new Rectangle(0, 0, videoBuffer.Width, videoBuffer.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);\n                DriverInterface.SetData(imageLock.Scan0, imageLock.Stride, imageLock.Width, imageLock.Height);\n                videoBuffer.UnlockBits(imageLock);\n\n                if (videoBuffer != rawInput)\n                {\n                    videoBuffer.Dispose();\n                }\n                rawInput.Dispose();\n            }\n        }\n\n        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)\n        {\n            api.Dispose();\n        }\n\n        private void cameraKeepAlive_Tick(object sender, EventArgs e)\n        {\n            if (activeCamera != null && activeCamera.SessionOpen)\n            {\n                activeCamera.SendCommand(EOSDigital.SDK.CameraCommand.ExtendShutDownTimer, 0);\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverCanon/MainForm.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <metadata name=\"cameraKeepAlive.TrayLocation\" type=\"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\">\n    <value>17, 17</value>\n  </metadata>\n</root>"
  },
  {
    "path": "UserLand/UserDriverCanon/Program.cs",
    "content": "﻿using DriverInterfaceWrapper;\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace UserDriverCanon\n{\n    static class Program\n    {\n        [MTAThread]\n        static void Main()\n        {\n            Application.EnableVisualStyles();\n            Application.SetCompatibleTextRenderingDefault(false);\n\n            if (!DriverInterface.Init())\n            {\n                MessageBox.Show(\"Unable to init DriverInterface!\");\n\n                return;\n            }\n\n            Thread sta = new Thread(new ThreadStart(() =>\n            {\n                Application.Run(new MainForm());\n            }));\n\n            sta.SetApartmentState(ApartmentState.STA);\n            sta.Start();\n            sta.Join();\n\n            DriverInterface.Free();\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverCanon/Properties/AssemblyInfo.cs",
    "content": "﻿using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following\n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n[assembly: AssemblyTitle(\"UserDriverCanon\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"UserDriverCanon\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2020\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible\n// to COM components.  If you need to access a type in this assembly from\n// COM, set the ComVisible attribute to true on that type.\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n[assembly: Guid(\"31052155-fb0e-4e7f-a50c-ffd9dd73f40c\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version\n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers\n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\n"
  },
  {
    "path": "UserLand/UserDriverCanon/Properties/Resources.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace UserDriverCanon.Properties\n{\n\n\n    /// <summary>\n    ///   A strongly-typed resource class, for looking up localized strings, etc.\n    /// </summary>\n    // This class was auto-generated by the StronglyTypedResourceBuilder\n    // class via a tool like ResGen or Visual Studio.\n    // To add or remove a member, edit your .ResX file then rerun ResGen\n    // with the /str option, or rebuild your VS project.\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"4.0.0.0\")]\n    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    internal class Resources\n    {\n\n        private static global::System.Resources.ResourceManager resourceMan;\n\n        private static global::System.Globalization.CultureInfo resourceCulture;\n\n        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n        internal Resources()\n        {\n        }\n\n        /// <summary>\n        ///   Returns the cached ResourceManager instance used by this class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Resources.ResourceManager ResourceManager\n        {\n            get\n            {\n                if ((resourceMan == null))\n                {\n                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(\"UserDriverCanon.Properties.Resources\", typeof(Resources).Assembly);\n                    resourceMan = temp;\n                }\n                return resourceMan;\n            }\n        }\n\n        /// <summary>\n        ///   Overrides the current thread's CurrentUICulture property for all\n        ///   resource lookups using this strongly typed resource class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Globalization.CultureInfo Culture\n        {\n            get\n            {\n                return resourceCulture;\n            }\n            set\n            {\n                resourceCulture = value;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverCanon/Properties/Resources.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "UserLand/UserDriverCanon/Properties/Settings.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace UserDriverCanon.Properties\n{\n\n\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator\", \"11.0.0.0\")]\n    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase\n    {\n\n        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));\n\n        public static Settings Default\n        {\n            get\n            {\n                return defaultInstance;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverCanon/Properties/Settings.settings",
    "content": "﻿<?xml version='1.0' encoding='utf-8'?>\n<SettingsFile xmlns=\"http://schemas.microsoft.com/VisualStudio/2004/01/settings\" CurrentProfile=\"(Default)\">\n  <Profiles>\n    <Profile Name=\"(Default)\" />\n  </Profiles>\n  <Settings />\n</SettingsFile>\n"
  },
  {
    "path": "UserLand/UserDriverCanon/UserDriverCanon.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}</ProjectGuid>\n    <OutputType>WinExe</OutputType>\n    <RootNamespace>UserDriverCanon</RootNamespace>\n    <AssemblyName>UserDriverCanon</AssemblyName>\n    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>\n    <FileAlignment>512</FileAlignment>\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\n    <Deterministic>true</Deterministic>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugSymbols>true</DebugSymbols>\n    <DebugType>full</DebugType>\n    <Optimize>false</Optimize>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugType>pdbonly</DebugType>\n    <Optimize>true</Optimize>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <DefineConstants>TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n    <Reference Include=\"System.Core\" />\n    <Reference Include=\"System.Xml.Linq\" />\n    <Reference Include=\"System.Data.DataSetExtensions\" />\n    <Reference Include=\"Microsoft.CSharp\" />\n    <Reference Include=\"System.Data\" />\n    <Reference Include=\"System.Deployment\" />\n    <Reference Include=\"System.Drawing\" />\n    <Reference Include=\"System.Net.Http\" />\n    <Reference Include=\"System.Windows.Forms\" />\n    <Reference Include=\"System.Xml\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Compile Include=\"CameraListItem.cs\" />\n    <Compile Include=\"FitPictureBox.cs\">\n      <SubType>Component</SubType>\n    </Compile>\n    <Compile Include=\"MainForm.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"MainForm.Designer.cs\">\n      <DependentUpon>MainForm.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Program.cs\" />\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\n    <EmbeddedResource Include=\"MainForm.resx\">\n      <DependentUpon>MainForm.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Properties\\Resources.resx\">\n      <Generator>ResXFileCodeGenerator</Generator>\n      <LastGenOutput>Resources.Designer.cs</LastGenOutput>\n      <SubType>Designer</SubType>\n    </EmbeddedResource>\n    <Compile Include=\"Properties\\Resources.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Resources.resx</DependentUpon>\n    </Compile>\n    <None Include=\"Properties\\Settings.settings\">\n      <Generator>SettingsSingleFileGenerator</Generator>\n      <LastGenOutput>Settings.Designer.cs</LastGenOutput>\n    </None>\n    <Compile Include=\"Properties\\Settings.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Settings.settings</DependentUpon>\n      <DesignTimeSharedInput>True</DesignTimeSharedInput>\n    </Compile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"App.config\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\DriverInterfaceWrapper\\DriverInterfaceWrapper.csproj\">\n      <Project>{6f9843c8-f363-4b39-b40a-6a5814a99442}</Project>\n      <Name>DriverInterfaceWrapper</Name>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\EDSDKLib\\EDSDKLib.csproj\">\n      <Project>{15e99248-6161-46a4-9183-609ca62406a6}</Project>\n      <Name>EDSDKLib</Name>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n</Project>"
  },
  {
    "path": "UserLand/UserDriverStaticImage/App.config",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<configuration>\n    <startup> \n        <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.7\" />\n    </startup>\n</configuration>"
  },
  {
    "path": "UserLand/UserDriverStaticImage/MainForm.Designer.cs",
    "content": "﻿namespace UserDriverStaticImage\n{\n    partial class MainForm\n    {\n        /// <summary>\n        /// Required designer variable.\n        /// </summary>\n        private System.ComponentModel.IContainer components = null;\n\n        /// <summary>\n        /// Clean up any resources being used.\n        /// </summary>\n        /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing && (components != null))\n            {\n                components.Dispose();\n            }\n            base.Dispose(disposing);\n        }\n\n        #region Windows Form Designer generated code\n\n        /// <summary>\n        /// Required method for Designer support - do not modify\n        /// the contents of this method with the code editor.\n        /// </summary>\n        private void InitializeComponent()\n        {\n            this.label1 = new System.Windows.Forms.Label();\n            this.cbDevices = new System.Windows.Forms.ComboBox();\n            this.groupDevice = new System.Windows.Forms.GroupBox();\n            this.btnDeviceRefresh = new System.Windows.Forms.Button();\n            this.groupPicture = new System.Windows.Forms.GroupBox();\n            this.btnLoadImage = new System.Windows.Forms.Button();\n            this.picView = new System.Windows.Forms.PictureBox();\n            this.groupDevice.SuspendLayout();\n            this.groupPicture.SuspendLayout();\n            ((System.ComponentModel.ISupportInitialize)(this.picView)).BeginInit();\n            this.SuspendLayout();\n            // \n            // label1\n            // \n            this.label1.AutoSize = true;\n            this.label1.Location = new System.Drawing.Point(21, 38);\n            this.label1.Name = \"label1\";\n            this.label1.Size = new System.Drawing.Size(42, 18);\n            this.label1.TabIndex = 0;\n            this.label1.Text = \"Path:\";\n            // \n            // cbDevices\n            // \n            this.cbDevices.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.cbDevices.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n            this.cbDevices.FormattingEnabled = true;\n            this.cbDevices.Location = new System.Drawing.Point(69, 34);\n            this.cbDevices.Name = \"cbDevices\";\n            this.cbDevices.Size = new System.Drawing.Size(523, 26);\n            this.cbDevices.TabIndex = 1;\n            this.cbDevices.SelectedIndexChanged += new System.EventHandler(this.cbDevices_SelectedIndexChanged);\n            // \n            // groupDevice\n            // \n            this.groupDevice.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.groupDevice.Controls.Add(this.btnDeviceRefresh);\n            this.groupDevice.Controls.Add(this.cbDevices);\n            this.groupDevice.Controls.Add(this.label1);\n            this.groupDevice.Location = new System.Drawing.Point(12, 12);\n            this.groupDevice.Name = \"groupDevice\";\n            this.groupDevice.Size = new System.Drawing.Size(736, 88);\n            this.groupDevice.TabIndex = 2;\n            this.groupDevice.TabStop = false;\n            this.groupDevice.Text = \"Device\";\n            // \n            // btnDeviceRefresh\n            // \n            this.btnDeviceRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnDeviceRefresh.Location = new System.Drawing.Point(598, 34);\n            this.btnDeviceRefresh.Name = \"btnDeviceRefresh\";\n            this.btnDeviceRefresh.Size = new System.Drawing.Size(112, 26);\n            this.btnDeviceRefresh.TabIndex = 2;\n            this.btnDeviceRefresh.Text = \"Refresh\";\n            this.btnDeviceRefresh.UseVisualStyleBackColor = true;\n            this.btnDeviceRefresh.Click += new System.EventHandler(this.btnDeviceRefresh_Click);\n            // \n            // groupPicture\n            // \n            this.groupPicture.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.groupPicture.Controls.Add(this.btnLoadImage);\n            this.groupPicture.Controls.Add(this.picView);\n            this.groupPicture.Enabled = false;\n            this.groupPicture.Location = new System.Drawing.Point(12, 106);\n            this.groupPicture.Name = \"groupPicture\";\n            this.groupPicture.Size = new System.Drawing.Size(736, 412);\n            this.groupPicture.TabIndex = 3;\n            this.groupPicture.TabStop = false;\n            this.groupPicture.Text = \"Image\";\n            // \n            // btnLoadImage\n            // \n            this.btnLoadImage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\n            this.btnLoadImage.Location = new System.Drawing.Point(618, 380);\n            this.btnLoadImage.Name = \"btnLoadImage\";\n            this.btnLoadImage.Size = new System.Drawing.Size(112, 26);\n            this.btnLoadImage.TabIndex = 3;\n            this.btnLoadImage.Text = \"Load\";\n            this.btnLoadImage.UseVisualStyleBackColor = true;\n            this.btnLoadImage.Click += new System.EventHandler(this.btnLoadImage_Click);\n            // \n            // picView\n            // \n            this.picView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) \n            | System.Windows.Forms.AnchorStyles.Left) \n            | System.Windows.Forms.AnchorStyles.Right)));\n            this.picView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\n            this.picView.Location = new System.Drawing.Point(6, 23);\n            this.picView.Name = \"picView\";\n            this.picView.Size = new System.Drawing.Size(724, 351);\n            this.picView.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;\n            this.picView.TabIndex = 0;\n            this.picView.TabStop = false;\n            // \n            // MainForm\n            // \n            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;\n            this.ClientSize = new System.Drawing.Size(760, 530);\n            this.Controls.Add(this.groupPicture);\n            this.Controls.Add(this.groupDevice);\n            this.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));\n            this.Name = \"MainForm\";\n            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\n            this.Text = \"UserDriverStaticImage\";\n            this.Load += new System.EventHandler(this.MainForm_Load);\n            this.groupDevice.ResumeLayout(false);\n            this.groupDevice.PerformLayout();\n            this.groupPicture.ResumeLayout(false);\n            ((System.ComponentModel.ISupportInitialize)(this.picView)).EndInit();\n            this.ResumeLayout(false);\n\n        }\n\n        #endregion\n\n        private System.Windows.Forms.Label label1;\n        private System.Windows.Forms.ComboBox cbDevices;\n        private System.Windows.Forms.GroupBox groupDevice;\n        private System.Windows.Forms.Button btnDeviceRefresh;\n        private System.Windows.Forms.GroupBox groupPicture;\n        private System.Windows.Forms.Button btnLoadImage;\n        private System.Windows.Forms.PictureBox picView;\n    }\n}\n\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/MainForm.cs",
    "content": "﻿using DriverInterfaceWrapper;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Diagnostics;\nusing System.Drawing;\nusing System.Drawing.Imaging;\nusing System.Linq;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace UserDriverStaticImage\n{\n    public partial class MainForm : Form\n    {\n        public MainForm()\n        {\n            InitializeComponent();\n        }\n\n        private void MainForm_Load(object sender, EventArgs e)\n        {\n            btnDeviceRefresh_Click(sender, e);\n        }\n\n        private void btnDeviceRefresh_Click(object sender, EventArgs e)\n        {\n            DeviceInfo[] info = DriverInterface.GetDevices();\n\n            cbDevices.Items.Clear();\n            cbDevices.Items.AddRange(info);\n        }\n\n        private void cbDevices_SelectedIndexChanged(object sender, EventArgs e)\n        {\n            groupPicture.Enabled = (cbDevices.SelectedIndex != -1);\n\n            if (groupPicture.Enabled && !DriverInterface.SelectDevice(((DeviceInfo)cbDevices.SelectedItem).Path))\n            {\n                cbDevices.SelectedIndex = -1;\n                MessageBox.Show(\"Failed to select device!\");\n                return;\n            }\n        }\n\n        private void btnLoadImage_Click(object sender, EventArgs e)\n        {\n            OpenFileDialog opf = new OpenFileDialog();\n            opf.Filter = \"Image files|*.bmp;*.jpg;*.png\";\n            if (opf.ShowDialog(this) == DialogResult.OK)\n            {\n                Bitmap rawInput = new Bitmap(opf.FileName);\n                Bitmap videoBuffer = null;\n\n                if (rawInput.Width != DriverInterface.Width || rawInput.Height != DriverInterface.Height)\n                {\n                    videoBuffer = new Bitmap(DriverInterface.Width, DriverInterface.Height);\n                    Graphics gfx = Graphics.FromImage(videoBuffer);\n\n                    float scaleX = 1.0f;\n                    if (rawInput.Width != DriverInterface.Width)\n                    {\n                        scaleX = DriverInterface.Width / (float)rawInput.Width;\n                    }\n\n                    float scaleY = 1.0f;\n                    if (rawInput.Height != DriverInterface.Height)\n                    {\n                        scaleY = DriverInterface.Height / (float)rawInput.Height;\n                    }\n\n                    float scale = Math.Min(scaleX, scaleY);\n\n                    int newWidth = (int)Math.Floor(scale * rawInput.Width);\n                    int newHeight = (int)Math.Floor(scale * rawInput.Height);\n\n                    gfx.Clear(Color.Black);\n                    gfx.DrawImage(rawInput, new Rectangle((videoBuffer.Width / 2) - (newWidth / 2), (videoBuffer.Height / 2) - (newHeight / 2), newWidth, newHeight));\n\n                    gfx.Dispose();\n                }\n                else\n                {\n                    videoBuffer = rawInput;\n                }\n\n                if (picView.Image != null)\n                {\n                    picView.Image.Dispose();\n                }\n                picView.Image = (Bitmap)videoBuffer.Clone();\n\n                Stopwatch sw = new Stopwatch();\n                BitmapData imageLock = videoBuffer.LockBits(new Rectangle(0, 0, videoBuffer.Width, videoBuffer.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);\n                sw.Start();\n                DriverInterface.SetData(imageLock.Scan0, imageLock.Stride, imageLock.Width, imageLock.Height);\n                sw.Stop();\n                videoBuffer.UnlockBits(imageLock);\n\n                Console.WriteLine(sw.Elapsed.ToString());\n                \n                if (videoBuffer != rawInput)\n                {\n                    videoBuffer.Dispose();\n                }\n                rawInput.Dispose();\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/MainForm.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" use=\"required\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n              <xsd:attribute ref=\"xml:space\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "UserLand/UserDriverStaticImage/Program.cs",
    "content": "﻿using DriverInterfaceWrapper;\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\nnamespace UserDriverStaticImage\n{\n    static class Program\n    {\n        [MTAThread]\n        static void Main()\n        {\n            Application.EnableVisualStyles();\n            Application.SetCompatibleTextRenderingDefault(false);\n\n            if (!DriverInterface.Init())\n            {\n                MessageBox.Show(\"Unable to init DriverInterface!\");\n\n                return;\n            }\n\n            Thread sta = new Thread(new ThreadStart(() =>\n            {\n                Application.Run(new MainForm());\n            }));\n\n            sta.SetApartmentState(ApartmentState.STA);\n            sta.Start();\n            sta.Join();\n\n            DriverInterface.Free();\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/Properties/AssemblyInfo.cs",
    "content": "﻿using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following\n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n[assembly: AssemblyTitle(\"UserDriverStaticImage\")]\n[assembly: AssemblyDescription(\"\")]\n[assembly: AssemblyConfiguration(\"\")]\n[assembly: AssemblyCompany(\"\")]\n[assembly: AssemblyProduct(\"UserDriverStaticImage\")]\n[assembly: AssemblyCopyright(\"Copyright ©  2020\")]\n[assembly: AssemblyTrademark(\"\")]\n[assembly: AssemblyCulture(\"\")]\n\n// Setting ComVisible to false makes the types in this assembly not visible\n// to COM components.  If you need to access a type in this assembly from\n// COM, set the ComVisible attribute to true on that type.\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n[assembly: Guid(\"b9dcf2a1-593e-45de-9780-9b98060c20f3\")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version\n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers\n// by using the '*' as shown below:\n// [assembly: AssemblyVersion(\"1.0.*\")]\n[assembly: AssemblyVersion(\"1.0.0.0\")]\n[assembly: AssemblyFileVersion(\"1.0.0.0\")]\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/Properties/Resources.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace UserDriverStaticImage.Properties\n{\n\n\n    /// <summary>\n    ///   A strongly-typed resource class, for looking up localized strings, etc.\n    /// </summary>\n    // This class was auto-generated by the StronglyTypedResourceBuilder\n    // class via a tool like ResGen or Visual Studio.\n    // To add or remove a member, edit your .ResX file then rerun ResGen\n    // with the /str option, or rebuild your VS project.\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"4.0.0.0\")]\n    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    internal class Resources\n    {\n\n        private static global::System.Resources.ResourceManager resourceMan;\n\n        private static global::System.Globalization.CultureInfo resourceCulture;\n\n        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n        internal Resources()\n        {\n        }\n\n        /// <summary>\n        ///   Returns the cached ResourceManager instance used by this class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Resources.ResourceManager ResourceManager\n        {\n            get\n            {\n                if ((resourceMan == null))\n                {\n                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(\"UserDriverStaticImage.Properties.Resources\", typeof(Resources).Assembly);\n                    resourceMan = temp;\n                }\n                return resourceMan;\n            }\n        }\n\n        /// <summary>\n        ///   Overrides the current thread's CurrentUICulture property for all\n        ///   resource lookups using this strongly typed resource class.\n        /// </summary>\n        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]\n        internal static global::System.Globalization.CultureInfo Culture\n        {\n            get\n            {\n                return resourceCulture;\n            }\n            set\n            {\n                resourceCulture = value;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/Properties/Resources.resx",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<root>\n  <!-- \n    Microsoft ResX Schema \n    \n    Version 2.0\n    \n    The primary goals of this format is to allow a simple XML format \n    that is mostly human readable. The generation and parsing of the \n    various data types are done through the TypeConverter classes \n    associated with the data types.\n    \n    Example:\n    \n    ... ado.net/XML headers & schema ...\n    <resheader name=\"resmimetype\">text/microsoft-resx</resheader>\n    <resheader name=\"version\">2.0</resheader>\n    <resheader name=\"reader\">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>\n    <resheader name=\"writer\">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>\n    <data name=\"Name1\"><value>this is my long string</value><comment>this is a comment</comment></data>\n    <data name=\"Color1\" type=\"System.Drawing.Color, System.Drawing\">Blue</data>\n    <data name=\"Bitmap1\" mimetype=\"application/x-microsoft.net.object.binary.base64\">\n        <value>[base64 mime encoded serialized .NET Framework object]</value>\n    </data>\n    <data name=\"Icon1\" type=\"System.Drawing.Icon, System.Drawing\" mimetype=\"application/x-microsoft.net.object.bytearray.base64\">\n        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>\n        <comment>This is a comment</comment>\n    </data>\n                \n    There are any number of \"resheader\" rows that contain simple \n    name/value pairs.\n    \n    Each data row contains a name, and value. The row also contains a \n    type or mimetype. Type corresponds to a .NET class that support \n    text/value conversion through the TypeConverter architecture. \n    Classes that don't support this are serialized and stored with the \n    mimetype set.\n    \n    The mimetype is used for serialized objects, and tells the \n    ResXResourceReader how to depersist the object. This is currently not \n    extensible. For a given mimetype the value must be set accordingly:\n    \n    Note - application/x-microsoft.net.object.binary.base64 is the format \n    that the ResXResourceWriter will generate, however the reader can \n    read any of the formats listed below.\n    \n    mimetype: application/x-microsoft.net.object.binary.base64\n    value   : The object must be serialized with \n            : System.Serialization.Formatters.Binary.BinaryFormatter\n            : and then encoded with base64 encoding.\n    \n    mimetype: application/x-microsoft.net.object.soap.base64\n    value   : The object must be serialized with \n            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter\n            : and then encoded with base64 encoding.\n\n    mimetype: application/x-microsoft.net.object.bytearray.base64\n    value   : The object must be serialized into a byte array \n            : using a System.ComponentModel.TypeConverter\n            : and then encoded with base64 encoding.\n    -->\n  <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n    <xsd:element name=\"root\" msdata:IsDataSet=\"true\">\n      <xsd:complexType>\n        <xsd:choice maxOccurs=\"unbounded\">\n          <xsd:element name=\"metadata\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"assembly\">\n            <xsd:complexType>\n              <xsd:attribute name=\"alias\" type=\"xsd:string\" />\n              <xsd:attribute name=\"name\" type=\"xsd:string\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"data\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n                <xsd:element name=\"comment\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"2\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" msdata:Ordinal=\"1\" />\n              <xsd:attribute name=\"type\" type=\"xsd:string\" msdata:Ordinal=\"3\" />\n              <xsd:attribute name=\"mimetype\" type=\"xsd:string\" msdata:Ordinal=\"4\" />\n            </xsd:complexType>\n          </xsd:element>\n          <xsd:element name=\"resheader\">\n            <xsd:complexType>\n              <xsd:sequence>\n                <xsd:element name=\"value\" type=\"xsd:string\" minOccurs=\"0\" msdata:Ordinal=\"1\" />\n              </xsd:sequence>\n              <xsd:attribute name=\"name\" type=\"xsd:string\" use=\"required\" />\n            </xsd:complexType>\n          </xsd:element>\n        </xsd:choice>\n      </xsd:complexType>\n    </xsd:element>\n  </xsd:schema>\n  <resheader name=\"resmimetype\">\n    <value>text/microsoft-resx</value>\n  </resheader>\n  <resheader name=\"version\">\n    <value>2.0</value>\n  </resheader>\n  <resheader name=\"reader\">\n    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n  <resheader name=\"writer\">\n    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\n  </resheader>\n</root>"
  },
  {
    "path": "UserLand/UserDriverStaticImage/Properties/Settings.Designer.cs",
    "content": "﻿//------------------------------------------------------------------------------\n// <auto-generated>\n//     This code was generated by a tool.\n//     Runtime Version:4.0.30319.42000\n//\n//     Changes to this file may cause incorrect behavior and will be lost if\n//     the code is regenerated.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\nnamespace UserDriverStaticImage.Properties\n{\n\n\n    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\n    [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator\", \"11.0.0.0\")]\n    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase\n    {\n\n        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));\n\n        public static Settings Default\n        {\n            get\n            {\n                return defaultInstance;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/Properties/Settings.settings",
    "content": "﻿<?xml version='1.0' encoding='utf-8'?>\n<SettingsFile xmlns=\"http://schemas.microsoft.com/VisualStudio/2004/01/settings\" CurrentProfile=\"(Default)\">\n  <Profiles>\n    <Profile Name=\"(Default)\" />\n  </Profiles>\n  <Settings />\n</SettingsFile>\n"
  },
  {
    "path": "UserLand/UserDriverStaticImage/UserDriverStaticImage.csproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <PropertyGroup>\n    <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>\n    <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>\n    <ProjectGuid>{B9DCF2A1-593E-45DE-9780-9B98060C20F3}</ProjectGuid>\n    <OutputType>WinExe</OutputType>\n    <RootNamespace>UserDriverStaticImage</RootNamespace>\n    <AssemblyName>UserDriverStaticImage</AssemblyName>\n    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>\n    <FileAlignment>512</FileAlignment>\n    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>\n    <Deterministic>true</Deterministic>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugSymbols>true</DebugSymbols>\n    <DebugType>full</DebugType>\n    <Optimize>false</Optimize>\n    <OutputPath>bin\\Debug\\</OutputPath>\n    <DefineConstants>DEBUG;TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' \">\n    <PlatformTarget>AnyCPU</PlatformTarget>\n    <DebugType>pdbonly</DebugType>\n    <Optimize>true</Optimize>\n    <OutputPath>bin\\Release\\</OutputPath>\n    <DefineConstants>TRACE</DefineConstants>\n    <ErrorReport>prompt</ErrorReport>\n    <WarningLevel>4</WarningLevel>\n  </PropertyGroup>\n  <ItemGroup>\n    <Reference Include=\"System\" />\n    <Reference Include=\"System.Core\" />\n    <Reference Include=\"System.Xml.Linq\" />\n    <Reference Include=\"System.Data.DataSetExtensions\" />\n    <Reference Include=\"Microsoft.CSharp\" />\n    <Reference Include=\"System.Data\" />\n    <Reference Include=\"System.Deployment\" />\n    <Reference Include=\"System.Drawing\" />\n    <Reference Include=\"System.Net.Http\" />\n    <Reference Include=\"System.Windows.Forms\" />\n    <Reference Include=\"System.Xml\" />\n  </ItemGroup>\n  <ItemGroup>\n    <Compile Include=\"MainForm.cs\">\n      <SubType>Form</SubType>\n    </Compile>\n    <Compile Include=\"MainForm.Designer.cs\">\n      <DependentUpon>MainForm.cs</DependentUpon>\n    </Compile>\n    <Compile Include=\"Program.cs\" />\n    <Compile Include=\"Properties\\AssemblyInfo.cs\" />\n    <EmbeddedResource Include=\"MainForm.resx\">\n      <DependentUpon>MainForm.cs</DependentUpon>\n    </EmbeddedResource>\n    <EmbeddedResource Include=\"Properties\\Resources.resx\">\n      <Generator>ResXFileCodeGenerator</Generator>\n      <LastGenOutput>Resources.Designer.cs</LastGenOutput>\n      <SubType>Designer</SubType>\n    </EmbeddedResource>\n    <Compile Include=\"Properties\\Resources.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Resources.resx</DependentUpon>\n    </Compile>\n    <None Include=\"Properties\\Settings.settings\">\n      <Generator>SettingsSingleFileGenerator</Generator>\n      <LastGenOutput>Settings.Designer.cs</LastGenOutput>\n    </None>\n    <Compile Include=\"Properties\\Settings.Designer.cs\">\n      <AutoGen>True</AutoGen>\n      <DependentUpon>Settings.settings</DependentUpon>\n      <DesignTimeSharedInput>True</DesignTimeSharedInput>\n    </Compile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"App.config\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\DriverInterfaceWrapper\\DriverInterfaceWrapper.csproj\">\n      <Project>{6f9843c8-f363-4b39-b40a-6a5814a99442}</Project>\n      <Name>DriverInterfaceWrapper</Name>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n</Project>"
  },
  {
    "path": "UserLand/VirtualCameraDriver.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 15\nVisualStudioVersion = 15.0.28307.645\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"UserDriverStaticImage\", \"UserDriverStaticImage\\UserDriverStaticImage.csproj\", \"{B9DCF2A1-593E-45DE-9780-9B98060C20F3}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"DriverInterface\", \"DriverInterface\\DriverInterface.vcxproj\", \"{4621FE02-0FE3-4810-80CD-6183638C0270}\"\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"DriverInterfaceWrapper\", \"DriverInterfaceWrapper\\DriverInterfaceWrapper.csproj\", \"{6F9843C8-F363-4B39-B40A-6A5814A99442}\"\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Interface\", \"Interface\", \"{6A973FBE-8BE6-45E4-950C-D6486B22AB7A}\"\nEndProject\nProject(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"TestApps\", \"TestApps\", \"{6B8931B2-CDDC-474A-B9DE-A906D369D69E}\"\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"UserDriverCanon\", \"UserDriverCanon\\UserDriverCanon.csproj\", \"{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}\"\nEndProject\nProject(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"EDSDKLib\", \"EDSDKLib\\EDSDKLib.csproj\", \"{15E99248-6161-46A4-9183-609CA62406A6}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Any CPU = Debug|Any CPU\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|Any CPU = Release|Any CPU\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Release|x64.Build.0 = Release|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3}.Release|x86.Build.0 = Release|Any CPU\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Debug|Any CPU.ActiveCfg = Debug|Win32\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Debug|x64.Build.0 = Debug|x64\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Debug|x86.Build.0 = Debug|Win32\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Release|Any CPU.ActiveCfg = Release|Win32\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Release|x64.ActiveCfg = Release|x64\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Release|x64.Build.0 = Release|x64\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Release|x86.ActiveCfg = Release|Win32\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270}.Release|x86.Build.0 = Release|Win32\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Release|x64.Build.0 = Release|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442}.Release|x86.Build.0 = Release|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Debug|Any CPU.Build.0 = Debug|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Debug|x64.ActiveCfg = Debug|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Debug|x64.Build.0 = Debug|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Debug|x86.ActiveCfg = Debug|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Debug|x86.Build.0 = Debug|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Release|Any CPU.ActiveCfg = Release|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Release|Any CPU.Build.0 = Release|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Release|x64.ActiveCfg = Release|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Release|x64.Build.0 = Release|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Release|x86.ActiveCfg = Release|Any CPU\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C}.Release|x86.Build.0 = Release|Any CPU\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Debug|Any CPU.ActiveCfg = Debug|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Debug|x64.ActiveCfg = Debug|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Debug|x86.ActiveCfg = Debug|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Debug|x86.Build.0 = Debug|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Release|Any CPU.ActiveCfg = Release|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Release|x64.ActiveCfg = Release|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Release|x86.ActiveCfg = Release|x86\n\t\t{15E99248-6161-46A4-9183-609CA62406A6}.Release|x86.Build.0 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(NestedProjects) = preSolution\n\t\t{B9DCF2A1-593E-45DE-9780-9B98060C20F3} = {6B8931B2-CDDC-474A-B9DE-A906D369D69E}\n\t\t{4621FE02-0FE3-4810-80CD-6183638C0270} = {6A973FBE-8BE6-45E4-950C-D6486B22AB7A}\n\t\t{6F9843C8-F363-4B39-B40A-6A5814A99442} = {6A973FBE-8BE6-45E4-950C-D6486B22AB7A}\n\t\t{31052155-FB0E-4E7F-A50C-FFD9DD73F40C} = {6B8931B2-CDDC-474A-B9DE-A906D369D69E}\n\t\t{15E99248-6161-46A4-9183-609CA62406A6} = {6B8931B2-CDDC-474A-B9DE-A906D369D69E}\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {BF95B73C-3E52-4624-912E-845AA4997238}\n\tEndGlobalSection\nEndGlobal\n"
  }
]