Asi me funciona:
#include <stdio.h>
void function(){
int i;
unsigned char *p = (unsigned char*)&i+0xC;
*p += 0x1A;
}
void main(){
int j;
function();
j=5;
j=6;
}
Siendo main:
0x080483f3 <main+0>: lea 0x4(%esp),%ecx
0x080483f7 <main+4>: and $0xfffffff0,%esp
0x080483fa <main+7>: pushl -0x4(%ecx)
0x080483fd <main+10>: push %ebp
0x080483fe <main+11>: mov %esp,%ebp
0x08048400 <main+13>: push %ecx
0x08048401 <main+14>: sub $0x24,%esp
0x08048404 <main+17>: call 0x80483d4 <function>
0x08048409 <main+22>: movl $0x5,-0x8(%ebp) ;direccion original
0x08048410 <main+29>: mov -0x8(%ebp),%eax
0x08048413 <main+32>: mov %eax,0x4(%esp)
0x08048417 <main+36>: movl $0x8048510,(%esp)
0x0804841e <main+43>: call 0x8048310 <printf@plt>
---Type <return> to continue, or q <return> to quit---
0x08048423 <main+48>: movl $0x6,-0x8(%ebp) ;direccion a la que queremos saltar
0x0804842a <main+55>: mov -0x8(%ebp),%eax
0x0804842d <main+58>: mov %eax,0x4(%esp)
0x08048431 <main+62>: movl $0x8048510,(%esp)
0x08048438 <main+69>: call 0x8048310 <printf@plt>
0x0804843d <main+74>: add $0x24,%esp
0x08048440 <main+77>: pop %ecx
0x08048441 <main+78>: pop %ebp
0x08048442 <main+79>: lea -0x4(%ecx),%esp
0x08048445 <main+82>: ret
Y function:
0x080483d4 <function+0>: push %ebp
0x080483d5 <function+1>: mov %esp,%ebp
0x080483d7 <function+3>: sub $0x10,%esp
0x080483da <function+6>: lea -0x8(%ebp),%eax
0x080483dd <function+9>: add $0xc,%eax
0x080483e0 <function+12>: mov %eax,-0x4(%ebp)
0x080483e3 <function+15>: mov -0x4(%ebp),%eax
0x080483e6 <function+18>: movzbl (%eax),%eax
0x080483e9 <function+21>: lea 0x1a(%eax),%edx
0x080483ec <function+24>: mov -0x4(%ebp),%eax
0x080483ef <function+27>: mov %dl,(%eax)
0x080483f1 <function+29>: leave
0x080483f2 <function+30>: ret
0x23-0x9=0x1A.