Created
November 22, 2014 14:58
-
-
Save SemenMartynov/b73785ae4dbf8f8fa34e to your computer and use it in GitHub Desktop.
Evgeny Golovachyov
This file contains hidden or 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
// Evgeny Golovachyov | |
#include <string> | |
#include <utility> | |
typedef std::pair<std::string, int> Obj; | |
int main() { | |
using namespace std; | |
Obj object("Ololo", 1234); | |
int* ptr = &object.second; | |
char* OrigSecBytes = reinterpret_cast<char*>(ptr); | |
Obj* FakeObjPtr = reinterpret_cast<Obj*>(ptr); | |
char* FakeObjBytes = reinterpret_cast<char*>(FakeObjPtr); | |
int* FakeSecPtr = &FakeObjPtr->second; | |
char* FakeSecBytes = reinterpret_cast<char*>(FakeSecPtr); | |
unsigned int offset = FakeSecBytes - FakeObjBytes; | |
Obj* OrigObjPtr = reinterpret_cast<Obj*>(OrigSecBytes - offset); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment