[STDUNK][PORTCLS][CMIDriver] Fix issue with operator new/delete

Fix for MSVC warning "C2323: 'operator new': non-member operator new or delete functions may not be declared static or in a namespace other than the global namespace."

See https://docs.microsoft.com/en-us/cpp/porting/visual-cpp-what-s-new-2003-through-2015?view=vs-2019 section "Overloaded operator new and operator delete"
This commit is contained in:
Timo Kreuzer 2019-05-25 12:22:04 +02:00
parent f565083d58
commit 99fa38809f
10 changed files with 115 additions and 3 deletions

View file

@ -11,6 +11,58 @@
#include <stdunk.h>
inline
PVOID
KCOM_New(
size_t size,
POOL_TYPE pool_type,
ULONG tag)
{
PVOID result;
result = ExAllocatePoolWithTag(pool_type, size, tag);
if (result)
RtlZeroMemory(result, size);
return result;
}
PVOID
__cdecl
operator new(
size_t size,
POOL_TYPE pool_type)
{
return KCOM_New(size, pool_type, 'wNcP');
}
PVOID
__cdecl
operator new(
size_t size,
POOL_TYPE pool_type,
ULONG tag)
{
return KCOM_New(size, pool_type, tag);
}
void
__cdecl
operator delete(
PVOID ptr)
{
ExFreePool(ptr);
}
void
__cdecl
operator delete(
PVOID ptr, UINT_PTR)
{
ExFreePool(ptr);
}
CUnknown::CUnknown(PUNKNOWN outer_unknown)
{
m_ref_count = 0;