forked from cheat-engine/cheat-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointerscan.cu
executable file
·145 lines (108 loc) · 2.94 KB
/
pointerscan.cu
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
Pointerscan core
While the original pointerscan can run forever using recursive loops for each thread, the cuda implementation can not do that.
If a kernel does not exit within 2 seconds, it will crash. So, in order to deal with this, the recusrsive loop hase been replaced with a recursion replacement which
allows resume capability
*/
#include "cuda_runtime.h"
#include <windows.h>
#include <stdio.h>
#include "pscanfileaccess.h"
#include "cudapointervaluelist.cuh"
#define MAXCOMMANDLISTSIZE 2048
#pragma pack(16)
typedef __declspec(align(16)) struct _rcaller //recursion replacement
{
UINT_PTR valueToFind;
UINT_PTR startvalue;
UINT_PTR stopvalue;
PPointerList plist;
int plistIndex; //index in the plist to start off with
} rcaller, *prcaller;
typedef __declspec(align(16)) struct _workcommand //same as continuedata but no plist data
{
UINT_PTR valueToFind;
int level;
int *offsets;
} WorkCommand, *PWorkCommand;
__global__ void pscan(PWorkCommand queueElements, PWorkCommand staticoutputqueue, int staticoutputquesize, PWorkCommand *allocatedoutputqueue, int *allocatedoutputsize)
/*
The pointerscanner iteration
*/
{
int index = threadIdx.x;// 0; // blockIdx.x * blockDim.x + threadIdx.x;
UINT_PTR stopValue = queueElements[index].valueToFind + 4096;
PPointerList pl;
int i;
pl = findPointerValue(queueElements[index].valueToFind, &stopValue);
if (pl == NULL)
{
staticoutputqueue[index].level = 666;
staticoutputqueue[index].offsets = 0;
}
else
{
staticoutputqueue[index].level = 777;
staticoutputqueue[index].offsets = 0;
}
}
int pointerscan(UINT_PTR address, int structsize, int maxlevel)
{
PWorkCommand wc = (PWorkCommand)malloc(sizeof(WorkCommand) * 1024);
int wcsize = 1;
int i=0;
BOOL done=FALSE;
cudaError_t err;
//loop till all are done
/*
while (!done)
{
if (i%10==0)
{
int r=0;
err=cudaMemcpyToSymbol(didWork, &r, sizeof(r));
if (err!=cudaSuccess)
{
printf("CUDA error: %s\n", cudaGetErrorString(err));
break;
}
r=12;
err=cudaMemcpyFromSymbol(&r, didWork, sizeof(r));
if (err!=cudaSuccess)
{
printf("CUDA error: %s\n", cudaGetErrorString(err));
break;
}
if (r!=0)
{
printf("FAIL\n");
break;
}
}
// printf("------------SCAN %d------------------\n", i);
pscan<<<1,1024>>>(cd, structsize, 5);
cudaDeviceSynchronize();
err=cudaGetLastError();
if (err!=cudaSuccess)
{
printf("CUDA error: %s\n", cudaGetErrorString(err));
break;
}
if (i%10==0)
{
int r=0;
err=cudaMemcpyFromSymbol(&r, didWork, sizeof(r));
if (err!=cudaSuccess)
{
printf("CUDA error: %s\n", cudaGetErrorString(err));
break;
}
if (r==0)
done=TRUE;
}
i++;
}
//loop
*/
return 0;
}