-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhancement] Restore pointer after send message #1
- Loading branch information
Showing
5 changed files
with
226 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,49 @@ | ||
#include "Offsets.h" | ||
#include "Utils.h" | ||
|
||
HANDLE hProcess; | ||
uintptr_t moduleBaseAddr; | ||
uintptr_t messageCaveAddr; | ||
|
||
bool isBattlefieldChatOpen() { | ||
uintptr_t ptr = readPointer(hProcess, moduleBaseAddr, 0x39f1e50); | ||
if (ptr == 0) return false; | ||
|
||
ptr = readPointer(hProcess, ptr, 0x8); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x28); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x0); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x20); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x18); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x28); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x38); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x40); | ||
if (ptr == 0) return false; | ||
unsigned char value = readByte(hProcess, ptr, 0x30); | ||
return value == 1; | ||
} | ||
|
||
|
||
bool writeBattlefieldChatLength(int length) { | ||
uintptr_t ptr = readPointer(hProcess, moduleBaseAddr, 0x3A2CA60); | ||
if (ptr == 0) return false; | ||
|
||
ptr = readPointer(hProcess, ptr, 0x20); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x38); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x18); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x10); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x30); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x20); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0xB8); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x10); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x10); | ||
if (ptr == 0) return false; | ||
return writeLong(hProcess, ptr, 0x188, messageCaveAddr + length); | ||
bool ChatOpenPointer::refreshPointer() { | ||
pointer = baseModuleAddress; | ||
if (!offset(0x39f1e50)) return false; | ||
if (!offset(0x8)) return false; | ||
if (!offset(0x28)) return false; | ||
if (!offset(0x0)) return false; | ||
if (!offset(0x20)) return false; | ||
if (!offset(0x18)) return false; | ||
if (!offset(0x28)) return false; | ||
if (!offset(0x38)) return false; | ||
if (!offset(0x40)) return false; | ||
pointer += 0x30; | ||
return true; | ||
} | ||
|
||
bool writeBattlefieldChatPointer() { | ||
uintptr_t ptr = readPointer(hProcess, moduleBaseAddr, 0x3a327e0); | ||
if (ptr == 0) return false; | ||
|
||
ptr = readPointer(hProcess, ptr, 0x20); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x18); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x38); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x8); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x68); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0xb8); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x10); | ||
if (ptr == 0) return false; | ||
ptr = readPointer(hProcess, ptr, 0x10); | ||
if (ptr == 0) return false; | ||
return writePointer(hProcess, ptr, 0x180, messageCaveAddr); | ||
bool ChatLengthPointer::refreshPointer() { | ||
pointer = baseModuleAddress; | ||
if (!offset(0x3a327e0)) return false; | ||
if (!offset(0x20)) return false; | ||
if (!offset(0x18)) return false; | ||
if (!offset(0x38)) return false; | ||
if (!offset(0x8)) return false; | ||
if (!offset(0x68)) return false; | ||
if (!offset(0xB8)) return false; | ||
if (!offset(0x10)) return false; | ||
if (!offset(0x10)) return false; | ||
pointer += 0x188; | ||
return true; | ||
} | ||
|
||
bool writeBattlefieldChatMessage(std::string str) { | ||
return writeString(hProcess, messageCaveAddr, str.c_str(), str.size()); | ||
} | ||
bool ChatMessagePointer::refreshPointer() { | ||
pointer = baseModuleAddress; | ||
if (!offset(0x3a327e0)) return false; | ||
if (!offset(0x20)) return false; | ||
if (!offset(0x18)) return false; | ||
if (!offset(0x38)) return false; | ||
if (!offset(0x8)) return false; | ||
if (!offset(0x68)) return false; | ||
if (!offset(0xB8)) return false; | ||
if (!offset(0x10)) return false; | ||
if (!offset(0x10)) return false; | ||
pointer += 0x180; | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
#pragma once | ||
#include <string> | ||
#include <Windows.h> | ||
#include "Pointer.h" | ||
|
||
extern HANDLE hProcess; | ||
extern uintptr_t moduleBaseAddr; | ||
extern uintptr_t messageCaveAddr; | ||
|
||
bool isBattlefieldChatOpen(); | ||
bool writeBattlefieldChatLength(int length); | ||
bool writeBattlefieldChatMessage(std::string str); | ||
bool writeBattlefieldChatPointer(); | ||
class ChatOpenPointer : public Pointer { | ||
public: | ||
ChatOpenPointer() : Pointer(hProcess, moduleBaseAddr) {} | ||
bool refreshPointer(); | ||
}; | ||
|
||
class ChatLengthPointer : public Pointer { | ||
public: | ||
ChatLengthPointer() : Pointer(hProcess, moduleBaseAddr) {} | ||
bool refreshPointer(); | ||
}; | ||
|
||
class ChatMessagePointer : public Pointer { | ||
public: | ||
ChatMessagePointer() : Pointer(hProcess, moduleBaseAddr) {} | ||
bool refreshPointer(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "Pointer.h" | ||
|
||
bool Pointer::refreshPointer() { | ||
return false; | ||
} | ||
|
||
bool Pointer::readBoolean() { | ||
bool value; | ||
if (ReadProcessMemory(hProcess, (LPCVOID)pointer, &value, sizeof(value), 0)) | ||
return value; | ||
return false; | ||
} | ||
|
||
uintptr_t Pointer::readAddress() { | ||
uintptr_t value; | ||
if (ReadProcessMemory(hProcess, (LPCVOID)pointer, &value, sizeof(value), 0)) | ||
return value; | ||
return 0; | ||
} | ||
bool Pointer::writeAddress(uintptr_t address) { | ||
SIZE_T size = sizeof(address); | ||
DWORD oldprotect; | ||
if (!VirtualProtectEx(hProcess, (LPVOID)pointer, size, PAGE_EXECUTE_READWRITE, &oldprotect)) | ||
return false; | ||
if (!WriteProcessMemory(hProcess, (LPVOID)pointer, (LPCVOID)&address, size, nullptr)) | ||
return false; | ||
if (!VirtualProtectEx(hProcess, (LPVOID)pointer, size, oldprotect, &oldprotect)) | ||
return false; | ||
return true; | ||
} | ||
|
||
bool Pointer::writeStringPtr(std::string data) { | ||
uintptr_t address = readAddress(); | ||
if (address == 0) throw 1; | ||
SIZE_T size = data.size(); | ||
DWORD oldprotect; | ||
if (!VirtualProtectEx(hProcess, (LPVOID)address, size, PAGE_EXECUTE_READWRITE, &oldprotect)) | ||
return false; | ||
if (!WriteProcessMemory(hProcess, (LPVOID)address, data.c_str(), size, nullptr)) | ||
return false; | ||
if (!VirtualProtectEx(hProcess, (LPVOID)address, size, oldprotect, &oldprotect)) | ||
return false; | ||
return true; | ||
} | ||
|
||
bool Pointer::writeString(std::string data) { | ||
SIZE_T size = data.size(); | ||
DWORD oldprotect; | ||
if (!VirtualProtectEx(hProcess, (LPVOID)pointer, size, PAGE_EXECUTE_READWRITE, &oldprotect)) | ||
return false; | ||
if (!WriteProcessMemory(hProcess, (LPVOID)pointer, data.c_str(), size, nullptr)) | ||
return false; | ||
if (!VirtualProtectEx(hProcess, (LPVOID)pointer, size, oldprotect, &oldprotect)) | ||
return false; | ||
return true; | ||
} | ||
|
||
Pointer::Pointer(HANDLE pProcessHandle, uintptr_t pBaseModuleAddress) { | ||
hProcess = pProcessHandle; | ||
baseModuleAddress = pBaseModuleAddress; | ||
} | ||
|
||
bool Pointer::offset(uintptr_t offset) { | ||
pointer += offset; | ||
return (pointer = readAddress()) != 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <string> | ||
#include <cstdint> | ||
#include <Windows.h> | ||
|
||
class Pointer { | ||
public: | ||
uintptr_t pointer = 0; | ||
|
||
bool refreshPointer(); | ||
|
||
bool readBoolean(); | ||
|
||
uintptr_t readAddress(); | ||
bool writeAddress(uintptr_t address); | ||
|
||
bool writeStringPtr(std::string data); | ||
bool writeString(std::string data); | ||
|
||
Pointer(HANDLE pProcessHandle, uintptr_t pBaseModuleAddress); | ||
protected: | ||
HANDLE hProcess; | ||
uintptr_t baseModuleAddress; | ||
|
||
bool offset(uintptr_t offset); | ||
}; | ||
|