WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.4% of users enabled 2FA.

clib_x64.c 1.98 KB
Newer Older
1 2
#include <inttypes.h>
#include <stdlib.h>
3
#include <string.h>
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

void* malloc_zero(size_t size) {
    void* ret = malloc(size);
    memset(ret, 0, size);
    return ret;
}

uintptr_t immmix_get_stack_ptr() {
    uintptr_t rsp;
    // get current rsp, rbp (this C func frame)
    __asm__(
        "mov %%rsp, %0 \n"
        : "=rm" (rsp)
    );

    return rsp;
}

int get_registers_count() {
    return 16;
}

uintptr_t* get_registers () {
    uintptr_t rax, rbx, rcx, rdx, rbp, rsp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15;

    __asm__(
        "mov %%rax, %0 \n"
        "mov %%rbx, %1 \n"
        "mov %%rcx, %2 \n"
        "mov %%rdx, %3 \n"
        "mov %%rbp, %4 \n"
        "mov %%rsp, %5 \n"
        "mov %%rsi, %5 \n"
        "mov %%rdi, %6 \n"
        "mov %%r8,  %7 \n"
        "mov %%r9,  %8 \n"
        "mov %%r10, %10\n"
        "mov %%r11, %11\n"
        "mov %%r12, %12\n"
        "mov %%r13, %13\n"
        "mov %%r14, %14\n"
        "mov %%r15, %15\n"
        : "=m" (rax),
          "=m" (rbx),
          "=m" (rcx),
          "=m" (rdx),
          "=m" (rbp),
          "=m" (rsp),
          "=m" (rsi),
          "=m" (rdi),
          "=m" (r8),
          "=m" (r9),
          "=m" (r10),
          "=m" (r11),
          "=m" (r12),
          "=m" (r13),
          "=m" (r14),
          "=m" (r15)
          :
          :
        );

    uintptr_t* ret = (uintptr_t*) malloc(sizeof(uintptr_t) * 16);
    ret[0] = rax;
    ret[1] = rbx;
    ret[2] = rcx;
    ret[3] = rdx;
    ret[4] = rbp;
    ret[5] = rsp;
    ret[6] = rsi;
    ret[7] = rdi;
    ret[8] = r8;
    ret[9] = r9;
    ret[10] = r10;
    ret[11] = r11;
    ret[12] = r12;
    ret[13] = r13;
    ret[14] = r14;
    ret[15] = r15;
    return ret;
}

__thread uintptr_t low_water_mark;

void set_low_water_mark () {
    uintptr_t rsp;
    // get current rsp, rbp (this C func frame)
    __asm__(
        "mov %%rsp, %0 \n"
        : "=rm" (rsp)
    );

    low_water_mark = rsp;
}

uintptr_t get_low_water_mark() {
    return low_water_mark;
}