forked from iTruth/cheatlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheatlib_utils.h
45 lines (36 loc) · 1.33 KB
/
cheatlib_utils.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
cheatlib util moulde
Copyright (C) 2020 iTruth
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
#ifndef _H_CHEATLIB_UTILS
#define _H_CHEATLIB_UTILS
#include <windows.h>
#include <assert.h>
void IntToByte(int i, BYTE *bytes)
{
assert(bytes != NULL);
bytes[0] = (byte) (0xff & i);
bytes[1] = (byte) ((0xff00 & i) >> 8);
bytes[2] = (byte) ((0xff0000 & i) >> 16);
bytes[3] = (byte) ((0xff000000 & i) >> 24);
}
void JmpBuilder(BYTE *pCmdOutput, DWORD dwTargetAddr, DWORD dwCurrentAddr)
{
assert(pCmdOutput != NULL);
pCmdOutput[0] = 0xE9;
DWORD jmpOffset = dwTargetAddr - dwCurrentAddr - 5;
IntToByte(jmpOffset, pCmdOutput+1);
}
#endif