-
Notifications
You must be signed in to change notification settings - Fork 13
/
TargetExample.cc
67 lines (60 loc) · 1.62 KB
/
TargetExample.cc
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file serves as a standalone test file for the obfuscation framework to work on.
// It is non optimized and self isolated, does not feature a runtime and is heavily restricted,
// in order to minimize the size of included code to the bare minimum to optimize testing.
#include <sof/sdk.h>
#include <intrin.h>
#define IN
#define OUT
#define INOUT
#define OPT
volatile int SwitchSelect;
__declspec(noinline) void Call0() { __nop(); }
__declspec(noinline) void Call1() { __nop(); }
__declspec(noinline) void Call2() { __nop(); }
__declspec(noinline) void Call3() { __nop(); }
__declspec(noinline) void Call4() { __nop(); }
__declspec(noinline) void Call5() { __nop(); }
__declspec(noinline) void Call9() { __nop(); }
// #pragma optimize("", off)
void MsvcX64JumptableTest() {
SingularityVirtualCodeBegin();
switch (SwitchSelect) {
case 0: Call0(); break;
case 1: Call1(); break;
case 2: Call2(); break;
case 3: Call3(); break;
case 4: Call4(); break;
case 5: Call5(); break;
default:
Call9();
}
SingularityVirtualCodeEnd();
}
#pragma optimize("", off)
int TestFunction(
IN int Argument
) {
SingularityVirtualCodeBegin();
auto Result = Argument % 2 ? Argument * 2 : 0;
SingularityVirtualCodeEnd();
return Result;
}
int TestFunction2() {
SingularityVirtualCodeBegin();
int Result = 0;
for (int i = 0; i < 5; ++i)
Result += i;
SingularityVirtualCodeEnd();
return Result;
}
int EntryPoint(
IN unsigned long long RCX,
IN unsigned long long RDX,
IN unsigned long long R8,
IN unsigned long long R9
) {
auto ReturnValue = TestFunction(1);
ReturnValue = TestFunction2();
return ReturnValue;
}
#pragma optimize("", on)