diff options
author | midipix <writeonce@midipix.org> | 2016-12-11 19:44:51 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-11 19:56:28 -0500 |
commit | ff22b1948a1f2ee7f62d915c543d46a379e2082e (patch) | |
tree | afe918de0d2ed11e92064cc0142ea8fa31011f03 /include/pemagine/bits/nt32/pe_inline_asm__common.h | |
parent | b80821b1a7d30d36e1a844036720cf682d5dda0f (diff) | |
download | pemagine-ff22b1948a1f2ee7f62d915c543d46a379e2082e.tar.bz2 pemagine-ff22b1948a1f2ee7f62d915c543d46a379e2082e.tar.xz |
api headers: added visual studio and hosted environment support.
Diffstat (limited to 'include/pemagine/bits/nt32/pe_inline_asm__common.h')
-rw-r--r-- | include/pemagine/bits/nt32/pe_inline_asm__common.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/include/pemagine/bits/nt32/pe_inline_asm__common.h b/include/pemagine/bits/nt32/pe_inline_asm__common.h new file mode 100644 index 0000000..10473b4 --- /dev/null +++ b/include/pemagine/bits/nt32/pe_inline_asm__common.h @@ -0,0 +1,89 @@ +static __inline__ void * pe_get_teb_address(void) +{ + void * ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x18, %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + + +static __inline__ void * pe_get_peb_address(void) +{ + void * ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x18, %0\n\t" + "mov %%ds:0x30(%0), %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + + +static __inline__ void * pe_get_peb_address_alt(void) +{ + void * ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x30, %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + + +static __inline__ void * pe_get_peb_ldr_data_address(void) +{ + void * ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x18, %0\n\t" + "mov %%ds:0x30(%0), %0\n\t" + "mov %%ds:0x0C(%0), %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + + +static __inline__ void * pe_get_peb_ldr_data_address_alt(void) +{ + void * ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x30, %0\n\t" + "mov %%ds:0x0C(%0), %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + +static __inline__ uint32_t pe_get_current_process_id(void) +{ + uint32_t ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x20, %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + +static __inline__ uint32_t pe_get_current_thread_id(void) +{ + uint32_t ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x24, %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} + +static __inline__ uint32_t pe_get_current_session_id(void) +{ + uint32_t ptrRet; + __asm__ __volatile__ ( + "mov %%fs:0x18, %0\n\t" + "mov %%ds:0x30(%0), %0\n\t" + "mov %%ds:0x1d4(%0), %0\n\t" + : "=r" (ptrRet) : : + ); + return ptrRet; +} |