-
Notifications
You must be signed in to change notification settings - Fork 160
/
fuzz.cpp
43 lines (40 loc) · 1.18 KB
/
fuzz.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <StdAfx.h>
#include <core/smartview/SmartView.h>
#include <core/addin/mfcmapi.h>
#include <core/addin/addin.h>
#include <core/utility/registry.h>
#include <core/utility/strings.h>
#ifdef FUZZ
std::once_flag _initFlag;
void EnsureInit()
{
addin::MergeAddInArrays();
registry::doSmartView = true;
registry::useGetPropList = true;
registry::parseNamedProps = true;
registry::cacheNamedProps = true;
strings::setTestInstance(GetModuleHandleW(L"mfcmapi.exe"));
}
void test(const SBinary hex)
{
for (const auto parser : SmartViewParserTypeArray)
{
if (parser.type == parserType::NOPARSING) continue;
//wprintf(L"Testing %ws\r\n", addin::AddInStructTypeToString(parser.type).c_str());
(void) smartview::InterpretBinary(hex, parser.type, nullptr);
}
}
#ifdef __cplusplus
#define FUZZ_EXPORT extern "C" __declspec(dllexport)
#else
#define FUZZ_EXPORT __declspec(dllexport)
#endif
FUZZ_EXPORT int __cdecl LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
std::call_once(_initFlag, EnsureInit);
const SBinary input = {static_cast<ULONG>(size), (LPBYTE) (data)};
//wprintf(L"Fuzzing: %ws\r\n", strings::BinToHexString(&input, true).c_str());
test(input);
return 0;
}
#endif // FUZZ