PROJECT: some formatting
This commit is contained in:
parent
305faec66b
commit
0e1c1449ce
|
@ -1,130 +1,130 @@
|
|||
#include "_global.h"
|
||||
#include "_dbgfunctions.h"
|
||||
#include "assemble.h"
|
||||
#include "debugger.h"
|
||||
#include "addrinfo.h"
|
||||
#include "patches.h"
|
||||
#include "memory.h"
|
||||
#include "disasm_fast.h"
|
||||
#include "stackinfo.h"
|
||||
|
||||
static DBGFUNCTIONS _dbgfunctions;
|
||||
|
||||
const DBGFUNCTIONS* dbgfunctionsget()
|
||||
{
|
||||
return &_dbgfunctions;
|
||||
}
|
||||
|
||||
static bool _assembleatex(duint addr, const char* instruction, char* error, bool fillnop)
|
||||
{
|
||||
return assembleat(addr, instruction, 0, error, fillnop);
|
||||
}
|
||||
|
||||
static bool _sectionfromaddr(duint addr, char* section)
|
||||
{
|
||||
HMODULE hMod=(HMODULE)modbasefromaddr(addr);
|
||||
if(!hMod)
|
||||
return false;
|
||||
char curModPath[MAX_PATH]="";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, hMod, curModPath, MAX_PATH))
|
||||
return false;
|
||||
HANDLE FileHandle;
|
||||
DWORD LoadedSize;
|
||||
HANDLE FileMap;
|
||||
ULONG_PTR FileMapVA;
|
||||
if(StaticFileLoad(curModPath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
{
|
||||
uint rva=addr-(uint)hMod;
|
||||
int sectionNumber=GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE)+rva);
|
||||
if(sectionNumber>=0)
|
||||
{
|
||||
const char* name=(const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
|
||||
if(section)
|
||||
strcpy(section, name);
|
||||
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
|
||||
return true;
|
||||
}
|
||||
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _patchget(duint addr)
|
||||
{
|
||||
return patchget(addr, 0);
|
||||
}
|
||||
|
||||
static bool _patchinrange(duint start, duint end)
|
||||
{
|
||||
if(start > end)
|
||||
{
|
||||
duint a=start;
|
||||
start=end;
|
||||
end=a;
|
||||
}
|
||||
for(duint i=start; i<end+1; i++)
|
||||
if(_patchget(i))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _mempatch(duint va, const unsigned char* src, duint size)
|
||||
{
|
||||
return mempatch(fdProcessInfo->hProcess, (void*)va, src, size, 0);
|
||||
}
|
||||
|
||||
static void _patchrestorerange(duint start, duint end)
|
||||
{
|
||||
if(start > end)
|
||||
{
|
||||
duint a=start;
|
||||
start=end;
|
||||
end=a;
|
||||
}
|
||||
for(duint i=start; i<end+1; i++)
|
||||
patchdel(i, true);
|
||||
GuiUpdatePatches();
|
||||
}
|
||||
|
||||
static bool _patchrestore(duint addr)
|
||||
{
|
||||
return patchdel(addr, true);
|
||||
}
|
||||
|
||||
static int _modpathfromaddr(duint addr, char* path, int size)
|
||||
{
|
||||
return GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), path, size);
|
||||
}
|
||||
|
||||
static int _modpathfromname(const char* modname, char* path, int size)
|
||||
{
|
||||
return _modpathfromaddr(modbasefromname(modname), path, size);
|
||||
}
|
||||
|
||||
static void _getcallstack(DBGCALLSTACK* callstack)
|
||||
{
|
||||
stackgetcallstack(GetContextData(UE_CSP), (CALLSTACK*)callstack);
|
||||
}
|
||||
|
||||
void dbgfunctionsinit()
|
||||
{
|
||||
_dbgfunctions.AssembleAtEx=_assembleatex;
|
||||
_dbgfunctions.SectionFromAddr=_sectionfromaddr;
|
||||
_dbgfunctions.ModNameFromAddr=modnamefromaddr;
|
||||
_dbgfunctions.ModBaseFromAddr=modbasefromaddr;
|
||||
_dbgfunctions.ModBaseFromName=modbasefromname;
|
||||
_dbgfunctions.ModSizeFromAddr=modsizefromaddr;
|
||||
_dbgfunctions.Assemble=assemble;
|
||||
_dbgfunctions.PatchGet=_patchget;
|
||||
_dbgfunctions.PatchInRange=_patchinrange;
|
||||
_dbgfunctions.MemPatch=_mempatch;
|
||||
_dbgfunctions.PatchRestoreRange=_patchrestorerange;
|
||||
_dbgfunctions.PatchEnum=(PATCHENUM)patchenum;
|
||||
_dbgfunctions.PatchRestore=_patchrestore;
|
||||
_dbgfunctions.PatchFile=(PATCHFILE)patchfile;
|
||||
_dbgfunctions.ModPathFromAddr=_modpathfromaddr;
|
||||
_dbgfunctions.ModPathFromName=_modpathfromname;
|
||||
_dbgfunctions.DisasmFast=disasmfast;
|
||||
_dbgfunctions.MemUpdateMap=memupdatemap;
|
||||
_dbgfunctions.GetCallStack=_getcallstack;
|
||||
}
|
||||
#include "_global.h"
|
||||
#include "_dbgfunctions.h"
|
||||
#include "assemble.h"
|
||||
#include "debugger.h"
|
||||
#include "addrinfo.h"
|
||||
#include "patches.h"
|
||||
#include "memory.h"
|
||||
#include "disasm_fast.h"
|
||||
#include "stackinfo.h"
|
||||
|
||||
static DBGFUNCTIONS _dbgfunctions;
|
||||
|
||||
const DBGFUNCTIONS* dbgfunctionsget()
|
||||
{
|
||||
return &_dbgfunctions;
|
||||
}
|
||||
|
||||
static bool _assembleatex(duint addr, const char* instruction, char* error, bool fillnop)
|
||||
{
|
||||
return assembleat(addr, instruction, 0, error, fillnop);
|
||||
}
|
||||
|
||||
static bool _sectionfromaddr(duint addr, char* section)
|
||||
{
|
||||
HMODULE hMod=(HMODULE)modbasefromaddr(addr);
|
||||
if(!hMod)
|
||||
return false;
|
||||
char curModPath[MAX_PATH]="";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, hMod, curModPath, MAX_PATH))
|
||||
return false;
|
||||
HANDLE FileHandle;
|
||||
DWORD LoadedSize;
|
||||
HANDLE FileMap;
|
||||
ULONG_PTR FileMapVA;
|
||||
if(StaticFileLoad(curModPath, UE_ACCESS_READ, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
{
|
||||
uint rva=addr-(uint)hMod;
|
||||
int sectionNumber=GetPE32SectionNumberFromVA(FileMapVA, GetPE32DataFromMappedFile(FileMapVA, 0, UE_IMAGEBASE)+rva);
|
||||
if(sectionNumber>=0)
|
||||
{
|
||||
const char* name=(const char*)GetPE32DataFromMappedFile(FileMapVA, sectionNumber, UE_SECTIONNAME);
|
||||
if(section)
|
||||
strcpy(section, name);
|
||||
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
|
||||
return true;
|
||||
}
|
||||
StaticFileUnload(curModPath, false, FileHandle, LoadedSize, FileMap, FileMapVA);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _patchget(duint addr)
|
||||
{
|
||||
return patchget(addr, 0);
|
||||
}
|
||||
|
||||
static bool _patchinrange(duint start, duint end)
|
||||
{
|
||||
if(start > end)
|
||||
{
|
||||
duint a=start;
|
||||
start=end;
|
||||
end=a;
|
||||
}
|
||||
for(duint i=start; i<end+1; i++)
|
||||
if(_patchget(i))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _mempatch(duint va, const unsigned char* src, duint size)
|
||||
{
|
||||
return mempatch(fdProcessInfo->hProcess, (void*)va, src, size, 0);
|
||||
}
|
||||
|
||||
static void _patchrestorerange(duint start, duint end)
|
||||
{
|
||||
if(start > end)
|
||||
{
|
||||
duint a=start;
|
||||
start=end;
|
||||
end=a;
|
||||
}
|
||||
for(duint i=start; i<end+1; i++)
|
||||
patchdel(i, true);
|
||||
GuiUpdatePatches();
|
||||
}
|
||||
|
||||
static bool _patchrestore(duint addr)
|
||||
{
|
||||
return patchdel(addr, true);
|
||||
}
|
||||
|
||||
static int _modpathfromaddr(duint addr, char* path, int size)
|
||||
{
|
||||
return GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbasefromaddr(addr), path, size);
|
||||
}
|
||||
|
||||
static int _modpathfromname(const char* modname, char* path, int size)
|
||||
{
|
||||
return _modpathfromaddr(modbasefromname(modname), path, size);
|
||||
}
|
||||
|
||||
static void _getcallstack(DBGCALLSTACK* callstack)
|
||||
{
|
||||
stackgetcallstack(GetContextData(UE_CSP), (CALLSTACK*)callstack);
|
||||
}
|
||||
|
||||
void dbgfunctionsinit()
|
||||
{
|
||||
_dbgfunctions.AssembleAtEx=_assembleatex;
|
||||
_dbgfunctions.SectionFromAddr=_sectionfromaddr;
|
||||
_dbgfunctions.ModNameFromAddr=modnamefromaddr;
|
||||
_dbgfunctions.ModBaseFromAddr=modbasefromaddr;
|
||||
_dbgfunctions.ModBaseFromName=modbasefromname;
|
||||
_dbgfunctions.ModSizeFromAddr=modsizefromaddr;
|
||||
_dbgfunctions.Assemble=assemble;
|
||||
_dbgfunctions.PatchGet=_patchget;
|
||||
_dbgfunctions.PatchInRange=_patchinrange;
|
||||
_dbgfunctions.MemPatch=_mempatch;
|
||||
_dbgfunctions.PatchRestoreRange=_patchrestorerange;
|
||||
_dbgfunctions.PatchEnum=(PATCHENUM)patchenum;
|
||||
_dbgfunctions.PatchRestore=_patchrestore;
|
||||
_dbgfunctions.PatchFile=(PATCHFILE)patchfile;
|
||||
_dbgfunctions.ModPathFromAddr=_modpathfromaddr;
|
||||
_dbgfunctions.ModPathFromName=_modpathfromname;
|
||||
_dbgfunctions.DisasmFast=disasmfast;
|
||||
_dbgfunctions.MemUpdateMap=memupdatemap;
|
||||
_dbgfunctions.GetCallStack=_getcallstack;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
#ifndef _DBGFUNCTIONS_H
|
||||
#define _DBGFUNCTIONS_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char mod[MAX_MODULE_SIZE];
|
||||
duint addr;
|
||||
unsigned char oldbyte;
|
||||
unsigned char newbyte;
|
||||
} DBGPATCHINFO;
|
||||
|
||||
#ifndef _DBGFUNCTIONS_H
|
||||
#define _DBGFUNCTIONS_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char mod[MAX_MODULE_SIZE];
|
||||
duint addr;
|
||||
unsigned char oldbyte;
|
||||
unsigned char newbyte;
|
||||
} DBGPATCHINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
duint addr;
|
||||
|
@ -25,56 +25,56 @@ typedef struct
|
|||
{
|
||||
int total;
|
||||
DBGCALLSTACKENTRY* entries;
|
||||
} DBGCALLSTACK;
|
||||
|
||||
typedef bool (*ASSEMBLEATEX)(duint addr, const char* instruction, char* error, bool fillnop);
|
||||
typedef bool (*SECTIONFROMADDR)(duint addr, char* section);
|
||||
typedef bool (*MODNAMEFROMADDR)(duint addr, char* modname, bool extension);
|
||||
typedef duint (*MODBASEFROMADDR)(duint addr);
|
||||
typedef duint (*MODBASEFROMNAME)(const char* modname);
|
||||
typedef duint (*MODSIZEFROMADDR)(duint addr);
|
||||
typedef bool (*ASSEMBLE)(duint addr, unsigned char* dest, int* size, const char* instruction, char* error);
|
||||
typedef bool (*PATCHGET)(duint addr);
|
||||
typedef bool (*PATCHINRANGE)(duint start, duint end);
|
||||
typedef bool (*MEMPATCH)(duint va, const unsigned char* src, duint size);
|
||||
typedef void (*PATCHRESTORERANGE)(duint start, duint end);
|
||||
typedef bool (*PATCHENUM)(DBGPATCHINFO* patchlist, size_t* cbsize);
|
||||
typedef bool (*PATCHRESTORE)(duint addr);
|
||||
typedef int (*PATCHFILE)(DBGPATCHINFO* patchlist, int count, const char* szFileName, char* error);
|
||||
typedef int (*MODPATHFROMADDR)(duint addr, char* path, int size);
|
||||
typedef int (*MODPATHFROMNAME)(const char* modname, char* path, int size);
|
||||
typedef bool (*DISASMFAST)(unsigned char* data, duint addr, BASIC_INSTRUCTION_INFO* basicinfo);
|
||||
typedef void (*MEMUPDATEMAP)(HANDLE hProcess);
|
||||
typedef void (*GETCALLSTACK)(DBGCALLSTACK* callstack);
|
||||
|
||||
typedef struct DBGFUNCTIONS_
|
||||
{
|
||||
ASSEMBLEATEX AssembleAtEx;
|
||||
SECTIONFROMADDR SectionFromAddr;
|
||||
MODNAMEFROMADDR ModNameFromAddr;
|
||||
MODBASEFROMADDR ModBaseFromAddr;
|
||||
MODBASEFROMNAME ModBaseFromName;
|
||||
MODSIZEFROMADDR ModSizeFromAddr;
|
||||
ASSEMBLE Assemble;
|
||||
PATCHGET PatchGet;
|
||||
PATCHINRANGE PatchInRange;
|
||||
MEMPATCH MemPatch;
|
||||
PATCHRESTORERANGE PatchRestoreRange;
|
||||
PATCHENUM PatchEnum;
|
||||
PATCHRESTORE PatchRestore;
|
||||
PATCHFILE PatchFile;
|
||||
MODPATHFROMADDR ModPathFromAddr;
|
||||
MODPATHFROMNAME ModPathFromName;
|
||||
DISASMFAST DisasmFast;
|
||||
MEMUPDATEMAP MemUpdateMap;
|
||||
GETCALLSTACK GetCallStack;
|
||||
} DBGFUNCTIONS;
|
||||
|
||||
#ifdef BUILD_DBG
|
||||
|
||||
const DBGFUNCTIONS* dbgfunctionsget();
|
||||
void dbgfunctionsinit();
|
||||
|
||||
#endif //BUILD_DBG
|
||||
|
||||
#endif //_DBGFUNCTIONS_H
|
||||
} DBGCALLSTACK;
|
||||
|
||||
typedef bool (*ASSEMBLEATEX)(duint addr, const char* instruction, char* error, bool fillnop);
|
||||
typedef bool (*SECTIONFROMADDR)(duint addr, char* section);
|
||||
typedef bool (*MODNAMEFROMADDR)(duint addr, char* modname, bool extension);
|
||||
typedef duint (*MODBASEFROMADDR)(duint addr);
|
||||
typedef duint (*MODBASEFROMNAME)(const char* modname);
|
||||
typedef duint (*MODSIZEFROMADDR)(duint addr);
|
||||
typedef bool (*ASSEMBLE)(duint addr, unsigned char* dest, int* size, const char* instruction, char* error);
|
||||
typedef bool (*PATCHGET)(duint addr);
|
||||
typedef bool (*PATCHINRANGE)(duint start, duint end);
|
||||
typedef bool (*MEMPATCH)(duint va, const unsigned char* src, duint size);
|
||||
typedef void (*PATCHRESTORERANGE)(duint start, duint end);
|
||||
typedef bool (*PATCHENUM)(DBGPATCHINFO* patchlist, size_t* cbsize);
|
||||
typedef bool (*PATCHRESTORE)(duint addr);
|
||||
typedef int (*PATCHFILE)(DBGPATCHINFO* patchlist, int count, const char* szFileName, char* error);
|
||||
typedef int (*MODPATHFROMADDR)(duint addr, char* path, int size);
|
||||
typedef int (*MODPATHFROMNAME)(const char* modname, char* path, int size);
|
||||
typedef bool (*DISASMFAST)(unsigned char* data, duint addr, BASIC_INSTRUCTION_INFO* basicinfo);
|
||||
typedef void (*MEMUPDATEMAP)(HANDLE hProcess);
|
||||
typedef void (*GETCALLSTACK)(DBGCALLSTACK* callstack);
|
||||
|
||||
typedef struct DBGFUNCTIONS_
|
||||
{
|
||||
ASSEMBLEATEX AssembleAtEx;
|
||||
SECTIONFROMADDR SectionFromAddr;
|
||||
MODNAMEFROMADDR ModNameFromAddr;
|
||||
MODBASEFROMADDR ModBaseFromAddr;
|
||||
MODBASEFROMNAME ModBaseFromName;
|
||||
MODSIZEFROMADDR ModSizeFromAddr;
|
||||
ASSEMBLE Assemble;
|
||||
PATCHGET PatchGet;
|
||||
PATCHINRANGE PatchInRange;
|
||||
MEMPATCH MemPatch;
|
||||
PATCHRESTORERANGE PatchRestoreRange;
|
||||
PATCHENUM PatchEnum;
|
||||
PATCHRESTORE PatchRestore;
|
||||
PATCHFILE PatchFile;
|
||||
MODPATHFROMADDR ModPathFromAddr;
|
||||
MODPATHFROMNAME ModPathFromName;
|
||||
DISASMFAST DisasmFast;
|
||||
MEMUPDATEMAP MemUpdateMap;
|
||||
GETCALLSTACK GetCallStack;
|
||||
} DBGFUNCTIONS;
|
||||
|
||||
#ifdef BUILD_DBG
|
||||
|
||||
const DBGFUNCTIONS* dbgfunctionsget();
|
||||
void dbgfunctionsinit();
|
||||
|
||||
#endif //BUILD_DBG
|
||||
|
||||
#endif //_DBGFUNCTIONS_H
|
||||
|
|
|
@ -1,195 +1,195 @@
|
|||
#include "patches.h"
|
||||
#include "addrinfo.h"
|
||||
#include "memory.h"
|
||||
#include "debugger.h"
|
||||
#include "console.h"
|
||||
|
||||
PatchesInfo patches;
|
||||
|
||||
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
|
||||
{
|
||||
if(!DbgIsDebugging() || !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||
return false;
|
||||
if(oldbyte==newbyte)
|
||||
return true; //no need to make a patch for a byte that is equal to itself
|
||||
PATCHINFO newPatch;
|
||||
newPatch.addr=addr-modbasefromaddr(addr);
|
||||
modnamefromaddr(addr, newPatch.mod, true);
|
||||
newPatch.oldbyte=oldbyte;
|
||||
newPatch.newbyte=newbyte;
|
||||
uint key=modhashfromva(addr);
|
||||
PatchesInfo::iterator found=patches.find(key);
|
||||
if(found!=patches.end()) //we found a patch on the specified address
|
||||
{
|
||||
if(found->second.oldbyte == newbyte) //patch is undone
|
||||
{
|
||||
patches.erase(found);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPatch.oldbyte=found->second.oldbyte; //keep the original byte from the previous patch
|
||||
found->second=newPatch;
|
||||
}
|
||||
}
|
||||
else
|
||||
patches.insert(std::make_pair(key, newPatch));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool patchget(uint addr, PATCHINFO* patch)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
PatchesInfo::iterator found=patches.find(modhashfromva(addr));
|
||||
if(found==patches.end()) //not found
|
||||
return false;
|
||||
if(patch)
|
||||
{
|
||||
*patch=found->second;
|
||||
patch->addr+=modbasefromaddr(addr);
|
||||
return true;
|
||||
}
|
||||
return (found->second.oldbyte != found->second.newbyte);
|
||||
}
|
||||
|
||||
bool patchdel(uint addr, bool restore)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
PatchesInfo::iterator found=patches.find(modhashfromva(addr));
|
||||
if(found==patches.end()) //not found
|
||||
return false;
|
||||
if(restore)
|
||||
memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr+modbasefromaddr(addr)), &found->second.oldbyte, sizeof(char), 0);
|
||||
patches.erase(found);
|
||||
return true;
|
||||
}
|
||||
|
||||
void patchdelrange(uint start, uint end, bool restore)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
bool bDelAll=(start==0 && end==~0); //0x00000000-0xFFFFFFFF
|
||||
uint modbase=modbasefromaddr(start);
|
||||
if(modbase!=modbasefromaddr(end))
|
||||
return;
|
||||
start-=modbase;
|
||||
end-=modbase;
|
||||
PatchesInfo::iterator i=patches.begin();
|
||||
while(i!=patches.end())
|
||||
{
|
||||
if(bDelAll || (i->second.addr>=start && i->second.addr<end))
|
||||
{
|
||||
if(restore)
|
||||
memwrite(fdProcessInfo->hProcess, (void*)(i->second.addr+modbase), &i->second.oldbyte, sizeof(char), 0);
|
||||
patches.erase(i++);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void patchclear(const char* mod)
|
||||
{
|
||||
if(!mod or !*mod)
|
||||
patches.clear();
|
||||
else
|
||||
{
|
||||
PatchesInfo::iterator i=patches.begin();
|
||||
while(i!=patches.end())
|
||||
{
|
||||
if(!_stricmp(i->second.mod, mod))
|
||||
patches.erase(i++);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
if(!patcheslist && !cbsize)
|
||||
return false;
|
||||
if(!patcheslist && cbsize)
|
||||
{
|
||||
*cbsize=patches.size()*sizeof(LOOPSINFO);
|
||||
return true;
|
||||
}
|
||||
int j=0;
|
||||
for(PatchesInfo::iterator i=patches.begin(); i!=patches.end(); ++i,j++)
|
||||
{
|
||||
patcheslist[j]=i->second;
|
||||
uint modbase=modbasefromname(patcheslist[j].mod);
|
||||
patcheslist[j].addr+=modbase;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, char* error)
|
||||
{
|
||||
if(!count)
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "no patches to apply");
|
||||
return -1;
|
||||
}
|
||||
char modname[MAX_MODULE_SIZE]="";
|
||||
strcpy(modname, patchlist[0].mod);
|
||||
//check if all patches are in the same module
|
||||
for(int i=0; i<count; i++)
|
||||
if(_stricmp(patchlist[i].mod, modname))
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "not all patches are in module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
uint modbase=modbasefromname(modname);
|
||||
if(!modbase) //module not loaded
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "failed to get base of module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
char szOriginalName[MAX_PATH]="";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "failed to get module path of module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
if(!CopyFileA(szOriginalName, szFileName, false))
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "failed to make a copy of the original file (patch target is in use?)");
|
||||
return -1;
|
||||
}
|
||||
HANDLE FileHandle;
|
||||
DWORD LoadedSize;
|
||||
HANDLE FileMap;
|
||||
ULONG_PTR FileMapVA;
|
||||
if(StaticFileLoad((char*)szFileName, UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
{
|
||||
int patched=0;
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
unsigned char* ptr = (unsigned char*)ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, modbase, patchlist[i].addr, false, true);
|
||||
if(!ptr) //skip patches that do not have a raw address
|
||||
continue;
|
||||
dprintf("patch%.4d|%s[%.8X]:%.2X/%.2X->%.2X\n", i+1, modname, ptr-FileMapVA, *ptr, patchlist[i].oldbyte, patchlist[i].newbyte);
|
||||
*ptr=patchlist[i].newbyte;
|
||||
patched++;
|
||||
}
|
||||
if(!StaticFileUnload((char*)szFileName, true, FileHandle, LoadedSize, FileMap, FileMapVA))
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "StaticFileUnload failed");
|
||||
return -1;
|
||||
}
|
||||
return patched;
|
||||
}
|
||||
strcpy(error, "StaticFileLoad failed");
|
||||
return -1;
|
||||
}
|
||||
#include "patches.h"
|
||||
#include "addrinfo.h"
|
||||
#include "memory.h"
|
||||
#include "debugger.h"
|
||||
#include "console.h"
|
||||
|
||||
PatchesInfo patches;
|
||||
|
||||
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte)
|
||||
{
|
||||
if(!DbgIsDebugging() || !memisvalidreadptr(fdProcessInfo->hProcess, addr))
|
||||
return false;
|
||||
if(oldbyte==newbyte)
|
||||
return true; //no need to make a patch for a byte that is equal to itself
|
||||
PATCHINFO newPatch;
|
||||
newPatch.addr=addr-modbasefromaddr(addr);
|
||||
modnamefromaddr(addr, newPatch.mod, true);
|
||||
newPatch.oldbyte=oldbyte;
|
||||
newPatch.newbyte=newbyte;
|
||||
uint key=modhashfromva(addr);
|
||||
PatchesInfo::iterator found=patches.find(key);
|
||||
if(found!=patches.end()) //we found a patch on the specified address
|
||||
{
|
||||
if(found->second.oldbyte == newbyte) //patch is undone
|
||||
{
|
||||
patches.erase(found);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPatch.oldbyte=found->second.oldbyte; //keep the original byte from the previous patch
|
||||
found->second=newPatch;
|
||||
}
|
||||
}
|
||||
else
|
||||
patches.insert(std::make_pair(key, newPatch));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool patchget(uint addr, PATCHINFO* patch)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
PatchesInfo::iterator found=patches.find(modhashfromva(addr));
|
||||
if(found==patches.end()) //not found
|
||||
return false;
|
||||
if(patch)
|
||||
{
|
||||
*patch=found->second;
|
||||
patch->addr+=modbasefromaddr(addr);
|
||||
return true;
|
||||
}
|
||||
return (found->second.oldbyte != found->second.newbyte);
|
||||
}
|
||||
|
||||
bool patchdel(uint addr, bool restore)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
PatchesInfo::iterator found=patches.find(modhashfromva(addr));
|
||||
if(found==patches.end()) //not found
|
||||
return false;
|
||||
if(restore)
|
||||
memwrite(fdProcessInfo->hProcess, (void*)(found->second.addr+modbasefromaddr(addr)), &found->second.oldbyte, sizeof(char), 0);
|
||||
patches.erase(found);
|
||||
return true;
|
||||
}
|
||||
|
||||
void patchdelrange(uint start, uint end, bool restore)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
bool bDelAll=(start==0 && end==~0); //0x00000000-0xFFFFFFFF
|
||||
uint modbase=modbasefromaddr(start);
|
||||
if(modbase!=modbasefromaddr(end))
|
||||
return;
|
||||
start-=modbase;
|
||||
end-=modbase;
|
||||
PatchesInfo::iterator i=patches.begin();
|
||||
while(i!=patches.end())
|
||||
{
|
||||
if(bDelAll || (i->second.addr>=start && i->second.addr<end))
|
||||
{
|
||||
if(restore)
|
||||
memwrite(fdProcessInfo->hProcess, (void*)(i->second.addr+modbase), &i->second.oldbyte, sizeof(char), 0);
|
||||
patches.erase(i++);
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void patchclear(const char* mod)
|
||||
{
|
||||
if(!mod or !*mod)
|
||||
patches.clear();
|
||||
else
|
||||
{
|
||||
PatchesInfo::iterator i=patches.begin();
|
||||
while(i!=patches.end())
|
||||
{
|
||||
if(!_stricmp(i->second.mod, mod))
|
||||
patches.erase(i++);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool patchenum(PATCHINFO* patcheslist, size_t* cbsize)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
if(!patcheslist && !cbsize)
|
||||
return false;
|
||||
if(!patcheslist && cbsize)
|
||||
{
|
||||
*cbsize=patches.size()*sizeof(LOOPSINFO);
|
||||
return true;
|
||||
}
|
||||
int j=0;
|
||||
for(PatchesInfo::iterator i=patches.begin(); i!=patches.end(); ++i,j++)
|
||||
{
|
||||
patcheslist[j]=i->second;
|
||||
uint modbase=modbasefromname(patcheslist[j].mod);
|
||||
patcheslist[j].addr+=modbase;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, char* error)
|
||||
{
|
||||
if(!count)
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "no patches to apply");
|
||||
return -1;
|
||||
}
|
||||
char modname[MAX_MODULE_SIZE]="";
|
||||
strcpy(modname, patchlist[0].mod);
|
||||
//check if all patches are in the same module
|
||||
for(int i=0; i<count; i++)
|
||||
if(_stricmp(patchlist[i].mod, modname))
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "not all patches are in module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
uint modbase=modbasefromname(modname);
|
||||
if(!modbase) //module not loaded
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "failed to get base of module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
char szOriginalName[MAX_PATH]="";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "failed to get module path of module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
if(!CopyFileA(szOriginalName, szFileName, false))
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "failed to make a copy of the original file (patch target is in use?)");
|
||||
return -1;
|
||||
}
|
||||
HANDLE FileHandle;
|
||||
DWORD LoadedSize;
|
||||
HANDLE FileMap;
|
||||
ULONG_PTR FileMapVA;
|
||||
if(StaticFileLoad((char*)szFileName, UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
{
|
||||
int patched=0;
|
||||
for(int i=0; i<count; i++)
|
||||
{
|
||||
unsigned char* ptr = (unsigned char*)ConvertVAtoFileOffsetEx(FileMapVA, LoadedSize, modbase, patchlist[i].addr, false, true);
|
||||
if(!ptr) //skip patches that do not have a raw address
|
||||
continue;
|
||||
dprintf("patch%.4d|%s[%.8X]:%.2X/%.2X->%.2X\n", i+1, modname, ptr-FileMapVA, *ptr, patchlist[i].oldbyte, patchlist[i].newbyte);
|
||||
*ptr=patchlist[i].newbyte;
|
||||
patched++;
|
||||
}
|
||||
if(!StaticFileUnload((char*)szFileName, true, FileHandle, LoadedSize, FileMap, FileMapVA))
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "StaticFileUnload failed");
|
||||
return -1;
|
||||
}
|
||||
return patched;
|
||||
}
|
||||
strcpy(error, "StaticFileLoad failed");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
#ifndef _PATCHES_H
|
||||
#define _PATCHES_H
|
||||
|
||||
#include "_global.h"
|
||||
|
||||
struct PATCHINFO
|
||||
{
|
||||
char mod[MAX_MODULE_SIZE];
|
||||
uint addr;
|
||||
unsigned char oldbyte;
|
||||
unsigned char newbyte;
|
||||
};
|
||||
typedef std::map<uint, PATCHINFO> PatchesInfo;
|
||||
|
||||
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte);
|
||||
bool patchget(uint addr, PATCHINFO* patch);
|
||||
bool patchdel(uint addr, bool restore);
|
||||
void patchdelrange(uint start, uint end, bool restore);
|
||||
void patchclear(const char* mod = 0);
|
||||
bool patchenum(PATCHINFO* patchlist, size_t* cbsize);
|
||||
int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, char* error);
|
||||
|
||||
#endif //_PATCHES_H
|
||||
#ifndef _PATCHES_H
|
||||
#define _PATCHES_H
|
||||
|
||||
#include "_global.h"
|
||||
|
||||
struct PATCHINFO
|
||||
{
|
||||
char mod[MAX_MODULE_SIZE];
|
||||
uint addr;
|
||||
unsigned char oldbyte;
|
||||
unsigned char newbyte;
|
||||
};
|
||||
typedef std::map<uint, PATCHINFO> PatchesInfo;
|
||||
|
||||
bool patchset(uint addr, unsigned char oldbyte, unsigned char newbyte);
|
||||
bool patchget(uint addr, PATCHINFO* patch);
|
||||
bool patchdel(uint addr, bool restore);
|
||||
void patchdelrange(uint start, uint end, bool restore);
|
||||
void patchclear(const char* mod = 0);
|
||||
bool patchenum(PATCHINFO* patchlist, size_t* cbsize);
|
||||
int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, char* error);
|
||||
|
||||
#endif //_PATCHES_H
|
||||
|
|
|
@ -198,7 +198,8 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent *e)
|
|||
|
||||
QString wCmd;
|
||||
// create --> disable --> delete --> create --> ...
|
||||
switch(Breakpoints::BPState(bp_normal,wVA)){
|
||||
switch(Breakpoints::BPState(bp_normal,wVA))
|
||||
{
|
||||
case bp_enabled:
|
||||
// breakpoint exists and is enabled --> disable breakpoint
|
||||
wCmd = "bd " + QString("%1").arg(wVA, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
|
|
|
@ -1,125 +1,125 @@
|
|||
#include "HexEditDialog.h"
|
||||
#include "ui_HexEditDialog.h"
|
||||
#include "QHexEdit/QHexEdit.h"
|
||||
#include "Configuration.h"
|
||||
|
||||
HexEditDialog::HexEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::HexEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setFixedSize(this->size()); //fixed size
|
||||
setModal(true); //modal window
|
||||
|
||||
//setup text fields
|
||||
QFont font("Monospace", 8, QFont::Normal, false);
|
||||
font.setFixedPitch(true);
|
||||
font.setStyleHint(QFont::Monospace);
|
||||
ui->lineEditAscii->setFont(font);
|
||||
ui->lineEditUnicode->setFont(font);
|
||||
ui->chkEntireBlock->hide();
|
||||
connect(Bridge::getBridge(), SIGNAL(repaintGui()), this, SLOT(updateStyle()));
|
||||
updateStyle();
|
||||
|
||||
//setup hex editor
|
||||
mHexEdit = new QHexEdit(this);
|
||||
mHexEdit->setEditFont(ConfigFont("HexEdit"));
|
||||
mHexEdit->setHorizontalSpacing(6);
|
||||
mHexEdit->setOverwriteMode(true);
|
||||
mHexEdit->setTextColor(ConfigColor("HexEditTextColor"));
|
||||
mHexEdit->setWildcardColor(ConfigColor("HexEditWildcardColor"));
|
||||
mHexEdit->setBackgroundColor(ConfigColor("HexEditBackgroundColor"));
|
||||
mHexEdit->setSelectionColor(ConfigColor("HexEditSelectionColor"));
|
||||
connect(mHexEdit, SIGNAL(dataChanged()), this, SLOT(dataChangedSlot()));
|
||||
ui->scrollArea->setWidget(mHexEdit);
|
||||
mHexEdit->widget()->setFocus();
|
||||
mHexEdit->setTabOrder(ui->btnUnicode2Hex, mHexEdit->widget());
|
||||
}
|
||||
|
||||
HexEditDialog::~HexEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void HexEditDialog::showEntireBlock(bool show)
|
||||
{
|
||||
if(show)
|
||||
ui->chkEntireBlock->show();
|
||||
else
|
||||
ui->chkEntireBlock->hide();
|
||||
}
|
||||
|
||||
bool HexEditDialog::entireBlock()
|
||||
{
|
||||
return ui->chkEntireBlock->isChecked();
|
||||
}
|
||||
|
||||
void HexEditDialog::updateStyle()
|
||||
{
|
||||
QString style = QString("QLineEdit { border-style: outset; border-width: 1px; border-color: %1; color: %1; background-color: %2 }").arg(ConfigColor("HexEditTextColor").name(), ConfigColor("HexEditBackgroundColor").name());
|
||||
ui->lineEditAscii->setStyleSheet(style);
|
||||
ui->lineEditUnicode->setStyleSheet(style);
|
||||
}
|
||||
|
||||
void HexEditDialog::on_btnAscii2Hex_clicked()
|
||||
{
|
||||
QString text = ui->lineEditAscii->text();
|
||||
QByteArray data;
|
||||
for(int i=0; i<text.length(); i++)
|
||||
data.append(text[i].toAscii());
|
||||
if(ui->chkKeepSize->isChecked()) //keep size
|
||||
{
|
||||
int dataSize = mHexEdit->data().size();
|
||||
if(dataSize < data.size())
|
||||
data.resize(dataSize);
|
||||
else if(dataSize > data.size())
|
||||
data.append(QByteArray(dataSize-data.size(), 0));
|
||||
}
|
||||
mHexEdit->setData(data);
|
||||
}
|
||||
|
||||
void HexEditDialog::on_btnUnicode2Hex_clicked()
|
||||
{
|
||||
QByteArray data = QTextCodec::codecForName("UTF-16")->makeEncoder(QTextCodec::IgnoreHeader)->fromUnicode(ui->lineEditUnicode->text());
|
||||
if(ui->chkKeepSize->isChecked()) //keep size
|
||||
{
|
||||
int dataSize = mHexEdit->data().size();
|
||||
if(dataSize < data.size())
|
||||
data.resize(dataSize);
|
||||
else if(dataSize > data.size())
|
||||
data.append(QByteArray(dataSize-data.size(), 0));
|
||||
}
|
||||
mHexEdit->setData(data);
|
||||
}
|
||||
|
||||
void HexEditDialog::on_chkKeepSize_toggled(bool checked)
|
||||
{
|
||||
mHexEdit->setKeepSize(checked);
|
||||
}
|
||||
|
||||
void HexEditDialog::dataChangedSlot()
|
||||
{
|
||||
QByteArray data = mHexEdit->data();
|
||||
QString ascii;
|
||||
for(int i=0; i<data.size(); i++)
|
||||
{
|
||||
QChar ch(data.constData()[i]);
|
||||
if(ch.isPrint())
|
||||
ascii+=ch.toAscii();
|
||||
else
|
||||
ascii+='.';
|
||||
}
|
||||
QString unicode;
|
||||
for(int i=0,j=0; i<data.size(); i+=2,j++)
|
||||
{
|
||||
QChar wch(((wchar_t*)data.constData())[j]);
|
||||
if(wch.isPrint())
|
||||
unicode+=wch;
|
||||
else
|
||||
unicode+='.';
|
||||
}
|
||||
ui->lineEditAscii->setText(ascii);
|
||||
ui->lineEditUnicode->setText(unicode);
|
||||
}
|
||||
#include "HexEditDialog.h"
|
||||
#include "ui_HexEditDialog.h"
|
||||
#include "QHexEdit/QHexEdit.h"
|
||||
#include "Configuration.h"
|
||||
|
||||
HexEditDialog::HexEditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::HexEditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setFixedSize(this->size()); //fixed size
|
||||
setModal(true); //modal window
|
||||
|
||||
//setup text fields
|
||||
QFont font("Monospace", 8, QFont::Normal, false);
|
||||
font.setFixedPitch(true);
|
||||
font.setStyleHint(QFont::Monospace);
|
||||
ui->lineEditAscii->setFont(font);
|
||||
ui->lineEditUnicode->setFont(font);
|
||||
ui->chkEntireBlock->hide();
|
||||
connect(Bridge::getBridge(), SIGNAL(repaintGui()), this, SLOT(updateStyle()));
|
||||
updateStyle();
|
||||
|
||||
//setup hex editor
|
||||
mHexEdit = new QHexEdit(this);
|
||||
mHexEdit->setEditFont(ConfigFont("HexEdit"));
|
||||
mHexEdit->setHorizontalSpacing(6);
|
||||
mHexEdit->setOverwriteMode(true);
|
||||
mHexEdit->setTextColor(ConfigColor("HexEditTextColor"));
|
||||
mHexEdit->setWildcardColor(ConfigColor("HexEditWildcardColor"));
|
||||
mHexEdit->setBackgroundColor(ConfigColor("HexEditBackgroundColor"));
|
||||
mHexEdit->setSelectionColor(ConfigColor("HexEditSelectionColor"));
|
||||
connect(mHexEdit, SIGNAL(dataChanged()), this, SLOT(dataChangedSlot()));
|
||||
ui->scrollArea->setWidget(mHexEdit);
|
||||
mHexEdit->widget()->setFocus();
|
||||
mHexEdit->setTabOrder(ui->btnUnicode2Hex, mHexEdit->widget());
|
||||
}
|
||||
|
||||
HexEditDialog::~HexEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void HexEditDialog::showEntireBlock(bool show)
|
||||
{
|
||||
if(show)
|
||||
ui->chkEntireBlock->show();
|
||||
else
|
||||
ui->chkEntireBlock->hide();
|
||||
}
|
||||
|
||||
bool HexEditDialog::entireBlock()
|
||||
{
|
||||
return ui->chkEntireBlock->isChecked();
|
||||
}
|
||||
|
||||
void HexEditDialog::updateStyle()
|
||||
{
|
||||
QString style = QString("QLineEdit { border-style: outset; border-width: 1px; border-color: %1; color: %1; background-color: %2 }").arg(ConfigColor("HexEditTextColor").name(), ConfigColor("HexEditBackgroundColor").name());
|
||||
ui->lineEditAscii->setStyleSheet(style);
|
||||
ui->lineEditUnicode->setStyleSheet(style);
|
||||
}
|
||||
|
||||
void HexEditDialog::on_btnAscii2Hex_clicked()
|
||||
{
|
||||
QString text = ui->lineEditAscii->text();
|
||||
QByteArray data;
|
||||
for(int i=0; i<text.length(); i++)
|
||||
data.append(text[i].toAscii());
|
||||
if(ui->chkKeepSize->isChecked()) //keep size
|
||||
{
|
||||
int dataSize = mHexEdit->data().size();
|
||||
if(dataSize < data.size())
|
||||
data.resize(dataSize);
|
||||
else if(dataSize > data.size())
|
||||
data.append(QByteArray(dataSize-data.size(), 0));
|
||||
}
|
||||
mHexEdit->setData(data);
|
||||
}
|
||||
|
||||
void HexEditDialog::on_btnUnicode2Hex_clicked()
|
||||
{
|
||||
QByteArray data = QTextCodec::codecForName("UTF-16")->makeEncoder(QTextCodec::IgnoreHeader)->fromUnicode(ui->lineEditUnicode->text());
|
||||
if(ui->chkKeepSize->isChecked()) //keep size
|
||||
{
|
||||
int dataSize = mHexEdit->data().size();
|
||||
if(dataSize < data.size())
|
||||
data.resize(dataSize);
|
||||
else if(dataSize > data.size())
|
||||
data.append(QByteArray(dataSize-data.size(), 0));
|
||||
}
|
||||
mHexEdit->setData(data);
|
||||
}
|
||||
|
||||
void HexEditDialog::on_chkKeepSize_toggled(bool checked)
|
||||
{
|
||||
mHexEdit->setKeepSize(checked);
|
||||
}
|
||||
|
||||
void HexEditDialog::dataChangedSlot()
|
||||
{
|
||||
QByteArray data = mHexEdit->data();
|
||||
QString ascii;
|
||||
for(int i=0; i<data.size(); i++)
|
||||
{
|
||||
QChar ch(data.constData()[i]);
|
||||
if(ch.isPrint())
|
||||
ascii+=ch.toAscii();
|
||||
else
|
||||
ascii+='.';
|
||||
}
|
||||
QString unicode;
|
||||
for(int i=0,j=0; i<data.size(); i+=2,j++)
|
||||
{
|
||||
QChar wch(((wchar_t*)data.constData())[j]);
|
||||
if(wch.isPrint())
|
||||
unicode+=wch;
|
||||
else
|
||||
unicode+='.';
|
||||
}
|
||||
ui->lineEditAscii->setText(ascii);
|
||||
ui->lineEditUnicode->setText(unicode);
|
||||
}
|
||||
|
|
|
@ -1,35 +1,36 @@
|
|||
#ifndef HEXEDITDIALOG_H
|
||||
#define HEXEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "QHexEdit/QHexEdit.h"
|
||||
|
||||
namespace Ui {
|
||||
class HexEditDialog;
|
||||
}
|
||||
|
||||
class HexEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HexEditDialog(QWidget *parent = 0);
|
||||
~HexEditDialog();
|
||||
|
||||
void showEntireBlock(bool show);
|
||||
bool entireBlock();
|
||||
|
||||
QHexEdit* mHexEdit;
|
||||
|
||||
private slots:
|
||||
void updateStyle();
|
||||
void on_btnAscii2Hex_clicked();
|
||||
void on_btnUnicode2Hex_clicked();
|
||||
void on_chkKeepSize_toggled(bool checked);
|
||||
void dataChangedSlot();
|
||||
|
||||
private:
|
||||
Ui::HexEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // HEXEDITDIALOG_H
|
||||
#ifndef HEXEDITDIALOG_H
|
||||
#define HEXEDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "QHexEdit/QHexEdit.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class HexEditDialog;
|
||||
}
|
||||
|
||||
class HexEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HexEditDialog(QWidget *parent = 0);
|
||||
~HexEditDialog();
|
||||
|
||||
void showEntireBlock(bool show);
|
||||
bool entireBlock();
|
||||
|
||||
QHexEdit* mHexEdit;
|
||||
|
||||
private slots:
|
||||
void updateStyle();
|
||||
void on_btnAscii2Hex_clicked();
|
||||
void on_btnUnicode2Hex_clicked();
|
||||
void on_chkKeepSize_toggled(bool checked);
|
||||
void dataChangedSlot();
|
||||
|
||||
private:
|
||||
Ui::HexEditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // HEXEDITDIALOG_H
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,65 +1,66 @@
|
|||
#ifndef PATCHDIALOG_H
|
||||
#define PATCHDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "Bridge.h"
|
||||
#include "PatchDialogGroupSelector.h"
|
||||
|
||||
namespace Ui {
|
||||
class PatchDialog;
|
||||
}
|
||||
|
||||
class PatchDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
struct STATUSINFO
|
||||
{
|
||||
bool checked;
|
||||
int group;
|
||||
};
|
||||
|
||||
typedef QPair<DBGPATCHINFO, STATUSINFO> PatchPair;
|
||||
typedef QList<PatchPair> PatchInfoList;
|
||||
typedef QMap<QString, PatchInfoList> PatchMap;
|
||||
|
||||
static bool PatchInfoLess(const PatchPair & a, const PatchPair & b)
|
||||
{
|
||||
return a.first.addr < b.first.addr;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit PatchDialog(QWidget *parent = 0);
|
||||
~PatchDialog();
|
||||
|
||||
private:
|
||||
Ui::PatchDialog *ui;
|
||||
PatchMap* mPatches;
|
||||
PatchDialogGroupSelector* mGroupSelector;
|
||||
bool mIsWorking;
|
||||
|
||||
bool isPartOfPreviousGroup(const PatchInfoList & patchList, int index);
|
||||
bool isGroupEnabled(const PatchInfoList & patchList, int group);
|
||||
bool hasPreviousGroup(const PatchInfoList & patchList, int group);
|
||||
bool hasNextGroup(const PatchInfoList & patchList, int group);
|
||||
int_t getGroupAddress(const PatchInfoList & patchList, int group);
|
||||
|
||||
private slots:
|
||||
void dbgStateChanged(DBGSTATE state);
|
||||
void updatePatches();
|
||||
void groupToggle();
|
||||
void groupPrevious();
|
||||
void groupNext();
|
||||
void on_listModules_itemSelectionChanged();
|
||||
void on_listPatches_itemChanged(QListWidgetItem *item);
|
||||
void on_btnSelectAll_clicked();
|
||||
void on_btnDeselectAll_clicked();
|
||||
void on_btnRestoreSelected_clicked();
|
||||
void on_listPatches_itemSelectionChanged();
|
||||
void on_btnPickGroups_clicked();
|
||||
void on_btnPatchFile_clicked();
|
||||
void on_btnImport_clicked();
|
||||
void on_btnExport_clicked();
|
||||
};
|
||||
|
||||
#endif // PATCHDIALOG_H
|
||||
#ifndef PATCHDIALOG_H
|
||||
#define PATCHDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "Bridge.h"
|
||||
#include "PatchDialogGroupSelector.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PatchDialog;
|
||||
}
|
||||
|
||||
class PatchDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
struct STATUSINFO
|
||||
{
|
||||
bool checked;
|
||||
int group;
|
||||
};
|
||||
|
||||
typedef QPair<DBGPATCHINFO, STATUSINFO> PatchPair;
|
||||
typedef QList<PatchPair> PatchInfoList;
|
||||
typedef QMap<QString, PatchInfoList> PatchMap;
|
||||
|
||||
static bool PatchInfoLess(const PatchPair & a, const PatchPair & b)
|
||||
{
|
||||
return a.first.addr < b.first.addr;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit PatchDialog(QWidget *parent = 0);
|
||||
~PatchDialog();
|
||||
|
||||
private:
|
||||
Ui::PatchDialog *ui;
|
||||
PatchMap* mPatches;
|
||||
PatchDialogGroupSelector* mGroupSelector;
|
||||
bool mIsWorking;
|
||||
|
||||
bool isPartOfPreviousGroup(const PatchInfoList & patchList, int index);
|
||||
bool isGroupEnabled(const PatchInfoList & patchList, int group);
|
||||
bool hasPreviousGroup(const PatchInfoList & patchList, int group);
|
||||
bool hasNextGroup(const PatchInfoList & patchList, int group);
|
||||
int_t getGroupAddress(const PatchInfoList & patchList, int group);
|
||||
|
||||
private slots:
|
||||
void dbgStateChanged(DBGSTATE state);
|
||||
void updatePatches();
|
||||
void groupToggle();
|
||||
void groupPrevious();
|
||||
void groupNext();
|
||||
void on_listModules_itemSelectionChanged();
|
||||
void on_listPatches_itemChanged(QListWidgetItem *item);
|
||||
void on_btnSelectAll_clicked();
|
||||
void on_btnDeselectAll_clicked();
|
||||
void on_btnRestoreSelected_clicked();
|
||||
void on_listPatches_itemSelectionChanged();
|
||||
void on_btnPickGroups_clicked();
|
||||
void on_btnPatchFile_clicked();
|
||||
void on_btnImport_clicked();
|
||||
void on_btnExport_clicked();
|
||||
};
|
||||
|
||||
#endif // PATCHDIALOG_H
|
||||
|
|
|
@ -1,74 +1,74 @@
|
|||
#include "PatchDialogGroupSelector.h"
|
||||
#include "ui_PatchDialogGroupSelector.h"
|
||||
|
||||
PatchDialogGroupSelector::PatchDialogGroupSelector(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PatchDialogGroupSelector)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setFixedSize(this->size()); //fixed size
|
||||
setModal(false); //non-modal window
|
||||
|
||||
mGroup = 0;
|
||||
}
|
||||
|
||||
PatchDialogGroupSelector::~PatchDialogGroupSelector()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if(event->modifiers() != Qt::NoModifier)
|
||||
return;
|
||||
if(event->key() == Qt::Key_Space)
|
||||
on_btnToggle_clicked();
|
||||
else if(event->key() == Qt::Key_BracketLeft)
|
||||
on_btnPrevious_clicked();
|
||||
else if(event->key() == Qt::Key_BracketRight)
|
||||
on_btnNext_clicked();
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setGroupTitle(const QString &title)
|
||||
{
|
||||
ui->lblTitle->setText(title);
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setPreviousEnabled(bool enable)
|
||||
{
|
||||
ui->btnPrevious->setEnabled(enable);
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setNextEnabled(bool enable)
|
||||
{
|
||||
ui->btnNext->setEnabled(enable);
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setGroup(int group)
|
||||
{
|
||||
mGroup = group;
|
||||
}
|
||||
|
||||
int PatchDialogGroupSelector::group()
|
||||
{
|
||||
return mGroup;
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::on_btnToggle_clicked()
|
||||
{
|
||||
emit groupToggle();
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::on_btnPrevious_clicked()
|
||||
{
|
||||
if(ui->btnPrevious->isEnabled())
|
||||
emit groupPrevious();
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::on_btnNext_clicked()
|
||||
{
|
||||
if(ui->btnNext->isEnabled())
|
||||
emit groupNext();
|
||||
}
|
||||
#include "PatchDialogGroupSelector.h"
|
||||
#include "ui_PatchDialogGroupSelector.h"
|
||||
|
||||
PatchDialogGroupSelector::PatchDialogGroupSelector(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PatchDialogGroupSelector)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
setFixedSize(this->size()); //fixed size
|
||||
setModal(false); //non-modal window
|
||||
|
||||
mGroup = 0;
|
||||
}
|
||||
|
||||
PatchDialogGroupSelector::~PatchDialogGroupSelector()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if(event->modifiers() != Qt::NoModifier)
|
||||
return;
|
||||
if(event->key() == Qt::Key_Space)
|
||||
on_btnToggle_clicked();
|
||||
else if(event->key() == Qt::Key_BracketLeft)
|
||||
on_btnPrevious_clicked();
|
||||
else if(event->key() == Qt::Key_BracketRight)
|
||||
on_btnNext_clicked();
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setGroupTitle(const QString &title)
|
||||
{
|
||||
ui->lblTitle->setText(title);
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setPreviousEnabled(bool enable)
|
||||
{
|
||||
ui->btnPrevious->setEnabled(enable);
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setNextEnabled(bool enable)
|
||||
{
|
||||
ui->btnNext->setEnabled(enable);
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::setGroup(int group)
|
||||
{
|
||||
mGroup = group;
|
||||
}
|
||||
|
||||
int PatchDialogGroupSelector::group()
|
||||
{
|
||||
return mGroup;
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::on_btnToggle_clicked()
|
||||
{
|
||||
emit groupToggle();
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::on_btnPrevious_clicked()
|
||||
{
|
||||
if(ui->btnPrevious->isEnabled())
|
||||
emit groupPrevious();
|
||||
}
|
||||
|
||||
void PatchDialogGroupSelector::on_btnNext_clicked()
|
||||
{
|
||||
if(ui->btnNext->isEnabled())
|
||||
emit groupNext();
|
||||
}
|
||||
|
|
|
@ -1,42 +1,43 @@
|
|||
#ifndef PATCHDIALOGGROUPSELECTOR_H
|
||||
#define PATCHDIALOGGROUPSELECTOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QKeyEvent>
|
||||
|
||||
namespace Ui {
|
||||
class PatchDialogGroupSelector;
|
||||
}
|
||||
|
||||
class PatchDialogGroupSelector : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PatchDialogGroupSelector(QWidget *parent = 0);
|
||||
~PatchDialogGroupSelector();
|
||||
void setGroupTitle(const QString & title);
|
||||
void setPreviousEnabled(bool enable);
|
||||
void setNextEnabled(bool enable);
|
||||
void setGroup(int group);
|
||||
int group();
|
||||
|
||||
signals:
|
||||
void groupToggle();
|
||||
void groupPrevious();
|
||||
void groupNext();
|
||||
|
||||
private slots:
|
||||
void on_btnToggle_clicked();
|
||||
void on_btnPrevious_clicked();
|
||||
void on_btnNext_clicked();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
private:
|
||||
Ui::PatchDialogGroupSelector *ui;
|
||||
int mGroup;
|
||||
};
|
||||
|
||||
#endif // PATCHDIALOGGROUPSELECTOR_H
|
||||
#ifndef PATCHDIALOGGROUPSELECTOR_H
|
||||
#define PATCHDIALOGGROUPSELECTOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QKeyEvent>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PatchDialogGroupSelector;
|
||||
}
|
||||
|
||||
class PatchDialogGroupSelector : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PatchDialogGroupSelector(QWidget *parent = 0);
|
||||
~PatchDialogGroupSelector();
|
||||
void setGroupTitle(const QString & title);
|
||||
void setPreviousEnabled(bool enable);
|
||||
void setNextEnabled(bool enable);
|
||||
void setGroup(int group);
|
||||
int group();
|
||||
|
||||
signals:
|
||||
void groupToggle();
|
||||
void groupPrevious();
|
||||
void groupNext();
|
||||
|
||||
private slots:
|
||||
void on_btnToggle_clicked();
|
||||
void on_btnPrevious_clicked();
|
||||
void on_btnNext_clicked();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
private:
|
||||
Ui::PatchDialogGroupSelector *ui;
|
||||
int mGroup;
|
||||
};
|
||||
|
||||
#endif // PATCHDIALOGGROUPSELECTOR_H
|
||||
|
|
|
@ -258,7 +258,7 @@ bool RegistersView::identifyRegister(const int line, const int offset, REGISTER_
|
|||
if( (it.value().line == (line - mVScrollOffset)) /* same line ? */
|
||||
&& ( (1 + it.value().start) <= offset) /* between start ... ? */
|
||||
&& ( offset<= (1+it.value().start+it.value().labelwidth+it.value().valuesize)) /* ... and end ? */
|
||||
)
|
||||
)
|
||||
{
|
||||
// we found a matching register in the viewport
|
||||
if(clickedReg)
|
||||
|
@ -341,24 +341,24 @@ void RegistersView::keyPressEvent(QKeyEvent *event)
|
|||
{
|
||||
case Qt::Key_0:
|
||||
wCM_Zero->trigger();
|
||||
break;
|
||||
break;
|
||||
case Qt::Key_1:
|
||||
wCM_SetToOne->trigger();
|
||||
break;
|
||||
break;
|
||||
case Qt::Key_Plus:
|
||||
wCM_Increment->trigger();
|
||||
break;
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
wCM_Decrement->trigger();
|
||||
break;
|
||||
break;
|
||||
case Qt::Key_Space:
|
||||
wCM_ToggleValue->trigger();
|
||||
break;
|
||||
break;
|
||||
case Qt::Key_Return:
|
||||
wCM_Modify->trigger();
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,106 +1,106 @@
|
|||
#include "ArrayCommand.h"
|
||||
|
||||
CharCommand::CharCommand(XByteArray * xData, Cmd cmd, int charPos, char newChar, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
_xData = xData;
|
||||
_charPos = charPos;
|
||||
_newChar = newChar;
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
bool CharCommand::mergeWith(const QUndoCommand *command)
|
||||
{
|
||||
const CharCommand *nextCommand = static_cast<const CharCommand *>(command);
|
||||
bool result = false;
|
||||
|
||||
if (_cmd != remove)
|
||||
{
|
||||
if (nextCommand->_cmd == replace)
|
||||
if (nextCommand->_charPos == _charPos)
|
||||
{
|
||||
_newChar = nextCommand->_newChar;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CharCommand::undo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->remove(_charPos, 1);
|
||||
break;
|
||||
case replace:
|
||||
_xData->replace(_charPos, _oldChar);
|
||||
break;
|
||||
case remove:
|
||||
_xData->insert(_charPos, _oldChar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CharCommand::redo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->insert(_charPos, _newChar);
|
||||
break;
|
||||
case replace:
|
||||
_oldChar = _xData->data()[_charPos];
|
||||
_xData->replace(_charPos, _newChar);
|
||||
break;
|
||||
case remove:
|
||||
_oldChar = _xData->data()[_charPos];
|
||||
_xData->remove(_charPos, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ArrayCommand::ArrayCommand(XByteArray * xData, Cmd cmd, int baPos, QByteArray newBa, int len, QUndoCommand *parent)
|
||||
: QUndoCommand(parent)
|
||||
{
|
||||
_cmd = cmd;
|
||||
_xData = xData;
|
||||
_baPos = baPos;
|
||||
_newBa = newBa;
|
||||
_len = len;
|
||||
}
|
||||
|
||||
void ArrayCommand::undo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->remove(_baPos, _newBa.length());
|
||||
break;
|
||||
case replace:
|
||||
_xData->replace(_baPos, _oldBa);
|
||||
break;
|
||||
case remove:
|
||||
_xData->insert(_baPos, _oldBa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayCommand::redo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->insert(_baPos, _newBa);
|
||||
break;
|
||||
case replace:
|
||||
_oldBa = _xData->data().mid(_baPos, _len);
|
||||
_xData->replace(_baPos, _newBa);
|
||||
break;
|
||||
case remove:
|
||||
_oldBa = _xData->data().mid(_baPos, _len);
|
||||
_xData->remove(_baPos, _len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#include "ArrayCommand.h"
|
||||
|
||||
CharCommand::CharCommand(XByteArray * xData, Cmd cmd, int charPos, char newChar, QUndoCommand *parent) : QUndoCommand(parent)
|
||||
{
|
||||
_xData = xData;
|
||||
_charPos = charPos;
|
||||
_newChar = newChar;
|
||||
_cmd = cmd;
|
||||
}
|
||||
|
||||
bool CharCommand::mergeWith(const QUndoCommand *command)
|
||||
{
|
||||
const CharCommand *nextCommand = static_cast<const CharCommand *>(command);
|
||||
bool result = false;
|
||||
|
||||
if (_cmd != remove)
|
||||
{
|
||||
if (nextCommand->_cmd == replace)
|
||||
if (nextCommand->_charPos == _charPos)
|
||||
{
|
||||
_newChar = nextCommand->_newChar;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CharCommand::undo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->remove(_charPos, 1);
|
||||
break;
|
||||
case replace:
|
||||
_xData->replace(_charPos, _oldChar);
|
||||
break;
|
||||
case remove:
|
||||
_xData->insert(_charPos, _oldChar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CharCommand::redo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->insert(_charPos, _newChar);
|
||||
break;
|
||||
case replace:
|
||||
_oldChar = _xData->data()[_charPos];
|
||||
_xData->replace(_charPos, _newChar);
|
||||
break;
|
||||
case remove:
|
||||
_oldChar = _xData->data()[_charPos];
|
||||
_xData->remove(_charPos, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ArrayCommand::ArrayCommand(XByteArray * xData, Cmd cmd, int baPos, QByteArray newBa, int len, QUndoCommand *parent)
|
||||
: QUndoCommand(parent)
|
||||
{
|
||||
_cmd = cmd;
|
||||
_xData = xData;
|
||||
_baPos = baPos;
|
||||
_newBa = newBa;
|
||||
_len = len;
|
||||
}
|
||||
|
||||
void ArrayCommand::undo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->remove(_baPos, _newBa.length());
|
||||
break;
|
||||
case replace:
|
||||
_xData->replace(_baPos, _oldBa);
|
||||
break;
|
||||
case remove:
|
||||
_xData->insert(_baPos, _oldBa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ArrayCommand::redo()
|
||||
{
|
||||
switch (_cmd)
|
||||
{
|
||||
case insert:
|
||||
_xData->insert(_baPos, _newBa);
|
||||
break;
|
||||
case replace:
|
||||
_oldBa = _xData->data().mid(_baPos, _len);
|
||||
_xData->replace(_baPos, _newBa);
|
||||
break;
|
||||
case remove:
|
||||
_oldBa = _xData->data().mid(_baPos, _len);
|
||||
_xData->remove(_baPos, _len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
#ifndef ARRAYCOMMAND_H
|
||||
#define ARRAYCOMMAND_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include "XByteArray.h"
|
||||
|
||||
class CharCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
enum { Id = 1234 };
|
||||
enum Cmd {insert, remove, replace};
|
||||
|
||||
CharCommand(XByteArray * xData, Cmd cmd, int charPos, char newChar,
|
||||
QUndoCommand *parent=0);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
bool mergeWith(const QUndoCommand *command);
|
||||
int id() const
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
private:
|
||||
XByteArray * _xData;
|
||||
int _charPos;
|
||||
char _newChar;
|
||||
char _oldChar;
|
||||
Cmd _cmd;
|
||||
};
|
||||
|
||||
class ArrayCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
enum Cmd {insert, remove, replace};
|
||||
ArrayCommand(XByteArray * xData, Cmd cmd, int baPos, QByteArray newBa=QByteArray(), int len=0, QUndoCommand *parent=0);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
private:
|
||||
Cmd _cmd;
|
||||
XByteArray * _xData;
|
||||
int _baPos;
|
||||
int _len;
|
||||
QByteArray _wasChanged;
|
||||
QByteArray _newBa;
|
||||
QByteArray _oldBa;
|
||||
};
|
||||
|
||||
#endif // ARRAYCOMMAND_H
|
||||
#ifndef ARRAYCOMMAND_H
|
||||
#define ARRAYCOMMAND_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include "XByteArray.h"
|
||||
|
||||
class CharCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
enum { Id = 1234 };
|
||||
enum Cmd {insert, remove, replace};
|
||||
|
||||
CharCommand(XByteArray * xData, Cmd cmd, int charPos, char newChar,
|
||||
QUndoCommand *parent=0);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
bool mergeWith(const QUndoCommand *command);
|
||||
int id() const
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
private:
|
||||
XByteArray * _xData;
|
||||
int _charPos;
|
||||
char _newChar;
|
||||
char _oldChar;
|
||||
Cmd _cmd;
|
||||
};
|
||||
|
||||
class ArrayCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
enum Cmd {insert, remove, replace};
|
||||
ArrayCommand(XByteArray * xData, Cmd cmd, int baPos, QByteArray newBa=QByteArray(), int len=0, QUndoCommand *parent=0);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
private:
|
||||
Cmd _cmd;
|
||||
XByteArray * _xData;
|
||||
int _baPos;
|
||||
int _len;
|
||||
QByteArray _wasChanged;
|
||||
QByteArray _newBa;
|
||||
QByteArray _oldBa;
|
||||
};
|
||||
|
||||
#endif // ARRAYCOMMAND_H
|
||||
|
|
|
@ -1,258 +1,258 @@
|
|||
#include <QtGui>
|
||||
|
||||
#include "QHexEdit.h"
|
||||
|
||||
QHexEdit::QHexEdit(QWidget *parent) : QScrollArea(parent)
|
||||
{
|
||||
qHexEdit_p = new QHexEditPrivate(this);
|
||||
setWidget(qHexEdit_p);
|
||||
setWidgetResizable(true);
|
||||
|
||||
connect(qHexEdit_p, SIGNAL(currentAddressChanged(int)), this, SIGNAL(currentAddressChanged(int)));
|
||||
connect(qHexEdit_p, SIGNAL(currentSizeChanged(int)), this, SIGNAL(currentSizeChanged(int)));
|
||||
connect(qHexEdit_p, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
|
||||
connect(qHexEdit_p, SIGNAL(overwriteModeChanged(bool)), this, SIGNAL(overwriteModeChanged(bool)));
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
}
|
||||
|
||||
void QHexEdit::setEditFont(const QFont & font)
|
||||
{
|
||||
qHexEdit_p->setFont(font);
|
||||
}
|
||||
|
||||
void QHexEdit::insert(int i, const QByteArray & ba, const QByteArray & mask)
|
||||
{
|
||||
qHexEdit_p->insert(i, ba, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::insert(int i, char ch, char mask)
|
||||
{
|
||||
qHexEdit_p->insert(i, ch, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::remove(int pos, int len)
|
||||
{
|
||||
qHexEdit_p->remove(pos, len);
|
||||
}
|
||||
|
||||
void QHexEdit::replace( int pos, int len, const QByteArray & after, const QByteArray & mask)
|
||||
{
|
||||
qHexEdit_p->replace(pos, len, after, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::fill(int index, const QString & pattern)
|
||||
{
|
||||
QString convert;
|
||||
for(int i=0; i<pattern.length(); i++)
|
||||
{
|
||||
QChar ch = pattern[i].toLower();
|
||||
if((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (wildcardEnabled() && ch == '?'))
|
||||
convert += ch;
|
||||
}
|
||||
if(convert.length()%2) //odd length
|
||||
convert += "0";
|
||||
QByteArray data(convert.length(), 0);
|
||||
QByteArray mask(data.length(), 0);
|
||||
for(int i=0; i<convert.length(); i++)
|
||||
{
|
||||
if(convert[i] == '?')
|
||||
{
|
||||
data[i]='0';
|
||||
mask[i]='1';
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i]=convert[i].toAscii();
|
||||
mask[i]='0';
|
||||
}
|
||||
}
|
||||
qHexEdit_p->fill(index, QByteArray().fromHex(data), QByteArray().fromHex(mask));
|
||||
}
|
||||
|
||||
void QHexEdit::redo()
|
||||
{
|
||||
qHexEdit_p->redo();
|
||||
}
|
||||
|
||||
void QHexEdit::undo()
|
||||
{
|
||||
qHexEdit_p->undo();
|
||||
}
|
||||
|
||||
void QHexEdit::setCursorPosition(int cursorPos)
|
||||
{
|
||||
// cursorPos in QHexEditPrivate is the position of the textcoursor without
|
||||
// blanks, means bytePos*2
|
||||
qHexEdit_p->setCursorPos(cursorPos*2);
|
||||
}
|
||||
|
||||
int QHexEdit::cursorPosition()
|
||||
{
|
||||
return qHexEdit_p->cursorPos() / 2;
|
||||
}
|
||||
|
||||
void QHexEdit::setData(const QByteArray & data, const QByteArray & mask)
|
||||
{
|
||||
qHexEdit_p->setData(data, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::setData(const QByteArray & data)
|
||||
{
|
||||
qHexEdit_p->setData(data, QByteArray(data.size(), 0));
|
||||
}
|
||||
|
||||
void QHexEdit::setData(const QString & pattern)
|
||||
{
|
||||
QString convert;
|
||||
for(int i=0; i<pattern.length(); i++)
|
||||
{
|
||||
QChar ch = pattern[i].toLower();
|
||||
if((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (wildcardEnabled() && ch == '?'))
|
||||
convert += ch;
|
||||
}
|
||||
if(convert.length()%2) //odd length
|
||||
convert += "0";
|
||||
QByteArray data(convert.length(), 0);
|
||||
QByteArray mask(data.length(), 0);
|
||||
for(int i=0; i<convert.length(); i++)
|
||||
{
|
||||
if(convert[i] == '?')
|
||||
{
|
||||
data[i]='0';
|
||||
mask[i]='1';
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i]=convert[i].toAscii();
|
||||
mask[i]='0';
|
||||
}
|
||||
}
|
||||
qHexEdit_p->setData(QByteArray().fromHex(data), QByteArray().fromHex(mask));
|
||||
}
|
||||
|
||||
QByteArray QHexEdit::applyMaskedData(const QByteArray & data)
|
||||
{
|
||||
QByteArray ret = data.toHex();
|
||||
QByteArray _data = this->data().toHex();
|
||||
QByteArray _mask = this->mask().toHex();
|
||||
if(ret.size() != _data.size())
|
||||
ret.resize(_data.size());
|
||||
for(int i=0; i<_data.size(); i++)
|
||||
{
|
||||
if(_mask[i]!='1')
|
||||
ret[i]=_data[i];
|
||||
}
|
||||
return QByteArray().fromHex(ret);
|
||||
}
|
||||
|
||||
QByteArray QHexEdit::data()
|
||||
{
|
||||
return qHexEdit_p->data();
|
||||
}
|
||||
|
||||
QByteArray QHexEdit::mask()
|
||||
{
|
||||
return qHexEdit_p->mask();
|
||||
}
|
||||
|
||||
QString QHexEdit::pattern(bool space)
|
||||
{
|
||||
QString result;
|
||||
for (int i = 0; i < this->data().size(); i++)
|
||||
{
|
||||
QString byte = this->data().mid(i, 1).toHex();
|
||||
QString mask = this->mask().mid(i, 1).toHex();
|
||||
if(mask[0] == '1')
|
||||
result += "?";
|
||||
else
|
||||
result += byte[0];
|
||||
if(mask[1] == '1')
|
||||
result += "?";
|
||||
else
|
||||
result += byte[1];
|
||||
if(space)
|
||||
result += " ";
|
||||
}
|
||||
return result.toUpper().trimmed();
|
||||
}
|
||||
|
||||
void QHexEdit::setOverwriteMode(bool overwriteMode)
|
||||
{
|
||||
qHexEdit_p->setOverwriteMode(overwriteMode);
|
||||
}
|
||||
|
||||
bool QHexEdit::overwriteMode()
|
||||
{
|
||||
return qHexEdit_p->overwriteMode();
|
||||
}
|
||||
|
||||
void QHexEdit::setWildcardEnabled(bool enabled)
|
||||
{
|
||||
qHexEdit_p->setWildcardEnabled(enabled);
|
||||
}
|
||||
|
||||
bool QHexEdit::wildcardEnabled()
|
||||
{
|
||||
return qHexEdit_p->wildcardEnabled();
|
||||
}
|
||||
|
||||
void QHexEdit::setKeepSize(bool enabled)
|
||||
{
|
||||
qHexEdit_p->setKeepSize(enabled);
|
||||
}
|
||||
|
||||
bool QHexEdit::keepSize()
|
||||
{
|
||||
return qHexEdit_p->keepSize();
|
||||
}
|
||||
|
||||
void QHexEdit::setTextColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setTextColor(color);
|
||||
}
|
||||
|
||||
void QHexEdit::setHorizontalSpacing(int x)
|
||||
{
|
||||
qHexEdit_p->setHorizontalSpacing(x);
|
||||
}
|
||||
|
||||
int QHexEdit::horizontalSpacing()
|
||||
{
|
||||
return qHexEdit_p->horizontalSpacing();
|
||||
}
|
||||
|
||||
QColor QHexEdit::textColor()
|
||||
{
|
||||
return qHexEdit_p->textColor();
|
||||
}
|
||||
|
||||
void QHexEdit::setWildcardColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setWildcardColor(color);
|
||||
}
|
||||
|
||||
QColor QHexEdit::wildcardColor()
|
||||
{
|
||||
return qHexEdit_p->wildcardColor();
|
||||
}
|
||||
|
||||
void QHexEdit::setBackgroundColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setBackgroundColor(color);
|
||||
}
|
||||
|
||||
QColor QHexEdit::backgroundColor()
|
||||
{
|
||||
return qHexEdit_p->backgroundColor();
|
||||
}
|
||||
|
||||
void QHexEdit::setSelectionColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setSelectionColor(color);
|
||||
}
|
||||
|
||||
QColor QHexEdit::selectionColor()
|
||||
{
|
||||
return qHexEdit_p->selectionColor();
|
||||
}
|
||||
#include <QtGui>
|
||||
|
||||
#include "QHexEdit.h"
|
||||
|
||||
QHexEdit::QHexEdit(QWidget *parent) : QScrollArea(parent)
|
||||
{
|
||||
qHexEdit_p = new QHexEditPrivate(this);
|
||||
setWidget(qHexEdit_p);
|
||||
setWidgetResizable(true);
|
||||
|
||||
connect(qHexEdit_p, SIGNAL(currentAddressChanged(int)), this, SIGNAL(currentAddressChanged(int)));
|
||||
connect(qHexEdit_p, SIGNAL(currentSizeChanged(int)), this, SIGNAL(currentSizeChanged(int)));
|
||||
connect(qHexEdit_p, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
|
||||
connect(qHexEdit_p, SIGNAL(overwriteModeChanged(bool)), this, SIGNAL(overwriteModeChanged(bool)));
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
}
|
||||
|
||||
void QHexEdit::setEditFont(const QFont & font)
|
||||
{
|
||||
qHexEdit_p->setFont(font);
|
||||
}
|
||||
|
||||
void QHexEdit::insert(int i, const QByteArray & ba, const QByteArray & mask)
|
||||
{
|
||||
qHexEdit_p->insert(i, ba, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::insert(int i, char ch, char mask)
|
||||
{
|
||||
qHexEdit_p->insert(i, ch, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::remove(int pos, int len)
|
||||
{
|
||||
qHexEdit_p->remove(pos, len);
|
||||
}
|
||||
|
||||
void QHexEdit::replace( int pos, int len, const QByteArray & after, const QByteArray & mask)
|
||||
{
|
||||
qHexEdit_p->replace(pos, len, after, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::fill(int index, const QString & pattern)
|
||||
{
|
||||
QString convert;
|
||||
for(int i=0; i<pattern.length(); i++)
|
||||
{
|
||||
QChar ch = pattern[i].toLower();
|
||||
if((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (wildcardEnabled() && ch == '?'))
|
||||
convert += ch;
|
||||
}
|
||||
if(convert.length()%2) //odd length
|
||||
convert += "0";
|
||||
QByteArray data(convert.length(), 0);
|
||||
QByteArray mask(data.length(), 0);
|
||||
for(int i=0; i<convert.length(); i++)
|
||||
{
|
||||
if(convert[i] == '?')
|
||||
{
|
||||
data[i]='0';
|
||||
mask[i]='1';
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i]=convert[i].toAscii();
|
||||
mask[i]='0';
|
||||
}
|
||||
}
|
||||
qHexEdit_p->fill(index, QByteArray().fromHex(data), QByteArray().fromHex(mask));
|
||||
}
|
||||
|
||||
void QHexEdit::redo()
|
||||
{
|
||||
qHexEdit_p->redo();
|
||||
}
|
||||
|
||||
void QHexEdit::undo()
|
||||
{
|
||||
qHexEdit_p->undo();
|
||||
}
|
||||
|
||||
void QHexEdit::setCursorPosition(int cursorPos)
|
||||
{
|
||||
// cursorPos in QHexEditPrivate is the position of the textcoursor without
|
||||
// blanks, means bytePos*2
|
||||
qHexEdit_p->setCursorPos(cursorPos*2);
|
||||
}
|
||||
|
||||
int QHexEdit::cursorPosition()
|
||||
{
|
||||
return qHexEdit_p->cursorPos() / 2;
|
||||
}
|
||||
|
||||
void QHexEdit::setData(const QByteArray & data, const QByteArray & mask)
|
||||
{
|
||||
qHexEdit_p->setData(data, mask);
|
||||
}
|
||||
|
||||
void QHexEdit::setData(const QByteArray & data)
|
||||
{
|
||||
qHexEdit_p->setData(data, QByteArray(data.size(), 0));
|
||||
}
|
||||
|
||||
void QHexEdit::setData(const QString & pattern)
|
||||
{
|
||||
QString convert;
|
||||
for(int i=0; i<pattern.length(); i++)
|
||||
{
|
||||
QChar ch = pattern[i].toLower();
|
||||
if((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (wildcardEnabled() && ch == '?'))
|
||||
convert += ch;
|
||||
}
|
||||
if(convert.length()%2) //odd length
|
||||
convert += "0";
|
||||
QByteArray data(convert.length(), 0);
|
||||
QByteArray mask(data.length(), 0);
|
||||
for(int i=0; i<convert.length(); i++)
|
||||
{
|
||||
if(convert[i] == '?')
|
||||
{
|
||||
data[i]='0';
|
||||
mask[i]='1';
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i]=convert[i].toAscii();
|
||||
mask[i]='0';
|
||||
}
|
||||
}
|
||||
qHexEdit_p->setData(QByteArray().fromHex(data), QByteArray().fromHex(mask));
|
||||
}
|
||||
|
||||
QByteArray QHexEdit::applyMaskedData(const QByteArray & data)
|
||||
{
|
||||
QByteArray ret = data.toHex();
|
||||
QByteArray _data = this->data().toHex();
|
||||
QByteArray _mask = this->mask().toHex();
|
||||
if(ret.size() != _data.size())
|
||||
ret.resize(_data.size());
|
||||
for(int i=0; i<_data.size(); i++)
|
||||
{
|
||||
if(_mask[i]!='1')
|
||||
ret[i]=_data[i];
|
||||
}
|
||||
return QByteArray().fromHex(ret);
|
||||
}
|
||||
|
||||
QByteArray QHexEdit::data()
|
||||
{
|
||||
return qHexEdit_p->data();
|
||||
}
|
||||
|
||||
QByteArray QHexEdit::mask()
|
||||
{
|
||||
return qHexEdit_p->mask();
|
||||
}
|
||||
|
||||
QString QHexEdit::pattern(bool space)
|
||||
{
|
||||
QString result;
|
||||
for (int i = 0; i < this->data().size(); i++)
|
||||
{
|
||||
QString byte = this->data().mid(i, 1).toHex();
|
||||
QString mask = this->mask().mid(i, 1).toHex();
|
||||
if(mask[0] == '1')
|
||||
result += "?";
|
||||
else
|
||||
result += byte[0];
|
||||
if(mask[1] == '1')
|
||||
result += "?";
|
||||
else
|
||||
result += byte[1];
|
||||
if(space)
|
||||
result += " ";
|
||||
}
|
||||
return result.toUpper().trimmed();
|
||||
}
|
||||
|
||||
void QHexEdit::setOverwriteMode(bool overwriteMode)
|
||||
{
|
||||
qHexEdit_p->setOverwriteMode(overwriteMode);
|
||||
}
|
||||
|
||||
bool QHexEdit::overwriteMode()
|
||||
{
|
||||
return qHexEdit_p->overwriteMode();
|
||||
}
|
||||
|
||||
void QHexEdit::setWildcardEnabled(bool enabled)
|
||||
{
|
||||
qHexEdit_p->setWildcardEnabled(enabled);
|
||||
}
|
||||
|
||||
bool QHexEdit::wildcardEnabled()
|
||||
{
|
||||
return qHexEdit_p->wildcardEnabled();
|
||||
}
|
||||
|
||||
void QHexEdit::setKeepSize(bool enabled)
|
||||
{
|
||||
qHexEdit_p->setKeepSize(enabled);
|
||||
}
|
||||
|
||||
bool QHexEdit::keepSize()
|
||||
{
|
||||
return qHexEdit_p->keepSize();
|
||||
}
|
||||
|
||||
void QHexEdit::setTextColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setTextColor(color);
|
||||
}
|
||||
|
||||
void QHexEdit::setHorizontalSpacing(int x)
|
||||
{
|
||||
qHexEdit_p->setHorizontalSpacing(x);
|
||||
}
|
||||
|
||||
int QHexEdit::horizontalSpacing()
|
||||
{
|
||||
return qHexEdit_p->horizontalSpacing();
|
||||
}
|
||||
|
||||
QColor QHexEdit::textColor()
|
||||
{
|
||||
return qHexEdit_p->textColor();
|
||||
}
|
||||
|
||||
void QHexEdit::setWildcardColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setWildcardColor(color);
|
||||
}
|
||||
|
||||
QColor QHexEdit::wildcardColor()
|
||||
{
|
||||
return qHexEdit_p->wildcardColor();
|
||||
}
|
||||
|
||||
void QHexEdit::setBackgroundColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setBackgroundColor(color);
|
||||
}
|
||||
|
||||
QColor QHexEdit::backgroundColor()
|
||||
{
|
||||
return qHexEdit_p->backgroundColor();
|
||||
}
|
||||
|
||||
void QHexEdit::setSelectionColor(QColor color)
|
||||
{
|
||||
qHexEdit_p->setSelectionColor(color);
|
||||
}
|
||||
|
||||
QColor QHexEdit::selectionColor()
|
||||
{
|
||||
return qHexEdit_p->selectionColor();
|
||||
}
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
#ifndef QHEXEDIT_H
|
||||
#define QHEXEDIT_H
|
||||
|
||||
#include <QtGui>
|
||||
#include "QHexEditPrivate.h"
|
||||
|
||||
class QHexEdit : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QHexEdit(QWidget *parent = 0);
|
||||
|
||||
//data management
|
||||
void setData(const QByteArray & data, const QByteArray & mask);
|
||||
void setData(const QByteArray & data);
|
||||
void setData(const QString & pattern);
|
||||
QByteArray applyMaskedData(const QByteArray & data);
|
||||
QByteArray data();
|
||||
QByteArray mask();
|
||||
QString pattern(bool space = false);
|
||||
void insert(int i, const QByteArray & ba, const QByteArray & mask);
|
||||
void insert(int i, char ch, char mask);
|
||||
void remove(int pos, int len=1);
|
||||
void replace(int pos, int len, const QByteArray & after, const QByteArray & mask);
|
||||
void fill(int index, const QString & pattern);
|
||||
|
||||
//properties
|
||||
void setCursorPosition(int cusorPos);
|
||||
int cursorPosition();
|
||||
void setOverwriteMode(bool overwriteMode);
|
||||
bool overwriteMode();
|
||||
void setWildcardEnabled(bool enabled);
|
||||
bool wildcardEnabled();
|
||||
void setKeepSize(bool enabled);
|
||||
bool keepSize();
|
||||
void setHorizontalSpacing(int x);
|
||||
int horizontalSpacing();
|
||||
void setTextColor(QColor color);
|
||||
QColor textColor();
|
||||
void setWildcardColor(QColor color);
|
||||
QColor wildcardColor();
|
||||
void setBackgroundColor(QColor color);
|
||||
QColor backgroundColor();
|
||||
void setSelectionColor(QColor color);
|
||||
QColor selectionColor();
|
||||
void setEditFont(const QFont & font);
|
||||
|
||||
public slots:
|
||||
void redo();
|
||||
void undo();
|
||||
|
||||
signals:
|
||||
void currentAddressChanged(int address);
|
||||
void currentSizeChanged(int size);
|
||||
void dataChanged();
|
||||
void overwriteModeChanged(bool state);
|
||||
|
||||
private:
|
||||
QHexEditPrivate *qHexEdit_p;
|
||||
QHBoxLayout *layout;
|
||||
QScrollArea *scrollArea;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef QHEXEDIT_H
|
||||
#define QHEXEDIT_H
|
||||
|
||||
#include <QtGui>
|
||||
#include "QHexEditPrivate.h"
|
||||
|
||||
class QHexEdit : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QHexEdit(QWidget *parent = 0);
|
||||
|
||||
//data management
|
||||
void setData(const QByteArray & data, const QByteArray & mask);
|
||||
void setData(const QByteArray & data);
|
||||
void setData(const QString & pattern);
|
||||
QByteArray applyMaskedData(const QByteArray & data);
|
||||
QByteArray data();
|
||||
QByteArray mask();
|
||||
QString pattern(bool space = false);
|
||||
void insert(int i, const QByteArray & ba, const QByteArray & mask);
|
||||
void insert(int i, char ch, char mask);
|
||||
void remove(int pos, int len=1);
|
||||
void replace(int pos, int len, const QByteArray & after, const QByteArray & mask);
|
||||
void fill(int index, const QString & pattern);
|
||||
|
||||
//properties
|
||||
void setCursorPosition(int cusorPos);
|
||||
int cursorPosition();
|
||||
void setOverwriteMode(bool overwriteMode);
|
||||
bool overwriteMode();
|
||||
void setWildcardEnabled(bool enabled);
|
||||
bool wildcardEnabled();
|
||||
void setKeepSize(bool enabled);
|
||||
bool keepSize();
|
||||
void setHorizontalSpacing(int x);
|
||||
int horizontalSpacing();
|
||||
void setTextColor(QColor color);
|
||||
QColor textColor();
|
||||
void setWildcardColor(QColor color);
|
||||
QColor wildcardColor();
|
||||
void setBackgroundColor(QColor color);
|
||||
QColor backgroundColor();
|
||||
void setSelectionColor(QColor color);
|
||||
QColor selectionColor();
|
||||
void setEditFont(const QFont & font);
|
||||
|
||||
public slots:
|
||||
void redo();
|
||||
void undo();
|
||||
|
||||
signals:
|
||||
void currentAddressChanged(int address);
|
||||
void currentSizeChanged(int size);
|
||||
void dataChanged();
|
||||
void overwriteModeChanged(bool state);
|
||||
|
||||
private:
|
||||
QHexEditPrivate *qHexEdit_p;
|
||||
QHBoxLayout *layout;
|
||||
QScrollArea *scrollArea;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,110 +1,110 @@
|
|||
#ifndef QHEXEDITPRIVATE_H
|
||||
#define QHEXEDITPRIVATE_H
|
||||
|
||||
#include <QtGui>
|
||||
#include "XByteArray.h"
|
||||
|
||||
class QHexEditPrivate : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QHexEditPrivate(QScrollArea *parent);
|
||||
|
||||
//properties
|
||||
void setCursorPos(int position);
|
||||
int cursorPos();
|
||||
void setOverwriteMode(bool overwriteMode);
|
||||
bool overwriteMode();
|
||||
void setWildcardEnabled(bool enabled);
|
||||
bool wildcardEnabled();
|
||||
void setKeepSize(bool enabled);
|
||||
bool keepSize();
|
||||
void setHorizontalSpacing(int x);
|
||||
int horizontalSpacing();
|
||||
void setTextColor(QColor color);
|
||||
QColor textColor();
|
||||
void setWildcardColor(QColor color);
|
||||
QColor wildcardColor();
|
||||
void setBackgroundColor(QColor color);
|
||||
QColor backgroundColor();
|
||||
void setSelectionColor(QColor color);
|
||||
QColor selectionColor();
|
||||
|
||||
//data management
|
||||
void setData(const QByteArray & data, const QByteArray & mask);
|
||||
QByteArray data();
|
||||
QByteArray mask();
|
||||
void insert(int index, const QByteArray & ba, const QByteArray & mask);
|
||||
void insert(int index, char ch, char mask);
|
||||
void remove(int index, int len=1);
|
||||
void replace(int index, char ch, char mask);
|
||||
void replace(int index, const QByteArray & ba, const QByteArray & mask);
|
||||
void replace(int pos, int len, const QByteArray & after, const QByteArray & mask);
|
||||
void fill(int index, const QByteArray & ba, const QByteArray & mask);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
signals:
|
||||
void currentAddressChanged(int address);
|
||||
void currentSizeChanged(int size);
|
||||
void dataChanged();
|
||||
void overwriteModeChanged(bool state);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void mouseMoveEvent(QMouseEvent * event);
|
||||
void mousePressEvent(QMouseEvent * event);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
int cursorPos(QPoint pos); // calc cursorpos from graphics position. DOES NOT STORE POSITION
|
||||
|
||||
void resetSelection(int pos); // set selectionStart && selectionEnd to pos
|
||||
void resetSelection(); // set selectionEnd to selectionStart
|
||||
void setSelection(int pos); // set min (if below init) || max (if greater init)
|
||||
int getSelectionBegin();
|
||||
int getSelectionEnd();
|
||||
|
||||
private slots:
|
||||
void updateCursor();
|
||||
|
||||
private:
|
||||
void adjust();
|
||||
void ensureVisible();
|
||||
|
||||
QScrollArea *_scrollArea;
|
||||
QTimer _cursorTimer;
|
||||
QUndoStack *_undoDataStack;
|
||||
QUndoStack *_undoMaskStack;
|
||||
|
||||
XByteArray _xData;
|
||||
XByteArray _xMask;
|
||||
|
||||
QColor _textColor;
|
||||
QColor _wildcardColor;
|
||||
QColor _backgroundColor;
|
||||
QColor _selectionColor;
|
||||
|
||||
bool _blink; // true: then cursor blinks
|
||||
bool _overwriteMode;
|
||||
bool _wildcardEnabled;
|
||||
bool _keepSize;
|
||||
|
||||
int _charWidth, _charHeight; // char dimensions (dpendend on font)
|
||||
int _cursorX, _cursorY; // graphics position of the cursor
|
||||
int _cursorPosition; // character positioin in stream (on byte ends in to steps)
|
||||
int _xPosHex; // graphics x-position of the areas
|
||||
|
||||
int _selectionBegin; // First selected char
|
||||
int _selectionEnd; // Last selected char
|
||||
int _selectionInit; // That's, where we pressed the mouse button
|
||||
|
||||
int _size;
|
||||
int _initSize;
|
||||
int _horizonalSpacing;
|
||||
};
|
||||
|
||||
#endif //QHEXEDITPRIVATE_H
|
||||
|
||||
#ifndef QHEXEDITPRIVATE_H
|
||||
#define QHEXEDITPRIVATE_H
|
||||
|
||||
#include <QtGui>
|
||||
#include "XByteArray.h"
|
||||
|
||||
class QHexEditPrivate : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QHexEditPrivate(QScrollArea *parent);
|
||||
|
||||
//properties
|
||||
void setCursorPos(int position);
|
||||
int cursorPos();
|
||||
void setOverwriteMode(bool overwriteMode);
|
||||
bool overwriteMode();
|
||||
void setWildcardEnabled(bool enabled);
|
||||
bool wildcardEnabled();
|
||||
void setKeepSize(bool enabled);
|
||||
bool keepSize();
|
||||
void setHorizontalSpacing(int x);
|
||||
int horizontalSpacing();
|
||||
void setTextColor(QColor color);
|
||||
QColor textColor();
|
||||
void setWildcardColor(QColor color);
|
||||
QColor wildcardColor();
|
||||
void setBackgroundColor(QColor color);
|
||||
QColor backgroundColor();
|
||||
void setSelectionColor(QColor color);
|
||||
QColor selectionColor();
|
||||
|
||||
//data management
|
||||
void setData(const QByteArray & data, const QByteArray & mask);
|
||||
QByteArray data();
|
||||
QByteArray mask();
|
||||
void insert(int index, const QByteArray & ba, const QByteArray & mask);
|
||||
void insert(int index, char ch, char mask);
|
||||
void remove(int index, int len=1);
|
||||
void replace(int index, char ch, char mask);
|
||||
void replace(int index, const QByteArray & ba, const QByteArray & mask);
|
||||
void replace(int pos, int len, const QByteArray & after, const QByteArray & mask);
|
||||
void fill(int index, const QByteArray & ba, const QByteArray & mask);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
signals:
|
||||
void currentAddressChanged(int address);
|
||||
void currentSizeChanged(int size);
|
||||
void dataChanged();
|
||||
void overwriteModeChanged(bool state);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent* event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void mouseMoveEvent(QMouseEvent * event);
|
||||
void mousePressEvent(QMouseEvent * event);
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
int cursorPos(QPoint pos); // calc cursorpos from graphics position. DOES NOT STORE POSITION
|
||||
|
||||
void resetSelection(int pos); // set selectionStart && selectionEnd to pos
|
||||
void resetSelection(); // set selectionEnd to selectionStart
|
||||
void setSelection(int pos); // set min (if below init) || max (if greater init)
|
||||
int getSelectionBegin();
|
||||
int getSelectionEnd();
|
||||
|
||||
private slots:
|
||||
void updateCursor();
|
||||
|
||||
private:
|
||||
void adjust();
|
||||
void ensureVisible();
|
||||
|
||||
QScrollArea *_scrollArea;
|
||||
QTimer _cursorTimer;
|
||||
QUndoStack *_undoDataStack;
|
||||
QUndoStack *_undoMaskStack;
|
||||
|
||||
XByteArray _xData;
|
||||
XByteArray _xMask;
|
||||
|
||||
QColor _textColor;
|
||||
QColor _wildcardColor;
|
||||
QColor _backgroundColor;
|
||||
QColor _selectionColor;
|
||||
|
||||
bool _blink; // true: then cursor blinks
|
||||
bool _overwriteMode;
|
||||
bool _wildcardEnabled;
|
||||
bool _keepSize;
|
||||
|
||||
int _charWidth, _charHeight; // char dimensions (dpendend on font)
|
||||
int _cursorX, _cursorY; // graphics position of the cursor
|
||||
int _cursorPosition; // character positioin in stream (on byte ends in to steps)
|
||||
int _xPosHex; // graphics x-position of the areas
|
||||
|
||||
int _selectionBegin; // First selected char
|
||||
int _selectionEnd; // Last selected char
|
||||
int _selectionInit; // That's, where we pressed the mouse button
|
||||
|
||||
int _size;
|
||||
int _initSize;
|
||||
int _horizonalSpacing;
|
||||
};
|
||||
|
||||
#endif //QHEXEDITPRIVATE_H
|
||||
|
||||
|
|
|
@ -1,61 +1,61 @@
|
|||
#include "XByteArray.h"
|
||||
|
||||
XByteArray::XByteArray()
|
||||
{
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::data()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
void XByteArray::setData(QByteArray data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
int XByteArray::size()
|
||||
{
|
||||
return _data.size();
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::insert(int i, char ch)
|
||||
{
|
||||
_data.insert(i, ch);
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::insert(int i, const QByteArray & ba)
|
||||
{
|
||||
_data.insert(i, ba);
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::remove(int i, int len)
|
||||
{
|
||||
_data.remove(i, len);
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::replace(int index, char ch)
|
||||
{
|
||||
_data[index] = ch;
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::replace(int index, const QByteArray & ba)
|
||||
{
|
||||
int len = ba.length();
|
||||
return replace(index, len, ba);
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::replace(int index, int length, const QByteArray & ba)
|
||||
{
|
||||
int len;
|
||||
if ((index + length) > _data.length())
|
||||
len = _data.length() - index;
|
||||
else
|
||||
len = length;
|
||||
_data.replace(index, len, ba.mid(0, len));
|
||||
return _data;
|
||||
}
|
||||
#include "XByteArray.h"
|
||||
|
||||
XByteArray::XByteArray()
|
||||
{
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::data()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
void XByteArray::setData(QByteArray data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
int XByteArray::size()
|
||||
{
|
||||
return _data.size();
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::insert(int i, char ch)
|
||||
{
|
||||
_data.insert(i, ch);
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::insert(int i, const QByteArray & ba)
|
||||
{
|
||||
_data.insert(i, ba);
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::remove(int i, int len)
|
||||
{
|
||||
_data.remove(i, len);
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::replace(int index, char ch)
|
||||
{
|
||||
_data[index] = ch;
|
||||
return _data;
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::replace(int index, const QByteArray & ba)
|
||||
{
|
||||
int len = ba.length();
|
||||
return replace(index, len, ba);
|
||||
}
|
||||
|
||||
QByteArray & XByteArray::replace(int index, int length, const QByteArray & ba)
|
||||
{
|
||||
int len;
|
||||
if ((index + length) > _data.length())
|
||||
len = _data.length() - index;
|
||||
else
|
||||
len = length;
|
||||
_data.replace(index, len, ba.mid(0, len));
|
||||
return _data;
|
||||
}
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
#ifndef XBYTEARRAY_H
|
||||
#define XBYTEARRAY_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class XByteArray
|
||||
{
|
||||
public:
|
||||
explicit XByteArray();
|
||||
|
||||
QByteArray & data();
|
||||
void setData(QByteArray data);
|
||||
int size();
|
||||
|
||||
QByteArray & insert(int i, char ch);
|
||||
QByteArray & insert(int i, const QByteArray & ba);
|
||||
|
||||
QByteArray & remove(int pos, int len);
|
||||
|
||||
QByteArray & replace(int index, char ch);
|
||||
QByteArray & replace(int index, const QByteArray & ba);
|
||||
QByteArray & replace(int index, int length, const QByteArray & ba);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QByteArray _data; //raw byte array
|
||||
};
|
||||
|
||||
#endif // XBYTEARRAY_H
|
||||
#ifndef XBYTEARRAY_H
|
||||
#define XBYTEARRAY_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class XByteArray
|
||||
{
|
||||
public:
|
||||
explicit XByteArray();
|
||||
|
||||
QByteArray & data();
|
||||
void setData(QByteArray data);
|
||||
int size();
|
||||
|
||||
QByteArray & insert(int i, char ch);
|
||||
QByteArray & insert(int i, const QByteArray & ba);
|
||||
|
||||
QByteArray & remove(int pos, int len);
|
||||
|
||||
QByteArray & replace(int index, char ch);
|
||||
QByteArray & replace(int index, const QByteArray & ba);
|
||||
QByteArray & replace(int index, int length, const QByteArray & ba);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QByteArray _data; //raw byte array
|
||||
};
|
||||
|
||||
#endif // XBYTEARRAY_H
|
||||
|
|
|
@ -1,52 +1,52 @@
|
|||
#include "UpdateChecker.h"
|
||||
#include <QMessageBox>
|
||||
#include "Bridge.h"
|
||||
|
||||
UpdateChecker::UpdateChecker(QWidget* parent)
|
||||
{
|
||||
mParent=parent;
|
||||
connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void UpdateChecker::checkForUpdates()
|
||||
{
|
||||
get(QNetworkRequest(QUrl("http://x64dbg.com/version.txt")));
|
||||
}
|
||||
|
||||
void UpdateChecker::finishedSlot(QNetworkReply* reply)
|
||||
{
|
||||
if(reply->error() != QNetworkReply::NoError) //error
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Network Error!", reply->errorString());
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
bool ok = false;
|
||||
int version = QString(reply->readAll()).toInt(&ok);
|
||||
reply->close();
|
||||
if(!ok)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Error!", "File on server could not be parsed...");
|
||||
msg.setParent(mParent);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
QString info;
|
||||
int dbgVersion = BridgeGetDbgVersion();
|
||||
if(version > dbgVersion)
|
||||
info = QString().sprintf("New version v%d available!\nDownload at http://x64dbg.com\n\nYou are now on version v%d", version, dbgVersion);
|
||||
else if(version < dbgVersion)
|
||||
info = QString().sprintf("You have a development version (v%d) of x64_dbg!", dbgVersion);
|
||||
else
|
||||
info = QString().sprintf("You have the latest version (%d) of x64_dbg!", version);
|
||||
QMessageBox msg(QMessageBox::Information, "Information", info);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/information.png"));
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
}
|
||||
#include "UpdateChecker.h"
|
||||
#include <QMessageBox>
|
||||
#include "Bridge.h"
|
||||
|
||||
UpdateChecker::UpdateChecker(QWidget* parent)
|
||||
{
|
||||
mParent=parent;
|
||||
connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void UpdateChecker::checkForUpdates()
|
||||
{
|
||||
get(QNetworkRequest(QUrl("http://x64dbg.com/version.txt")));
|
||||
}
|
||||
|
||||
void UpdateChecker::finishedSlot(QNetworkReply* reply)
|
||||
{
|
||||
if(reply->error() != QNetworkReply::NoError) //error
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Network Error!", reply->errorString());
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
bool ok = false;
|
||||
int version = QString(reply->readAll()).toInt(&ok);
|
||||
reply->close();
|
||||
if(!ok)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Error!", "File on server could not be parsed...");
|
||||
msg.setParent(mParent);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
QString info;
|
||||
int dbgVersion = BridgeGetDbgVersion();
|
||||
if(version > dbgVersion)
|
||||
info = QString().sprintf("New version v%d available!\nDownload at http://x64dbg.com\n\nYou are now on version v%d", version, dbgVersion);
|
||||
else if(version < dbgVersion)
|
||||
info = QString().sprintf("You have a development version (v%d) of x64_dbg!", dbgVersion);
|
||||
else
|
||||
info = QString().sprintf("You have the latest version (%d) of x64_dbg!", version);
|
||||
QMessageBox msg(QMessageBox::Information, "Information", info);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/information.png"));
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#ifndef UPDATECHECKER_H
|
||||
#define UPDATECHECKER_H
|
||||
|
||||
#include <QtNetwork>
|
||||
#include <QtGui>
|
||||
|
||||
class UpdateChecker : public QNetworkAccessManager
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UpdateChecker(QWidget* parent);
|
||||
void checkForUpdates();
|
||||
|
||||
private slots:
|
||||
void finishedSlot(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QWidget* mParent;
|
||||
|
||||
};
|
||||
|
||||
#endif // UPDATECHECKER_H
|
||||
#ifndef UPDATECHECKER_H
|
||||
#define UPDATECHECKER_H
|
||||
|
||||
#include <QtNetwork>
|
||||
#include <QtGui>
|
||||
|
||||
class UpdateChecker : public QNetworkAccessManager
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UpdateChecker(QWidget* parent);
|
||||
void checkForUpdates();
|
||||
|
||||
private slots:
|
||||
void finishedSlot(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QWidget* mParent;
|
||||
|
||||
};
|
||||
|
||||
#endif // UPDATECHECKER_H
|
||||
|
|
Loading…
Reference in New Issue