aboutsummaryrefslogtreecommitdiffstats
path: root/toj/center/src/judgk_security_asm.S
blob: 80edf376559c70ce737864523c680c776fca4ba7 (plain) (blame)
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
.code64
.section .data  //Don't run these code, just data for copy
.global judgk_security_block
.global judgk_security_blockend
.extern judgk_security_checkaddr

//First 8 bytes is original function address
judgk_security_block:
    push %rbx
    push %rcx
    push %rdx
    push %rsi
    push %rdi
    push %rbp
    push %r8
    push %r9
    push %r10
    push %r11
    push %r12
    push %r13
    push %r14
    push %r15
    pushfq
    
    callq *(judgk_security_checkaddr)

    popfq
    pop %r15
    pop %r14
    pop %r13
    pop %r12
    pop %r11
    pop %r10
    pop %r9
    pop %r8
    pop %rbp
    pop %rdi
    pop %rsi
    pop %rdx
    pop %rcx
    pop %rbx

    test %rax,%rax
    jnz .block

    call .getrip
.offset:
    sub $(.offset - judgk_security_block + 8),%rax
    jmp *(%rax)

.block:
    ret

.getrip:
    mov (%rsp),%rax
    ret
judgk_security_blockend: