Error C2440

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
#include "PatternFind.h"
 
unsigned int ulMissGodmode;
unsigned int ulFullGodmode;
 
void InitializeTrainer(HINSTANCE hInstance)
{
    PFSEARCH pf; // This is the pattern search struct
    LPVOID lpvMapleBase = NULL;
    DWORD dwMapleSize = 0;
 
    DisableThreadLibraryCalls(hInstance);
    GetModuleSize(GetModuleHandle(NULL), &lpvMapleBase, &dwMapleSize); // Obtain Maple base address & size
 
    FindPattern("8b 9c 24 ? 00 00 00 85 db 7f ? 8d", &pf, lpvMapleBase, dwMapleSize); // Perform search
    ulMissGodmode = pf.lpvResult; // The result is stored in the struct
    FindPattern("0F 85 ? ? 00 00 8B 86 ? ? ? ? 83 E0 FE 83 F8 12 0F 84 ? ? 00 00 E8 ? ? ? ? 8B F8", &pf, lpvMapleBase, dwMapleSize);
    ulFullGodmode = pf.lpvResult;
}
 
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fwdreason, LPVOID /*lpvReserved*/)
{
    switch (fwdreason){
        case DLL_PROCESS_ATTACH:
            CreateThread(NULL, 0,
                reinterpret_cast<LPTHREAD_START_ROUTINE>(InitializeTrainer),
                reinterpret_cast<LPVOID>(hInstance), 0, 0);
            break;
 
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}

PatternFind.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
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
#include "PatternFind.h"

#include <dbghelp.h>
#include <psapi.h>
#pragma  comment(lib, "dbghelp")
#pragma  comment(lib, "psapi")

BOOL GetModuleSize(HMODULE hModule, LPVOID* lplpBase, LPDWORD lpdwSize) {
	if (hModule == GetModuleHandle(NULL)) {
		PIMAGE_NT_HEADERS pImageNtHeaders = ImageNtHeader((PVOID)hModule);

		if (pImageNtHeaders == NULL)
			return FALSE;

		*lplpBase = (LPVOID)hModule;
		*lpdwSize = pImageNtHeaders->OptionalHeader.SizeOfImage;
	} else {
		MODULEINFO  ModuleInfo;

		if (!GetModuleInformation(GetCurrentProcess(), hModule, &ModuleInfo, sizeof(MODULEINFO)))
			return FALSE;

		*lplpBase = ModuleInfo.lpBaseOfDll;
		*lpdwSize = ModuleInfo.SizeOfImage;
	}
	return TRUE;
}

DWORD PFAPI GetPatternCB(char *szPattern) {
	DWORD cb = 0;
	bool first_nibble = false;
	for (DWORD i=0; i<strlen(szPattern); i++) {
		char c = toupper(szPattern[i]);
		if (c != ' ') {
			if (c == '?') {
				if (!first_nibble) cb++;
				else return 0;
			} else {
				if (!isxdigit(c)) return 0;
				if (first_nibble) cb++;
				first_nibble ^= true;
			}
		}
	}
	if (first_nibble) return 0;
	return cb;
}

BOOL PFAPI GeneratePatternMask(char *szPattern, char *buffer) {
	bool first_nibble = false;
	for (DWORD i=0; i<strlen(szPattern); i++) {
		char c = toupper(szPattern[i]);
		if (c != ' ') {
			if (c == '?') {
				if (!first_nibble) strcat_s(buffer, MAX_PATTERN, "?");
				else return FALSE;
			} else {
				if (!isxdigit(c)) return FALSE;
				if (first_nibble) strcat_s(buffer, MAX_PATTERN, "x");
				first_nibble ^= true;
			}
		}
	}
	if (first_nibble) return FALSE;
	return TRUE;
}

BOOL PFAPI GeneratePatternBytes(char *szPattern, LPBYTE buffer) {
	bool first_nibble = false;
	DWORD cb = 0;
	for (DWORD i=0; i<strlen(szPattern); i++) {
		char c = toupper(szPattern[i]);
		if (c != ' ') {
			if (c == '?') {
				if (!first_nibble) {
					buffer[cb] = 0x00;
					cb++;
				}
				else return FALSE;
			} else {
				if (!isxdigit(c)) return FALSE;
				if (first_nibble) {
					char byte[3] = {0};
					byte[0] = szPattern[i-1];
					byte[1] = c;
					byte[2] = '\0';
					buffer[cb] = (BYTE)strtol(byte, NULL, 16);
					cb++;
				}
				first_nibble ^= true;
			}
		}
	}
	if (first_nibble) return FALSE;
	return TRUE;
}

VOID PFAPI SearchPattern(PFSEARCH *ppf, LPVOID lpvBase, DWORD dwSize) {
	ppf->lpvResult = 0;
	DWORD dwBase = reinterpret_cast<DWORD>(lpvBase);
	for (DWORD i=dwBase; i<dwBase+dwSize; i++) {
		bool found = true;
		for (DWORD j=0; j<ppf->dwLength; j++) {
			if (ppf->szMask[j] == 'x') {
				if (*reinterpret_cast<BYTE*>(i+j) != ppf->lpbData[j]) {
					found = false;
					break;
				}
			}
		}
		if (found) {
			ppf->lpvResult = reinterpret_cast<LPVOID>(i);
			return;
		}
	}
}

DWORD PFAPI FindPattern(char *szPattern, PFSEARCH *ppf, LPVOID lpvBase, DWORD dwSize) {
	ZeroMemory(ppf, sizeof(PFSEARCH));
	bool invalid = false;

	ppf->dwLength = GetPatternCB(szPattern);
	invalid = invalid || !ppf->dwLength;
	invalid = invalid || !GeneratePatternMask(szPattern, ppf->szMask);
	invalid = invalid || !GeneratePatternBytes(szPattern, ppf->lpbData);

	if (invalid)
		return PF_INVALID;

	if (ppf->dwLength > MAX_PATTERN)
		return PF_OVERFLOW;

	SearchPattern(ppf, lpvBase, dwSize);
	if (!ppf->lpvResult)
		return PF_NOT_FOUND;

	return PF_NONE;
}


PatternFind.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <Windows.h>




#define PFAPI __stdcall
#define MAX_PATTERN 255

#define PF_NONE 0
#define PF_INVALID 1
#define PF_NOT_FOUND 2
#define PF_OVERFLOW 3

struct PFSEARCH {
	DWORD dwLength;
	char szMask[MAX_PATTERN+1];
	BYTE lpbData[MAX_PATTERN];
	LPVOID lpvResult;
};

BOOL GetModuleSize(HMODULE hModule, LPVOID* lplpBase, LPDWORD lpdwSize);
DWORD PFAPI FindPattern(char *szPattern, PFSEARCH *ppf, LPVOID lpvBase, DWORD dwSize);


I got this Error please help me
1
2
3
4
5
Mian.cpp(16): error C2440: '=' : cannot convert from 'LPVOID' to 'unsigned int'
1>          There is no context in which this conversion is possible
1>Mian.cpp(18): error C2440: '=' : cannot convert from 'LPVOID' to 'unsigned int'
1>          There is no context in which this conversion is possible
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
Show declaration of FindPattern
Topic archived. No new replies allowed.