forked from somma/_MyLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_test_asm.cpp
More file actions
72 lines (52 loc) · 1.45 KB
/
_test_asm.cpp
File metadata and controls
72 lines (52 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**----------------------------------------------------------------------------
* _test_asm.cpp
*-----------------------------------------------------------------------------
*
*-----------------------------------------------------------------------------
* All rights reserved by Noh,Yonghwan (fixbrain@gmail.com, unsorted@msn.com)
*-----------------------------------------------------------------------------
* 2014:10:30 23:26 created
**---------------------------------------------------------------------------*/
#include "stdafx.h"
#if !defined(_WIN64)
bool test_asm_func(){return true;}
ULONG64 sum64(ULONG64 a, ULONG64 b, ULONG64 c, ULONG64 d){return 0;}
void trampoline(){}
ULONG64 direct_jump(){ return 0; }
ULONG64 indirect_jump() {return 0; }
void push_mov_ret() {}
void push_mov_ret2() {}
#else
//
// x64 only
//
#ifdef __cplusplus
extern "C" {
#endif
ULONG64 sum64(ULONG64 a, ULONG64 b, ULONG64 c, ULONG64 d);
void trampoline();
ULONG64 direct_jump();
ULONG64 indirect_jump();
void push_mov_ret();
void push_mov_ret2();
#ifdef __cplusplus
}
#endif
/**
* @brief
**/
bool test_asm_func()
{
ULONG64 ret = sum64(1,1,1,1);
if (4 != ret) return false;
//trampoline();
ret = direct_jump();
ret = indirect_jump();
push_mov_ret();
push_mov_ret2(); // crash!
ULONG64 addr = (ULONG64)test_asm_func;
ULONG32 low = addr & 0x00000000ffffffff;
ULONG32 high = (addr & 0xffffffff00000000) >> 32;
return true;
}
#endif//#if !defined(_WIN64)