CPP: Pre-autoformat.

This commit is contained in:
Geoffrey White
2019-11-22 15:34:20 +00:00
parent 1d233f2f9e
commit c73d3ebbb6

View File

@@ -11,32 +11,54 @@ class MallocAllocationFunction extends AllocationFunction {
exists(string name | exists(string name |
hasGlobalOrStdName(name) and hasGlobalOrStdName(name) and
( (
(name = "malloc" and sizeArg = 0) // malloc(size) // malloc(size)
(name = "malloc" and sizeArg = 0)
) )
or or
hasGlobalName(name) and hasGlobalName(name) and
( (
(name = "ExAllocatePool" and sizeArg = 1) or // ExAllocatePool(type, size) // ExAllocatePool(type, size)
(name = "ExAllocatePoolWithTag" and sizeArg = 1) or // ExAllocatePool(type, size, tag) (name = "ExAllocatePool" and sizeArg = 1) or
(name = "ExAllocatePoolWithTagPriority" and sizeArg = 1) or // ExAllocatePoolWithTagPriority(type, size, tag, priority) // ExAllocatePool(type, size, tag)
(name = "ExAllocatePoolWithQuota" and sizeArg = 1) or // ExAllocatePoolWithQuota(type, size) (name = "ExAllocatePoolWithTag" and sizeArg = 1) or
(name = "ExAllocatePoolWithQuotaTag" and sizeArg = 1) or // ExAllocatePoolWithQuotaTag(type, size, tag) // ExAllocatePoolWithTagPriority(type, size, tag, priority)
(name = "IoAllocateMdl" and sizeArg = 1) or // IoAllocateMdl(address, size, flag, flag, irp) (name = "ExAllocatePoolWithTagPriority" and sizeArg = 1) or
(name = "IoAllocateErrorLogEntry" and sizeArg = 1) or // IoAllocateErrorLogEntry(object, size) // ExAllocatePoolWithQuota(type, size)
(name = "MmAllocateContiguousMemory" and sizeArg = 0) or // MmAllocateContiguousMemory(size, maxaddress) (name = "ExAllocatePoolWithQuota" and sizeArg = 1) or
(name = "MmAllocateContiguousNodeMemory" and sizeArg = 0) or // MmAllocateContiguousNodeMemory(size, minaddress, maxaddress, bound, flag, prefer) // ExAllocatePoolWithQuotaTag(type, size, tag)
(name = "MmAllocateContiguousMemorySpecifyCache" and sizeArg = 0) or // MmAllocateContiguousMemorySpecifyCache(size, minaddress, maxaddress, bound, type) (name = "ExAllocatePoolWithQuotaTag" and sizeArg = 1) or
(name = "MmAllocateContiguousMemorySpecifyCacheNode" and sizeArg = 0) or // MmAllocateContiguousMemorySpecifyCacheNode(size, minaddress, maxaddress, bound, type, prefer) // IoAllocateMdl(address, size, flag, flag, irp)
(name = "MmAllocateNonCachedMemory" and sizeArg = 0) or // MmAllocateNonCachedMemory(size) (name = "IoAllocateMdl" and sizeArg = 1) or
(name = "MmAllocateMappingAddress" and sizeArg = 0) or // MmAllocateMappingAddress(size, tag) // IoAllocateErrorLogEntry(object, size)
(name = "MmAllocatePagesForMdl" and sizeArg = 3) or // MmAllocatePagesForMdl(minaddress, maxaddress, skip, size) (name = "IoAllocateErrorLogEntry" and sizeArg = 1) or
(name = "MmAllocatePagesForMdlEx" and sizeArg = 3) or // MmAllocatePagesForMdlEx(minaddress, maxaddress, skip, size, type, flags) // MmAllocateContiguousMemory(size, maxaddress)
(name = "MmAllocateNodePagesForMdlEx" and sizeArg = 3) or // MmAllocateNodePagesForMdlEx(minaddress, maxaddress, skip, size, type, prefer, flags) (name = "MmAllocateContiguousMemory" and sizeArg = 0) or
(name = "LocalAlloc" and sizeArg = 1) or // LocalAlloc(flags, size) // MmAllocateContiguousNodeMemory(size, minaddress, maxaddress, bound, flag, prefer)
(name = "GlobalAlloc" and sizeArg = 1) or // GlobalAlloc(flags, size) (name = "MmAllocateContiguousNodeMemory" and sizeArg = 0) or
(name = "HeapAlloc" and sizeArg = 2) or // HeapAlloc(heap, flags, size) // MmAllocateContiguousMemorySpecifyCache(size, minaddress, maxaddress, bound, type)
(name = "VirtualAlloc" and sizeArg = 1) or // VirtualAlloc(address, size, type, flag) (name = "MmAllocateContiguousMemorySpecifyCache" and sizeArg = 0) or
(name = "CoTaskMemAlloc" and sizeArg = 0) // CoTaskMemAlloc(size) // MmAllocateContiguousMemorySpecifyCacheNode(size, minaddress, maxaddress, bound, type, prefer)
(name = "MmAllocateContiguousMemorySpecifyCacheNode" and sizeArg = 0) or
// MmAllocateNonCachedMemory(size)
(name = "MmAllocateNonCachedMemory" and sizeArg = 0) or
// MmAllocateMappingAddress(size, tag)
(name = "MmAllocateMappingAddress" and sizeArg = 0) or
// MmAllocatePagesForMdl(minaddress, maxaddress, skip, size)
(name = "MmAllocatePagesForMdl" and sizeArg = 3) or
// MmAllocatePagesForMdlEx(minaddress, maxaddress, skip, size, type, flags)
(name = "MmAllocatePagesForMdlEx" and sizeArg = 3) or
// MmAllocateNodePagesForMdlEx(minaddress, maxaddress, skip, size, type, prefer, flags)
(name = "MmAllocateNodePagesForMdlEx" and sizeArg = 3) or
// LocalAlloc(flags, size)
(name = "LocalAlloc" and sizeArg = 1) or
// GlobalAlloc(flags, size)
(name = "GlobalAlloc" and sizeArg = 1) or
// HeapAlloc(heap, flags, size)
(name = "HeapAlloc" and sizeArg = 2) or
// VirtualAlloc(address, size, type, flag)
(name = "VirtualAlloc" and sizeArg = 1) or
// CoTaskMemAlloc(size)
(name = "CoTaskMemAlloc" and sizeArg = 0)
) )
) )
} }
@@ -57,7 +79,8 @@ class CallocAllocationFunction extends AllocationFunction {
CallocAllocationFunction() { CallocAllocationFunction() {
exists(string name | exists(string name |
hasGlobalOrStdName(name) and hasGlobalOrStdName(name) and
(name = "calloc" and sizeArg = 1 and multArg = 0) // calloc(num, size) // calloc(num, size)
(name = "calloc" and sizeArg = 1 and multArg = 0)
) )
} }
@@ -81,15 +104,20 @@ class ReallocAllocationFunction extends AllocationFunction {
ReallocAllocationFunction() { exists(string name | ReallocAllocationFunction() { exists(string name |
hasGlobalOrStdName(name) and hasGlobalOrStdName(name) and
( (
(name = "realloc" and sizeArg = 1 and reallocArg = 0) // realloc(ptr, size) // realloc(ptr, size)
(name = "realloc" and sizeArg = 1 and reallocArg = 0)
) )
or or
hasGlobalName(name) and hasGlobalName(name) and
( (
(name = "LocalReAlloc" and sizeArg = 1 and reallocArg = 0) or // LocalReAlloc(ptr, size, flags) // LocalReAlloc(ptr, size, flags)
(name = "GlobalReAlloc" and sizeArg = 1 and reallocArg = 0) or // GlobalReAlloc(ptr, size, flags) (name = "LocalReAlloc" and sizeArg = 1 and reallocArg = 0) or
(name = "HeapReAlloc" and sizeArg = 3 and reallocArg = 2) or // HeapReAlloc(heap, flags, ptr, size) // GlobalReAlloc(ptr, size, flags)
(name = "CoTaskMemRealloc" and sizeArg = 1 and reallocArg = 0) // CoTaskMemRealloc(ptr, size) (name = "GlobalReAlloc" and sizeArg = 1 and reallocArg = 0) or
// HeapReAlloc(heap, flags, ptr, size)
(name = "HeapReAlloc" and sizeArg = 3 and reallocArg = 2) or
// CoTaskMemRealloc(ptr, size)
(name = "CoTaskMemRealloc" and sizeArg = 1 and reallocArg = 0)
) )
) )
} }
@@ -112,23 +140,36 @@ class StrdupAllocationFunction extends AllocationFunction {
exists(string name | exists(string name |
hasGlobalOrStdName(name) and hasGlobalOrStdName(name) and
( (
name = "strdup" or // strdup(str) // strdup(str)
name = "wcsdup" // wcsdup(str) name = "strdup" or
// wcsdup(str)
name = "wcsdup"
) )
or or
hasGlobalName(name) and hasGlobalName(name) and
( (
name = "_strdup" or // _strdup(str) // _strdup(str)
name = "_wcsdup" or // _wcsdup(str) name = "_strdup" or
name = "_mbsdup" or // _mbsdup(str) // _wcsdup(str)
name = "ExAllocateFromLookasideListEx" or // ExAllocateFromLookasideListEx(list) name = "_wcsdup" or
name = "ExAllocateFromPagedLookasideList" or // ExAllocateFromPagedLookasideList(list) // _mbsdup(str)
name = "ExAllocateFromNPagedLookasideList" or // ExAllocateFromNPagedLookasideList(list) name = "_mbsdup" or
name = "ExAllocateTimer" or // ExAllocateTimer(callback, context, attributes) // ExAllocateFromLookasideListEx(list)
name = "IoAllocateWorkItem" or // IoAllocateWorkItem(object) name = "ExAllocateFromLookasideListEx" or
name = "MmMapLockedPagesWithReservedMapping" or // MmMapLockedPagesWithReservedMapping(address, tag, list, type) // ExAllocateFromPagedLookasideList(list)
name = "MmMapLockedPages" or // MmMapLockedPages(list, mode) name = "ExAllocateFromPagedLookasideList" or
name = "MmMapLockedPagesSpecifyCache" // MmMapLockedPagesSpecifyCache(list, mode, type, address, flag, flag) // ExAllocateFromNPagedLookasideList(list)
name = "ExAllocateFromNPagedLookasideList" or
// ExAllocateTimer(callback, context, attributes)
name = "ExAllocateTimer" or
// IoAllocateWorkItem(object)
name = "IoAllocateWorkItem" or
// MmMapLockedPagesWithReservedMapping(address, tag, list, type)
name = "MmMapLockedPagesWithReservedMapping" or
// MmMapLockedPages(list, mode)
name = "MmMapLockedPages" or
// MmMapLockedPagesSpecifyCache(list, mode, type, address, flag, flag)
name = "MmMapLockedPagesSpecifyCache"
) )
) )
} }