您好,登錄后才能下訂單哦!
本篇內容主要講解“C語言匯編dll注入獲取x64寄存器值的方法是什么”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“C語言匯編dll注入獲取x64寄存器值的方法是什么”吧!
/* * @Author: https://github.com/zengfr * @Date: 2020-10-27 10:35:05 * @Last Modified by: https://github.com/zengfr * @Last Modified time: 2020-10-27 10:35:05 */ #include <stdio.h> #include <stdint.h> extern "C" __declspec(dllexport) __cdecl char* getAuthor() { char author[] = "Author:https://github.com/zengfr"; char *pstr = author; return pstr; } extern "C" __declspec(dllexport) __cdecl void * getRegisters() { static uint64_t rs[16]={ 0l,0,0,0l, 0,0,0,0, 0,0,0,0, 0,0,0,0l}; __asm__ __volatile__( " mov %%eax,%0 ;\n\t" " mov %%ebx,%1 ;\n\t" " mov %%ecx,%2 ;\n\t" " mov %%edx,%3 ;\n\t" " mov %%ebp,%4 ;\n\t" " mov %%esp,%5 ;\n\t" " mov %%esi,%6 ;\n\t" " mov %%edi,%7 ;\n\t" " mov %%r8,%8 ;\n\t" " mov %%r9,%9 ;\n\t" " mov %%cs,%10 ;\n\t" " mov %%ds,%11 ;\n\t" " mov %%es,%12 ;\n\t" " mov %%ss,%13 ;\n\t" :"=m"(rs[0]),"=m"(rs[1]),"=m"(rs[2]) ,"=m"(rs[3]) ,"=m"(rs[4]),"=m"(rs[5]),"=m"(rs[6]) ,"=m"(rs[7]) ,"=m"(rs[8]),"=m"(rs[9]),"=m"(rs[10]),"=m"(rs[11]) ,"=m"(rs[12]),"=m"(rs[13]) //: /* no registers */ //: /* no registers */ ); return rs; } extern "C" __declspec(dllexport) __cdecl void * getBaseRegisters() { static uint64_t rs[8]={0l,0,0,0l,0,0l,0,0l}; __asm__ __volatile__( " mov %%eax,%0 ;\n\t" " mov %%ebx,%1 ;\n\t" " mov %%ecx,%2 ;\n\t" " mov %%edx,%3 ;\n\t" " mov %%ebp,%4 ;\n\t" " mov %%esp,%5 ;\n\t" " mov %%esi,%6 ;\n\t" " mov %%edi,%7 ;\n\t" :"=m"(rs[0]),"=m"(rs[1]),"=m"(rs[2]) ,"=m"(rs[3]) ,"=m"(rs[4]),"=m"(rs[5]),"=m"(rs[6]) ,"=m"(rs[7]) //: /* no registers */ //: /* no registers */ ); return rs; } extern "C" __declspec(dllexport) __cdecl void * getSegmentRegisters() { static uint64_t rs[8]={0l,0,0,0l,0,0l,0,0l}; __asm__ __volatile__( " mov %%cs,%0 ;\n\t" " mov %%ds,%1 ;\n\t" " mov %%es,%2 ;\n\t" " mov %%fs,%3 ;\n\t" " mov %%gs,%4 ;\n\t" " mov %%ss,%5 ;\n\t" :"=m"(rs[0]),"=m"(rs[1]),"=m"(rs[2]) ,"=m"(rs[3]) ,"=m"(rs[4]),"=m"(rs[5]) //: /* no registers */ //: /* no registers */ ); return rs; } extern "C" __declspec(dllexport) __cdecl void * getCpRegisters() { static uint64_t rs[8]={ 0l,0l,0l,0l, 0l,0l,0l,0l }; __asm__ __volatile__( " mov %%r8,%0 ;\n\t" " mov %%r9,%1 ;\n\t" " mov %%r10,%2 ;\n\t" " mov %%r11,%3 ;\n\t" " mov %%r12,%4 ;\n\t" " mov %%r13,%5 ;\n\t" " mov %%r14,%6 ;\n\t" " mov %%r15,%7 ;\n\t" :"=m"(rs[0]),"=m"(rs[1]),"=m"(rs[2]) ,"=m"(rs[3]) ,"=m"(rs[4]),"=m"(rs[5]),"=m"(rs[6]) ,"=m"(rs[7]) //: /* no registers */ //: /* no registers */ ); return rs; } extern "C" __declspec(dllexport) __cdecl inline uint64_t readMem64(uint64_t *reg) { uint64_t value; __asm__ __volatile__( "mov %[reg], %[val]\n" : [val] "=rm" (value) : [reg] "rm" (*reg) ); return value; } extern "C" __declspec(dllexport) __cdecl inline uint32_t readMem32(uint32_t *reg) { uint32_t value; __asm__ __volatile__( "mov %[reg], %[val]\n" : [val] "=rm" (value) : [reg] "rm" (*reg) ); return value; }
到此,相信大家對“C語言匯編dll注入獲取x64寄存器值的方法是什么”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。