summaryrefslogtreecommitdiffhomepage
path: root/include/pemagine/bits/nt32/pe_inline_asm__gcc.h
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-05-08 23:22:07 -0400
committermidipix <writeonce@midipix.org>2015-05-08 23:22:07 -0400
commitfeffc7263bb2fd33ae467de2dd51f1ddbbb1b895 (patch)
tree983daec02a2d1833796ad8bd04d43d9b3ec42765 /include/pemagine/bits/nt32/pe_inline_asm__gcc.h
parent23329916dde5e0ffa056f74a81aeda1bfb7e54cc (diff)
downloadpemagine-feffc7263bb2fd33ae467de2dd51f1ddbbb1b895.tar.bz2
pemagine-feffc7263bb2fd33ae467de2dd51f1ddbbb1b895.tar.xz
initial commit.
Diffstat (limited to 'include/pemagine/bits/nt32/pe_inline_asm__gcc.h')
-rw-r--r--include/pemagine/bits/nt32/pe_inline_asm__gcc.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/include/pemagine/bits/nt32/pe_inline_asm__gcc.h b/include/pemagine/bits/nt32/pe_inline_asm__gcc.h
new file mode 100644
index 0000000..10473b4
--- /dev/null
+++ b/include/pemagine/bits/nt32/pe_inline_asm__gcc.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;
+}