-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.cpp
More file actions
95 lines (95 loc) · 2.19 KB
/
Copy pathcode.cpp
File metadata and controls
95 lines (95 loc) · 2.19 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<Windows.h>
#include<iostream>
using namespace std;
int p[100][100] = { 0 };
int sum = 0;
int dp[100][100];
void Decrypt(char *ptr,int Size,int code)
{
MEMORY_BASIC_INFORMATION mbi_thunk;
VirtualQuery(ptr, &mbi_thunk, sizeof(MEMORY_BASIC_INFORMATION));
VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, PAGE_EXECUTE_READWRITE, &mbi_thunk.Protect);
while (Size--)
{
*ptr = (*ptr) ^ code;
++ptr;
}
DWORD dwOldProtect;
VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize, mbi_thunk.Protect, &dwOldProtect);
}
void then(char *step)
{
int address1, address2;
__asm
{
mov address1,offset begindecrypt
mov address2,offset enddecrypt
}
bool bSucceed = 0;
int Size = address2 - address1;
char *ptr = (char *)address1;
Decrypt(ptr, Size,4);
__asm inc eax
__asm dec eax
begindecrypt://--------------------------------
for (int i = 0;i < 19;++i)
{
if(i%2)
step[i] ^= 4;
}
enddecrypt://----------------------------------
__asm inc eax
__asm dec eax
Decrypt(ptr, Size, 4);
return;
}
int main()
{
srand(0xc);
memset(dp, 0, sizeof(dp));
char step[100];
int i, j;
for (i = 1;i <= 20;++i)
{
for (j = 1;j <= i;++j)
{
p[i][j] = rand() % 100000;
}
}
printf("input your key with your operation can get the maximum:");
scanf("%s", step);
if (strlen(step) != 19)
{
printf("error\n");
system("pause");
return 0;
}
then(step);
int time = 0;
i = j = 1;
sum = sum + p[i][j];
while (time<19)
{
if (step[time] == 'L')
{
sum = sum + p[++i][j];
}
else if (step[time] == 'R')
{
sum = sum + p[++i][++j];
}
else
{
printf("error\n");
system("pause");
return 0;
}
time++;
}
printf("your operation can get %d points\n", sum);
system("pause");
return 0;
}