示例#1
0
void CUtil::GetOffset(std::string name, HMODULE hModule, std::string pattern, std::string mask, DWORD offset) {

	pattern.erase(std::remove(pattern.begin(), pattern.end(), ' '), pattern.end());
	unsigned char byte_array[2048];
	HexStrToByteArray(pattern.c_str(), byte_array, 2048);
	DWORD objManager = this->FindPattern((DWORD)hModule, this->GetModuleInfo(hModule).SizeOfImage, byte_array, (char*)mask.c_str());
	objManager = (*((DWORD*)(objManager + offset))) - (DWORD)this->GetLOLBaseAddress();
	std::stringstream buffer;
	buffer << name << ": 0x" << std::hex << objManager << std::endl;
	this->AddLog((char*)buffer.str().c_str());
	//memset(&byte_array[0], 0, sizeof(byte_array));
}
void Battlenet::ModuleManager::Load()
{
    QueryResult result = LoginDatabase.Query("SELECT `Hash`, `Name`, `Type`, `System`, `Data` FROM battlenet_modules");
    if (result)
    {
        do
        {
            Field* fields = result->Fetch();
            ModuleInfo* module = new ModuleInfo();
            module->Type = fields[2].GetString();
            HexStrToByteArray(fields[0].GetString(), module->ModuleId);
            std::string data = fields[4].GetString();
            module->DataSize = data.length() / 2;
            if (module->DataSize)
            {
                module->Data = new uint8[data.length() / 2];
                HexStrToByteArray(data, module->Data);
            }

            _modules[{ fields[3].GetString(), fields[1].GetString() }] = module;
        } while (result->NextRow());
    }
}