- 2
- 0
- Версия SA-MP
-
- 0.3.7-R2
Привет, я использую Google Translate.
Я попытался заставить GPCI работать на R2 независимо от sampfuncs и moonloader.
code:
// HWID_GPCI.asi plugin for SA-MP R2 using real GPCI logic (SHA1 + bit mutation + ttmath)
// No MoonLoader, No SAMPFUNCS - Standalone spoof on game startup
#include <windows.h>
#include <string>
#include <sstream>
#include <fstream>
#include <ctime>
#include <objbase.h>
#include <ttmath/ttmath.h>
const DWORD GPCI_MEMORY = 0xC906AC; // SA-MP R2 GPCI buffer
const size_t GPCI_LENGTH = 46;
const char* CONFIG_FILE = "gpci_config.txt";
#define ROTL(x,y) (((x) <<
) | ((x) >> (32-
)))
typedef struct {
unsigned int h0, h1, h2, h3, h4;
unsigned int lcount;
unsigned int hcount;
unsigned char block[64];
unsigned int block_index;
bool computed;
bool corrupted;
} SHA1Context_;
class CSHA1_ : public SHA1Context_ {
public:
CSHA1_() { Reset(); }
void Reset() {
lcount = hcount = block_index = 0;
h0 = 0x67452301; h1 = 0xEFCDAB89; h2 = 0x98BADCFE; h3 = 0x10325476; h4 = 0xC3D2E1F0;
computed = corrupted = false;
}
void Transform();
void Final();
bool GetHash(unsigned int* states);
void Update(unsigned char* data, unsigned int length);
void Update(char* data, int len) { Update((unsigned char*)data, len); }
};
void CSHA1_::Transform() {
unsigned int a, b, c, d, e, i, t, w[80] = {0};
for (i = 0; i < 16; i++) w = (block[i*4]<<24)|(block[i*4+1]<<16)|(block[i*4+2]<<8)|block[i*4+3];
for (i = 16; i < 80; i++) w = ROTL(w[i-3]^w[i-8]^w[i-14]^w[i-16], 1);
a = h0; b = h1; c = h2; d = h3; e = h4;
for (i = 0; i < 80; i++) {
if (i<20) t = ROTL(a,5) + ((b&c)|((~b)&d)) + e + w + 0x5A827999;
else if (i<40) t = ROTL(a,5) + (b^c^d) + e + w + 0x6ED9EBA1;
else if (i<60) t = ROTL(a,5) + ((b&c)|(b&d)|(c&d)) + e + w + 0x8F1BBCDC;
else t = ROTL(a,5) + (b^c^d) + e + w + 0xCA62C1D6;
e = d; d = c; c = ROTL(b,30); b = a; a = t;
}
h0 += a; h1 += b; h2 += c; h3 += d; h4 += e;
block_index = 0;
}
void CSHA1_::Final() {
block[block_index++] = 0x80;
while (block_index != 56 && block_index < 64) block[block_index++] = 0;
if (block_index >= 64) { Transform(); while (block_index < 56) block[block_index++] = 0; }
block[56] = hcount >> 24; block[57] = hcount >> 16; block[58] = hcount >> 8; block[59] = hcount;
block[60] = lcount >> 24; block[61] = lcount >> 16; block[62] = lcount >> 8; block[63] = lcount;
Transform();
}
bool CSHA1_::GetHash(unsigned int* states) {
if (corrupted) return 0;
if (!computed) { Final(); computed = true; }
states[0]=h0; states[1]=h1; states[2]=h2; states[3]=h3; states[4]=h4; return 1;
}
void CSHA1_::Update(unsigned char* data, unsigned int len) {
if (computed || corrupted) { corrupted = true; return; }
while (len-- && !corrupted) {
block[block_index++] = *data++; lcount += 8;
if (lcount == 0) if (++hcount == 0) corrupted = true;
if (block_index == 64) Transform();
}
}
char bits_to_char(unsigned char b) {
char c = b + 0x30; return (c > 0x39) ? (b + 0x37) : c;
}
void bytes_to_string(char* output, unsigned char* state_input) {
for (int x = 0; x < 20; x++) {
output[x*2] = bits_to_char(state_input[x] >> 4);
output[x*2+1] = bits_to_char(state_input[x] & 0xF);
}
output[40] = '\0';
}
std::string GenerateRealGPCI(const std::string& seed, int unk) {
unsigned int states[5] = {0};
unsigned char* state_bytes;
char result[44];
CSHA1_ sha1;
sha1.Update((char*)seed.c_str(), seed.length());
sha1.GetHash(states);
state_bytes = (unsigned char*)states;
BYTE b0, b1, b2, b3;
for (int i = 0; i < 20; i++) {
b0 = state_bytes & 3; b1 = (state_bytes >> 2) & 3;
b2 = (b0 <= b1) ? (b0 | 4 * b1) : (b1 | 4 * b0);
b0 = (state_bytes >> 4) & 3; b1 = state_bytes >> 6;
b3 = (b0 <= b1) ? (b0 | 4 * b1) : (b1 | 4 * b0);
state_bytes = b2 | 16 * b3;
}
bytes_to_string(result, state_bytes);
ttmath::UInt<100> m; m.FromString(result, 16); m.MulInt(unk);
return m.ToString(16);
}
std::string GenerateUUID() {
UUID uuid; UuidCreate(&uuid);
char buffer[37];
snprintf(buffer, sizeof(buffer), "%08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X",
uuid.Data1, uuid.Data2, uuid.Data3,
(uuid.Data4[0] << 8) | uuid.Data4[1],
uuid.Data4[2], uuid.Data4[3], uuid.Data4[4],
uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]);
return std::string(buffer);
}
void PatchGPCIMemory(const std::string& hwid) {
for (size_t i = 0; i < hwid.size() && i < GPCI_LENGTH; ++i)
*(BYTE*)(GPCI_MEMORY + i) = hwid;
for (size_t i = hwid.size(); i < GPCI_LENGTH; ++i)
*(BYTE*)(GPCI_MEMORY + i) = 0;
}
void LogToFile(const std::string& msg) {
std::ofstream log("gpci_log.txt", std::ios::app);
if (log.is_open()) {
time_t now = time(0); tm* t = localtime(&now);
log << "[" << 1900 + t->tm_year << "/" << 1 + t->tm_mon << "/" << t->tm_mday
<< " " << t->tm_hour << ":" << t->tm_min << ":" << t->tm_sec << "] ";
log << msg << "\n"; log.close();
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
std::ifstream file(CONFIG_FILE);
std::string hwid;
if (file.is_open()) { std::getline(file, hwid); file.close(); }
if (hwid.empty()) {
std::string uuid = GenerateUUID();
hwid = GenerateRealGPCI(uuid, 1);
std::ofstream save(CONFIG_FILE); if (save.is_open()) { save << hwid; save.close(); }
LogToFile("Generated new GPCI: " + hwid);
}
PatchGPCIMemory(hwid);
LogToFile("Patched GPCI in memory: " + hwid);
}
return TRUE;
}
да, это сделано с помощью chatgpt, если вам интересно, но в чем проблема, почему у меня не работает gpci?
Я попытался заставить GPCI работать на R2 независимо от sampfuncs и moonloader.
code:
// HWID_GPCI.asi plugin for SA-MP R2 using real GPCI logic (SHA1 + bit mutation + ttmath)
// No MoonLoader, No SAMPFUNCS - Standalone spoof on game startup
#include <windows.h>
#include <string>
#include <sstream>
#include <fstream>
#include <ctime>
#include <objbase.h>
#include <ttmath/ttmath.h>
const DWORD GPCI_MEMORY = 0xC906AC; // SA-MP R2 GPCI buffer
const size_t GPCI_LENGTH = 46;
const char* CONFIG_FILE = "gpci_config.txt";
#define ROTL(x,y) (((x) <<
typedef struct {
unsigned int h0, h1, h2, h3, h4;
unsigned int lcount;
unsigned int hcount;
unsigned char block[64];
unsigned int block_index;
bool computed;
bool corrupted;
} SHA1Context_;
class CSHA1_ : public SHA1Context_ {
public:
CSHA1_() { Reset(); }
void Reset() {
lcount = hcount = block_index = 0;
h0 = 0x67452301; h1 = 0xEFCDAB89; h2 = 0x98BADCFE; h3 = 0x10325476; h4 = 0xC3D2E1F0;
computed = corrupted = false;
}
void Transform();
void Final();
bool GetHash(unsigned int* states);
void Update(unsigned char* data, unsigned int length);
void Update(char* data, int len) { Update((unsigned char*)data, len); }
};
void CSHA1_::Transform() {
unsigned int a, b, c, d, e, i, t, w[80] = {0};
for (i = 0; i < 16; i++) w = (block[i*4]<<24)|(block[i*4+1]<<16)|(block[i*4+2]<<8)|block[i*4+3];
for (i = 16; i < 80; i++) w = ROTL(w[i-3]^w[i-8]^w[i-14]^w[i-16], 1);
a = h0; b = h1; c = h2; d = h3; e = h4;
for (i = 0; i < 80; i++) {
if (i<20) t = ROTL(a,5) + ((b&c)|((~b)&d)) + e + w + 0x5A827999;
else if (i<40) t = ROTL(a,5) + (b^c^d) + e + w + 0x6ED9EBA1;
else if (i<60) t = ROTL(a,5) + ((b&c)|(b&d)|(c&d)) + e + w + 0x8F1BBCDC;
else t = ROTL(a,5) + (b^c^d) + e + w + 0xCA62C1D6;
e = d; d = c; c = ROTL(b,30); b = a; a = t;
}
h0 += a; h1 += b; h2 += c; h3 += d; h4 += e;
block_index = 0;
}
void CSHA1_::Final() {
block[block_index++] = 0x80;
while (block_index != 56 && block_index < 64) block[block_index++] = 0;
if (block_index >= 64) { Transform(); while (block_index < 56) block[block_index++] = 0; }
block[56] = hcount >> 24; block[57] = hcount >> 16; block[58] = hcount >> 8; block[59] = hcount;
block[60] = lcount >> 24; block[61] = lcount >> 16; block[62] = lcount >> 8; block[63] = lcount;
Transform();
}
bool CSHA1_::GetHash(unsigned int* states) {
if (corrupted) return 0;
if (!computed) { Final(); computed = true; }
states[0]=h0; states[1]=h1; states[2]=h2; states[3]=h3; states[4]=h4; return 1;
}
void CSHA1_::Update(unsigned char* data, unsigned int len) {
if (computed || corrupted) { corrupted = true; return; }
while (len-- && !corrupted) {
block[block_index++] = *data++; lcount += 8;
if (lcount == 0) if (++hcount == 0) corrupted = true;
if (block_index == 64) Transform();
}
}
char bits_to_char(unsigned char b) {
char c = b + 0x30; return (c > 0x39) ? (b + 0x37) : c;
}
void bytes_to_string(char* output, unsigned char* state_input) {
for (int x = 0; x < 20; x++) {
output[x*2] = bits_to_char(state_input[x] >> 4);
output[x*2+1] = bits_to_char(state_input[x] & 0xF);
}
output[40] = '\0';
}
std::string GenerateRealGPCI(const std::string& seed, int unk) {
unsigned int states[5] = {0};
unsigned char* state_bytes;
char result[44];
CSHA1_ sha1;
sha1.Update((char*)seed.c_str(), seed.length());
sha1.GetHash(states);
state_bytes = (unsigned char*)states;
BYTE b0, b1, b2, b3;
for (int i = 0; i < 20; i++) {
b0 = state_bytes & 3; b1 = (state_bytes >> 2) & 3;
b2 = (b0 <= b1) ? (b0 | 4 * b1) : (b1 | 4 * b0);
b0 = (state_bytes >> 4) & 3; b1 = state_bytes >> 6;
b3 = (b0 <= b1) ? (b0 | 4 * b1) : (b1 | 4 * b0);
state_bytes = b2 | 16 * b3;
}
bytes_to_string(result, state_bytes);
ttmath::UInt<100> m; m.FromString(result, 16); m.MulInt(unk);
return m.ToString(16);
}
std::string GenerateUUID() {
UUID uuid; UuidCreate(&uuid);
char buffer[37];
snprintf(buffer, sizeof(buffer), "%08X-%04X-%04X-%04X-%02X%02X%02X%02X%02X%02X",
uuid.Data1, uuid.Data2, uuid.Data3,
(uuid.Data4[0] << 8) | uuid.Data4[1],
uuid.Data4[2], uuid.Data4[3], uuid.Data4[4],
uuid.Data4[5], uuid.Data4[6], uuid.Data4[7]);
return std::string(buffer);
}
void PatchGPCIMemory(const std::string& hwid) {
for (size_t i = 0; i < hwid.size() && i < GPCI_LENGTH; ++i)
*(BYTE*)(GPCI_MEMORY + i) = hwid;
for (size_t i = hwid.size(); i < GPCI_LENGTH; ++i)
*(BYTE*)(GPCI_MEMORY + i) = 0;
}
void LogToFile(const std::string& msg) {
std::ofstream log("gpci_log.txt", std::ios::app);
if (log.is_open()) {
time_t now = time(0); tm* t = localtime(&now);
log << "[" << 1900 + t->tm_year << "/" << 1 + t->tm_mon << "/" << t->tm_mday
<< " " << t->tm_hour << ":" << t->tm_min << ":" << t->tm_sec << "] ";
log << msg << "\n"; log.close();
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
std::ifstream file(CONFIG_FILE);
std::string hwid;
if (file.is_open()) { std::getline(file, hwid); file.close(); }
if (hwid.empty()) {
std::string uuid = GenerateUUID();
hwid = GenerateRealGPCI(uuid, 1);
std::ofstream save(CONFIG_FILE); if (save.is_open()) { save << hwid; save.close(); }
LogToFile("Generated new GPCI: " + hwid);
}
PatchGPCIMemory(hwid);
LogToFile("Patched GPCI in memory: " + hwid);
}
return TRUE;
}
да, это сделано с помощью chatgpt, если вам интересно, но в чем проблема, почему у меня не работает gpci?
Последнее редактирование: