пофиксите код пж
(это нейронка писала поэтому комментарии есть)
если это пздц то сори тапки не кидайте пжпжпж
(это нейронка писала поэтому комментарии есть)
C++:
/*
* CS2 Inventory Changer DLL
* Basic template for adding items to CS2 inventory
* NOTE: This is a template with placeholder values
* You MUST replace all placeholder values with actual memory addresses from your CS2 version
*/
#include <windows.h>
#include <vector>
#include <string>
#include <memoryapi.h>
#include <psapi.h>
// Placeholder values - REPLACE THESE WITH ACTUAL VALUES FROM YOUR GAME VERSION
namespace Placeholders {
// Inventory structure offsets from real CS2 dump
// CCSPlayerController_InventoryServices offsets
const uintptr_t INVENTORY_BASE_OFFSET = 0x40; // m_vecNetworkableLoadout offset
const uintptr_t ITEM_LIST_OFFSET = 0x210; // m_AttributeList offset in C_EconItemView
const uintptr_t ITEM_COUNT_OFFSET = 0x88; // m_vecServerAuthoritativeWeaponSlots offset
// Function signatures from real CS2 (Windows server)
// CCSPlayer_ItemServices::GiveNamedItem - for adding items to inventory
const char* ADD_ITEM_SIGNATURE = "48 89 5C 24 08 48 89 74 24 10 48 89 7C 24 20 44 89 44 24 18";
// CCSPlayerInventory::SendInventoryUpdateEvent - for updating inventory display
const char* INVENTORY_UPDATE_SIGNATURE = "83 79 ? ? 0F 10 49";
// Item structure size from real CS2 (C_EconItemView size)
const int ITEM_STRUCT_SIZE = 0x4C8; // Full size of C_EconItemView structure
}
// Memory utilities
class MemoryHelper {
public:
static uintptr_t FindPattern(const char* moduleName, const char* pattern) {
// This is a basic pattern scanner - you may need to improve it
HMODULE hModule = GetModuleHandleA(moduleName);
if (!hModule) return 0;
MODULEINFO moduleInfo;
GetModuleInformation(GetCurrentProcess(), hModule, &moduleInfo, sizeof(moduleInfo));
uintptr_t start = (uintptr_t)moduleInfo.lpBaseOfDll;
uintptr_t end = start + moduleInfo.SizeOfImage;
const char* pat = pattern;
uintptr_t firstMatch = 0;
for (uintptr_t pCur = start; pCur < end; pCur++) {
if (!*pat) return firstMatch;
if (*(PBYTE)pat == '\?' || *(BYTE*)pCur == GetByte(pat)) {
if (!firstMatch) firstMatch = pCur;
if (!pat[1] || !pat[2]) return firstMatch;
if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') pat += 3;
else pat += 2;
} else {
pat = pattern;
firstMatch = 0;
}
}
return 0;
}
static uintptr_t FindDMAAddy(uintptr_t ptr, std::vector<unsigned int> offsets) {
uintptr_t addr = ptr;
for (unsigned int i = 0; i < offsets.size(); ++i) {
addr = *(uintptr_t*)addr;
addr += offsets[i];
}
return addr;
}
private:
static BYTE GetByte(const char* pattern) {
return (BYTE)strtoul(pattern, nullptr, 16);
}
};
// Inventory item structure (example - adjust according to actual game structure)
struct InventoryItem {
int itemId;
int paintId;
int rarity;
int quality;
float wear;
char name[64];
// Add more fields as needed
};
// Main inventory changer class
class CS2InventoryChanger {
private:
uintptr_t gameModuleBase;
uintptr_t inventoryBase;
uintptr_t itemListAddress;
uintptr_t itemCountAddress;
// Function pointers (placeholders)
typedef bool(__cdecl* AddItemFunc)(int itemId, int paintId, float wear);
AddItemFunc addItemFunc = nullptr;
typedef void(__cdecl* UpdateInventoryFunc)();
UpdateInventoryFunc updateInventoryFunc = nullptr;
public:
CS2InventoryChanger() {
gameModuleBase = (uintptr_t)GetModuleHandleA("client.dll");
if (!gameModuleBase) {
MessageBoxA(nullptr, "Failed to find client.dll", "Error", MB_OK);
return;
}
// Initialize function pointers (replace signatures with actual ones)
addItemFunc = (AddItemFunc)MemoryHelper::FindPattern("client.dll", Placeholders::ADD_ITEM_SIGNATURE);
updateInventoryFunc = (UpdateInventoryFunc)MemoryHelper::FindPattern("client.dll", Placeholders::INVENTORY_UPDATE_SIGNATURE);
if (!addItemFunc || !updateInventoryFunc) {
MessageBoxA(nullptr, "Failed to find required functions", "Error", MB_OK);
}
}
bool AddItemToInventory(int itemId, int paintId = 0, float wear = 0.01f) {
if (!addItemFunc) return false;
// Call the game's add item function
bool result = addItemFunc(itemId, paintId, wear);
// Update inventory to reflect changes
if (updateInventoryFunc && result) {
updateInventoryFunc();
}
return result;
}
// Alternative method using direct memory manipulation
bool AddItemDirect(int itemId, int paintId = 0, float wear = 0.01f) {
if (!gameModuleBase) return false;
// Find inventory addresses (replace offsets with actual ones)
inventoryBase = MemoryHelper::FindDMAAddy(gameModuleBase + Placeholders::INVENTORY_BASE_OFFSET, {0});
itemListAddress = MemoryHelper::FindDMAAddy(inventoryBase + Placeholders::ITEM_LIST_OFFSET, {0});
itemCountAddress = MemoryHelper::FindDMAAddy(inventoryBase + Placeholders::ITEM_COUNT_OFFSET, {0});
if (!itemListAddress || !itemCountAddress) return false;
// Get current item count
int currentCount = *(int*)itemCountAddress;
// Create new item (this is a simplified example)
InventoryItem newItem;
newItem.itemId = itemId;
newItem.paintId = paintId;
newItem.rarity = 1; // Example rarity
newItem.quality = 0; // Normal quality
newItem.wear = wear;
sprintf_s(newItem.name, "Item %d", itemId);
// Write new item to memory (this is a simplified approach)
uintptr_t newItemAddress = itemListAddress + (currentCount * Placeholders::ITEM_STRUCT_SIZE);
memcpy((void*)newItemAddress, &newItem, sizeof(InventoryItem));
// Update item count
*(int*)itemCountAddress = currentCount + 1;
return true;
}
};
// DLL exports
extern "C" {
__declspec(dllexport) void __cdecl Initialize() {
// Initialize the inventory changer
static CS2InventoryChanger changer;
}
__declspec(dllexport) void __cdecl AddItem(int itemId, int paintId, float wear) {
static CS2InventoryChanger changer;
changer.AddItemToInventory(itemId, paintId, wear);
}
__declspec(dllexport) void __cdecl AddItemDirect(int itemId, int paintId, float wear) {
static CS2InventoryChanger changer;
changer.AddItemDirect(itemId, paintId, wear);
}
}
// DLL entry point
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
// Initialize when DLL is loaded
Initialize();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
