libPeConv
A library to load, manipulate, dump PE files.
Loading...
Searching...
No Matches
buffer_util.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <windows.h>
9
10#define MAX_DWORD 0xffffffff
11#define MAX_WORD 0xffff
12#define MASK_TO_DWORD(val) ((val < MAX_DWORD) ? (val & MAX_DWORD) : MAX_DWORD)
13#define MASK_TO_WORD(val) ((val < MAX_WORD) ? (val & MAX_WORD) : MAX_WORD)
14
15namespace peconv {
16
27 bool validate_ptr(
28 IN const void* buffer_bgn,
29 IN size_t buffer_size,
30 IN const void* field_bgn,
31 IN size_t field_size
32 );
33
34//-----------------------------------------------------------------------------------
35//
36// supported buffers:
37//
41 typedef PBYTE UNALIGNED_BUF;
42
46 typedef PBYTE ALIGNED_BUF;
47
48//
49// alloc/free unaligned buffers:
50//
54 UNALIGNED_BUF alloc_unaligned(size_t buf_size);
55
56 //
60 void free_unaligned(UNALIGNED_BUF section_buffer);
61
62//
63// alloc/free aligned buffers:
64//
65
69 ALIGNED_BUF alloc_aligned(size_t buffer_size, DWORD protect, ULONGLONG desired_base=NULL);
70
74 bool free_aligned(ALIGNED_BUF buffer, size_t buffer_size=0);
75
76 //PE buffers (wrappers)
77
81 ALIGNED_BUF alloc_pe_buffer(size_t buffer_size, DWORD protect, ULONGLONG desired_base=NULL);
82
86 bool free_pe_buffer(ALIGNED_BUF buffer, size_t buffer_size=0);
87
88}; //namespace peconv
bool free_aligned(ALIGNED_BUF buffer, size_t buffer_size=0)
ALIGNED_BUF alloc_aligned(size_t buffer_size, DWORD protect, ULONGLONG desired_base=NULL)
PBYTE ALIGNED_BUF
Definition buffer_util.h:46
UNALIGNED_BUF alloc_unaligned(size_t buf_size)
bool validate_ptr(IN const void *buffer_bgn, IN size_t buffer_size, IN const void *field_bgn, IN size_t field_size)
bool free_pe_buffer(ALIGNED_BUF buffer, size_t buffer_size=0)
ALIGNED_BUF alloc_pe_buffer(size_t buffer_size, DWORD protect, ULONGLONG desired_base=NULL)
PBYTE UNALIGNED_BUF
Definition buffer_util.h:41
void free_unaligned(UNALIGNED_BUF section_buffer)