From cfb78d8beb615d0cb3dd3bbd5524a410604cc2ee Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Tue, 10 Jun 2014 15:56:42 +0200 Subject: [PATCH] formatted the whole project (AStyle) --- .../DeviceNameResolver/DeviceNameResolver.h | 44 +- x64_dbg_dbg/disasm_fast.cpp | 166 +++--- x64_dbg_dbg/disasm_fast.h | 18 +- x64_dbg_dbg/reference.cpp | 158 ++--- x64_dbg_dbg/reference.h | 40 +- x64_dbg_dbg/simplescript.cpp | 4 +- x64_dbg_dbg/test/general/dll/main.h | 4 +- x64_dbg_dbg/undocumented.h | 310 +++++----- .../Src/BasicView/AbstractTableView.cpp | 18 +- .../Project/Src/BasicView/CommandHelpView.cpp | 266 ++++----- .../Project/Src/BasicView/CommandHelpView.h | 83 +-- .../Project/Src/BasicView/Disassembly.cpp | 4 +- .../Project/Src/BasicView/HistoryLineEdit.cpp | 102 ++-- .../Project/Src/BasicView/HistoryLineEdit.h | 58 +- .../Project/Src/BasicView/LineEditDialog.h | 3 +- .../Project/Src/BasicView/MemoryMapView.cpp | 46 +- .../Project/Src/BasicView/RegistersView.cpp | 6 +- .../Project/Src/BasicView/RegistersView.h | 10 +- .../Project/Src/BasicView/RichTextPainter.cpp | 88 +-- .../Project/Src/BasicView/RichTextPainter.h | 62 +- .../Project/Src/BasicView/ScriptView.cpp | 8 +- .../Project/Src/BasicView/SearchListView.h | 5 +- .../Project/Src/BasicView/SymbolView.h | 3 +- .../Project/Src/BasicView/ThreadView.cpp | 420 +++++++------- .../Project/Src/BasicView/ThreadView.h | 42 +- .../Project/Src/BasicView/WordEditDialog.h | 7 +- x64_dbg_gui/Project/Src/Bridge/Bridge.cpp | 12 +- x64_dbg_gui/Project/Src/Exports.h | 4 +- .../Project/Src/Gui/CPUDisassembly.cpp | 12 +- x64_dbg_gui/Project/Src/Gui/CPUJumps.cpp | 543 +++++++++--------- x64_dbg_gui/Project/Src/Gui/CPUJumps.h | 88 +-- x64_dbg_gui/Project/Src/Gui/CPUWidget.h | 5 +- x64_dbg_gui/Project/Src/Gui/Configuration.cpp | 139 ++--- x64_dbg_gui/Project/Src/Gui/Configuration.h | 59 +- .../Project/Src/Gui/ExceptionRangeDialog.cpp | 166 +++--- .../Project/Src/Gui/ExceptionRangeDialog.h | 61 +- x64_dbg_gui/Project/Src/Gui/GotoDialog.h | 3 +- x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 14 +- x64_dbg_gui/Project/Src/Gui/MainWindow.h | 7 +- x64_dbg_gui/Project/Src/Gui/SettingsDialog.h | 5 +- x64_dbg_gui/Project/Src/Gui/TabBar.cpp | 328 +++++------ x64_dbg_gui/Project/Src/Gui/TabBar.h | 100 ++-- x64_dbg_gui/Project/Src/Gui/TabWidget.cpp | 382 ++++++------ x64_dbg_gui/Project/Src/Gui/TabWidget.h | 158 ++--- .../Project/Src/Memory/MapViewOfMem.cpp | 4 +- x64_dbg_gui/Project/Src/Memory/MapViewOfMem.h | 54 +- .../Project/Src/Memory/ProcessMemoryMap.cpp | 98 ++-- .../Project/Src/Utils/ApiFingerprints.cpp | 231 ++++---- .../Project/Src/Utils/ApiFingerprints.h | 58 +- x64_dbg_gui/Project/Src/Utils/Breakpoints.cpp | 98 ++-- 50 files changed, 2329 insertions(+), 2275 deletions(-) diff --git a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h index 70e584ae..dc14d04d 100644 --- a/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h +++ b/x64_dbg_dbg/DeviceNameResolver/DeviceNameResolver.h @@ -1,22 +1,22 @@ -#ifndef _DEVICENAMERESOLVER_H -#define _DEVICENAMERESOLVER_H - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -__declspec(dllexport) bool DevicePathToPathW(const wchar_t* szDevicePath, wchar_t* szPath, size_t nSize); -__declspec(dllexport) bool DevicePathToPathA(const char* szDevicePath, char* szPath, size_t nSize); -__declspec(dllexport) bool DevicePathFromFileHandleW(HANDLE hFile, wchar_t* szDevicePath, size_t nSize); -__declspec(dllexport) bool DevicePathFromFileHandleA(HANDLE hFile, char* szDevicePath, size_t nSize); -__declspec(dllexport) bool PathFromFileHandleW(HANDLE hFile, wchar_t* szPath, size_t nSize); -__declspec(dllexport) bool PathFromFileHandleA(HANDLE hFile, char* szPath, size_t nSize); - -#ifdef __cplusplus -} -#endif - -#endif // _DEVICENAMERESOLVER_H +#ifndef _DEVICENAMERESOLVER_H +#define _DEVICENAMERESOLVER_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +__declspec(dllexport) bool DevicePathToPathW(const wchar_t* szDevicePath, wchar_t* szPath, size_t nSize); +__declspec(dllexport) bool DevicePathToPathA(const char* szDevicePath, char* szPath, size_t nSize); +__declspec(dllexport) bool DevicePathFromFileHandleW(HANDLE hFile, wchar_t* szDevicePath, size_t nSize); +__declspec(dllexport) bool DevicePathFromFileHandleA(HANDLE hFile, char* szDevicePath, size_t nSize); +__declspec(dllexport) bool PathFromFileHandleW(HANDLE hFile, wchar_t* szPath, size_t nSize); +__declspec(dllexport) bool PathFromFileHandleA(HANDLE hFile, char* szPath, size_t nSize); + +#ifdef __cplusplus +} +#endif + +#endif // _DEVICENAMERESOLVER_H diff --git a/x64_dbg_dbg/disasm_fast.cpp b/x64_dbg_dbg/disasm_fast.cpp index 601759a3..c1779fdb 100644 --- a/x64_dbg_dbg/disasm_fast.cpp +++ b/x64_dbg_dbg/disasm_fast.cpp @@ -1,83 +1,83 @@ -#include "disasm_fast.h" - -static MEMORY_SIZE argsize2memsize(int argsize) -{ - switch(argsize) - { - case 8: - return size_byte; - case 16: - return size_word; - case 32: - return size_dword; - case 64: - return size_qword; - } - return size_byte; -} - -void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo) -{ - //zero basicinfo - memset(basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO)); - //find immidiat - if(disasm->Instruction.BranchType==0) //no branch - { - if((disasm->Argument1.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE) - { - basicinfo->type|=TYPE_VALUE; - basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat; - basicinfo->value.size=argsize2memsize(disasm->Argument1.ArgSize); - } - else if((disasm->Argument2.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE) - { - basicinfo->type|=TYPE_VALUE; - basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat; - basicinfo->value.size=argsize2memsize(disasm->Argument2.ArgSize); - } - } - else //branch - basicinfo->branch=true; - //find memory displacement - if((disasm->Argument1.ArgType&MEMORY_TYPE)==MEMORY_TYPE || (disasm->Argument2.ArgType&MEMORY_TYPE)==MEMORY_TYPE) - { - if(disasm->Argument1.Memory.Displacement) - { - basicinfo->type|=TYPE_MEMORY; - basicinfo->memory.value=(ULONG_PTR)disasm->Argument1.Memory.Displacement; - strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); - basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize); - } - else if(disasm->Argument2.Memory.Displacement) - { - basicinfo->type|=TYPE_MEMORY; - basicinfo->memory.value=(ULONG_PTR)disasm->Argument2.Memory.Displacement; - strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); - basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize); - } - } - //find address value - if(disasm->Instruction.BranchType && disasm->Instruction.AddrValue) - { - basicinfo->type|=TYPE_ADDR; - basicinfo->addr=(ULONG_PTR)disasm->Instruction.AddrValue; - } - //rip-relative (non-branch) - if(disasm->Instruction.BranchType==0) - { - if((disasm->Argument1.ArgType&RELATIVE_)==RELATIVE_) - { - basicinfo->type|=TYPE_MEMORY; - basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue; - strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); - basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize); - } - else if((disasm->Argument2.ArgType&RELATIVE_)==RELATIVE_) - { - basicinfo->type|=TYPE_MEMORY; - basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue; - strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); - basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize); - } - } -} \ No newline at end of file +#include "disasm_fast.h" + +static MEMORY_SIZE argsize2memsize(int argsize) +{ + switch(argsize) + { + case 8: + return size_byte; + case 16: + return size_word; + case 32: + return size_dword; + case 64: + return size_qword; + } + return size_byte; +} + +void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo) +{ + //zero basicinfo + memset(basicinfo, 0, sizeof(BASIC_INSTRUCTION_INFO)); + //find immidiat + if(disasm->Instruction.BranchType==0) //no branch + { + if((disasm->Argument1.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE) + { + basicinfo->type|=TYPE_VALUE; + basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat; + basicinfo->value.size=argsize2memsize(disasm->Argument1.ArgSize); + } + else if((disasm->Argument2.ArgType&CONSTANT_TYPE)==CONSTANT_TYPE) + { + basicinfo->type|=TYPE_VALUE; + basicinfo->value.value=(ULONG_PTR)disasm->Instruction.Immediat; + basicinfo->value.size=argsize2memsize(disasm->Argument2.ArgSize); + } + } + else //branch + basicinfo->branch=true; + //find memory displacement + if((disasm->Argument1.ArgType&MEMORY_TYPE)==MEMORY_TYPE || (disasm->Argument2.ArgType&MEMORY_TYPE)==MEMORY_TYPE) + { + if(disasm->Argument1.Memory.Displacement) + { + basicinfo->type|=TYPE_MEMORY; + basicinfo->memory.value=(ULONG_PTR)disasm->Argument1.Memory.Displacement; + strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); + basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize); + } + else if(disasm->Argument2.Memory.Displacement) + { + basicinfo->type|=TYPE_MEMORY; + basicinfo->memory.value=(ULONG_PTR)disasm->Argument2.Memory.Displacement; + strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); + basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize); + } + } + //find address value + if(disasm->Instruction.BranchType && disasm->Instruction.AddrValue) + { + basicinfo->type|=TYPE_ADDR; + basicinfo->addr=(ULONG_PTR)disasm->Instruction.AddrValue; + } + //rip-relative (non-branch) + if(disasm->Instruction.BranchType==0) + { + if((disasm->Argument1.ArgType&RELATIVE_)==RELATIVE_) + { + basicinfo->type|=TYPE_MEMORY; + basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue; + strcpy(basicinfo->memory.mnemonic, disasm->Argument1.ArgMnemonic); + basicinfo->memory.size=argsize2memsize(disasm->Argument1.ArgSize); + } + else if((disasm->Argument2.ArgType&RELATIVE_)==RELATIVE_) + { + basicinfo->type|=TYPE_MEMORY; + basicinfo->memory.value=(ULONG_PTR)disasm->Instruction.AddrValue; + strcpy(basicinfo->memory.mnemonic, disasm->Argument2.ArgMnemonic); + basicinfo->memory.size=argsize2memsize(disasm->Argument2.ArgSize); + } + } +} diff --git a/x64_dbg_dbg/disasm_fast.h b/x64_dbg_dbg/disasm_fast.h index fa60eb49..44b0410e 100644 --- a/x64_dbg_dbg/disasm_fast.h +++ b/x64_dbg_dbg/disasm_fast.h @@ -1,9 +1,9 @@ -#ifndef _DISASM_FAST_H -#define _DISASM_FAST_H - -#include "_global.h" -#include "BeaEngine\BeaEngine.h" - -void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo); - -#endif //_DISASM_FAST_H \ No newline at end of file +#ifndef _DISASM_FAST_H +#define _DISASM_FAST_H + +#include "_global.h" +#include "BeaEngine\BeaEngine.h" + +void fillbasicinfo(DISASM* disasm, BASIC_INSTRUCTION_INFO* basicinfo); + +#endif //_DISASM_FAST_H diff --git a/x64_dbg_dbg/reference.cpp b/x64_dbg_dbg/reference.cpp index f278a7de..759974d3 100644 --- a/x64_dbg_dbg/reference.cpp +++ b/x64_dbg_dbg/reference.cpp @@ -1,79 +1,79 @@ -#include "reference.h" -#include "debugger.h" -#include "memory.h" -#include "console.h" - -int reffind(uint addr, uint size, CBREF cbRef, void* userinfo, bool silent) -{ - uint start_addr; - uint start_size; - uint base; - uint base_size; - base=memfindbaseaddr(fdProcessInfo->hProcess, addr, &base_size); - if(!base or !base_size) - { - if(!silent) - dputs("invalid memory page"); - return 0; - } - - if(!size) //assume the whole page - { - start_addr=base; - start_size=base_size; - } - else //custom boundaries - { - start_addr=addr; - uint maxsize=size-(start_addr-base); - if(sizehProcess, (const void*)start_addr, data, start_size, 0)) - { - if(!silent) - dputs("error reading memory"); - efree(data, "reffind:data"); - return 0; - } - DISASM disasm; - memset(&disasm, 0, sizeof(disasm)); -#ifdef _WIN64 - disasm.Archi=64; -#endif // _WIN64 - disasm.EIP=(UIntPtr)data; - disasm.VirtualAddr=(UInt64)start_addr; - uint i=0; - BASIC_INSTRUCTION_INFO basicinfo; - cbRef(&disasm, &basicinfo, 0); //allow initializing - REFINFO refinfo; - memset(&refinfo, 0, sizeof(REFINFO)); - refinfo.userinfo=userinfo; - while(ihProcess, addr, &base_size); + if(!base or !base_size) + { + if(!silent) + dputs("invalid memory page"); + return 0; + } + + if(!size) //assume the whole page + { + start_addr=base; + start_size=base_size; + } + else //custom boundaries + { + start_addr=addr; + uint maxsize=size-(start_addr-base); + if(sizehProcess, (const void*)start_addr, data, start_size, 0)) + { + if(!silent) + dputs("error reading memory"); + efree(data, "reffind:data"); + return 0; + } + DISASM disasm; + memset(&disasm, 0, sizeof(disasm)); +#ifdef _WIN64 + disasm.Archi=64; +#endif // _WIN64 + disasm.EIP=(UIntPtr)data; + disasm.VirtualAddr=(UInt64)start_addr; + uint i=0; + BASIC_INSTRUCTION_INFO basicinfo; + cbRef(&disasm, &basicinfo, 0); //allow initializing + REFINFO refinfo; + memset(&refinfo, 0, sizeof(REFINFO)); + refinfo.userinfo=userinfo; + while(i - -//Thanks to: https://github.com/zer0fl4g/Nanomite - -typedef LONG NTSTATUS; - -typedef struct _UNICODE_STRING -{ - USHORT Length; - USHORT MaximumLength; - PWSTR Buffer; -} UNICODE_STRING; - -typedef struct _CLIENT_ID -{ - HANDLE UniqueProcess; - HANDLE UniqueThread; -} CLIENT_ID; - -typedef struct _PEB -{ - BYTE InheritedAddressSpace; - BYTE ReadImageFileExecOptions; - BYTE BeingDebugged; - BYTE SpareBool; - DWORD Mutant; - DWORD ImageBaseAddress; - DWORD LoaderData; - DWORD ProcessParameters; - DWORD SubSystemData; - DWORD ProcessHeap; - DWORD FastPebLock; - DWORD FastPebLockRoutine; - DWORD FastPebUnlockRoutine; - DWORD EnviromentUpdateCount; - DWORD KernelCallbackTable; - DWORD UserSharedInfoPtr; - DWORD ThunksOrOptions; - DWORD FreeList; - DWORD TlsExpansionCounter; - DWORD TlsBitmap; - DWORD TlsBitmapBits[2]; - DWORD ReadOnlySharedMemoryBase; - DWORD ReadOnlySharedMemoryHeap; - DWORD ReadOnlyStaticServerData; - DWORD AnsiCodePageData; - DWORD OemCodePageData; - DWORD UnicodeCaseTableData; - DWORD NumberOfProcessors; - DWORD NtGlobalFlag; - DWORD Reserved; - LARGE_INTEGER CriticalSectionTimeout; - DWORD HeapSegmentReserve; - DWORD HeapSegmentCommit; - DWORD HeapDeCommitTotalFreeThreshold; - DWORD HeapDeCommitFreeBlockThreshold; - DWORD NumberOfHeaps; - DWORD MaximumNumberOfHeaps; - DWORD ProcessHeaps; - DWORD GdiSharedHandleTable; - DWORD ProcessStarterHelper; - DWORD GdiDCAttributeList; - DWORD LoaderLock; - DWORD OSMajorVersion; - DWORD OSMinorVersion; - WORD OSBuildNumber; - WORD OSCSDVersion; - DWORD OSPlatformId; - DWORD ImageSubsystem; - DWORD ImageSubsystemMajorVersion; - DWORD ImageSubsystemMinorVersion; - DWORD ImageProcessAffinityMask; - DWORD GdiHandleBuffer[34]; - DWORD PostProcessInitRoutine; - DWORD TlsExpansionBitmap; - DWORD TlsExpansionBitmapBits[32]; - DWORD SessionId; - ULARGE_INTEGER AppCompatFlags; - ULARGE_INTEGER AppCompatFlagsUser; - DWORD pShimData; - DWORD AppCompatInfo; - UNICODE_STRING CSDVersion; - DWORD ActivationContextData; - DWORD ProcessAssemblyStorageMap; - DWORD SystemDefaultActivationContextData; - DWORD SystemAssemblyStorageMap; - DWORD MinimumStackCommit; - DWORD FlsCallback; - DWORD FlsListHead_Flink; - DWORD FlsListHead_Blink; - DWORD FlsBitmap; - DWORD FlsBitmapBits[4]; - DWORD FlsHighIndex; -} PEB, *PPEB; - -typedef struct _TEB -{ - NT_TIB Tib; - PVOID EnvironmentPointer; - CLIENT_ID Cid; - PVOID ActiveRpcInfo; - PVOID ThreadLocalStoragePointer; - PPEB Peb; - ULONG LastErrorValue; - ULONG CountOfOwnedCriticalSections; - PVOID CsrClientThread; - PVOID Win32ThreadInfo; - ULONG Win32ClientInfo[0x1F]; - PVOID WOW32Reserved; - ULONG CurrentLocale; - ULONG FpSoftwareStatusRegister; - PVOID SystemReserved1[0x36]; - PVOID Spare1; - ULONG ExceptionCode; - ULONG SpareBytes1[0x28]; - PVOID SystemReserved2[0xA]; - ULONG GdiRgn; - ULONG GdiPen; - ULONG GdiBrush; - CLIENT_ID RealClientId; - PVOID GdiCachedProcessHandle; - ULONG GdiClientPID; - ULONG GdiClientTID; - PVOID GdiThreadLocaleInfo; - PVOID UserReserved[5]; - PVOID GlDispatchTable[0x118]; - ULONG GlReserved1[0x1A]; - PVOID GlReserved2; - PVOID GlSectionInfo; - PVOID GlSection; - PVOID GlTable; - PVOID GlCurrentRC; - PVOID GlContext; - NTSTATUS LastStatusValue; - UNICODE_STRING StaticUnicodeString; - WCHAR StaticUnicodeBuffer[0x105]; - PVOID DeallocationStack; - PVOID TlsSlots[0x40]; - LIST_ENTRY TlsLinks; - PVOID Vdm; - PVOID ReservedForNtRpc; - PVOID DbgSsReserved[0x2]; - ULONG HardErrorDisabled; - PVOID Instrumentation[0x10]; - PVOID WinSockData; - ULONG GdiBatchCount; - ULONG Spare2; - ULONG Spare3; - ULONG Spare4; - PVOID ReservedForOle; - ULONG WaitingOnLoaderLock; - PVOID StackCommit; - PVOID StackCommitMax; - PVOID StackReserved; -} TEB, *PTEB; +#include + +//Thanks to: https://github.com/zer0fl4g/Nanomite + +typedef LONG NTSTATUS; + +typedef struct _UNICODE_STRING +{ + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; +} UNICODE_STRING; + +typedef struct _CLIENT_ID +{ + HANDLE UniqueProcess; + HANDLE UniqueThread; +} CLIENT_ID; + +typedef struct _PEB +{ + BYTE InheritedAddressSpace; + BYTE ReadImageFileExecOptions; + BYTE BeingDebugged; + BYTE SpareBool; + DWORD Mutant; + DWORD ImageBaseAddress; + DWORD LoaderData; + DWORD ProcessParameters; + DWORD SubSystemData; + DWORD ProcessHeap; + DWORD FastPebLock; + DWORD FastPebLockRoutine; + DWORD FastPebUnlockRoutine; + DWORD EnviromentUpdateCount; + DWORD KernelCallbackTable; + DWORD UserSharedInfoPtr; + DWORD ThunksOrOptions; + DWORD FreeList; + DWORD TlsExpansionCounter; + DWORD TlsBitmap; + DWORD TlsBitmapBits[2]; + DWORD ReadOnlySharedMemoryBase; + DWORD ReadOnlySharedMemoryHeap; + DWORD ReadOnlyStaticServerData; + DWORD AnsiCodePageData; + DWORD OemCodePageData; + DWORD UnicodeCaseTableData; + DWORD NumberOfProcessors; + DWORD NtGlobalFlag; + DWORD Reserved; + LARGE_INTEGER CriticalSectionTimeout; + DWORD HeapSegmentReserve; + DWORD HeapSegmentCommit; + DWORD HeapDeCommitTotalFreeThreshold; + DWORD HeapDeCommitFreeBlockThreshold; + DWORD NumberOfHeaps; + DWORD MaximumNumberOfHeaps; + DWORD ProcessHeaps; + DWORD GdiSharedHandleTable; + DWORD ProcessStarterHelper; + DWORD GdiDCAttributeList; + DWORD LoaderLock; + DWORD OSMajorVersion; + DWORD OSMinorVersion; + WORD OSBuildNumber; + WORD OSCSDVersion; + DWORD OSPlatformId; + DWORD ImageSubsystem; + DWORD ImageSubsystemMajorVersion; + DWORD ImageSubsystemMinorVersion; + DWORD ImageProcessAffinityMask; + DWORD GdiHandleBuffer[34]; + DWORD PostProcessInitRoutine; + DWORD TlsExpansionBitmap; + DWORD TlsExpansionBitmapBits[32]; + DWORD SessionId; + ULARGE_INTEGER AppCompatFlags; + ULARGE_INTEGER AppCompatFlagsUser; + DWORD pShimData; + DWORD AppCompatInfo; + UNICODE_STRING CSDVersion; + DWORD ActivationContextData; + DWORD ProcessAssemblyStorageMap; + DWORD SystemDefaultActivationContextData; + DWORD SystemAssemblyStorageMap; + DWORD MinimumStackCommit; + DWORD FlsCallback; + DWORD FlsListHead_Flink; + DWORD FlsListHead_Blink; + DWORD FlsBitmap; + DWORD FlsBitmapBits[4]; + DWORD FlsHighIndex; +} PEB, *PPEB; + +typedef struct _TEB +{ + NT_TIB Tib; + PVOID EnvironmentPointer; + CLIENT_ID Cid; + PVOID ActiveRpcInfo; + PVOID ThreadLocalStoragePointer; + PPEB Peb; + ULONG LastErrorValue; + ULONG CountOfOwnedCriticalSections; + PVOID CsrClientThread; + PVOID Win32ThreadInfo; + ULONG Win32ClientInfo[0x1F]; + PVOID WOW32Reserved; + ULONG CurrentLocale; + ULONG FpSoftwareStatusRegister; + PVOID SystemReserved1[0x36]; + PVOID Spare1; + ULONG ExceptionCode; + ULONG SpareBytes1[0x28]; + PVOID SystemReserved2[0xA]; + ULONG GdiRgn; + ULONG GdiPen; + ULONG GdiBrush; + CLIENT_ID RealClientId; + PVOID GdiCachedProcessHandle; + ULONG GdiClientPID; + ULONG GdiClientTID; + PVOID GdiThreadLocaleInfo; + PVOID UserReserved[5]; + PVOID GlDispatchTable[0x118]; + ULONG GlReserved1[0x1A]; + PVOID GlReserved2; + PVOID GlSectionInfo; + PVOID GlSection; + PVOID GlTable; + PVOID GlCurrentRC; + PVOID GlContext; + NTSTATUS LastStatusValue; + UNICODE_STRING StaticUnicodeString; + WCHAR StaticUnicodeBuffer[0x105]; + PVOID DeallocationStack; + PVOID TlsSlots[0x40]; + LIST_ENTRY TlsLinks; + PVOID Vdm; + PVOID ReservedForNtRpc; + PVOID DbgSsReserved[0x2]; + ULONG HardErrorDisabled; + PVOID Instrumentation[0x10]; + PVOID WinSockData; + ULONG GdiBatchCount; + ULONG Spare2; + ULONG Spare3; + ULONG Spare4; + PVOID ReservedForOle; + ULONG WaitingOnLoaderLock; + PVOID StackCommit; + PVOID StackCommitMax; + PVOID StackReserved; +} TEB, *PTEB; diff --git a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp index c4724fc8..da3110bc 100644 --- a/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/AbstractTableView.cpp @@ -129,7 +129,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event) y = getHeaderHeight(); x += getColumnWidth(j); } - emit repainted(); + emit repainted(); } @@ -258,7 +258,7 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event) repaint(); } default: - break; + break; } } @@ -458,19 +458,19 @@ void AbstractTableView::vertSliderActionSlot(int action) switch(action) { case QAbstractSlider::SliderNoAction: - break; + break; case QAbstractSlider::SliderSingleStepAdd: wDelta = 1; - break; + break; case QAbstractSlider::SliderSingleStepSub: wDelta = -1; - break; + break; case QAbstractSlider::SliderPageStepAdd: wDelta = 30; - break; + break; case QAbstractSlider::SliderPageStepSub: wDelta = -30; - break; + break; case QAbstractSlider::SliderToMinimum: case QAbstractSlider::SliderToMaximum: case QAbstractSlider::SliderMove: @@ -479,9 +479,9 @@ void AbstractTableView::vertSliderActionSlot(int action) #else wDelta = wSliderPos - mTableOffset; #endif - break; + break; default: - break; + break; } // Call the hook (Usefull for disassembly) diff --git a/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.cpp b/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.cpp index 7d770644..083bfd7f 100644 --- a/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.cpp @@ -1,133 +1,133 @@ -#include "CommandHelpView.h" -#include "ui_CommandHelpView.h" - -CommandHelpView::CommandHelpView(QWidget *parent) : - QWidget(parent), - ui(new Ui::CommandHelpView) -{ - ui->setupUi(this); - - // Set main layout - mMainLayout = new QVBoxLayout; - mMainLayout->setContentsMargins(0, 0, 0, 0); - mMainLayout->addWidget(ui->mainSplitter); - setLayout(mMainLayout); - - // Create reference view - mSearchListView = new SearchListView(); - mSearchListView->mSearchStartCol = 1; - - // Get font information - QFont wFont("Monospace", 8); - wFont.setStyleHint(QFont::Monospace); - wFont.setFixedPitch(true); - //int charwidth=QFontMetrics(wFont).width(QChar(' ')); - - // Create module list - mModuleList = new StdTable(); - mModuleList->addColumnAt(0, "Module", false); - - // Setup symbol list - mSearchListView->mList->addColumnAt(0, "Command", true); - - // Setup search list - mSearchListView->mSearchList->addColumnAt(0, "Command", true); - - // Setup list splitter - ui->listSplitter->addWidget(mModuleList); - ui->listSplitter->addWidget(mSearchListView); -#ifdef _WIN64 - // mModuleList : mSymbolList = 40 : 100 - ui->listSplitter->setStretchFactor(0, 40); - ui->listSplitter->setStretchFactor(1, 100); -#else - // mModuleList : mSymbolList = 30 : 100 - ui->listSplitter->setStretchFactor(0, 30); - ui->listSplitter->setStretchFactor(1, 100); -#endif //_WIN64 - - // Setup log edit - ui->symbolLogEdit->setFont(wFont); - ui->symbolLogEdit->setStyleSheet("QTextEdit { background-color: rgb(255, 251, 240) }"); - ui->symbolLogEdit->setUndoRedoEnabled(false); - ui->symbolLogEdit->setReadOnly(true); - // Log : List = 2 : 9 - ui->mainSplitter->setStretchFactor(1, 9); - ui->mainSplitter->setStretchFactor(0, 1); - - connect(mModuleList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int))); - connect(mSearchListView->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(symbolSelectionChanged(int))); - - //fill with example data - mModuleList->setRowCount(2); - mModuleList->setCellContent(0, 0, "x64_dbg"); - mModuleList->setCellContent(1, 0, "testplugin"); - - mModuleList->setSingleSelection(0); -} - -CommandHelpView::~CommandHelpView() -{ - delete ui; -} - -void CommandHelpView::moduleSelectionChanged(int index) -{ - mSearchListView->mList->setRowCount(0); - - if(index==0) //x64_dbg - { - mCurrentMode=0; - mSearchListView->mList->setRowCount(3); - mSearchListView->mList->setCellContent(0, 0, "InitDebug"); - mSearchListView->mList->setCellContent(1, 0, "StopDebug"); - mSearchListView->mList->setCellContent(2, 0, "run"); - } - else if(index==1) //testplugin - { - mCurrentMode=1; - mSearchListView->mList->setRowCount(2); - mSearchListView->mList->setCellContent(0, 0, "plugin1"); - mSearchListView->mList->setCellContent(1, 0, "grs"); - } - - mSearchListView->mList->reloadData(); - mSearchListView->mList->setSingleSelection(0); - mSearchListView->mList->setTableOffset(0); - mSearchListView->mList->setFocus(); - mSearchListView->mSearchBox->setText(""); -} - -void CommandHelpView::symbolSelectionChanged(int index) -{ - QString info=""; - if(mCurrentMode==0) //x64_dbg - { - switch(index) - { - case 0: //InitDebug - info="Initialize debugging a file.\n\nExample:\nInitDebug \"C:\\test.exe\", commandline, \"C:\\homeDir\""; - break; - case 1: //StopDebug - info="Stop debugging (terminate the target).\n\nExample:\nStopDebug"; - break; - case 2: //run - info="Resume debugging.\n\nExample:\nrun"; - break; - } - } - else if(mCurrentMode==1) //testplugin - { - switch(index) - { - case 0: //plugin1 - info="Just a simple plugin test command.\n\nExample:\nplugin1"; - break; - case 1: //grs - info="Get relocation table size.\n\nExample:\ngrs 404000"; - break; - } - - } - ui->symbolLogEdit->setText(info); -} +#include "CommandHelpView.h" +#include "ui_CommandHelpView.h" + +CommandHelpView::CommandHelpView(QWidget *parent) : + QWidget(parent), + ui(new Ui::CommandHelpView) +{ + ui->setupUi(this); + + // Set main layout + mMainLayout = new QVBoxLayout; + mMainLayout->setContentsMargins(0, 0, 0, 0); + mMainLayout->addWidget(ui->mainSplitter); + setLayout(mMainLayout); + + // Create reference view + mSearchListView = new SearchListView(); + mSearchListView->mSearchStartCol = 1; + + // Get font information + QFont wFont("Monospace", 8); + wFont.setStyleHint(QFont::Monospace); + wFont.setFixedPitch(true); + //int charwidth=QFontMetrics(wFont).width(QChar(' ')); + + // Create module list + mModuleList = new StdTable(); + mModuleList->addColumnAt(0, "Module", false); + + // Setup symbol list + mSearchListView->mList->addColumnAt(0, "Command", true); + + // Setup search list + mSearchListView->mSearchList->addColumnAt(0, "Command", true); + + // Setup list splitter + ui->listSplitter->addWidget(mModuleList); + ui->listSplitter->addWidget(mSearchListView); +#ifdef _WIN64 + // mModuleList : mSymbolList = 40 : 100 + ui->listSplitter->setStretchFactor(0, 40); + ui->listSplitter->setStretchFactor(1, 100); +#else + // mModuleList : mSymbolList = 30 : 100 + ui->listSplitter->setStretchFactor(0, 30); + ui->listSplitter->setStretchFactor(1, 100); +#endif //_WIN64 + + // Setup log edit + ui->symbolLogEdit->setFont(wFont); + ui->symbolLogEdit->setStyleSheet("QTextEdit { background-color: rgb(255, 251, 240) }"); + ui->symbolLogEdit->setUndoRedoEnabled(false); + ui->symbolLogEdit->setReadOnly(true); + // Log : List = 2 : 9 + ui->mainSplitter->setStretchFactor(1, 9); + ui->mainSplitter->setStretchFactor(0, 1); + + connect(mModuleList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int))); + connect(mSearchListView->mList, SIGNAL(selectionChangedSignal(int)), this, SLOT(symbolSelectionChanged(int))); + + //fill with example data + mModuleList->setRowCount(2); + mModuleList->setCellContent(0, 0, "x64_dbg"); + mModuleList->setCellContent(1, 0, "testplugin"); + + mModuleList->setSingleSelection(0); +} + +CommandHelpView::~CommandHelpView() +{ + delete ui; +} + +void CommandHelpView::moduleSelectionChanged(int index) +{ + mSearchListView->mList->setRowCount(0); + + if(index==0) //x64_dbg + { + mCurrentMode=0; + mSearchListView->mList->setRowCount(3); + mSearchListView->mList->setCellContent(0, 0, "InitDebug"); + mSearchListView->mList->setCellContent(1, 0, "StopDebug"); + mSearchListView->mList->setCellContent(2, 0, "run"); + } + else if(index==1) //testplugin + { + mCurrentMode=1; + mSearchListView->mList->setRowCount(2); + mSearchListView->mList->setCellContent(0, 0, "plugin1"); + mSearchListView->mList->setCellContent(1, 0, "grs"); + } + + mSearchListView->mList->reloadData(); + mSearchListView->mList->setSingleSelection(0); + mSearchListView->mList->setTableOffset(0); + mSearchListView->mList->setFocus(); + mSearchListView->mSearchBox->setText(""); +} + +void CommandHelpView::symbolSelectionChanged(int index) +{ + QString info=""; + if(mCurrentMode==0) //x64_dbg + { + switch(index) + { + case 0: //InitDebug + info="Initialize debugging a file.\n\nExample:\nInitDebug \"C:\\test.exe\", commandline, \"C:\\homeDir\""; + break; + case 1: //StopDebug + info="Stop debugging (terminate the target).\n\nExample:\nStopDebug"; + break; + case 2: //run + info="Resume debugging.\n\nExample:\nrun"; + break; + } + } + else if(mCurrentMode==1) //testplugin + { + switch(index) + { + case 0: //plugin1 + info="Just a simple plugin test command.\n\nExample:\nplugin1"; + break; + case 1: //grs + info="Get relocation table size.\n\nExample:\ngrs 404000"; + break; + } + + } + ui->symbolLogEdit->setText(info); +} diff --git a/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.h b/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.h index 8e2a990b..0109674e 100644 --- a/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.h +++ b/x64_dbg_gui/Project/Src/BasicView/CommandHelpView.h @@ -1,41 +1,42 @@ -#ifndef COMMANDHELPVIEW_H -#define COMMANDHELPVIEW_H - -#include -#include -#include -#include -#include "StdTable.h" -#include "Bridge.h" -#include "SearchListView.h" - -namespace Ui { -class CommandHelpView; -} - -class CommandHelpView : public QWidget -{ - Q_OBJECT - -public: - explicit CommandHelpView(QWidget *parent = 0); - ~CommandHelpView(); - -private slots: - void moduleSelectionChanged(int index); - void symbolSelectionChanged(int index); - -signals: - void showCpu(); - -private: - Ui::CommandHelpView *ui; - QVBoxLayout* mMainLayout; - QVBoxLayout* mSymbolLayout; - QWidget* mSymbolPlaceHolder; - SearchListView* mSearchListView; - StdTable* mModuleList; - int mCurrentMode; -}; - -#endif // COMMANDHELPVIEW_H +#ifndef COMMANDHELPVIEW_H +#define COMMANDHELPVIEW_H + +#include +#include +#include +#include +#include "StdTable.h" +#include "Bridge.h" +#include "SearchListView.h" + +namespace Ui +{ +class CommandHelpView; +} + +class CommandHelpView : public QWidget +{ + Q_OBJECT + +public: + explicit CommandHelpView(QWidget *parent = 0); + ~CommandHelpView(); + +private slots: + void moduleSelectionChanged(int index); + void symbolSelectionChanged(int index); + +signals: + void showCpu(); + +private: + Ui::CommandHelpView *ui; + QVBoxLayout* mMainLayout; + QVBoxLayout* mSymbolLayout; + QWidget* mSymbolPlaceHolder; + SearchListView* mSearchListView; + StdTable* mModuleList; + int mCurrentMode; +}; + +#endif // COMMANDHELPVIEW_H diff --git a/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp b/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp index c721a773..9a80a156 100644 --- a/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/Disassembly.cpp @@ -282,7 +282,9 @@ QString Disassembly::paintContent(QPainter* painter, int_t rowBase, int rowOffse painter->setPen(Configuration::instance()->color("DisassemblyCommentColor")); //DisassemblyCommentColor painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, QString(comment)); painter->restore(); - }else{ + } + else + { painter->save(); painter->setPen(Configuration::instance()->color("DisassemblyCommentColor")); //DisassemblyCommentColor //painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, "QString(comment)"); diff --git a/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.cpp b/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.cpp index b37b4384..b70562e2 100644 --- a/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.cpp @@ -1,51 +1,51 @@ -#include "HistoryLineEdit.h" - -HistoryLineEdit::HistoryLineEdit(QWidget *parent) : QLineEdit(parent) -{ - mCmdHistory.clear(); - mCmdIndex = -1; -} - -void HistoryLineEdit::addLineToHistory(QString parLine) -{ - mCmdHistory.prepend(parLine); - - if(mCmdHistory.size() > 32) - mCmdHistory.removeLast(); - - mCmdIndex = -1; -} - -void HistoryLineEdit::keyPressEvent(QKeyEvent* event) -{ - int wKey = event->key(); - - if(wKey == Qt::Key_Up || wKey == Qt::Key_Down) - { - if(wKey == Qt::Key_Up) - mCmdIndex++; - else if(wKey == Qt::Key_Down) - mCmdIndex--; - - mCmdIndex = mCmdIndex < -1 ? -1 : mCmdIndex; - mCmdIndex = mCmdIndex > mCmdHistory.size() - 1 ? mCmdHistory.size() - 1 : mCmdIndex; - - if(mCmdIndex == -1) - { - setText(""); - } - else - { - setText(mCmdHistory.at(mCmdIndex)); - } - } - - QLineEdit::keyPressEvent(event); -} - -void HistoryLineEdit::setFocus() -{ - mCmdIndex = -1; - QLineEdit::setFocus(); -} - +#include "HistoryLineEdit.h" + +HistoryLineEdit::HistoryLineEdit(QWidget *parent) : QLineEdit(parent) +{ + mCmdHistory.clear(); + mCmdIndex = -1; +} + +void HistoryLineEdit::addLineToHistory(QString parLine) +{ + mCmdHistory.prepend(parLine); + + if(mCmdHistory.size() > 32) + mCmdHistory.removeLast(); + + mCmdIndex = -1; +} + +void HistoryLineEdit::keyPressEvent(QKeyEvent* event) +{ + int wKey = event->key(); + + if(wKey == Qt::Key_Up || wKey == Qt::Key_Down) + { + if(wKey == Qt::Key_Up) + mCmdIndex++; + else if(wKey == Qt::Key_Down) + mCmdIndex--; + + mCmdIndex = mCmdIndex < -1 ? -1 : mCmdIndex; + mCmdIndex = mCmdIndex > mCmdHistory.size() - 1 ? mCmdHistory.size() - 1 : mCmdIndex; + + if(mCmdIndex == -1) + { + setText(""); + } + else + { + setText(mCmdHistory.at(mCmdIndex)); + } + } + + QLineEdit::keyPressEvent(event); +} + +void HistoryLineEdit::setFocus() +{ + mCmdIndex = -1; + QLineEdit::setFocus(); +} + diff --git a/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.h b/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.h index 7ef9485a..87e7926e 100644 --- a/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.h +++ b/x64_dbg_gui/Project/Src/BasicView/HistoryLineEdit.h @@ -1,29 +1,29 @@ -#ifndef HISTORYLINEEDIT_H -#define HISTORYLINEEDIT_H - -#include -#include -#include - -class HistoryLineEdit : public QLineEdit -{ - Q_OBJECT -public: - explicit HistoryLineEdit(QWidget *parent = 0); - void keyPressEvent(QKeyEvent* event); - void addLineToHistory(QString parLine); - void setFocus(); - -signals: - void keyPressed(int parKey); - -public slots: - - -private: - QList mCmdHistory; - int mCmdIndex; - -}; - -#endif // HISTORYLINEEDIT_H +#ifndef HISTORYLINEEDIT_H +#define HISTORYLINEEDIT_H + +#include +#include +#include + +class HistoryLineEdit : public QLineEdit +{ + Q_OBJECT +public: + explicit HistoryLineEdit(QWidget *parent = 0); + void keyPressEvent(QKeyEvent* event); + void addLineToHistory(QString parLine); + void setFocus(); + +signals: + void keyPressed(int parKey); + +public slots: + + +private: + QList mCmdHistory; + int mCmdIndex; + +}; + +#endif // HISTORYLINEEDIT_H diff --git a/x64_dbg_gui/Project/Src/BasicView/LineEditDialog.h b/x64_dbg_gui/Project/Src/BasicView/LineEditDialog.h index 8de68484..ab8ff5a3 100644 --- a/x64_dbg_gui/Project/Src/BasicView/LineEditDialog.h +++ b/x64_dbg_gui/Project/Src/BasicView/LineEditDialog.h @@ -3,7 +3,8 @@ #include -namespace Ui { +namespace Ui +{ class LineEditDialog; } diff --git a/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp b/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp index b1c07fb4..989be809 100644 --- a/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/MemoryMapView.cpp @@ -87,35 +87,35 @@ void MemoryMapView::stateChangedSlot(DBGSTATE state) // State switch(wMbi.State) { - case MEM_FREE: - wS = QString("FREE"); - break; - case MEM_COMMIT: - wS = QString("COMM"); - break; - case MEM_RESERVE: - wS = QString("RESV"); - break; - default: - wS = QString("????"); + case MEM_FREE: + wS = QString("FREE"); + break; + case MEM_COMMIT: + wS = QString("COMM"); + break; + case MEM_RESERVE: + wS = QString("RESV"); + break; + default: + wS = QString("????"); } setCellContent(wI, 3, wS); // Type switch(wMbi.Type) { - case MEM_IMAGE: - wS = QString("IMG"); - break; - case MEM_MAPPED: - wS = QString("MAP"); - break; - case MEM_PRIVATE: - wS = QString("PRV"); - break; - default: - wS = QString("N/A"); - break; + case MEM_IMAGE: + wS = QString("IMG"); + break; + case MEM_MAPPED: + wS = QString("MAP"); + break; + case MEM_PRIVATE: + wS = QString("PRV"); + break; + default: + wS = QString("N/A"); + break; } setCellContent(wI, 3, wS); diff --git a/x64_dbg_gui/Project/Src/BasicView/RegistersView.cpp b/x64_dbg_gui/Project/Src/BasicView/RegistersView.cpp index 4b44b1ab..fc51793f 100644 --- a/x64_dbg_gui/Project/Src/BasicView/RegistersView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/RegistersView.cpp @@ -205,7 +205,8 @@ void RegistersView::mouseDoubleClickEvent(QMouseEvent* event) mRegNamesList->at(mSelected) == CIP || mRegNamesList->at(mSelected) == EFLAGS) - { //double clicked general register + { + //double clicked general register displayEditDialog(); } else if(mRegNamesList->at(mSelected) == CF || @@ -217,7 +218,8 @@ void RegistersView::mouseDoubleClickEvent(QMouseEvent* event) mRegNamesList->at(mSelected) == IF || mRegNamesList->at(mSelected) == DF || mRegNamesList->at(mSelected) == OF) - { //double clicked a flag + { + //double clicked a flag setRegister(mRegNamesList->at(mSelected), mRegList->at(mSelected)->text().toInt()^1); //toggle flag (stupid way in fact) } } diff --git a/x64_dbg_gui/Project/Src/BasicView/RegistersView.h b/x64_dbg_gui/Project/Src/BasicView/RegistersView.h index 6ac7b3d9..08210295 100644 --- a/x64_dbg_gui/Project/Src/BasicView/RegistersView.h +++ b/x64_dbg_gui/Project/Src/BasicView/RegistersView.h @@ -8,16 +8,18 @@ #include "WordEditDialog.h" #include "LineEditDialog.h" -namespace Ui { +namespace Ui +{ class RegistersView; } class RegistersView : public QWidget { Q_OBJECT - + public: - enum REGISTER_NAME { + enum REGISTER_NAME + { CAX, CCX, CDX, @@ -75,7 +77,7 @@ public slots: void displayCustomContextMenuSlot(QPoint pos); void setRegister(REGISTER_NAME reg, uint_t value); void debugStateChangedSlot(DBGSTATE state); - + private: void displayEditDialog(); Ui::RegistersView *ui; diff --git a/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.cpp b/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.cpp index a7b71151..d6d3750a 100644 --- a/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.cpp @@ -1,44 +1,44 @@ -#include "RichTextPainter.h" - -void RichTextPainter::paintRichText(QPainter* painter, int x, int y, int w, int h, int xinc, const QList* richText, int charwidth) -{ - int len=richText->size(); - for(int i=0; iat(i); - int curRichTextLength=curRichText.text.length(); - int backgroundWidth=charwidth*curRichTextLength; - if(backgroundWidth+xinc>w) - backgroundWidth=w-xinc; - if(backgroundWidth<=0) //stop drawing when going outside the specified width - break; - switch(curRichText.flags) - { - case FlagNone: //defaults - painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); - break; - case FlagColor: //color only - painter->save(); - painter->setPen(QPen(curRichText.textColor)); - painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); - painter->restore(); - break; - case FlagBackground: //background only - painter->save(); - if(backgroundWidth>0) - painter->fillRect(QRect(x+xinc, y, backgroundWidth, h), QBrush(curRichText.textBackground)); - painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); - painter->restore(); - break; - case FlagAll: //color+background - painter->save(); - if(backgroundWidth>0) - painter->fillRect(QRect(x+xinc, y, backgroundWidth, h), QBrush(curRichText.textBackground)); - painter->setPen(QPen(curRichText.textColor)); - painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); - painter->restore(); - break; - } - xinc+=charwidth*curRichTextLength; - } -} +#include "RichTextPainter.h" + +void RichTextPainter::paintRichText(QPainter* painter, int x, int y, int w, int h, int xinc, const QList* richText, int charwidth) +{ + int len=richText->size(); + for(int i=0; iat(i); + int curRichTextLength=curRichText.text.length(); + int backgroundWidth=charwidth*curRichTextLength; + if(backgroundWidth+xinc>w) + backgroundWidth=w-xinc; + if(backgroundWidth<=0) //stop drawing when going outside the specified width + break; + switch(curRichText.flags) + { + case FlagNone: //defaults + painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); + break; + case FlagColor: //color only + painter->save(); + painter->setPen(QPen(curRichText.textColor)); + painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); + painter->restore(); + break; + case FlagBackground: //background only + painter->save(); + if(backgroundWidth>0) + painter->fillRect(QRect(x+xinc, y, backgroundWidth, h), QBrush(curRichText.textBackground)); + painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); + painter->restore(); + break; + case FlagAll: //color+background + painter->save(); + if(backgroundWidth>0) + painter->fillRect(QRect(x+xinc, y, backgroundWidth, h), QBrush(curRichText.textBackground)); + painter->setPen(QPen(curRichText.textColor)); + painter->drawText(QRect(x+xinc, y, w-xinc, h), 0, curRichText.text); + painter->restore(); + break; + } + xinc+=charwidth*curRichTextLength; + } +} diff --git a/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.h b/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.h index a3b64137..1b32e5ff 100644 --- a/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.h +++ b/x64_dbg_gui/Project/Src/BasicView/RichTextPainter.h @@ -1,31 +1,31 @@ -#ifndef RICHTEXTPAINTER_H -#define RICHTEXTPAINTER_H - -#include -#include - -//structures -enum CustomRichTextFlags -{ - FlagNone, - FlagColor, - FlagBackground, - FlagAll -}; - -typedef struct _CustomRichText_t -{ - QString text; - QColor textColor; - QColor textBackground; - CustomRichTextFlags flags; -} CustomRichText_t; - -class RichTextPainter -{ -public: - //functions - static void paintRichText(QPainter* painter, int x, int y, int w, int h, int xinc, const QList* richText, int charwidth); -}; - -#endif // RICHTEXTPAINTER_H +#ifndef RICHTEXTPAINTER_H +#define RICHTEXTPAINTER_H + +#include +#include + +//structures +enum CustomRichTextFlags +{ + FlagNone, + FlagColor, + FlagBackground, + FlagAll +}; + +typedef struct _CustomRichText_t +{ + QString text; + QColor textColor; + QColor textBackground; + CustomRichTextFlags flags; +} CustomRichText_t; + +class RichTextPainter +{ +public: + //functions + static void paintRichText(QPainter* painter, int x, int y, int w, int h, int xinc, const QList* richText, int charwidth); +}; + +#endif // RICHTEXTPAINTER_H diff --git a/x64_dbg_gui/Project/Src/BasicView/ScriptView.cpp b/x64_dbg_gui/Project/Src/BasicView/ScriptView.cpp index b31df9eb..23d39970 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ScriptView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/ScriptView.cpp @@ -130,7 +130,7 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset case scriptjmp: //unconditional jumps newRichText.flags=FlagBackground; newRichText.textBackground=QColor("#FFFF00"); - break; + break; case scriptjnejnz: //conditional jumps case scriptjejz: @@ -141,16 +141,16 @@ QString ScriptView::paintContent(QPainter* painter, int_t rowBase, int rowOffset newRichText.flags=FlagAll; newRichText.textBackground=QColor("#FFFF00"); newRichText.textColor=QColor("#FF0000"); - break; + break; case scriptcall: //calls newRichText.flags=FlagBackground; newRichText.textBackground=QColor("#00FFFF"); - break; + break; default: newRichText.flags=FlagNone; - break; + break; } newRichText.text=command.left(i); richText.push_back(newRichText); diff --git a/x64_dbg_gui/Project/Src/BasicView/SearchListView.h b/x64_dbg_gui/Project/Src/BasicView/SearchListView.h index 83cde398..b28a40ea 100644 --- a/x64_dbg_gui/Project/Src/BasicView/SearchListView.h +++ b/x64_dbg_gui/Project/Src/BasicView/SearchListView.h @@ -6,8 +6,9 @@ #include #include "StdTable.h" -namespace Ui { - class SearchListView; +namespace Ui +{ +class SearchListView; } class SearchListView : public QWidget diff --git a/x64_dbg_gui/Project/Src/BasicView/SymbolView.h b/x64_dbg_gui/Project/Src/BasicView/SymbolView.h index cbbe0f12..abb33721 100644 --- a/x64_dbg_gui/Project/Src/BasicView/SymbolView.h +++ b/x64_dbg_gui/Project/Src/BasicView/SymbolView.h @@ -9,7 +9,8 @@ #include "Bridge.h" #include "SearchListView.h" -namespace Ui { +namespace Ui +{ class SymbolView; } diff --git a/x64_dbg_gui/Project/Src/BasicView/ThreadView.cpp b/x64_dbg_gui/Project/Src/BasicView/ThreadView.cpp index 5aa2b421..8f64ded9 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ThreadView.cpp +++ b/x64_dbg_gui/Project/Src/BasicView/ThreadView.cpp @@ -1,210 +1,210 @@ -#include "ThreadView.h" - -ThreadView::ThreadView(StdTable *parent) : StdTable(parent) -{ - int charwidth=QFontMetrics(this->font()).width(QChar(' ')); - addColumnAt(8+charwidth*sizeof(unsigned int)*2, "Number", false); - addColumnAt(8+charwidth*sizeof(unsigned int)*2, "ID", false); - addColumnAt(8+charwidth*sizeof(uint_t)*2, "Entry", false); - addColumnAt(8+charwidth*sizeof(uint_t)*2, "TEB", false); -#ifdef _WIN64 - addColumnAt(8+charwidth*sizeof(uint_t)*2, "RIP", false); -#else - addColumnAt(8+charwidth*sizeof(uint_t)*2, "EIP", false); -#endif //_WIN64 - addColumnAt(8+charwidth*14, "Suspend Count", false); - addColumnAt(8+charwidth*12, "Priority", false); - addColumnAt(8+charwidth*16, "WaitReason", false); - addColumnAt(8+charwidth*10, "LastError", false); - addColumnAt(0, "", false); - - connect(Bridge::getBridge(), SIGNAL(updateThreads()), this, SLOT(updateThreadList())); -} - -void ThreadView::updateThreadList() -{ - THREADLIST threadList; - memset(&threadList, 0, sizeof(THREADLIST)); - DbgGetThreadList(&threadList); - setRowCount(threadList.count); - for(int i=0; isave(); - painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000"))); - painter->setPen(QPen(QColor("#FFFFFF"))); //white text - painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, ret); - painter->restore(); - ret=""; - } - return ret; -} +#include "ThreadView.h" + +ThreadView::ThreadView(StdTable *parent) : StdTable(parent) +{ + int charwidth=QFontMetrics(this->font()).width(QChar(' ')); + addColumnAt(8+charwidth*sizeof(unsigned int)*2, "Number", false); + addColumnAt(8+charwidth*sizeof(unsigned int)*2, "ID", false); + addColumnAt(8+charwidth*sizeof(uint_t)*2, "Entry", false); + addColumnAt(8+charwidth*sizeof(uint_t)*2, "TEB", false); +#ifdef _WIN64 + addColumnAt(8+charwidth*sizeof(uint_t)*2, "RIP", false); +#else + addColumnAt(8+charwidth*sizeof(uint_t)*2, "EIP", false); +#endif //_WIN64 + addColumnAt(8+charwidth*14, "Suspend Count", false); + addColumnAt(8+charwidth*12, "Priority", false); + addColumnAt(8+charwidth*16, "WaitReason", false); + addColumnAt(8+charwidth*10, "LastError", false); + addColumnAt(0, "", false); + + connect(Bridge::getBridge(), SIGNAL(updateThreads()), this, SLOT(updateThreadList())); +} + +void ThreadView::updateThreadList() +{ + THREADLIST threadList; + memset(&threadList, 0, sizeof(THREADLIST)); + DbgGetThreadList(&threadList); + setRowCount(threadList.count); + for(int i=0; isave(); + painter->fillRect(QRect(x, y, w, h), QBrush(QColor("#000000"))); + painter->setPen(QPen(QColor("#FFFFFF"))); //white text + painter->drawText(QRect(x + 4, y , w - 4 , h), Qt::AlignVCenter | Qt::AlignLeft, ret); + painter->restore(); + ret=""; + } + return ret; +} diff --git a/x64_dbg_gui/Project/Src/BasicView/ThreadView.h b/x64_dbg_gui/Project/Src/BasicView/ThreadView.h index 95868167..1f67a666 100644 --- a/x64_dbg_gui/Project/Src/BasicView/ThreadView.h +++ b/x64_dbg_gui/Project/Src/BasicView/ThreadView.h @@ -1,21 +1,21 @@ -#ifndef THREADVIEW_H -#define THREADVIEW_H - -#include "StdTable.h" -#include "Bridge.h" - -class ThreadView : public StdTable -{ - Q_OBJECT -public: - explicit ThreadView(StdTable* parent = 0); - QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h); - -public slots: - void updateThreadList(); - -private: - int mCurrentThread; -}; - -#endif // THREADVIEW_H +#ifndef THREADVIEW_H +#define THREADVIEW_H + +#include "StdTable.h" +#include "Bridge.h" + +class ThreadView : public StdTable +{ + Q_OBJECT +public: + explicit ThreadView(StdTable* parent = 0); + QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h); + +public slots: + void updateThreadList(); + +private: + int mCurrentThread; +}; + +#endif // THREADVIEW_H diff --git a/x64_dbg_gui/Project/Src/BasicView/WordEditDialog.h b/x64_dbg_gui/Project/Src/BasicView/WordEditDialog.h index fe2dac05..9abb0a90 100644 --- a/x64_dbg_gui/Project/Src/BasicView/WordEditDialog.h +++ b/x64_dbg_gui/Project/Src/BasicView/WordEditDialog.h @@ -6,14 +6,15 @@ #include #include "Bridge.h" -namespace Ui { +namespace Ui +{ class WordEditDialog; } class WordEditDialog : public QDialog { Q_OBJECT - + public: explicit WordEditDialog(QWidget *parent = 0); ~WordEditDialog(); @@ -22,7 +23,7 @@ public: public slots: void expressionChanged(QString s); - + private: Ui::WordEditDialog *ui; uint_t mWord; diff --git a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp index f7186517..825008d4 100644 --- a/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp +++ b/x64_dbg_gui/Project/Src/Bridge/Bridge.cpp @@ -276,13 +276,13 @@ bool Bridge::emitSelectionGet(int hWindow, SELECTIONDATA* selection) { case GUI_DISASSEMBLY: emit selectionDisasmGet(selection); - break; + break; case GUI_DUMP: emit selectionDumpGet(selection); - break; + break; case GUI_STACK: emit selectionStackGet(selection); - break; + break; default: mBridgeMutex.unlock(); return false; @@ -309,13 +309,13 @@ bool Bridge::emitSelectionSet(int hWindow, const SELECTIONDATA* selection) { case GUI_DISASSEMBLY: emit selectionDisasmSet(selection); - break; + break; case GUI_DUMP: emit selectionDumpSet(selection); - break; + break; case GUI_STACK: emit selectionStackSet(selection); - break; + break; default: mBridgeMutex.unlock(); return false; diff --git a/x64_dbg_gui/Project/Src/Exports.h b/x64_dbg_gui/Project/Src/Exports.h index 01d6f569..291fcbfe 100644 --- a/x64_dbg_gui/Project/Src/Exports.h +++ b/x64_dbg_gui/Project/Src/Exports.h @@ -8,8 +8,8 @@ ************************************************************************************/ #ifdef BUILD_LIB - extern "C" __declspec(dllexport) int _gui_guiinit(int argc, char *argv[]); - extern "C" __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* param2); +extern "C" __declspec(dllexport) int _gui_guiinit(int argc, char *argv[]); +extern "C" __declspec(dllexport) void* _gui_sendmessage(GUIMSG type, void* param1, void* param2); #endif diff --git a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp index 8fad3fda..9fdcf712 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUDisassembly.cpp @@ -64,7 +64,7 @@ void CPUDisassembly::mouseDoubleClickEvent(QMouseEvent* event) default: Disassembly::mouseDoubleClickEvent(event); - break; + break; } } @@ -140,18 +140,18 @@ void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event) { case 0: msetHwBPOnSlot0Action->setText("Replace Slot 0 (0x" + QString("%1").arg(wBPList.bp[wI].addr, 8, 16, QChar('0')).toUpper() + ")"); - break; + break; case 1: msetHwBPOnSlot1Action->setText("Replace Slot 1 (0x" + QString("%1").arg(wBPList.bp[wI].addr, 8, 16, QChar('0')).toUpper() + ")"); - break; + break; case 2: msetHwBPOnSlot2Action->setText("Replace Slot 2 (0x" + QString("%1").arg(wBPList.bp[wI].addr, 8, 16, QChar('0')).toUpper() + ")"); - break; + break; case 3: msetHwBPOnSlot3Action->setText("Replace Slot 3 (0x" + QString("%1").arg(wBPList.bp[wI].addr, 8, 16, QChar('0')).toUpper() + ")"); - break; + break; default: - break; + break; } } diff --git a/x64_dbg_gui/Project/Src/Gui/CPUJumps.cpp b/x64_dbg_gui/Project/Src/Gui/CPUJumps.cpp index d7240cbd..8f6418c0 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUJumps.cpp +++ b/x64_dbg_gui/Project/Src/Gui/CPUJumps.cpp @@ -1,261 +1,282 @@ -#include "CPUJumps.h" -#include "Configuration.h" -CPUJumps::CPUJumps(CPUDisassembly *Ptr, QWidget *parent) : - QAbstractScrollArea(parent) -{ - - topVA = -1; - selectedVA = -1; - viewableRows = 0; - - CodePtr = Ptr; - - m_DefaultFont = QFont("Monospace", 8); - - const QFontMetrics metrics(m_DefaultFont); - fontWidth = metrics.width('W'); - fontHeight = metrics.height(); - - InstrBuffer = CodePtr->instructionsBuffer(); - - connect(Bridge::getBridge(), SIGNAL(disassembleAt(int_t, int_t)), this, SLOT(disassembleAt(int_t, int_t))); -} - -QSize CPUJumps::sizeHint() const -{ - return QSize(40,this->viewport()->height()); -} - - -void CPUJumps::disassembleAt(int_t parVA, int_t parCIP) -{ - //repaint(); -} - -void CPUJumps::repaint(){ - - viewport()->repaint(); -} - -void CPUJumps::changeTopmostAddress(int i) -{ - if(i!=topVA){ - topVA = i; - qDebug() << i; - repaint(); - } -} - -void CPUJumps::setViewableRows(int rows) -{ - viewableRows = rows; -} - -void CPUJumps::setSelection(int_t selVA) -{ - if(selVA != selectedVA){ - selectedVA = selVA; - repaint(); - } -} - -bool CPUJumps::isJump(int i) const{ - - int BranchType=InstrBuffer->at(i).disasm.Instruction.BranchType; - if(BranchType && BranchType!=RetType && BranchType!=CallType){ - return true; - } - return false; -} - -void CPUJumps::paintEvent(QPaintEvent *event) -{ - if(InstrBuffer->size() ==0) - return; - - painter = new QPainter(viewport()); - - int jumpoffset = 0; - - int_t last_va = InstrBuffer->last().rva + CodePtr->getBase(); - int_t first_va = InstrBuffer->first().rva + CodePtr->getBase(); - - for(int line=0;lineat(line).rva + CodePtr->getBase()) == bp_none); - - - if(isJump(line)){ - jumpoffset++; - - int_t destRVA = (int_t)InstrBuffer->at(line).disasm.Instruction.AddrValue; - - if( InstrBuffer->at(line).disasm.Instruction.Opcode == 0xFF) - continue; - - - bool cond = !((InstrBuffer->at(line).disasm.Instruction.Opcode == 0xEB) || InstrBuffer->at(line).disasm.Instruction.Opcode == 0xE9); - if(destRVA <= last_va && destRVA >= first_va){ - - int destLine = line+1; - - while(InstrBuffer->at(destLine).rva + CodePtr->getBase() != destRVA - && destLine at(line).rva+CodePtr->getBase())&&CodePtr->currentEIP() == InstrBuffer->at(line).rva, - selectedVA == InstrBuffer->at(line).rva+CodePtr->getBase()); - - - }else if(destRVA > last_va){ - drawJump(line, - viewableRows+6, - jumpoffset, - cond, - DbgIsJumpGoingToExecute(InstrBuffer->at(line).rva+CodePtr->getBase())&&CodePtr->currentEIP() == InstrBuffer->at(line).rva, - selectedVA == InstrBuffer->at(line).rva+CodePtr->getBase()); - }else if(destRVA < first_va){ - drawJump(line, - -6, - jumpoffset, - cond, - DbgIsJumpGoingToExecute(InstrBuffer->at(line).rva+CodePtr->getBase())&&CodePtr->currentEIP() == InstrBuffer->at(line).rva, - selectedVA == InstrBuffer->at(line).rva+CodePtr->getBase()); - } - - } - - if(InstrBuffer->at(line).rva == CodePtr->currentEIP()){ - drawLabel(line,"EIP"); - } - - } - - - //delete painter; -} - -void CPUJumps::drawJump(int startLine,int endLine,int jumpoffset, bool conditional, bool isexecute, bool isactive){ - painter->save(); - if(!conditional){ - painter->setPen(QPen(QColor("#000000"),1, Qt::SolidLine)); // jmp - }else{ - painter->setPen(QPen(QColor("#000000"),1, Qt::DashLine)); - } - QPen tmp = painter->pen(); - if(isexecute){ - tmp.setWidth(2); - //tmp.setColor(Qt::red); - } - if(isactive){ - tmp.setColor(Qt::red); - } - painter->setPen(tmp); - - const int JumpPadding = 15; - - const int x = viewport()->width()-jumpoffset*JumpPadding - 12; - const int x_right = viewport()->width()- 12; - const int y_start = fontHeight*(1+startLine)-0.5*fontHeight; - const int y_end = fontHeight*(1+endLine)-0.5*fontHeight; - - // vertical - painter->drawLine(x,y_start,x,y_end); - // start horizontal - painter->drawLine(x,y_start,x_right,y_start); - painter->drawLine(x,y_end,x_right,y_end); - - const int ArrowSizeX = 2; // width of arrow tip in pixel - const int ArrowSizeY = 3; // height of arrow tip in pixel - - - tmp = painter->pen(); - tmp.setStyle(Qt::SolidLine); - tmp.setWidth(2); - painter->setPen(tmp); - painter->drawLine(x_right-ArrowSizeX,y_end-ArrowSizeY,x_right,y_end); - painter->drawLine(x_right-ArrowSizeX,y_end+ArrowSizeY,x_right,y_end); - - - painter->restore(); -} - -void CPUJumps::drawBullets(int line, bool isbp){ - - - painter->save(); - - if( isbp) - painter->setBrush(QBrush("#808080")); - else - painter->setBrush(QBrush(Qt::red)); - - const int y = fontHeight*(1+line)-0.8*fontHeight ; - const int x = viewport()->width() - 10; - const int radius = 8; - - painter->setRenderHint(QPainter::Antialiasing, true); - painter->setPen(QPen("#ffffff")); - painter->drawEllipse(x,y,radius,radius); - - - - painter->restore(); -} - - - - -void CPUJumps::drawLabel(int Line, QString Text){ - - painter->save(); - const int LineCoordinate = fontHeight*(1+Line); - int length = Text.length(); - - painter->setBrush(QBrush(Configuration::instance()->color("EIPLabelBG"))); - painter->setPen(QPen(Configuration::instance()->color("EIPLabelBG"))); - int y = LineCoordinate-fontHeight; - - painter->drawRect(1,y,length*fontWidth,fontHeight); - painter->setPen(QPen(Configuration::instance()->color("EIPLabel"))); - painter->drawText(2,LineCoordinate-0.2*fontHeight,Text); - - y = fontHeight*(1+Line)-0.5*fontHeight; - painter->setPen(QPen(Configuration::instance()->color("EIPLabelBG"),2)); - painter->setBrush(QBrush(Configuration::instance()->color("EIPLabelBG"))); - - drawStraightArrow(painter,length*fontWidth,y,this->viewport()->width()-2-15,y); - painter->restore(); - -} - -void CPUJumps::drawStraightArrow(QPainter *painter, int x1, int y1, int x2, int y2) -{ - - - painter->drawLine(x1,y1,x2,y2); - - - - /* - // this does not work - QPainterPath path; - - path.moveTo( QPointF(x2, x2)); - path.lineTo (QPointF(x2-ArrowSizeX,y2-ArrowSizeY)); - path.lineTo (QPointF(x2-ArrowSizeX,y2+ArrowSizeY)); - path.closeSubpath(); - - painter->setPen (Qt :: NoPen); - painter->fillPath (path, QBrush (color));*/ - const int ArrowSizeX = 4; // width of arrow tip in pixel - const int ArrowSizeY = 4; // height of arrow tip in pixel - - - painter->drawLine(x2,y2,x2-ArrowSizeX,y2-ArrowSizeY); - painter->drawLine(x2,y2,x2-ArrowSizeX,y2+ArrowSizeY); - -} - +#include "CPUJumps.h" +#include "Configuration.h" +CPUJumps::CPUJumps(CPUDisassembly *Ptr, QWidget *parent) : + QAbstractScrollArea(parent) +{ + + topVA = -1; + selectedVA = -1; + viewableRows = 0; + + CodePtr = Ptr; + + m_DefaultFont = QFont("Monospace", 8); + + const QFontMetrics metrics(m_DefaultFont); + fontWidth = metrics.width('W'); + fontHeight = metrics.height(); + + InstrBuffer = CodePtr->instructionsBuffer(); + + connect(Bridge::getBridge(), SIGNAL(disassembleAt(int_t, int_t)), this, SLOT(disassembleAt(int_t, int_t))); +} + +QSize CPUJumps::sizeHint() const +{ + return QSize(40,this->viewport()->height()); +} + + +void CPUJumps::disassembleAt(int_t parVA, int_t parCIP) +{ + //repaint(); +} + +void CPUJumps::repaint() +{ + + viewport()->repaint(); +} + +void CPUJumps::changeTopmostAddress(int i) +{ + if(i!=topVA) + { + topVA = i; + qDebug() << i; + repaint(); + } +} + +void CPUJumps::setViewableRows(int rows) +{ + viewableRows = rows; +} + +void CPUJumps::setSelection(int_t selVA) +{ + if(selVA != selectedVA) + { + selectedVA = selVA; + repaint(); + } +} + +bool CPUJumps::isJump(int i) const +{ + + int BranchType=InstrBuffer->at(i).disasm.Instruction.BranchType; + if(BranchType && BranchType!=RetType && BranchType!=CallType) + { + return true; + } + return false; +} + +void CPUJumps::paintEvent(QPaintEvent *event) +{ + if(InstrBuffer->size() ==0) + return; + + painter = new QPainter(viewport()); + + int jumpoffset = 0; + + int_t last_va = InstrBuffer->last().rva + CodePtr->getBase(); + int_t first_va = InstrBuffer->first().rva + CodePtr->getBase(); + + for(int line=0; lineat(line).rva + CodePtr->getBase()) == bp_none); + + + if(isJump(line)) + { + jumpoffset++; + + int_t destRVA = (int_t)InstrBuffer->at(line).disasm.Instruction.AddrValue; + + if( InstrBuffer->at(line).disasm.Instruction.Opcode == 0xFF) + continue; + + + bool cond = !((InstrBuffer->at(line).disasm.Instruction.Opcode == 0xEB) || InstrBuffer->at(line).disasm.Instruction.Opcode == 0xE9); + if(destRVA <= last_va && destRVA >= first_va) + { + + int destLine = line+1; + + while(InstrBuffer->at(destLine).rva + CodePtr->getBase() != destRVA + && destLine at(line).rva+CodePtr->getBase())&&CodePtr->currentEIP() == InstrBuffer->at(line).rva, + selectedVA == InstrBuffer->at(line).rva+CodePtr->getBase()); + + + } + else if(destRVA > last_va) + { + drawJump(line, + viewableRows+6, + jumpoffset, + cond, + DbgIsJumpGoingToExecute(InstrBuffer->at(line).rva+CodePtr->getBase())&&CodePtr->currentEIP() == InstrBuffer->at(line).rva, + selectedVA == InstrBuffer->at(line).rva+CodePtr->getBase()); + } + else if(destRVA < first_va) + { + drawJump(line, + -6, + jumpoffset, + cond, + DbgIsJumpGoingToExecute(InstrBuffer->at(line).rva+CodePtr->getBase())&&CodePtr->currentEIP() == InstrBuffer->at(line).rva, + selectedVA == InstrBuffer->at(line).rva+CodePtr->getBase()); + } + + } + + if(InstrBuffer->at(line).rva == CodePtr->currentEIP()) + { + drawLabel(line,"EIP"); + } + + } + + + //delete painter; +} + +void CPUJumps::drawJump(int startLine,int endLine,int jumpoffset, bool conditional, bool isexecute, bool isactive) +{ + painter->save(); + if(!conditional) + { + painter->setPen(QPen(QColor("#000000"),1, Qt::SolidLine)); // jmp + } + else + { + painter->setPen(QPen(QColor("#000000"),1, Qt::DashLine)); + } + QPen tmp = painter->pen(); + if(isexecute) + { + tmp.setWidth(2); + //tmp.setColor(Qt::red); + } + if(isactive) + { + tmp.setColor(Qt::red); + } + painter->setPen(tmp); + + const int JumpPadding = 15; + + const int x = viewport()->width()-jumpoffset*JumpPadding - 12; + const int x_right = viewport()->width()- 12; + const int y_start = fontHeight*(1+startLine)-0.5*fontHeight; + const int y_end = fontHeight*(1+endLine)-0.5*fontHeight; + + // vertical + painter->drawLine(x,y_start,x,y_end); + // start horizontal + painter->drawLine(x,y_start,x_right,y_start); + painter->drawLine(x,y_end,x_right,y_end); + + const int ArrowSizeX = 2; // width of arrow tip in pixel + const int ArrowSizeY = 3; // height of arrow tip in pixel + + + tmp = painter->pen(); + tmp.setStyle(Qt::SolidLine); + tmp.setWidth(2); + painter->setPen(tmp); + painter->drawLine(x_right-ArrowSizeX,y_end-ArrowSizeY,x_right,y_end); + painter->drawLine(x_right-ArrowSizeX,y_end+ArrowSizeY,x_right,y_end); + + + painter->restore(); +} + +void CPUJumps::drawBullets(int line, bool isbp) +{ + + + painter->save(); + + if( isbp) + painter->setBrush(QBrush("#808080")); + else + painter->setBrush(QBrush(Qt::red)); + + const int y = fontHeight*(1+line)-0.8*fontHeight ; + const int x = viewport()->width() - 10; + const int radius = 8; + + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setPen(QPen("#ffffff")); + painter->drawEllipse(x,y,radius,radius); + + + + painter->restore(); +} + + + + +void CPUJumps::drawLabel(int Line, QString Text) +{ + + painter->save(); + const int LineCoordinate = fontHeight*(1+Line); + int length = Text.length(); + + painter->setBrush(QBrush(Configuration::instance()->color("EIPLabelBG"))); + painter->setPen(QPen(Configuration::instance()->color("EIPLabelBG"))); + int y = LineCoordinate-fontHeight; + + painter->drawRect(1,y,length*fontWidth,fontHeight); + painter->setPen(QPen(Configuration::instance()->color("EIPLabel"))); + painter->drawText(2,LineCoordinate-0.2*fontHeight,Text); + + y = fontHeight*(1+Line)-0.5*fontHeight; + painter->setPen(QPen(Configuration::instance()->color("EIPLabelBG"),2)); + painter->setBrush(QBrush(Configuration::instance()->color("EIPLabelBG"))); + + drawStraightArrow(painter,length*fontWidth,y,this->viewport()->width()-2-15,y); + painter->restore(); + +} + +void CPUJumps::drawStraightArrow(QPainter *painter, int x1, int y1, int x2, int y2) +{ + + + painter->drawLine(x1,y1,x2,y2); + + + + /* + // this does not work + QPainterPath path; + + path.moveTo( QPointF(x2, x2)); + path.lineTo (QPointF(x2-ArrowSizeX,y2-ArrowSizeY)); + path.lineTo (QPointF(x2-ArrowSizeX,y2+ArrowSizeY)); + path.closeSubpath(); + + painter->setPen (Qt :: NoPen); + painter->fillPath (path, QBrush (color));*/ + const int ArrowSizeX = 4; // width of arrow tip in pixel + const int ArrowSizeY = 4; // height of arrow tip in pixel + + + painter->drawLine(x2,y2,x2-ArrowSizeX,y2-ArrowSizeY); + painter->drawLine(x2,y2,x2-ArrowSizeX,y2+ArrowSizeY); + +} + diff --git a/x64_dbg_gui/Project/Src/Gui/CPUJumps.h b/x64_dbg_gui/Project/Src/Gui/CPUJumps.h index ae2eeca6..b9be3153 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUJumps.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUJumps.h @@ -1,44 +1,44 @@ -#ifndef CPUJUMPS_H -#define CPUJUMPS_H - -#include "NewTypes.h" -#include "Bridge.h" -#include "CPUDisassembly.h" -#include - -class CPUJumps : public QAbstractScrollArea -{ - Q_OBJECT - - int_t topVA; - int_t selectedVA; - QPainter *painter; - QFont m_DefaultFont; - int fontWidth, fontHeight; - int viewableRows; - - CPUDisassembly *CodePtr; - QList *InstrBuffer; -public: - explicit CPUJumps(CPUDisassembly *Ptr, QWidget *parent = 0); - QSize sizeHint() const; - - void drawStraightArrow(QPainter *painter, int x1, int y1, int x2, int y2); -signals: - -public slots: - - void disassembleAt(int_t parVA, int_t parCIP); - void repaint(); - void changeTopmostAddress(int i); - void setViewableRows(int rows); - void setSelection(int_t selVA); -protected: - void paintEvent(QPaintEvent *event); - void drawLabel(int Line, QString Text); - void drawBullets(int line, bool ispb); - bool isJump(int i) const; - void drawJump(int startLine, int endLine, int jumpoffset, bool conditional, bool isexecute, bool isactive); -}; - -#endif // CPUJUMPS_H +#ifndef CPUJUMPS_H +#define CPUJUMPS_H + +#include "NewTypes.h" +#include "Bridge.h" +#include "CPUDisassembly.h" +#include + +class CPUJumps : public QAbstractScrollArea +{ + Q_OBJECT + + int_t topVA; + int_t selectedVA; + QPainter *painter; + QFont m_DefaultFont; + int fontWidth, fontHeight; + int viewableRows; + + CPUDisassembly *CodePtr; + QList *InstrBuffer; +public: + explicit CPUJumps(CPUDisassembly *Ptr, QWidget *parent = 0); + QSize sizeHint() const; + + void drawStraightArrow(QPainter *painter, int x1, int y1, int x2, int y2); +signals: + +public slots: + + void disassembleAt(int_t parVA, int_t parCIP); + void repaint(); + void changeTopmostAddress(int i); + void setViewableRows(int rows); + void setSelection(int_t selVA); +protected: + void paintEvent(QPaintEvent *event); + void drawLabel(int Line, QString Text); + void drawBullets(int line, bool ispb); + bool isJump(int i) const; + void drawJump(int startLine, int endLine, int jumpoffset, bool conditional, bool isexecute, bool isactive); +}; + +#endif // CPUJUMPS_H diff --git a/x64_dbg_gui/Project/Src/Gui/CPUWidget.h b/x64_dbg_gui/Project/Src/Gui/CPUWidget.h index 21c665a7..8483e980 100644 --- a/x64_dbg_gui/Project/Src/Gui/CPUWidget.h +++ b/x64_dbg_gui/Project/Src/Gui/CPUWidget.h @@ -11,14 +11,15 @@ #include "InfoBox.h" #include "CPUJumps.h" -namespace Ui { +namespace Ui +{ class CPUWidget; } class CPUWidget : public QWidget { Q_OBJECT - + public: explicit CPUWidget(QWidget *parent = 0); ~CPUWidget(); diff --git a/x64_dbg_gui/Project/Src/Gui/Configuration.cpp b/x64_dbg_gui/Project/Src/Gui/Configuration.cpp index 271208f5..126af835 100644 --- a/x64_dbg_gui/Project/Src/Gui/Configuration.cpp +++ b/x64_dbg_gui/Project/Src/Gui/Configuration.cpp @@ -1,66 +1,73 @@ -#include "Configuration.h" - -Configuration* Configuration::mPtr = NULL; - - -Configuration::Configuration() -{ - load("config.json"); - //Colors = new QMap(); - //Colors = QMap(); - mPtr = this; -} - -Configuration *Configuration::instance() -{ - return mPtr; -} - -void Configuration::load(QString filename){ - // load configuration file - QFile configfile(filename); - - if (!configfile.open(QIODevice::ReadOnly)) { - qWarning("Couldn't open config file."); - return ; - } - QByteArray saveData = configfile.readAll(); - Config = QJsonDocument(QJsonDocument::fromJson(saveData)).object(); - - readColors(); - -} - -void Configuration::readColors() { - Colors.clear(); - - QJsonArray ColorArray = Config["colors"].toArray(); - for (int idx = 0; idx < ColorArray.size(); ++idx) { - QJsonArray colorObj = ColorArray[idx].toArray(); - Colors.insert(colorObj.at(0).toString(),QColor( colorObj.at(1).toString())); - } -} - -QList Configuration::ApiFingerprints(){ - QList files; - QJsonArray APIArray = Config["apifingerprints"].toArray(); - for (int idx = 0; idx < APIArray.size(); ++idx) { - QString filename = "data/"+APIArray.at(idx).toString()+".txt"; - QFile mFile(filename); - if(mFile.open(QFile::ReadOnly | QFile::Text)){ - files.append(APIArray.at(idx).toString()); - mFile.close(); - } - - } - return files; -} - -const QColor Configuration::color(QString id) const -{ - if(Colors.contains(id)) - return Colors.constFind(id).value(); - else - return Qt::black; -} - +#include "Configuration.h" + +Configuration* Configuration::mPtr = NULL; + + +Configuration::Configuration() +{ + load("config.json"); + //Colors = new QMap(); + //Colors = QMap(); + mPtr = this; +} + +Configuration *Configuration::instance() +{ + return mPtr; +} + +void Configuration::load(QString filename) +{ + // load configuration file + QFile configfile(filename); + + if (!configfile.open(QIODevice::ReadOnly)) + { + qWarning("Couldn't open config file."); + return ; + } + QByteArray saveData = configfile.readAll(); + Config = QJsonDocument(QJsonDocument::fromJson(saveData)).object(); + + readColors(); + +} + +void Configuration::readColors() +{ + Colors.clear(); + + QJsonArray ColorArray = Config["colors"].toArray(); + for (int idx = 0; idx < ColorArray.size(); ++idx) + { + QJsonArray colorObj = ColorArray[idx].toArray(); + Colors.insert(colorObj.at(0).toString(),QColor( colorObj.at(1).toString())); + } +} + +QList Configuration::ApiFingerprints() +{ + QList files; + QJsonArray APIArray = Config["apifingerprints"].toArray(); + for (int idx = 0; idx < APIArray.size(); ++idx) + { + QString filename = "data/"+APIArray.at(idx).toString()+".txt"; + QFile mFile(filename); + if(mFile.open(QFile::ReadOnly | QFile::Text)) + { + files.append(APIArray.at(idx).toString()); + mFile.close(); + } + + } + return files; +} + +const QColor Configuration::color(QString id) const +{ + if(Colors.contains(id)) + return Colors.constFind(id).value(); + else + return Qt::black; +} + diff --git a/x64_dbg_gui/Project/Src/Gui/Configuration.h b/x64_dbg_gui/Project/Src/Gui/Configuration.h index 26782673..4138f01b 100644 --- a/x64_dbg_gui/Project/Src/Gui/Configuration.h +++ b/x64_dbg_gui/Project/Src/Gui/Configuration.h @@ -1,31 +1,28 @@ -#ifndef CONFIGURATION_H -#define CONFIGURATION_H - -#include -#include -#include -#include -#include -#include -#include -#include - -class Configuration -{ - QJsonObject Config; - - QMap Colors; - - static Configuration* mPtr; -public: - Configuration(); - - static Configuration* instance(); - - void readColors(); - const QColor color(QString id) const; - void load(QString filename); - QList ApiFingerprints(); -}; - -#endif // CONFIGURATION_H +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + +#include +#include +#include +#include +#include + +class Configuration +{ + QJsonObject Config; + + QMap Colors; + + static Configuration* mPtr; +public: + Configuration(); + + static Configuration* instance(); + + void readColors(); + const QColor color(QString id) const; + void load(QString filename); + QList ApiFingerprints(); +}; + +#endif // CONFIGURATION_H diff --git a/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.cpp b/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.cpp index 4fac23ca..585be64b 100644 --- a/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.cpp +++ b/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.cpp @@ -1,83 +1,83 @@ -#include "ExceptionRangeDialog.h" -#include "ui_ExceptionRangeDialog.h" - -ExceptionRangeDialog::ExceptionRangeDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::ExceptionRangeDialog) -{ - ui->setupUi(this); - //set window flags - setModal(true); - setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); - setFixedSize(this->size()); //fixed size - ui->editStart->setCursorPosition(0); - ui->editEnd->setCursorPosition(0); - ui->btnOk->setEnabled(false); -} - -ExceptionRangeDialog::~ExceptionRangeDialog() -{ - delete ui; -} - -void ExceptionRangeDialog::on_editStart_textChanged(const QString &arg1) -{ - if(!ui->editStart->text().size()) //nothing entered - { - ui->btnOk->setEnabled(false); - return; - } - if(ui->editStart->text()=="-1") - ui->editStart->setText("FFFFFFFF"); - bool converted=false; - unsigned long start=ui->editStart->text().toUInt(&converted, 16); - if(!converted) - { - ui->btnOk->setEnabled(false); - return; - } - unsigned long end=ui->editEnd->text().toUInt(&converted, 16); - if(converted && endbtnOk->setEnabled(false); - else - ui->btnOk->setEnabled(true); -} - - -void ExceptionRangeDialog::on_editEnd_textChanged(const QString &arg1) -{ - if(!ui->editEnd->text().size() || !ui->editStart->text().size()) - { - ui->btnOk->setEnabled(false); - return; - } - if(ui->editEnd->text()=="-1") - ui->editEnd->setText("FFFFFFFF"); - bool converted=false; - unsigned long start=ui->editStart->text().toUInt(&converted, 16); - if(!converted) - { - ui->btnOk->setEnabled(false); - return; - } - unsigned long end=ui->editEnd->text().toUInt(&converted, 16); - if(!converted) - { - ui->btnOk->setEnabled(false); - return; - } - if(endbtnOk->setEnabled(false); - else - ui->btnOk->setEnabled(true); -} - -void ExceptionRangeDialog::on_btnOk_clicked() -{ - rangeStart=ui->editStart->text().toUInt(0, 16); - bool converted=false; - rangeEnd=ui->editEnd->text().toUInt(&converted, 16); - if(!converted) - rangeEnd=rangeStart; - accept(); -} +#include "ExceptionRangeDialog.h" +#include "ui_ExceptionRangeDialog.h" + +ExceptionRangeDialog::ExceptionRangeDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ExceptionRangeDialog) +{ + ui->setupUi(this); + //set window flags + setModal(true); + setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); + setFixedSize(this->size()); //fixed size + ui->editStart->setCursorPosition(0); + ui->editEnd->setCursorPosition(0); + ui->btnOk->setEnabled(false); +} + +ExceptionRangeDialog::~ExceptionRangeDialog() +{ + delete ui; +} + +void ExceptionRangeDialog::on_editStart_textChanged(const QString &arg1) +{ + if(!ui->editStart->text().size()) //nothing entered + { + ui->btnOk->setEnabled(false); + return; + } + if(ui->editStart->text()=="-1") + ui->editStart->setText("FFFFFFFF"); + bool converted=false; + unsigned long start=ui->editStart->text().toUInt(&converted, 16); + if(!converted) + { + ui->btnOk->setEnabled(false); + return; + } + unsigned long end=ui->editEnd->text().toUInt(&converted, 16); + if(converted && endbtnOk->setEnabled(false); + else + ui->btnOk->setEnabled(true); +} + + +void ExceptionRangeDialog::on_editEnd_textChanged(const QString &arg1) +{ + if(!ui->editEnd->text().size() || !ui->editStart->text().size()) + { + ui->btnOk->setEnabled(false); + return; + } + if(ui->editEnd->text()=="-1") + ui->editEnd->setText("FFFFFFFF"); + bool converted=false; + unsigned long start=ui->editStart->text().toUInt(&converted, 16); + if(!converted) + { + ui->btnOk->setEnabled(false); + return; + } + unsigned long end=ui->editEnd->text().toUInt(&converted, 16); + if(!converted) + { + ui->btnOk->setEnabled(false); + return; + } + if(endbtnOk->setEnabled(false); + else + ui->btnOk->setEnabled(true); +} + +void ExceptionRangeDialog::on_btnOk_clicked() +{ + rangeStart=ui->editStart->text().toUInt(0, 16); + bool converted=false; + rangeEnd=ui->editEnd->text().toUInt(&converted, 16); + if(!converted) + rangeEnd=rangeStart; + accept(); +} diff --git a/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.h b/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.h index 193f7b4f..e330162d 100644 --- a/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/ExceptionRangeDialog.h @@ -1,30 +1,31 @@ -#ifndef EXCEPTIONRANGEDIALOG_H -#define EXCEPTIONRANGEDIALOG_H - -#include - -namespace Ui { - class ExceptionRangeDialog; -} - -class ExceptionRangeDialog : public QDialog -{ - Q_OBJECT - -public: - explicit ExceptionRangeDialog(QWidget *parent = 0); - ~ExceptionRangeDialog(); - - unsigned long rangeStart; - unsigned long rangeEnd; - -private slots: - void on_editStart_textChanged(const QString &arg1); - void on_editEnd_textChanged(const QString &arg1); - void on_btnOk_clicked(); - -private: - Ui::ExceptionRangeDialog *ui; -}; - -#endif // EXCEPTIONRANGEDIALOG_H +#ifndef EXCEPTIONRANGEDIALOG_H +#define EXCEPTIONRANGEDIALOG_H + +#include + +namespace Ui +{ +class ExceptionRangeDialog; +} + +class ExceptionRangeDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ExceptionRangeDialog(QWidget *parent = 0); + ~ExceptionRangeDialog(); + + unsigned long rangeStart; + unsigned long rangeEnd; + +private slots: + void on_editStart_textChanged(const QString &arg1); + void on_editEnd_textChanged(const QString &arg1); + void on_btnOk_clicked(); + +private: + Ui::ExceptionRangeDialog *ui; +}; + +#endif // EXCEPTIONRANGEDIALOG_H diff --git a/x64_dbg_gui/Project/Src/Gui/GotoDialog.h b/x64_dbg_gui/Project/Src/Gui/GotoDialog.h index f82de572..08f418c9 100644 --- a/x64_dbg_gui/Project/Src/Gui/GotoDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/GotoDialog.h @@ -5,7 +5,8 @@ #include #include "Bridge.h" -namespace Ui { +namespace Ui +{ class GotoDialog; } diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 943da761..ee3c0fbc 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -77,7 +77,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi mThreadView->setWindowIcon(QIcon(":/icons/images/arrow-threads.png")); //Create the tab widget - mTabWidget = new MHTabWidget(NULL); + mTabWidget = new MHTabWidget(NULL); //Setup tabs mTabWidget->addTab(mCpuWidget, mCpuWidget->windowIcon(), mCpuWidget->windowTitle()); @@ -162,12 +162,12 @@ MainWindow::~MainWindow() void MainWindow::setTab(QWidget* widget) { - for(int i=0; icount(); i++) - if(mTabWidget->widget(i)==widget) - { - mTabWidget->setCurrentIndex(i); - break; - } + for(int i=0; icount(); i++) + if(mTabWidget->widget(i)==widget) + { + mTabWidget->setCurrentIndex(i); + break; + } } //Reads recent files list from settings diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.h b/x64_dbg_gui/Project/Src/Gui/MainWindow.h index 83cb4ad9..48ce8c2a 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.h +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.h @@ -21,14 +21,15 @@ #include "Configuration.h" #include "ApiFingerprints.h" -namespace Ui { +namespace Ui +{ class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT - + public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); @@ -76,7 +77,7 @@ private: Ui::MainWindow *ui; CommandLineEdit* mCmdLineEdit; - MHTabWidget* mTabWidget; + MHTabWidget* mTabWidget; CPUWidget* mCpuWidget; MemoryMapView* mMemMapView; LogView* mLogView; diff --git a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h index 3d2a3b66..34bb3dce 100644 --- a/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h +++ b/x64_dbg_gui/Project/Src/Gui/SettingsDialog.h @@ -6,8 +6,9 @@ #include "Bridge.h" #include "ExceptionRangeDialog.h" -namespace Ui { - class SettingsDialog; +namespace Ui +{ +class SettingsDialog; } class SettingsDialog : public QDialog diff --git a/x64_dbg_gui/Project/Src/Gui/TabBar.cpp b/x64_dbg_gui/Project/Src/Gui/TabBar.cpp index 34c356fc..a1242a7c 100644 --- a/x64_dbg_gui/Project/Src/Gui/TabBar.cpp +++ b/x64_dbg_gui/Project/Src/Gui/TabBar.cpp @@ -1,164 +1,164 @@ -// Qt includes -#include -#include -#include -#include -#include -#include -#include -#include - -#include "tabbar.h" -#include "tabwidget.h" - -////////////////////////////////////////////////////////////// -// Default Constructor -////////////////////////////////////////////////////////////// -MHTabBar::MHTabBar(QWidget *parent) : QTabBar(parent) -{ - setAcceptDrops(true); - setElideMode(Qt::ElideRight); - setSelectionBehaviorOnRemove(QTabBar::SelectLeftTab); - setMovable(true); -} - -////////////////////////////////////////////////////////////// -// Default Destructor -////////////////////////////////////////////////////////////// -MHTabBar::~MHTabBar(void) -{ -} - -void MHTabBar::contextMenuEvent(QContextMenuEvent* event) -{ - QMenu wMenu(this); - QAction wDetach("&Detach", this); - wMenu.addAction(&wDetach); - if(wMenu.exec(event->globalPos())==&wDetach) - { - QPoint p(0, 0); - OnDetachTab((int)tabAt(event->pos()), p); - } -} - - -/* -////////////////////////////////////////////////////////////////////////////// -void MHTabBar::mousePressEvent(QMouseEvent* event) -{ - if (event->button() == Qt::LeftButton) - m_dragStartPos = event->pos(); - - m_dragDroppedPos.setX(0); - m_dragDroppedPos.setY(0); - m_dragMovedPos.setX(0); - m_dragMovedPos.setY(0); - - m_dragInitiated = false; - - QTabBar::mousePressEvent(event); -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabBar::mouseMoveEvent(QMouseEvent* event) -{ - // Distinguish a drag - if ( !m_dragStartPos.isNull() && - ((event->pos() - m_dragStartPos).manhattanLength() < QApplication::startDragDistance()) ) - { - m_dragInitiated = true; - } - - // The left button is pressed - // And the move could also be a drag - // And the mouse moved outside the tab bar - if ((event->buttons() & Qt::LeftButton) && m_dragInitiated && !geometry().contains(event->pos())) - { - // Stop the move to be able to convert to a drag - { - QMouseEvent finishMoveEvent(QEvent::MouseMove, event->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); - QTabBar::mouseMoveEvent(&finishMoveEvent); - } - - // A crude way to distinguish tab-reordering drops from other ones - QMimeData* mimeData = new QMimeData; - mimeData->setData("action", "application/tab-detach"); - - // Initiate Drag - QDrag* drag = new QDrag(this); - drag->setMimeData(mimeData); - - // Create transparent screen dump - QPixmap pixmap = QPixmap::grabWindow(dynamic_cast(parentWidget())->currentWidget()->winId()).scaled(640, 480, Qt::KeepAspectRatio); - QPixmap targetPixmap(pixmap.size()); - - QPainter painter(&targetPixmap); - painter.setOpacity(0.5); - painter.drawPixmap(0, 0, pixmap); - painter.end(); - - drag->setPixmap(targetPixmap); - - // Handle Detach and Move - Qt::DropAction dragged = drag->exec(Qt::MoveAction | Qt::CopyAction); - - if (dragged == Qt::IgnoreAction) - { - event->accept(); - OnDetachTab(tabAt(m_dragStartPos), QCursor::pos()); - } - else if (dragged == Qt::MoveAction) - { - if (!m_dragDroppedPos.isNull()) - { - event->accept(); - OnMoveTab(tabAt(m_dragStartPos), tabAt(m_dragDroppedPos)); - } - } - - delete drag; - } - else - { - QTabBar::mouseMoveEvent(event); - } -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabBar::dragEnterEvent(QDragEnterEvent* event) -{ - // Only accept if it's an tab-reordering request (not a detach request) - const QMimeData* m = event->mimeData(); - - if (m->formats().contains("action") && (m->data("action") != "application/tab-detach")) - { - event->acceptProposedAction(); - } - - QTabBar::dragEnterEvent(event); -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabBar::dragMoveEvent(QDragMoveEvent* event) -{ - // Only accept if it's an tab-reordering request (not a detach request) - const QMimeData* m = event->mimeData(); - - if (m->formats().contains("action") && (m->data("action") != "application/tab-detach")) - { - m_dragMovedPos = event->pos(); - event->acceptProposedAction(); - } - - QTabBar::dragMoveEvent(event); -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabBar::dropEvent(QDropEvent* event) -{ - // If a dragged Event is dropped within this widget it is not a drag but a move. - m_dragDroppedPos = event->pos(); - - QTabBar::dropEvent(event); -} -*/ +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tabbar.h" +#include "tabwidget.h" + +////////////////////////////////////////////////////////////// +// Default Constructor +////////////////////////////////////////////////////////////// +MHTabBar::MHTabBar(QWidget *parent) : QTabBar(parent) +{ + setAcceptDrops(true); + setElideMode(Qt::ElideRight); + setSelectionBehaviorOnRemove(QTabBar::SelectLeftTab); + setMovable(true); +} + +////////////////////////////////////////////////////////////// +// Default Destructor +////////////////////////////////////////////////////////////// +MHTabBar::~MHTabBar(void) +{ +} + +void MHTabBar::contextMenuEvent(QContextMenuEvent* event) +{ + QMenu wMenu(this); + QAction wDetach("&Detach", this); + wMenu.addAction(&wDetach); + if(wMenu.exec(event->globalPos())==&wDetach) + { + QPoint p(0, 0); + OnDetachTab((int)tabAt(event->pos()), p); + } +} + + +/* +////////////////////////////////////////////////////////////////////////////// +void MHTabBar::mousePressEvent(QMouseEvent* event) +{ + if (event->button() == Qt::LeftButton) + m_dragStartPos = event->pos(); + + m_dragDroppedPos.setX(0); + m_dragDroppedPos.setY(0); + m_dragMovedPos.setX(0); + m_dragMovedPos.setY(0); + + m_dragInitiated = false; + + QTabBar::mousePressEvent(event); +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabBar::mouseMoveEvent(QMouseEvent* event) +{ + // Distinguish a drag + if ( !m_dragStartPos.isNull() && + ((event->pos() - m_dragStartPos).manhattanLength() < QApplication::startDragDistance()) ) + { + m_dragInitiated = true; + } + + // The left button is pressed + // And the move could also be a drag + // And the mouse moved outside the tab bar + if ((event->buttons() & Qt::LeftButton) && m_dragInitiated && !geometry().contains(event->pos())) + { + // Stop the move to be able to convert to a drag + { + QMouseEvent finishMoveEvent(QEvent::MouseMove, event->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QTabBar::mouseMoveEvent(&finishMoveEvent); + } + + // A crude way to distinguish tab-reordering drops from other ones + QMimeData* mimeData = new QMimeData; + mimeData->setData("action", "application/tab-detach"); + + // Initiate Drag + QDrag* drag = new QDrag(this); + drag->setMimeData(mimeData); + + // Create transparent screen dump + QPixmap pixmap = QPixmap::grabWindow(dynamic_cast(parentWidget())->currentWidget()->winId()).scaled(640, 480, Qt::KeepAspectRatio); + QPixmap targetPixmap(pixmap.size()); + + QPainter painter(&targetPixmap); + painter.setOpacity(0.5); + painter.drawPixmap(0, 0, pixmap); + painter.end(); + + drag->setPixmap(targetPixmap); + + // Handle Detach and Move + Qt::DropAction dragged = drag->exec(Qt::MoveAction | Qt::CopyAction); + + if (dragged == Qt::IgnoreAction) + { + event->accept(); + OnDetachTab(tabAt(m_dragStartPos), QCursor::pos()); + } + else if (dragged == Qt::MoveAction) + { + if (!m_dragDroppedPos.isNull()) + { + event->accept(); + OnMoveTab(tabAt(m_dragStartPos), tabAt(m_dragDroppedPos)); + } + } + + delete drag; + } + else + { + QTabBar::mouseMoveEvent(event); + } +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabBar::dragEnterEvent(QDragEnterEvent* event) +{ + // Only accept if it's an tab-reordering request (not a detach request) + const QMimeData* m = event->mimeData(); + + if (m->formats().contains("action") && (m->data("action") != "application/tab-detach")) + { + event->acceptProposedAction(); + } + + QTabBar::dragEnterEvent(event); +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabBar::dragMoveEvent(QDragMoveEvent* event) +{ + // Only accept if it's an tab-reordering request (not a detach request) + const QMimeData* m = event->mimeData(); + + if (m->formats().contains("action") && (m->data("action") != "application/tab-detach")) + { + m_dragMovedPos = event->pos(); + event->acceptProposedAction(); + } + + QTabBar::dragMoveEvent(event); +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabBar::dropEvent(QDropEvent* event) +{ + // If a dragged Event is dropped within this widget it is not a drag but a move. + m_dragDroppedPos = event->pos(); + + QTabBar::dropEvent(event); +} +*/ diff --git a/x64_dbg_gui/Project/Src/Gui/TabBar.h b/x64_dbg_gui/Project/Src/Gui/TabBar.h index 493b0e28..2d6693ba 100644 --- a/x64_dbg_gui/Project/Src/Gui/TabBar.h +++ b/x64_dbg_gui/Project/Src/Gui/TabBar.h @@ -1,50 +1,50 @@ -#ifndef __MHTABBAR_H__ -#define __MHTABBAR_H__ - -// Qt includes -#include -#include -#include - -// Qt forward class definitions -class MHTabBar; -class QMainWindow; - -////////////////////////////////////////////////////////////////////////////// -// Summary: -// MHTabBar implements the a Tab Bar with tear-off functionality. -////////////////////////////////////////////////////////////////////////////// -class MHTabBar: public QTabBar -{ - Q_OBJECT -public: - MHTabBar (QWidget* parent); - ~MHTabBar (void); - -protected: - void contextMenuEvent(QContextMenuEvent* event); - /* - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void dragEnterEvent(QDragEnterEvent* event); - void dragMoveEvent(QDragMoveEvent* event); - void dropEvent(QDropEvent* event); - */ - -signals: - // Detach Tab - void OnDetachTab (int index, QPoint& dropPoint); - // Move Tab - void OnMoveTab (int fromIndex, int toIndex); - -private: - /* - QPoint m_dragStartPos; - QPoint m_dragMovedPos; - QPoint m_dragDroppedPos; - bool m_dragInitiated; - int m_dragCurrentIndex; - */ -}; - -#endif // __MHTABBAR_H__ +#ifndef __MHTABBAR_H__ +#define __MHTABBAR_H__ + +// Qt includes +#include +#include +#include + +// Qt forward class definitions +class MHTabBar; +class QMainWindow; + +////////////////////////////////////////////////////////////////////////////// +// Summary: +// MHTabBar implements the a Tab Bar with tear-off functionality. +////////////////////////////////////////////////////////////////////////////// +class MHTabBar: public QTabBar +{ + Q_OBJECT +public: + MHTabBar (QWidget* parent); + ~MHTabBar (void); + +protected: + void contextMenuEvent(QContextMenuEvent* event); + /* + void mousePressEvent(QMouseEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void dragEnterEvent(QDragEnterEvent* event); + void dragMoveEvent(QDragMoveEvent* event); + void dropEvent(QDropEvent* event); + */ + +signals: + // Detach Tab + void OnDetachTab (int index, QPoint& dropPoint); + // Move Tab + void OnMoveTab (int fromIndex, int toIndex); + +private: + /* + QPoint m_dragStartPos; + QPoint m_dragMovedPos; + QPoint m_dragDroppedPos; + bool m_dragInitiated; + int m_dragCurrentIndex; + */ +}; + +#endif // __MHTABBAR_H__ diff --git a/x64_dbg_gui/Project/Src/Gui/TabWidget.cpp b/x64_dbg_gui/Project/Src/Gui/TabWidget.cpp index bde42582..962b2c8e 100644 --- a/x64_dbg_gui/Project/Src/Gui/TabWidget.cpp +++ b/x64_dbg_gui/Project/Src/Gui/TabWidget.cpp @@ -1,191 +1,191 @@ -// Qt includes -#include "tabbar.h" -#include "tabwidget.h" - -////////////////////////////////////////////////////////////// -// Default Constructor -////////////////////////////////////////////////////////////// -MHTabWidget::MHTabWidget(QWidget *parent) : QTabWidget(parent) -{ - m_tabBar = new MHTabBar(this); - connect(m_tabBar, SIGNAL(OnDetachTab(int, QPoint&)), this, SLOT(DetachTab(int, QPoint&))); - connect(m_tabBar, SIGNAL(OnMoveTab(int, int)), this, SLOT(MoveTab(int, int))); - - setTabBar(m_tabBar); - setMovable(true); - - m_Windows.clear(); -} - -QTabBar* MHTabWidget::tabBar() -{ - return m_tabBar; -} - -////////////////////////////////////////////////////////////// -// Default Destructor -////////////////////////////////////////////////////////////// -MHTabWidget::~MHTabWidget(void) -{ - disconnect(m_tabBar, SIGNAL(OnMoveTab(int, int)), this, SLOT(MoveTab(int, int))); - disconnect(m_tabBar, SIGNAL(OnDetachTab(int, QPoint&)), this, SLOT(DetachTab(int, QPoint&))); - delete m_tabBar; -} - -int MHTabWidget::count() const -{ - return QTabWidget::count() + m_Windows.size(); -} - -QWidget *MHTabWidget::widget(int index) const -{ - int baseCount = QTabWidget::count(); - - // Check if it's just a normal tab - if (index < baseCount) - return QTabWidget::widget(index); - - // Otherwise it's going to be a window - return m_Windows.at(index - baseCount); -} - -void MHTabWidget::setCurrentIndex(int index) -{ - // Check if it's just a normal tab - if (index < QTabWidget::count()) - { - QTabWidget::setCurrentIndex(index); - } - else - { - // Otherwise it's going to be a window (just bring it up) - MHDetachedWindow* window = dynamic_cast(widget(index)->parent()); - window->activateWindow(); - } -} - -void MHTabWidget::setCurrentWidget(QWidget *widget) -{ - widget = 0; - // To be implemented. -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabWidget::MoveTab(int fromIndex, int toIndex) -{ - removeTab(fromIndex); - insertTab(toIndex, widget(fromIndex), tabIcon(fromIndex), tabText(fromIndex)); - setCurrentIndex(toIndex); -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabWidget::DetachTab(int index, QPoint& dropPoint) -{ - Q_UNUSED(dropPoint); - // Create the window - MHDetachedWindow* detachedWidget = new MHDetachedWindow(parentWidget(), this); - detachedWidget->setWindowModality(Qt::NonModal); - - // Find Widget and connect - connect(detachedWidget, SIGNAL(OnClose(QWidget*)), this, SLOT(AttachTab(QWidget*))); - - detachedWidget->setWindowTitle(tabText(index)); - detachedWidget->setWindowIcon(tabIcon(index)); - - // Remove from tab bar - QWidget* tearOffWidget = widget(index); - tearOffWidget->setParent(detachedWidget); - - // Add it to the windows list - m_Windows.append(tearOffWidget); - - // Make first active - if (count() > 0) - setCurrentIndex(0); - - // Create and show - detachedWidget->setCentralWidget(tearOffWidget); - - // Needs to be done explicitly - tearOffWidget->show(); - QRect screenGeometry = QApplication::desktop()->screenGeometry(); - int w = 640; - int h = 480; - int x = (screenGeometry.width() - w) / 2; - int y = (screenGeometry.height() - h) / 2; - detachedWidget->show(); - detachedWidget->setGeometry(x, y, w, h); - detachedWidget->show(); -} - -////////////////////////////////////////////////////////////////////////////// -void MHTabWidget::AttachTab(QWidget *parent) -{ - // Retrieve widget - MHDetachedWindow* detachedWidget = dynamic_cast(parent); - QWidget* tearOffWidget = detachedWidget->centralWidget(); - - // Reattach the tab - int newIndex = addTab(tearOffWidget, detachedWidget->windowIcon(), detachedWidget->windowTitle()); - - // Remove it from the windows list - for(int i = 0; i < m_Windows.size(); i++) - { - if (m_Windows.at(i) == tearOffWidget) - m_Windows.removeAt(i); - } - - // Make Active - if (newIndex != -1) - setCurrentIndex(newIndex); - - // Cleanup Window - disconnect(detachedWidget, SIGNAL(OnClose(QWidget*)), this, SLOT(AttachTab(QWidget*))); - detachedWidget->hide(); - detachedWidget->close(); -} - -//---------------------------------------------------------------------------- - -////////////////////////////////////////////////////////////////////////////// -MHDetachedWindow::MHDetachedWindow(QWidget *parent, MHTabWidget *tabwidget) : QMainWindow(parent) -{ - m_TabWidget = tabwidget; -} - -////////////////////////////////////////////////////////////////////////////// -MHDetachedWindow::~MHDetachedWindow(void) -{ -} - -/* -////////////////////////////////////////////////////////////////////////////// -void MHDetachedWindow::moveEvent(QMoveEvent *event) -{ - QRect rect = m_TabWidget->geometry(); - QSize hint = m_TabWidget->tabBar()->sizeHint(); - - // Height of the actual top tab bar - rect.setBottom(rect.top() + hint.height()); - QPoint pos1(rect.x(), rect.y()); - pos1=m_TabWidget->mapToGlobal(pos1); - rect.setX(pos1.x()); - rect.setY(pos1.y()); - - if (rect.contains(event->pos())) - { - m_TabWidget->AttachTab(this); - event->accept(); - } - else - { - QMainWindow::moveEvent(event); - } -} -*/ - -////////////////////////////////////////////////////////////////////////////// -void MHDetachedWindow::closeEvent(QCloseEvent* /*event*/) -{ - emit OnClose(this); -} +// Qt includes +#include "tabbar.h" +#include "tabwidget.h" + +////////////////////////////////////////////////////////////// +// Default Constructor +////////////////////////////////////////////////////////////// +MHTabWidget::MHTabWidget(QWidget *parent) : QTabWidget(parent) +{ + m_tabBar = new MHTabBar(this); + connect(m_tabBar, SIGNAL(OnDetachTab(int, QPoint&)), this, SLOT(DetachTab(int, QPoint&))); + connect(m_tabBar, SIGNAL(OnMoveTab(int, int)), this, SLOT(MoveTab(int, int))); + + setTabBar(m_tabBar); + setMovable(true); + + m_Windows.clear(); +} + +QTabBar* MHTabWidget::tabBar() +{ + return m_tabBar; +} + +////////////////////////////////////////////////////////////// +// Default Destructor +////////////////////////////////////////////////////////////// +MHTabWidget::~MHTabWidget(void) +{ + disconnect(m_tabBar, SIGNAL(OnMoveTab(int, int)), this, SLOT(MoveTab(int, int))); + disconnect(m_tabBar, SIGNAL(OnDetachTab(int, QPoint&)), this, SLOT(DetachTab(int, QPoint&))); + delete m_tabBar; +} + +int MHTabWidget::count() const +{ + return QTabWidget::count() + m_Windows.size(); +} + +QWidget *MHTabWidget::widget(int index) const +{ + int baseCount = QTabWidget::count(); + + // Check if it's just a normal tab + if (index < baseCount) + return QTabWidget::widget(index); + + // Otherwise it's going to be a window + return m_Windows.at(index - baseCount); +} + +void MHTabWidget::setCurrentIndex(int index) +{ + // Check if it's just a normal tab + if (index < QTabWidget::count()) + { + QTabWidget::setCurrentIndex(index); + } + else + { + // Otherwise it's going to be a window (just bring it up) + MHDetachedWindow* window = dynamic_cast(widget(index)->parent()); + window->activateWindow(); + } +} + +void MHTabWidget::setCurrentWidget(QWidget *widget) +{ + widget = 0; + // To be implemented. +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabWidget::MoveTab(int fromIndex, int toIndex) +{ + removeTab(fromIndex); + insertTab(toIndex, widget(fromIndex), tabIcon(fromIndex), tabText(fromIndex)); + setCurrentIndex(toIndex); +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabWidget::DetachTab(int index, QPoint& dropPoint) +{ + Q_UNUSED(dropPoint); + // Create the window + MHDetachedWindow* detachedWidget = new MHDetachedWindow(parentWidget(), this); + detachedWidget->setWindowModality(Qt::NonModal); + + // Find Widget and connect + connect(detachedWidget, SIGNAL(OnClose(QWidget*)), this, SLOT(AttachTab(QWidget*))); + + detachedWidget->setWindowTitle(tabText(index)); + detachedWidget->setWindowIcon(tabIcon(index)); + + // Remove from tab bar + QWidget* tearOffWidget = widget(index); + tearOffWidget->setParent(detachedWidget); + + // Add it to the windows list + m_Windows.append(tearOffWidget); + + // Make first active + if (count() > 0) + setCurrentIndex(0); + + // Create and show + detachedWidget->setCentralWidget(tearOffWidget); + + // Needs to be done explicitly + tearOffWidget->show(); + QRect screenGeometry = QApplication::desktop()->screenGeometry(); + int w = 640; + int h = 480; + int x = (screenGeometry.width() - w) / 2; + int y = (screenGeometry.height() - h) / 2; + detachedWidget->show(); + detachedWidget->setGeometry(x, y, w, h); + detachedWidget->show(); +} + +////////////////////////////////////////////////////////////////////////////// +void MHTabWidget::AttachTab(QWidget *parent) +{ + // Retrieve widget + MHDetachedWindow* detachedWidget = dynamic_cast(parent); + QWidget* tearOffWidget = detachedWidget->centralWidget(); + + // Reattach the tab + int newIndex = addTab(tearOffWidget, detachedWidget->windowIcon(), detachedWidget->windowTitle()); + + // Remove it from the windows list + for(int i = 0; i < m_Windows.size(); i++) + { + if (m_Windows.at(i) == tearOffWidget) + m_Windows.removeAt(i); + } + + // Make Active + if (newIndex != -1) + setCurrentIndex(newIndex); + + // Cleanup Window + disconnect(detachedWidget, SIGNAL(OnClose(QWidget*)), this, SLOT(AttachTab(QWidget*))); + detachedWidget->hide(); + detachedWidget->close(); +} + +//---------------------------------------------------------------------------- + +////////////////////////////////////////////////////////////////////////////// +MHDetachedWindow::MHDetachedWindow(QWidget *parent, MHTabWidget *tabwidget) : QMainWindow(parent) +{ + m_TabWidget = tabwidget; +} + +////////////////////////////////////////////////////////////////////////////// +MHDetachedWindow::~MHDetachedWindow(void) +{ +} + +/* +////////////////////////////////////////////////////////////////////////////// +void MHDetachedWindow::moveEvent(QMoveEvent *event) +{ + QRect rect = m_TabWidget->geometry(); + QSize hint = m_TabWidget->tabBar()->sizeHint(); + + // Height of the actual top tab bar + rect.setBottom(rect.top() + hint.height()); + QPoint pos1(rect.x(), rect.y()); + pos1=m_TabWidget->mapToGlobal(pos1); + rect.setX(pos1.x()); + rect.setY(pos1.y()); + + if (rect.contains(event->pos())) + { + m_TabWidget->AttachTab(this); + event->accept(); + } + else + { + QMainWindow::moveEvent(event); + } +} +*/ + +////////////////////////////////////////////////////////////////////////////// +void MHDetachedWindow::closeEvent(QCloseEvent* /*event*/) +{ + emit OnClose(this); +} diff --git a/x64_dbg_gui/Project/Src/Gui/TabWidget.h b/x64_dbg_gui/Project/Src/Gui/TabWidget.h index 874913fb..4224ecf3 100644 --- a/x64_dbg_gui/Project/Src/Gui/TabWidget.h +++ b/x64_dbg_gui/Project/Src/Gui/TabWidget.h @@ -1,79 +1,79 @@ -#ifndef __MHTABWIDGET_H__ -#define __MHTABWIDGET_H__ - -// Qt includes -#include -#include -#include -#include -#include -#include - -// Qt forward class definitions -class MHTabBar; - -////////////////////////////////////////////////////////////////////////////// -// Summary: -// MHTabWidget implements the a Tab Widget with detach and attach -// functionality. -////////////////////////////////////////////////////////////////////////////// -class MHTabWidget: public QTabWidget -{ - Q_OBJECT - -public: - MHTabWidget(QWidget *parent); - virtual ~MHTabWidget(void); - QTabBar* tabBar(); - -public slots: - int count() const; - QWidget *widget(int index) const; - - // Move Tab - void MoveTab(int fromIndex, int toIndex); - - // Detach Tab - void DetachTab(int index, QPoint&); - - // Attach Tab - void AttachTab(QWidget *parent); - -public Q_SLOTS: - void setCurrentIndex(int index); - void setCurrentWidget(QWidget *widget); - -protected: - -private: - MHTabBar* m_tabBar; - - QList m_Windows; -}; - -////////////////////////////////////////////////////////////////////////////// -// Summary: -// MHDetachedWindow implements the WindowContainer for the Detached Widget -// -// Conditions: -// Header : MHTabWidget.h -////////////////////////////////////////////////////////////////////////////// -class MHDetachedWindow : public QMainWindow -{ - Q_OBJECT -public: - MHDetachedWindow(QWidget *parent = 0, MHTabWidget *tabwidget = 0); - ~MHDetachedWindow(void); - -protected: - MHTabWidget *m_TabWidget; - - //virtual void moveEvent(QMoveEvent *event); - void closeEvent(QCloseEvent *event); - -signals: - void OnClose(QWidget* widget); -}; - -#endif // __MHTABWIDGET_H__ - +#ifndef __MHTABWIDGET_H__ +#define __MHTABWIDGET_H__ + +// Qt includes +#include +#include +#include +#include +#include +#include + +// Qt forward class definitions +class MHTabBar; + +////////////////////////////////////////////////////////////////////////////// +// Summary: +// MHTabWidget implements the a Tab Widget with detach and attach +// functionality. +////////////////////////////////////////////////////////////////////////////// +class MHTabWidget: public QTabWidget +{ + Q_OBJECT + +public: + MHTabWidget(QWidget *parent); + virtual ~MHTabWidget(void); + QTabBar* tabBar(); + +public slots: + int count() const; + QWidget *widget(int index) const; + + // Move Tab + void MoveTab(int fromIndex, int toIndex); + + // Detach Tab + void DetachTab(int index, QPoint&); + + // Attach Tab + void AttachTab(QWidget *parent); + +public Q_SLOTS: + void setCurrentIndex(int index); + void setCurrentWidget(QWidget *widget); + +protected: + +private: + MHTabBar* m_tabBar; + + QList m_Windows; +}; + +////////////////////////////////////////////////////////////////////////////// +// Summary: +// MHDetachedWindow implements the WindowContainer for the Detached Widget +// +// Conditions: +// Header : MHTabWidget.h +////////////////////////////////////////////////////////////////////////////// +class MHDetachedWindow : public QMainWindow +{ + Q_OBJECT +public: + MHDetachedWindow(QWidget *parent = 0, MHTabWidget *tabwidget = 0); + ~MHDetachedWindow(void); + +protected: + MHTabWidget *m_TabWidget; + + //virtual void moveEvent(QMoveEvent *event); + void closeEvent(QCloseEvent *event); + +signals: + void OnClose(QWidget* widget); +}; + +#endif // __MHTABWIDGET_H__ + diff --git a/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.cpp b/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.cpp index 663a1d73..fce25a87 100644 --- a/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.cpp +++ b/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.cpp @@ -22,9 +22,9 @@ MapViewOfMem::MapViewOfMem(QString file) QFile wFile(file); if(wFile.open(QIODevice::ReadOnly) == false) - //qDebug() << "File has not been opened."; + //qDebug() << "File has not been opened."; - mData = wFile.readAll(); + mData = wFile.readAll(); //qDebug() << "Size: " << mData.size(); if(mData.size() == 0) diff --git a/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.h b/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.h index 8c395f63..2fda3dd6 100644 --- a/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.h +++ b/x64_dbg_gui/Project/Src/Memory/MapViewOfMem.h @@ -18,41 +18,41 @@ typedef struct _Selection_t class MapViewOfMem { - public: - MapViewOfMem(); - explicit MapViewOfMem(QString file); - explicit MapViewOfMem(uint_t startAddress , uint_t size); - ~MapViewOfMem(); - byte_t readByte(uint_t rva); - uint_t size(); - unsigned char *data(); +public: + MapViewOfMem(); + explicit MapViewOfMem(QString file); + explicit MapViewOfMem(uint_t startAddress , uint_t size); + ~MapViewOfMem(); + byte_t readByte(uint_t rva); + uint_t size(); + unsigned char *data(); - Selection_t getSelection(); - void setSelection(Selection_t sel); + Selection_t getSelection(); + void setSelection(Selection_t sel); - uint_t getBase(); - byte_t* getDataPtrForGui(uint_t rva, uint_t maxNbrOfBytesToRead, uint_t newCacheSize); + uint_t getBase(); + byte_t* getDataPtrForGui(uint_t rva, uint_t maxNbrOfBytesToRead, uint_t newCacheSize); - private: - typedef struct _MemDataCacheStruct_t - { - QVector* memDataCachePtr; - uint_t memDataCacheSize; - uint_t rva; - bool isInit; - } MemDataCacheStruct_t; +private: + typedef struct _MemDataCacheStruct_t + { + QVector* memDataCachePtr; + uint_t memDataCacheSize; + uint_t rva; + bool isInit; + } MemDataCacheStruct_t; - uint_t mBase; - unsigned long mStartAddress; - unsigned long mEndAddress; - unsigned long mSize; + uint_t mBase; + unsigned long mStartAddress; + unsigned long mEndAddress; + unsigned long mSize; - QByteArray mData; + QByteArray mData; - Selection_t mSelectedData; + Selection_t mSelectedData; - MemDataCacheStruct_t mGuiMemDataCache; + MemDataCacheStruct_t mGuiMemDataCache; }; #endif // MAPVIEWOFMEM_H diff --git a/x64_dbg_gui/Project/Src/Memory/ProcessMemoryMap.cpp b/x64_dbg_gui/Project/Src/Memory/ProcessMemoryMap.cpp index 59212a4f..94f594aa 100644 --- a/x64_dbg_gui/Project/Src/Memory/ProcessMemoryMap.cpp +++ b/x64_dbg_gui/Project/Src/Memory/ProcessMemoryMap.cpp @@ -119,17 +119,17 @@ void ProcessMemoryMap::printVirtualMemoryMap(QList par // State switch(wMemInfo.State) { - case MEM_FREE: - wTmpStr = QString("Free"); - break; - case MEM_COMMIT: - wTmpStr = QString("Commited"); - break; - case MEM_RESERVE: - wTmpStr = QString("Reserved"); - break; - default: - wTmpStr = QString("N/A"); + case MEM_FREE: + wTmpStr = QString("Free"); + break; + case MEM_COMMIT: + wTmpStr = QString("Commited"); + break; + case MEM_RESERVE: + wTmpStr = QString("Reserved"); + break; + default: + wTmpStr = QString("N/A"); } wStr += wTmpStr + QString(" ").repeated(10 - wTmpStr.length()); wStr += " | "; @@ -145,36 +145,36 @@ void ProcessMemoryMap::printVirtualMemoryMap(QList par { switch(wMemInfo.Protect & 0xFF) { - case PAGE_EXECUTE: - wTmpStr = QString("Execute"); - break; - case PAGE_EXECUTE_READ: - wTmpStr = QString("Execute/Read"); - break; - case PAGE_EXECUTE_READWRITE: - wTmpStr = QString("Execute/Read/Write"); - break; - case PAGE_NOACCESS: - wTmpStr = QString("No Access"); - break; - case PAGE_READONLY: - wTmpStr = QString("Read"); - break; - case PAGE_READWRITE: - wTmpStr = QString("Read/Write"); - break; - case PAGE_WRITECOPY: - wTmpStr = QString("Copy on Write"); - break; - case PAGE_EXECUTE_WRITECOPY: - wTmpStr = QString("Execute/Copy on Write"); - break; + case PAGE_EXECUTE: + wTmpStr = QString("Execute"); + break; + case PAGE_EXECUTE_READ: + wTmpStr = QString("Execute/Read"); + break; + case PAGE_EXECUTE_READWRITE: + wTmpStr = QString("Execute/Read/Write"); + break; + case PAGE_NOACCESS: + wTmpStr = QString("No Access"); + break; + case PAGE_READONLY: + wTmpStr = QString("Read"); + break; + case PAGE_READWRITE: + wTmpStr = QString("Read/Write"); + break; + case PAGE_WRITECOPY: + wTmpStr = QString("Copy on Write"); + break; + case PAGE_EXECUTE_WRITECOPY: + wTmpStr = QString("Execute/Copy on Write"); + break; } switch(wMemInfo.Protect & 0xFF00) { - case PAGE_GUARD: - wTmpStr += QString(" + Guard"); + case PAGE_GUARD: + wTmpStr += QString(" + Guard"); } wStr += wTmpStr + QString(" ").repeated(30 - wTmpStr.length()); @@ -184,18 +184,18 @@ void ProcessMemoryMap::printVirtualMemoryMap(QList par // Type switch(wMemInfo.Type) { - case MEM_IMAGE: - wTmpStr = QString("Image"); - break; - case MEM_MAPPED: - wTmpStr = QString("Mapped"); - break; - case MEM_PRIVATE: - wTmpStr = QString("Private"); - break; - default: - wTmpStr = QString("N/A"); - break; + case MEM_IMAGE: + wTmpStr = QString("Image"); + break; + case MEM_MAPPED: + wTmpStr = QString("Mapped"); + break; + case MEM_PRIVATE: + wTmpStr = QString("Private"); + break; + default: + wTmpStr = QString("N/A"); + break; } wStr += wTmpStr + QString(" ").repeated(10 - wTmpStr.length()); diff --git a/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.cpp b/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.cpp index 94427096..b53a5f05 100644 --- a/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.cpp +++ b/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.cpp @@ -1,110 +1,121 @@ -#include "ApiFingerprints.h" -#include "Configuration.h" - - - -/** - * @brief retrieves information (name, arguments) for given api function from database - * @param name of dll without ".dll" - * @param name of function - * @remark upper or lower case doesn't matter - * @return - */ -const APIFunction ApiFingerprints::function(QString dllname,QString functionname) const{ - return Library.constFind(dllname.toLower().trimmed()).value().constFind(functionname.toLower().trimmed()).value(); - /* - * example - * -------------------- - * "int MessageBoxA(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType)" - * - * APIFunction f = function("UsEr32 ","messAgebOxa"); - * f.Name = "MessageBoxA"; - * f.DLLName = "user32"; - * f.ReturnType = "int" - * f.Arguments.at(0).Name = "hWnd"; - * f.Arguments.at(0).Type = "HWND"; - * f.Arguments.at(1).Name = "lpText"; - * f.Arguments.at(1).Type = "LPCTSTR"; - * ... - * - * upper / lower case doesn't matter and additional whitespace will be trimmed - */ - - -} - - -ApiFingerprints::ApiFingerprints() -{ - // the config file should contain a list of possible data files for api calls - QList files = Configuration::instance()->ApiFingerprints(); - - // iterate all given files - foreach(QString file, files){ - QFile mFile("data/"+file+".txt"); - if(mFile.open(QFile::ReadOnly | QFile::Text)){ - // if file exists --> parse file - - QMap Functions; - QTextStream in(&mFile); - while ( !in.atEnd() ) - { - // reads raw line like "int;MessageBoxA;HWND hWnd;LPCTSTR lpText;LPCTSTR lpCaption;UINT uType;" - QString rawFunctionDescr = in.readLine(); - QStringList functionParts = rawFunctionDescr.split(";"); - // format : retType;FunctionName;Arg1;Arg2;Arg3;... - - - if(functionParts.count()<2){ - // each function description needs at least a return type and a name - // if not, we ignore the data - continue; - } - - // function data - APIFunction func; - func.DLLName = file; - func.ReturnType = functionParts.at(0); - func.Name = functionParts.at(1); - - // read parameters - for(int i=2;i use "*" to split type and name of argument - QStringList par = rawArgument.split("*"); - APIArgument arg; - if(par.count() > 1){ - arg.Name = par.at(1).trimmed(); - arg.Type = par.at(0).trimmed()+"*"; - - }else{ - // current argument is no pointer --> use " " to split - par = rawArgument.split(" "); - if(par.count()>1){ - arg.Name = par.at(1).trimmed(); - arg.Type = par.at(0).trimmed(); - }else{ - // we assume that there is only the type - arg.Name = ""; - arg.Type = rawArgument.trimmed(); - } - } - - func.Arguments.append(arg); - - } - - Functions.insert(func.Name.toLower().trimmed(),func); - - } - - Library.insert(file,Functions); - mFile.close(); - } - - } - -} +#include "ApiFingerprints.h" +#include "Configuration.h" + + + +/** + * @brief retrieves information (name, arguments) for given api function from database + * @param name of dll without ".dll" + * @param name of function + * @remark upper or lower case doesn't matter + * @return + */ +const APIFunction ApiFingerprints::function(QString dllname,QString functionname) const +{ + return Library.constFind(dllname.toLower().trimmed()).value().constFind(functionname.toLower().trimmed()).value(); + /* + * example + * -------------------- + * "int MessageBoxA(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType)" + * + * APIFunction f = function("UsEr32 ","messAgebOxa"); + * f.Name = "MessageBoxA"; + * f.DLLName = "user32"; + * f.ReturnType = "int" + * f.Arguments.at(0).Name = "hWnd"; + * f.Arguments.at(0).Type = "HWND"; + * f.Arguments.at(1).Name = "lpText"; + * f.Arguments.at(1).Type = "LPCTSTR"; + * ... + * + * upper / lower case doesn't matter and additional whitespace will be trimmed + */ + + +} + + +ApiFingerprints::ApiFingerprints() +{ + // the config file should contain a list of possible data files for api calls + QList files = Configuration::instance()->ApiFingerprints(); + + // iterate all given files + foreach(QString file, files) + { + QFile mFile("data/"+file+".txt"); + if(mFile.open(QFile::ReadOnly | QFile::Text)) + { + // if file exists --> parse file + + QMap Functions; + QTextStream in(&mFile); + while ( !in.atEnd() ) + { + // reads raw line like "int;MessageBoxA;HWND hWnd;LPCTSTR lpText;LPCTSTR lpCaption;UINT uType;" + QString rawFunctionDescr = in.readLine(); + QStringList functionParts = rawFunctionDescr.split(";"); + // format : retType;FunctionName;Arg1;Arg2;Arg3;... + + + if(functionParts.count()<2) + { + // each function description needs at least a return type and a name + // if not, we ignore the data + continue; + } + + // function data + APIFunction func; + func.DLLName = file; + func.ReturnType = functionParts.at(0); + func.Name = functionParts.at(1); + + // read parameters + for(int i=2; i use "*" to split type and name of argument + QStringList par = rawArgument.split("*"); + APIArgument arg; + if(par.count() > 1) + { + arg.Name = par.at(1).trimmed(); + arg.Type = par.at(0).trimmed()+"*"; + + } + else + { + // current argument is no pointer --> use " " to split + par = rawArgument.split(" "); + if(par.count()>1) + { + arg.Name = par.at(1).trimmed(); + arg.Type = par.at(0).trimmed(); + } + else + { + // we assume that there is only the type + arg.Name = ""; + arg.Type = rawArgument.trimmed(); + } + } + + func.Arguments.append(arg); + + } + + Functions.insert(func.Name.toLower().trimmed(),func); + + } + + Library.insert(file,Functions); + mFile.close(); + } + + } + +} diff --git a/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.h b/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.h index c30dcda4..f4b1eb34 100644 --- a/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.h +++ b/x64_dbg_gui/Project/Src/Utils/ApiFingerprints.h @@ -1,28 +1,30 @@ -#ifndef APIFINGERPRINTS_H -#define APIFINGERPRINTS_H - -#include -#include -#include - -struct APIArgument{ - QString Type; - QString Name; -}; - -struct APIFunction{ - QString DLLName; - QString ReturnType; - QString Name; - QList Arguments; -}; - -class ApiFingerprints -{ - QMap> Library; -public: - ApiFingerprints(); - const APIFunction function(QString dllname, QString functionname) const; -}; - -#endif // APIFINGERPRINTS_H +#ifndef APIFINGERPRINTS_H +#define APIFINGERPRINTS_H + +#include +#include +#include + +struct APIArgument +{ + QString Type; + QString Name; +}; + +struct APIFunction +{ + QString DLLName; + QString ReturnType; + QString Name; + QList Arguments; +}; + +class ApiFingerprints +{ + QMap> Library; +public: + ApiFingerprints(); + const APIFunction function(QString dllname, QString functionname) const; +}; + +#endif // APIFINGERPRINTS_H diff --git a/x64_dbg_gui/Project/Src/Utils/Breakpoints.cpp b/x64_dbg_gui/Project/Src/Utils/Breakpoints.cpp index a3f2b9e1..f433b852 100644 --- a/x64_dbg_gui/Project/Src/Utils/Breakpoints.cpp +++ b/x64_dbg_gui/Project/Src/Utils/Breakpoints.cpp @@ -19,29 +19,29 @@ void Breakpoints::setBP(BPXTYPE type, uint_t va) switch(type) { - case bp_normal: - { - wCmd = "bp " + QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - } - break; + case bp_normal: + { + wCmd = "bp " + QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + } + break; - case bp_hardware: - { - wCmd = "bph " + QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - } - break; + case bp_hardware: + { + wCmd = "bph " + QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + } + break; - case bp_memory: - { - wCmd = "bpm " + QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - } - break; + case bp_memory: + { + wCmd = "bpm " + QString("%1").arg(va, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + } + break; - default: - { + default: + { - } - break; + } + break; } DbgCmdExec(wCmd.toUtf8().constData()); @@ -177,29 +177,29 @@ void Breakpoints::removeBP(BRIDGEBP bp) switch(bp.type) { - case bp_normal: - { - wCmd = "bc " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - } - break; + case bp_normal: + { + wCmd = "bc " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + } + break; - case bp_hardware: - { - wCmd = "bphc " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - } - break; + case bp_hardware: + { + wCmd = "bphc " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + } + break; - case bp_memory: - { - wCmd = "bpmc " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); - } - break; + case bp_memory: + { + wCmd = "bpmc " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper(); + } + break; - default: - { + default: + { - } - break; + } + break; } DbgCmdExec(wCmd.toUtf8().constData()); @@ -316,17 +316,17 @@ void Breakpoints::toogleBPByRemoving(BPXTYPE type, uint_t va) switch(wBPList.bp[wI].type) { - case bp_normal: - wNormalWasRemoved = true; - break; - case bp_memory: - wMemoryWasRemoved = true; - break; - case bp_hardware: - wHardwareWasRemoved = true; - break; - default: - break; + case bp_normal: + wNormalWasRemoved = true; + break; + case bp_memory: + wMemoryWasRemoved = true; + break; + case bp_hardware: + wHardwareWasRemoved = true; + break; + default: + break; } } }