I got a minor problem with my unordered_map and I didn't found a "real" solution to it so I am asking all of you here for advice because either I'm derpin or I do something really wrong.
First, here's the precious code:
struct RedirectInfo
{
RedirectInfo(AMX_NATIVE hf) { this->orig_func = 0x0; this->hooked_func = hf; }
AMX_NATIVE orig_func;
AMX_NATIVE hooked_func;
};
std::unordered_map<std::string, std::shared_ptr<Natives::RedirectInfo>> redirected_natives;
I populate the map the following way:
const char *szNative = "somenative";
redirected_natives[szNative] = std::make_shared<RedirectInfo>(func);
Now.. I'm just using ::find to look if there's an entry and if I do some stuff... There's that code:
const char *szFuncName = "somenative";
auto it = redirected_natives.find(szFuncName);
if (it != redirected_natives.end())
{
it->second->orig_func = (AMX_NATIVE)0xDEAD; // that's also the problem ->orig_func doesn't get set!
}
So by getting the pointer to the "RedirectInfo" info I already found out that the object in the code above is located at 472cf0 but if I try to access the object with this code:
const char *szName = "somenative";
printf("%x", redirected_natives[szName]->orig_func) // <- returns 0 instead of 0xDEAD
then the value is like I said 0 and the object is offset by +4 / -4 and that's the weird part It seems like I'm accessing some other address space even tho it fetches the right values f.e. hooked_func.
I hope I explained my problem well enough for you guys. Have a nice day, and thank you in advance!
Aucun commentaire:
Enregistrer un commentaire