summaryrefslogtreecommitdiff
path: root/AVStream/avscamera/sys/AvsCamera.cpp
diff options
context:
space:
mode:
authorTrevor Baron <[email protected]>2017-01-06 13:36:58 -0800
committerTrevor Baron <[email protected]>2017-01-06 13:36:58 -0800
commit5e36b0da44ef66ee06557e59a721c756849f045c (patch)
tree7a6869b1f330f4e487936380307c846003396468 /AVStream/avscamera/sys/AvsCamera.cpp
parent3070c2df6eb41d1fef3588447d3a6424eaf48b41 (diff)
fix Code Analysis Warnings C4595
Diffstat (limited to 'AVStream/avscamera/sys/AvsCamera.cpp')
-rw-r--r--AVStream/avscamera/sys/AvsCamera.cpp188
1 files changed, 168 insertions, 20 deletions
diff --git a/AVStream/avscamera/sys/AvsCamera.cpp b/AVStream/avscamera/sys/AvsCamera.cpp
index 3742e69d..155ea689 100644
--- a/AVStream/avscamera/sys/AvsCamera.cpp
+++ b/AVStream/avscamera/sys/AvsCamera.cpp
@@ -1,28 +1,176 @@
/**************************************************************************
- A/V Stream Camera Sample
+A/V Stream Camera Sample
- Copyright (c) 2014, Microsoft Corporation.
+Copyright (c) 2014, Microsoft Corporation.
- File:
+File:
- AvsCamera.cpp
+AvsCamera.cpp
- Abstract:
+Abstract:
- Sample Camera driver initialization.
+Sample Camera driver initialization.
- History:
+History:
- created 5/15/2014
+created 5/15/2014
**************************************************************************/
#include "Common.h"
+PVOID operator new
+(
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType
+ )
+{
+ PVOID result = ExAllocatePoolWithTag(poolType, iSize, 'wNCK');
+
+ if (result) {
+ RtlZeroMemory(result, iSize);
+ }
+
+ return result;
+}
+
+PVOID operator new
+(
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType,
+ ULONG tag
+ )
+{
+ PVOID result = ExAllocatePoolWithTag(poolType, iSize, tag);
+
+ if (result) {
+ RtlZeroMemory(result, iSize);
+ }
+
+ return result;
+}
+
+PVOID
+operator new[](
+ size_t iSize,
+ _When_((poolType & NonPagedPoolMustSucceed) != 0,
+ __drv_reportError("Must succeed pool allocations are forbidden. "
+ "Allocation failures cause a system crash"))
+ POOL_TYPE poolType,
+ ULONG tag
+ )
+{
+ PVOID result = ExAllocatePoolWithTag(poolType, iSize, tag);
+
+ if (result)
+ {
+ RtlZeroMemory(result, iSize);
+ }
+
+ return result;
+}
+
+/*++
+
+Routine Description:
+
+Array delete() operator.
+
+Arguments:
+
+pVoid -
+The memory to free.
+
+Return Value:
+
+None
+
+--*/
+void
+__cdecl
+operator delete[](
+ PVOID pVoid
+ )
+{
+ if (pVoid)
+ {
+ ExFreePool(pVoid);
+ }
+}
+
+/*++
+
+Routine Description:
+
+Sized delete() operator.
+
+Arguments:
+
+pVoid -
+The memory to free.
+
+size -
+The size of the memory to free.
+
+Return Value:
+
+None
+
+--*/
+void __cdecl operator delete
+(
+ void *pVoid,
+ size_t /*size*/
+ )
+{
+ if (pVoid)
+ {
+ ExFreePool(pVoid);
+ }
+}
+
+/*++
+
+Routine Description:
+
+Sized delete[]() operator.
+
+Arguments:
+
+pVoid -
+The memory to free.
+
+size -
+The size of the memory to free.
+
+Return Value:
+
+None
+
+--*/
+void __cdecl operator delete[]
+(
+ void *pVoid,
+ size_t /*size*/
+ )
+{
+ if (pVoid)
+ {
+ ExFreePool(pVoid);
+ }
+}
+
+
/**************************************************************************
- DESCRIPTOR AND DISPATCH LAYOUT
+DESCRIPTOR AND DISPATCH LAYOUT
**************************************************************************/
@@ -33,7 +181,7 @@
// notifications as well as power management notifications are dispatched
// through this table.
//
-DEFINE_CAMERA_KSDEVICE_DISPATCH( AvsCameraDispatch, CAvsCameraDevice );
+DEFINE_CAMERA_KSDEVICE_DISPATCH(AvsCameraDispatch, CAvsCameraDevice);
//
// CaptureDeviceDescriptor:
@@ -55,7 +203,7 @@ AvsCameraDeviceDescriptor =
/**************************************************************************
- INITIALIZATION CODE
+INITIALIZATION CODE
**************************************************************************/
@@ -64,7 +212,7 @@ extern "C" DRIVER_INITIALIZE DriverEntry;
extern "C"
NTSTATUS
-DriverEntry (
+DriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
@@ -73,20 +221,20 @@ DriverEntry (
Routine Description:
- Driver entry point. Pass off control to the AVStream initialization
- function (KsInitializeDriver) and return the status code from it.
+Driver entry point. Pass off control to the AVStream initialization
+function (KsInitializeDriver) and return the status code from it.
Arguments:
- DriverObject -
- The WDM driver object for our driver
+DriverObject -
+The WDM driver object for our driver
- RegistryPath -
- The registry path for our registry info
+RegistryPath -
+The registry path for our registry info
Return Value:
- As from KsInitializeDriver
+As from KsInitializeDriver
--*/
@@ -98,7 +246,7 @@ Return Value:
// here.
//
return
- KsInitializeDriver (
+ KsInitializeDriver(
DriverObject,
RegistryPath,
&AvsCameraDeviceDescriptor