This repository has been archived by the owner on Jan 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processmemory.h
132 lines (119 loc) · 4.5 KB
/
processmemory.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
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
#ifndef PROCESSMEMORY_H
#define PROCESSMEMORY_H
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <conio.h>
#include <iostream>
#include <winsock2.h>
#include <time.h>
#include <fstream>
#include <string>
#include <vector>
#include < extdll.h >
#include "addresses.h"
// Stack of integers. This is the class definition.
class _memStack {
// Node structure.
struct node {
int val; // Data in this node.
node *next; // Next node.
// Construct a newly-created node.
node(int v, node *n) { val = v; next = n; }
// Delete all the nodes.
void killall() {
if(next) next->killall();
delete this;
}
// Print all the nodes.
void printall(std::ostream &strm) {
strm << val << " ";
if(next) next->printall(strm);
}
} *head;
public:
// Nice new empty.
_memStack() { head = 0; }
// Make it go away.
~_memStack() { if(head != 0) head->killall(); }
// Operations.
bool empty() const { return head == 0; }
void push(int i) { head = new node(i, head); }
int pop() { return 0; };
int top() const { return head->val; }
// Print contents
void print(std::ostream &) const;
};
//If we're defining global vars, make sure they're defined as extern and then define them once in the CPP file.
extern int _memCurrent;
/*
BYTE ReadByte(DWORD Address);
double ReadDouble(DWORD Address);
int ReadInt(DWORD Address);
void WriteInProcessByte(DWORD Address, BYTE Value);
FLOAT ReadFloat(DWORD Address);
void WriteInProcessFloat(DWORD Address, FLOAT Value);
void WriteInProcessDouble(DWORD Address, DOUBLE Value);
void WriteInProcessInt32(DWORD Address, INT32 Value);
void WriteInProcessChar(DWORD Address, char* Value);
//New
void WriteInt32(DWORD Address, UINT32 Value);
UINT32 ReadInt32(DWORD Address);
*/
BYTE Read(DWORD address, int length);
std::string ReadCharArray(DWORD Address, int length);
void WriteCharArray(DWORD Address, char *string, bool ZeroTheEnd);
//enums
/*
BYTE memGetByte(int ptr);
BYTE memGetInt(int ptr);
FLOAT memGetFloat(int ptr);
std::string memGetCharArray(int ptr);
void WriteMem(DWORD dwOffset, DWORD dwValue, int len);
//end of enums
//stacks
void memSetPtr(int ptr);
int memGetPtr();
void memOpen(int ptr);
void memClose();
*/
#define ReadByte(Address) *(BYTE*)(Address)
#define WriteInProcessByte(Address, Value) *(BYTE*)(Address) = Value
#define WriteInProcessFloat(Address, Value) *(FLOAT*)(Address) = Value
#define WriteInProcessDouble(Address, Value) *(DOUBLE*)(Address) = Value
#define WriteInProcessInt32(Address, Value) *(INT32*)(Address) = Value //typecast variable to a pointer of a byte and dereference the pointer, letting you change what it holds
#define WriteInProcessChar(Address, Value) *(char*)(Address) = Value
#define ReadFloat(Address) *(FLOAT*)(Address)
#define ReadDouble(Address) *(double*)(Address)
#define ReadInt(Address) *(UINT*)(Address)
//New
#define ReadInt32(Address) *(UINT32*)(Address)
#define WriteInt32(Address, Value) *(UINT32*)(Address) = Value //typecast variable to a pointer of a byte and dereference the pointer, letting you change what it holds
#define memGetByte(ptr) ReadByte((_memCurrent + ptr))
#define memGetInt(ptr) ReadInt32((_memCurrent + ptr))
#define memGetCharArray(ptr) ReadCharArray((_memCurrent + ptr), 512)
#define memGetFloat(ptr) ReadByte((_memCurrent + ptr))
//end of enums
//stack
#define memSetPtr(ptr) _memCurrent = ptr
#define memGetPtr() _memCurrent
//WRITE_BYTE, ETC
void WRITE_BYTE(int value);
void WRITE_SHORT(int value);
void WRITE_LONG(int value);
void WRITE_CHAR(int value);
void WRITE_COORD(float value);
void WRITE_ANGLE(Vector value);
void WRITE_STRING(char *value);
void WRITE_ENTITY(int value);
void MESSAGE_BEGIN(int edictptr, int unknown, int msgtype, int towho);
//int UserMessageBegin(int edictptr, int broadcast, int unknown2, char* msgtype);
int UserMessageBegin(int towho, char* msgtype);
void MESSAGE_END();
//Signed, unsigned fixes..
unsigned short FixedUnsigned16( float value, float scale );
short FixedSigned16(float value, float scale);
//cmd's
//BYTE cmdGive = {0xA1, 0x38, 0x2E, 0xB8, 0x44, 0x5, 0x78, 0x4B, 0x0, 0x0, 0x8B, 0x8, 0x8B, 0x89, 0x1C, 0x1, 0x0, 0x0, 0x68, 0x3C, 0x2E, 0xB8, 0x44, 0xE8, 0xDF, 0x6, 0xFC, 0xFE, 0xC7, 0x5, 0x34, 0x2E, 0xB8, 0x44, 0x0, 0x0, 0x0, 0x0, 0x61, 0xC3};
#endif