![]() |
|
||||||||
경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지 |
|
이정구 [appleii]
2008-08-27 20:28 X
eip 를 직접 접근할 수 있는 방법은 없죠. jmp ebs + $ 를 디스어셈블 하면 어떻게 될까요?
조금전에 MSDN에서 VC++2008 문서들을 읽다보니
jne $+5 이런식으로 사용하는게 가능한 것 같군요. $가 현재 위치 (current location counter)를 제공한답니다. (http://msdn.microsoft.com/en-us/library/78cxesy1.aspx) 빌더(2006)에서 같은 코드를 넣어봤더니 역시나 컴파일 에러가 나네요. 흠냘... short jump는 분명 상대주소로 점프지만... 그건 컴파일러가 알아서 번역하는거 아닌가요? jmp lbl_mylabel 이렇게 구현해도 lbl_mylabel이 근거리에 있는 경우 실제 OPCODE는 short jump로 번역되는것 같았습니다. 그렇다면 저렇게 $를 지원할 이유가 없어보이는데요... 일단 C++ Builder 2009에서 $를 지원하는지 테스트 해 봐야 겠습니다. 이런걸 하고싶은건데...
void __fastcall VectorArithmetic(float *arr1, float *arr2, int n, int op) { asm { dec ecx // fastcall 이므로 eax=arr1, edx=arr2, ecx=n 이 들어가 있습니다. mov ebx,op // op는 + = 0. - = 5, * = 10, / = 15 add ebx,0x0040312E // lbl_add:의 주소... 가변적임. 이걸 해결하고잡다... jmp lbl_loopfirstonly lbl_loop_begin: fstp dword ptr [eax+ecx*4] dec ecx cmp ecx,0 jl lbl_exit lbl_loopfirstonly: fld dword ptr [eax+ecx*4] jmp ebx // op만큼 상대주소 점프 lbl_add: fadd dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_sub: fsubr dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_mul: fmul dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_div: fdivr dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_exit: } } 꽁수버전... ㅎㅎ
되긴 됩니다. void __fastcall VectorArithmetic(float *arr1, float *arr2, int n, int op) { static const BYTE* AddrOfVectorArithmetic = (BYTE*)&VectorArithmetic+0x2A; __asm { dec ecx mov ebx,AddrOfVectorArithmetic add ebx,op jmp lbl_loopfirstonly lbl_loop_begin: fstp dword ptr [eax+ecx*4] dec ecx cmp ecx,0 jl lbl_exit lbl_loopfirstonly: fld dword ptr [eax+ecx*4] jmp ebx lbl_add: fadd dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_sub: fsubr dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_mul: fmul dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_div: fdivr dword ptr [edx+ecx*4] jmp lbl_loop_begin lbl_exit: } } 관련 글 리스트
|
Copyright © 1999-2015, borlandforum.com. All right reserved. |