diff options
| author | Trevor Baron <[email protected]> | 2017-01-06 13:36:58 -0800 |
|---|---|---|
| committer | Trevor Baron <[email protected]> | 2017-01-06 13:36:58 -0800 |
| commit | 5e36b0da44ef66ee06557e59a721c756849f045c (patch) | |
| tree | 7a6869b1f330f4e487936380307c846003396468 /avstream/avssamp/avssamp.cpp | |
| parent | 3070c2df6eb41d1fef3588447d3a6424eaf48b41 (diff) | |
fix Code Analysis Warnings C4595
Diffstat (limited to 'avstream/avssamp/avssamp.cpp')
| -rw-r--r-- | avstream/avssamp/avssamp.cpp | 175 |
1 files changed, 151 insertions, 24 deletions
diff --git a/avstream/avssamp/avssamp.cpp b/avstream/avssamp/avssamp.cpp index 2cf0aac5..5a2c2b77 100644 --- a/avstream/avssamp/avssamp.cpp +++ b/avstream/avssamp/avssamp.cpp @@ -1,20 +1,20 @@ /************************************************************************** - AVStream Filter-Centric Sample +AVStream Filter-Centric Sample - Copyright (c) 1999 - 2001, Microsoft Corporation +Copyright (c) 1999 - 2001, Microsoft Corporation - File: +File: - avssamp.cpp +avssamp.cpp - Abstract: +Abstract: - This is the main file for the filter-centric sample. +This is the main file for the filter-centric sample. - History: +History: - created 6/18/01 +created 6/18/01 **************************************************************************/ @@ -22,38 +22,165 @@ /************************************************************************** - INITIALIZATION CODE +INITIALIZATION CODE **************************************************************************/ - + extern "C" DRIVER_INITIALIZE DriverEntry; +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; +} + +/*++ + +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); + } +} + extern "C" NTSTATUS -DriverEntry ( +DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath - ) +) /*++ 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 --*/ @@ -66,17 +193,17 @@ Return Value: // here. // return - KsInitializeDriver ( + KsInitializeDriver( DriverObject, RegistryPath, &CaptureDeviceDescriptor - ); + ); } /************************************************************************** - DESCRIPTOR AND DISPATCH LAYOUT +DESCRIPTOR AND DISPATCH LAYOUT **************************************************************************/ @@ -86,7 +213,7 @@ Return Value: // The table of filter descriptors that this device supports. Each one of // these will be used as a template to create a filter-factory on the device. // -DEFINE_KSFILTER_DESCRIPTOR_TABLE (FilterDescriptors) { +DEFINE_KSFILTER_DESCRIPTOR_TABLE(FilterDescriptors) { &CaptureFilterDescriptor }; @@ -109,7 +236,7 @@ CaptureDeviceDescriptor = { // by AVStream will be quite sufficient. // NULL, - SIZEOF_ARRAY (FilterDescriptors), + SIZEOF_ARRAY(FilterDescriptors), FilterDescriptors, KSDEVICE_DESCRIPTOR_VERSION }; |
