GUI: removed ApiFingerprints
This commit is contained in:
parent
0338c72229
commit
563af7797d
|
|
@ -67,7 +67,6 @@ SOURCES += \
|
|||
Src/Gui/CommandHelpView.cpp \
|
||||
Src/BasicView/HistoryLineEdit.cpp \
|
||||
Src/Utils/Configuration.cpp \
|
||||
Src/Utils/ApiFingerprints.cpp \
|
||||
Src/Gui/CPUSideBar.cpp \
|
||||
Src/Gui/AppearanceDialog.cpp \
|
||||
Src/Disassembler/BeaTokenizer.cpp
|
||||
|
|
@ -116,7 +115,6 @@ HEADERS += \
|
|||
Src/Gui/CommandHelpView.h \
|
||||
Src/BasicView/HistoryLineEdit.h \
|
||||
Src/Utils/Configuration.h \
|
||||
Src/Utils/ApiFingerprints.h \
|
||||
Src/Gui/CPUSideBar.h \
|
||||
Src/Gui/AppearanceDialog.h \
|
||||
Src/Disassembler/BeaTokenizer.h
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ void BeaTokenizer::Argument(BeaInstructionToken* instr, const DISASM* disasm, co
|
|||
if(memSizeNames.contains(arg->ArgSize))
|
||||
AddToken(instr, TokenMemorySize, memSizeNames.find(arg->ArgSize).value() + " ptr", 0);
|
||||
else
|
||||
AddToken(instr, TokenMemorySize, QString().sprintf("???(%d) ptr", arg->ArgSize, 0);
|
||||
AddToken(instr, TokenMemorySize, QString().sprintf("???(%d) ptr", arg->ArgSize), 0);
|
||||
AddToken(instr, TokenSpace, " ", 0);
|
||||
AddToken(instr, TokenMemorySegment, segmentNames.at(arg->SegmentReg), 0);
|
||||
AddToken(instr, TokenUncategorized, ":", 0);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
|
||||
// load config file
|
||||
mConfiguration = new Configuration;
|
||||
mAPIFingerprints = new ApiFingerprints;
|
||||
|
||||
//Load recent files
|
||||
loadMRUList(16);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
#include "SettingsDialog.h"
|
||||
#include "tabwidget.h"
|
||||
#include "Configuration.h"
|
||||
#include "ApiFingerprints.h"
|
||||
#include "AppearanceDialog.h"
|
||||
|
||||
namespace Ui
|
||||
|
|
@ -96,7 +95,6 @@ private:
|
|||
StatusLabel* mLastLogLabel;
|
||||
|
||||
Configuration* mConfiguration;
|
||||
ApiFingerprints* mAPIFingerprints;
|
||||
|
||||
const char* mWindowMainTitle;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,130 +0,0 @@
|
|||
#include "ApiFingerprints.h"
|
||||
#include "Configuration.h"
|
||||
|
||||
|
||||
ApiFingerprints* ApiFingerprints::mPtr = NULL;
|
||||
|
||||
|
||||
ApiFingerprints *ApiFingerprints::instance()
|
||||
{
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief retrieves information (name, arguments) for given api function from database
|
||||
* @param name of dll without ".dll"
|
||||
* @param name of function
|
||||
* @remark upper or lower case doesn't matter
|
||||
* @return
|
||||
*/
|
||||
const APIFunction ApiFingerprints::function(QString dllname,QString functionname) const
|
||||
{
|
||||
return Library.constFind(dllname.toLower().trimmed()).value().constFind(functionname.toLower().trimmed()).value();
|
||||
/*
|
||||
* example
|
||||
* --------------------
|
||||
* "int MessageBoxA(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType)"
|
||||
*
|
||||
* APIFunction f = function("UsEr32 ","messAgebOxa");
|
||||
* f.Name = "MessageBoxA";
|
||||
* f.DLLName = "user32";
|
||||
* f.ReturnType = "int"
|
||||
* f.Arguments.at(0).Name = "hWnd";
|
||||
* f.Arguments.at(0).Type = "HWND";
|
||||
* f.Arguments.at(1).Name = "lpText";
|
||||
* f.Arguments.at(1).Type = "LPCTSTR";
|
||||
* ...
|
||||
*
|
||||
* upper / lower case doesn't matter and additional whitespace will be trimmed
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ApiFingerprints::ApiFingerprints()
|
||||
{
|
||||
mPtr = this;
|
||||
// the config file should contain a list of possible data files for api calls
|
||||
QList<QString> files = Configuration::instance()->ApiFingerprints();
|
||||
|
||||
// iterate all given files
|
||||
foreach(QString file, files)
|
||||
{
|
||||
QFile mFile("data/"+file+".txt");
|
||||
if(mFile.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
// if file exists --> parse file
|
||||
|
||||
QMap<QString, APIFunction> Functions;
|
||||
QTextStream in(&mFile);
|
||||
while ( !in.atEnd() )
|
||||
{
|
||||
// reads raw line like "int;MessageBoxA;HWND hWnd;LPCTSTR lpText;LPCTSTR lpCaption;UINT uType;"
|
||||
QString rawFunctionDescr = in.readLine();
|
||||
QStringList functionParts = rawFunctionDescr.split(";");
|
||||
// format : retType;FunctionName;Arg1;Arg2;Arg3;...
|
||||
|
||||
|
||||
if(functionParts.count()<2)
|
||||
{
|
||||
// each function description needs at least a return type and a name
|
||||
// if not, we ignore the data
|
||||
continue;
|
||||
}
|
||||
|
||||
// function data
|
||||
APIFunction func;
|
||||
func.DLLName = file;
|
||||
func.ReturnType = functionParts.at(0);
|
||||
func.Name = functionParts.at(1);
|
||||
|
||||
// read parameters
|
||||
for(int i=2; i<functionParts.count(); i++)
|
||||
{
|
||||
QString rawArgument = functionParts.at(i).trimmed();
|
||||
if(rawArgument.length() == 0)
|
||||
break;
|
||||
|
||||
// some functions have pointers as arguments --> use "*" to split type and name of argument
|
||||
QStringList par = rawArgument.split("*");
|
||||
APIArgument arg;
|
||||
if(par.count() > 1)
|
||||
{
|
||||
arg.Name = par.at(1).trimmed();
|
||||
arg.Type = par.at(0).trimmed()+"*";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// current argument is no pointer --> use " " to split
|
||||
par = rawArgument.split(" ");
|
||||
if(par.count()>1)
|
||||
{
|
||||
arg.Name = par.at(1).trimmed();
|
||||
arg.Type = par.at(0).trimmed();
|
||||
}
|
||||
else
|
||||
{
|
||||
// we assume that there is only the type
|
||||
arg.Name = "";
|
||||
arg.Type = rawArgument.trimmed();
|
||||
}
|
||||
}
|
||||
|
||||
func.Arguments.append(arg);
|
||||
|
||||
}
|
||||
|
||||
Functions.insert(func.Name.toLower().trimmed(),func);
|
||||
|
||||
}
|
||||
|
||||
Library.insert(file,Functions);
|
||||
mFile.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef APIFINGERPRINTS_H
|
||||
#define APIFINGERPRINTS_H
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
struct APIArgument
|
||||
{
|
||||
QString Type;
|
||||
QString Name;
|
||||
};
|
||||
|
||||
struct APIFunction
|
||||
{
|
||||
QString DLLName;
|
||||
QString ReturnType;
|
||||
QString Name;
|
||||
QList<APIArgument> Arguments;
|
||||
};
|
||||
|
||||
class ApiFingerprints
|
||||
{
|
||||
static ApiFingerprints* mPtr;
|
||||
QMap<QString,QMap<QString, APIFunction>> Library;
|
||||
public:
|
||||
ApiFingerprints();
|
||||
const APIFunction function(QString dllname, QString functionname) const;
|
||||
static ApiFingerprints *instance();
|
||||
};
|
||||
|
||||
#endif // APIFINGERPRINTS_H
|
||||
|
|
@ -210,17 +210,6 @@ void Configuration::writeBools()
|
|||
}
|
||||
}
|
||||
|
||||
const QList<QString> Configuration::ApiFingerprints()
|
||||
{
|
||||
char setting[MAX_SETTING_SIZE]="";
|
||||
if(!BridgeSettingGet("Engine", "APIFingerprints", setting))
|
||||
{
|
||||
strcpy(setting, "gdi32,kernel32,shell32,stdio,user32"); //default setting
|
||||
BridgeSettingSet("Engine", "APIFingerprints", setting);
|
||||
}
|
||||
return QString(setting).split(QChar(','), QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
const QColor Configuration::getColor(const QString id)
|
||||
{
|
||||
if(Colors.contains(id))
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public:
|
|||
void writeColors();
|
||||
void readBools();
|
||||
void writeBools();
|
||||
const QList<QString> ApiFingerprints();
|
||||
|
||||
const QColor getColor(const QString id);
|
||||
const bool getBool(const QString category, const QString id);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue