#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <sys/time.h>
using namespace std;
class HogeSDKClass {
public:
HogeSDKClass()
: value_(9999)
{
}
void print() {
printf("%d\n", value_);
}
private:
int value_; // この値は不可侵である
};
class HogeSDKClassHack {
public:
void hackValue() {
this->value_ = 1000;
}
protected:
int value_; // 不可侵な値のダミー
};
HogeSDKClass* getHogeSDKInstance() {
return new HogeSDKClass(); // これはSDKからやってくる
}
int main() {
HogeSDKClass* hoge = getHogeSDKInstance();
hoge->print(); // この値を書き換えたい……。
HogeSDKClassHack* hogeHack = reinterpret_cast<HogeSDKClassHack*>(hoge);
hogeHack->hackValue();
hoge->print();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHVub3JkZXJlZF9tYXA+CiNpbmNsdWRlIDxzeXMvdGltZS5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgSG9nZVNES0NsYXNzIHsKcHVibGljOgogICAgSG9nZVNES0NsYXNzKCkKICAgIDogdmFsdWVfKDk5OTkpCiAgICB7CiAgICAJCiAgICB9Cgl2b2lkIHByaW50KCkgewoJCXByaW50ZigiJWRcbiIsIHZhbHVlXyk7Cgl9CnByaXZhdGU6CiAgICBpbnQgdmFsdWVfOyAvLyDjgZPjga7lgKTjga/kuI3lj6/kvrXjgafjgYLjgosKfTsKCmNsYXNzIEhvZ2VTREtDbGFzc0hhY2sgewpwdWJsaWM6Cgl2b2lkIGhhY2tWYWx1ZSgpIHsKCQl0aGlzLT52YWx1ZV8gPSAxMDAwOwoJfQpwcm90ZWN0ZWQ6CiAgICBpbnQgdmFsdWVfOyAvLyDkuI3lj6/kvrXjgarlgKTjga7jg4Djg5/jg7wKfTsKCkhvZ2VTREtDbGFzcyogZ2V0SG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