Skip to content

Commit

Permalink
Added FakeGPS.Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
juliankay committed Jan 4, 2016
1 parent 6ccf84f commit 986dfdf
Show file tree
Hide file tree
Showing 25 changed files with 12,353 additions and 0 deletions.
97 changes: 97 additions & 0 deletions src/FakeGPS.Driver/Driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// 2016 OK

/*++
Module:
Driver.cpp
Description:
This module contains the implementation for the sensors service driver callback class.
--*/

#include "Internal.h"
#include "FakeGPSLib.h" // IDL Generated File
#include "Driver.tmh"
#include "Driver.h"
#include "FakeGPS.h"

/*++
CMyDriver::CMyDriver
Object constructor function
--*/
CMyDriver::CMyDriver()
{
}

/*++
CMyDriver::OnDeviceAdd
The framework call this function when device is detected. This driver creates a device callback object
Parameters:
pDriver - pointer to an IWDFDriver object
pDeviceInit - pointer to a device initialization object
Return Values:
S_OK: device initialized successfully
--*/
HRESULT CMyDriver::OnDeviceAdd(
_In_ IWDFDriver* pDriver,
_In_ IWDFDeviceInitialize* pDeviceInit)
{
// informational at the start of the run in case there are no other log entries to view
Trace(TRACE_LEVEL_CRITICAL, " ");
Trace(TRACE_LEVEL_CRITICAL, "------------------------------ START ------------------------------------------");
Trace(TRACE_LEVEL_CRITICAL, "FakeGPS - Trace log running with TRACE_LEVEL == CRITICAL");
Trace(TRACE_LEVEL_ERROR, "FakeGPS - Trace log running with TRACE_LEVEL == ERROR");
Trace(TRACE_LEVEL_WARNING, "FakeGPS - Trace log running with TRACE_LEVEL == WARNING");
Trace(TRACE_LEVEL_INFORMATION, "FakeGPS - Trace log running with TRACE_LEVEL == INFORMATION");
Trace(TRACE_LEVEL_VERBOSE, "FakeGPS - Trace log running with TRACE_LEVEL == VERBOSE");

Trace(TRACE_LEVEL_INFORMATION, "%!FUNC! Entry");

HRESULT hr = CFakeGPS::CreateInstance(pDriver, pDeviceInit);

return hr;
}

/*++
CMyDriver::OnInitialize
The framework calls this function just after loading the driver. The driver
can perform any global, device independent initialization in this routine.
--*/
HRESULT CMyDriver::OnInitialize(
_In_ IWDFDriver* pDriver)
{
UNREFERENCED_PARAMETER(pDriver);
return S_OK;
}

/*++
CMyDriver::OnDeinitialize
The framework calls this function just before de-initializing itself. All
WDF framework resources should be released by driver before returning
from this call.
--*/
void CMyDriver::OnDeinitialize(
_In_ IWDFDriver* pDriver)
{
UNREFERENCED_PARAMETER(pDriver);
return;
}
49 changes: 49 additions & 0 deletions src/FakeGPS.Driver/Driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 2016 OK

/*++
Module:
Driver.h
Description:
This module contains the type definitions for the sensors service
driver callback class.
--*/

#pragma once

//
// This class handles driver events for the sensors service driver.
// It supports the OnDeviceAdd event, which occurs when the driver is called
// to setup per-device handlers for a new device stack.
//

class ATL_NO_VTABLE CMyDriver :
public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CMyDriver, &CLSID_FakeGPS>,
public IDriverEntry
{
public:

CMyDriver();

DECLARE_NO_REGISTRY()
DECLARE_CLASSFACTORY()
DECLARE_NOT_AGGREGATABLE(CMyDriver)

BEGIN_COM_MAP(CMyDriver)
COM_INTERFACE_ENTRY(IDriverEntry)
END_COM_MAP()

public:

// IDriverEntry
STDMETHOD(OnInitialize)(_In_ IWDFDriver* pDriver);
STDMETHOD(OnDeviceAdd)(_In_ IWDFDriver* pDriver, _In_ IWDFDeviceInitialize* pDeviceInit);
STDMETHOD_(void, OnDeinitialize)(_In_ IWDFDriver* pDriver);
};

OBJECT_ENTRY_AUTO(__uuidof(FakeGPS), CMyDriver)
Loading

0 comments on commit 986dfdf

Please sign in to comment.