diff --git a/BrachTraceExe/BrachTraceExe.vcxproj b/BrachTraceExe/BrachTraceExe.vcxproj deleted file mode 100644 index 1bdaca2..0000000 --- a/BrachTraceExe/BrachTraceExe.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {8D95F0D0-2975-4A8B-9499-317C50E55264} - BrachTraceExe - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - false - - - true - - - true - - - false - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreadedDebug - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/BrachTraceExe/BrachTraceExe.vcxproj.filters b/BrachTraceExe/BrachTraceExe.vcxproj.filters deleted file mode 100644 index 93b404b..0000000 --- a/BrachTraceExe/BrachTraceExe.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - \ No newline at end of file diff --git a/BrachTraceExe/BrachTraceExe.vcxproj.user b/BrachTraceExe/BrachTraceExe.vcxproj.user deleted file mode 100644 index cb74406..0000000 --- a/BrachTraceExe/BrachTraceExe.vcxproj.user +++ /dev/null @@ -1,27 +0,0 @@ - - - - WindowsRemoteDebugger - $(TargetPath) - 192.168.3.7 - RemoteWithoutAuthentication - - - $(TargetPath) - WindowsRemoteDebugger - 192.168.3.7 - RemoteWithoutAuthentication - - - $(TargetPath) - WindowsRemoteDebugger - 192.168.3.7 - RemoteWithoutAuthentication - - - $(TargetPath) - WindowsRemoteDebugger - 192.168.3.7 - RemoteWithoutAuthentication - - \ No newline at end of file diff --git a/BrachTraceExe/brach-trace-exe.cpp b/BrachTraceExe/brach-trace-exe.cpp deleted file mode 100644 index de721ed..0000000 --- a/BrachTraceExe/brach-trace-exe.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include "..\BranchTracerSys\ioctls.h" -#include - - - -typedef struct _BTS_RECORD64 -{ - ULONG64 from; // ¼Ç¼·ÖÖ§µÄÔ´µØÖ· - ULONG64 to; // ¼Ç¼·ÖÖ§µÄÄ¿±êµØÖ· - ULONG64 branchPredicted; -}BTS_RECORD64, * PBTS_RECORD64; - - - -int main() { - HANDLE hDevice = CreateFileA("\\\\.\\Branch-Trace", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - - ULONG ThreadId = 0; - printf("Enter thread id:"); - scanf_s("%d", &ThreadId); - - START_THREAD_TRACE_PARAM StartRequest = { 0 }; - StartRequest.ThreadId = ThreadId; - - DWORD BytesReturned = 0; - if (!DeviceIoControl(hDevice, IOCTL_START_THREAD_TRACE, - (LPVOID)&StartRequest, sizeof(StartRequest), - (LPVOID)&StartRequest, sizeof(StartRequest), - &BytesReturned, NULL)) - { - printf("Start Trace failed!\n"); - return -1; - } - - printf("Press Enter to conttinue\n"); - system("pause"); - -#define BIFFER_SIZE 0x2000 - PVOID Buffer = VirtualAlloc(NULL, BIFFER_SIZE, MEM_COMMIT, PAGE_READWRITE); - STOP_THREAD_TRACE_PARAM StopRequest = { 0 }; - StopRequest.ThreadId = ThreadId; - StopRequest.Buffer = Buffer; - StopRequest.BufferSize = BIFFER_SIZE; - StopRequest.FilterStart = 0x00400000; - StopRequest.FilterEnd = 0x00D4C000+0x4000; - - - if (!DeviceIoControl(hDevice, IOCTL_STOP_THREAD_TRACE, - (LPVOID)&StopRequest, sizeof(StopRequest), - (LPVOID)&StopRequest, sizeof(StopRequest), - &BytesReturned, NULL)) - { - printf("Stop Trace failed!\n"); - getchar(); - return -1; - } - - printf("Successful Buffer:%p ReadSize:%x\n", StopRequest.Buffer, StopRequest.ReadSize); - - - PBTS_RECORD64 RecordStart = (PBTS_RECORD64)Buffer; - PBTS_RECORD64 RecordEnd = (PBTS_RECORD64)((ULONG_PTR)Buffer + StopRequest.ReadSize); - - - // ÄæÅÅ, ´ÓÇý¶¯À­»ØÀ´µÄ¼Ç¼˳Ðò¸úÖ´ÐÐ˳ÐòµÄÏà·´. - for (PBTS_RECORD64 p1 = RecordStart, p2 = RecordEnd - 1; - p1 < p2; - p1++, p2--) - { - BTS_RECORD64 temp = *p1; - *p1 = *p2; - *p2 = temp; - } - - PBTS_RECORD64 pRecord = RecordStart; - while (pRecord < RecordEnd) - { - printf("%llx-> %llx\n", pRecord->from, pRecord->to); - pRecord++; - } - - system("pause"); - getchar(); - - -} \ No newline at end of file