Skip to content

Instantly share code, notes, and snippets.

@usagi
Last active March 7, 2016 19:56
Show Gist options
  • Select an option

  • Save usagi/c82405ac4e584cc07df4 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/c82405ac4e584cc07df4 to your computer and use it in GitHub Desktop.
ビルド後のバイナリー実行ファイルにポストプロセスで変数の値を書き換える方法 ref: http://qiita.com/usagi/items/a0889903e09c1af2b462
static volatile constexpr char mojimoji[] = "abcd1234";
static volatile constexpr unsigned char mojisize = sizeof( mojimoji );
#include <iostream>
auto main() -> int
{
std::cout << ( const char* )mojimoji << " " << std::to_string( mojisize );
}
00000000004a7018 d mojimoji
00000000004a7010 d mojisize
pc+0x04: alloc small area: rsp = rsp - 0x28
Handler: 00000000004a6780.
User data:
000: ff ff 01 00
00000000004d4998 (rva: 000d4998): 00000000004a6d40 - 00000000004a6d4a
Version: 1, Flags: none
Nbr codes: 2, Prologue size: 0x04, Frame offset: 0x0, Frame reg: rbp
pc+0x04: FPReg: rbp = rsp + 0x0 (info = 0x0)
pc+0x01: push rbp
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 000a5db0 0000000000401000 0000000000401000 00000600 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00002f28 00000000004a7000 00000000004a7000 000a6400 2**5
CONTENTS, ALLOC, LOAD, DATA
2 .rdata 0000fbe0 00000000004aa000 00000000004aa000 000a9400 2**6
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .pdata 0000b04c 00000000004ba000 00000000004ba000 000b9000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .xdata 0000e9a0 00000000004c6000 00000000004c6000 000c4200 2**2
[134](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000018 _ZL8mojimoji
[138](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x0000000000000010 _ZL8mojisize
0a6418 a b c d 1 2 3 4 nul nul nul nul nul nul nul nul
0a6410 9 0 0 0 0 0 0 0 97 98 99 100 49 50 51 52
./b
ajipon 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment