Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Last active August 29, 2015 14:22
Show Gist options
  • Save pjc0247/90efbe9bfdd8557f98a7 to your computer and use it in GitHub Desktop.
Save pjc0247/90efbe9bfdd8557f98a7 to your computer and use it in GitHub Desktop.
// test_lemon.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include <stdlib.h>
#include <Windows.h>
#include <setjmp.h>
//jmp_buf co;
int co;
int ret_to;
void *sbp, *sbx, *sdi, *ssp;
int test_accept(){
printf("hello\n");
void *vstack = malloc(1024);
__asm {
mov eax, hello;
mov co, eax;
mov eax, [ebp+4];
mov ret_to,eax;
mov sbp, ebp;
mov sbx, ebx;
mov sdi, edi;
mov ssp, esp;
mov ebp, vstack;
jmp ret_to;
}
hello:
__asm {
mov ebp, sbp;
mov ebx, sbx;
mov edi, sdi;
mov esp, ssp;
}
printf("world\n");
vstack = malloc(1024);
__asm {
mov eax, hello2;
mov co, eax;
mov eax, [ebp+4];
mov ret_to,eax;
mov sbp, ebp;
mov sbx, ebx;
mov sdi, edi;
mov ssp, esp;
mov ebp, vstack;
jmp ret_to;
}
hello2:
__asm {
mov ebp, sbp;
mov ebx, sbx;
mov edi, sdi;
mov esp, ssp;
}
printf("end\n");
__asm {
mov eax, -1;
}
}
int _tmain(int argc, _TCHAR* argv[]){
int a = 1234;
int c;
if(test_accept() != -1){
int test_local = 1234;
printf("accepted : %d\n", test_local);
test_local = 12345;
__asm {
jmp co;
}
}
/*
__asm {
mov c, eax;
}
printf("ret\n");
Sleep(10);
if(c != -1){
}
*/
// printf("onret\n");
/*
hello:
__asm {
mov eax, hello;
mov c, eax;
}
printf("qwer");
__asm jmp c;
//mov ebp, vstack;
*/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment