2017-03-29 10:18:37 +00:00
|
|
|
#ifndef IMPORTSWIDGET_H
|
|
|
|
#define IMPORTSWIDGET_H
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2018-04-12 06:32:31 +00:00
|
|
|
#include <QAbstractTableModel>
|
2018-04-23 07:53:35 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
2018-04-12 06:32:31 +00:00
|
|
|
#include <QRegularExpression>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QStyledItemDelegate>
|
2017-05-19 07:45:26 +00:00
|
|
|
#include <QTreeWidgetItem>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2019-08-19 13:35:25 +00:00
|
|
|
#include "widgets/ListDockWidget.h"
|
|
|
|
#include "common/AddressableItemModel.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidget;
|
2018-10-10 11:33:55 +00:00
|
|
|
class ImportsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class ImportsModel : public AddressableItemModel<QAbstractTableModel>
|
2018-04-12 06:32:31 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend ImportsWidget;
|
|
|
|
|
2018-04-12 06:32:31 +00:00
|
|
|
private:
|
2021-01-24 14:50:13 +00:00
|
|
|
const QRegularExpression banned = QRegularExpression(
|
|
|
|
QStringLiteral("\\A(\\w\\.)*(system|strcpy|strcpyA|strcpyW|wcscpy|_tcscpy|_mbscpy|"
|
|
|
|
"StrCpy|StrCpyA|StrCpyW|lstrcpy|lstrcpyA|lstrcpyW"
|
|
|
|
"|_tccpy|_mbccpy|_ftcscpy|strcat|strcatA|strcatW|wcscat|_tcscat|_mbscat|"
|
|
|
|
"StrCat|StrCatA|StrCatW|lstrcat|lstrcatA|"
|
|
|
|
"lstrcatW|StrCatBuff|StrCatBuffA|StrCatBuffW|StrCatChainW|_tccat|_"
|
|
|
|
"mbccat|_ftcscat|sprintfW|sprintfA|wsprintf|wsprintfW|"
|
|
|
|
"wsprintfA|sprintf|swprintf|_stprintf|wvsprintf|wvsprintfA|wvsprintfW|"
|
|
|
|
"vsprintf|_vstprintf|vswprintf|strncpy|wcsncpy|"
|
|
|
|
"_tcsncpy|_mbsncpy|_mbsnbcpy|StrCpyN|StrCpyNA|StrCpyNW|StrNCpy|strcpynA|"
|
|
|
|
"StrNCpyA|StrNCpyW|lstrcpyn|lstrcpynA|lstrcpynW|"
|
|
|
|
"strncat|wcsncat|_tcsncat|_mbsncat|_mbsnbcat|StrCatN|StrCatNA|StrCatNW|"
|
|
|
|
"StrNCat|StrNCatA|StrNCatW|lstrncat|lstrcatnA|"
|
|
|
|
"lstrcatnW|lstrcatn|gets|_getts|_gettws|IsBadWritePtr|IsBadHugeWritePtr|"
|
|
|
|
"IsBadReadPtr|IsBadHugeReadPtr|IsBadCodePtr|"
|
|
|
|
"IsBadStringPtr|memcpy|RtlCopyMemory|CopyMemory|wmemcpy|wnsprintf|"
|
|
|
|
"wnsprintfA|wnsprintfW|_snwprintf|_snprintf|_sntprintf|"
|
|
|
|
"_vsnprintf|vsnprintf|_vsnwprintf|_vsntprintf|wvnsprintf|wvnsprintfA|"
|
|
|
|
"wvnsprintfW|strtok|_tcstok|wcstok|_mbstok|makepath|"
|
|
|
|
"_tmakepath| "
|
|
|
|
"_makepath|_wmakepath|_splitpath|_tsplitpath|_wsplitpath|scanf|wscanf|_"
|
|
|
|
"tscanf|sscanf|swscanf|_stscanf|snscanf|"
|
|
|
|
"snwscanf|_sntscanf|_itoa|_itow|_i64toa|_i64tow|_ui64toa|_ui64tot|_"
|
|
|
|
"ui64tow|_ultoa|_ultot|_ultow|CharToOem|CharToOemA|CharToOemW|"
|
|
|
|
"OemToChar|OemToCharA|OemToCharW|CharToOemBuffA|CharToOemBuffW|alloca|_"
|
|
|
|
"alloca|strlen|wcslen|_mbslen|_mbstrlen|StrLen|lstrlen|"
|
|
|
|
"ChangeWindowMessageFilter)\\z"));
|
2021-04-13 18:28:38 +00:00
|
|
|
QList<ImportDescription> imports;
|
2018-04-12 06:32:31 +00:00
|
|
|
|
|
|
|
public:
|
2021-01-24 14:50:13 +00:00
|
|
|
enum Column {
|
|
|
|
AddressColumn = 0,
|
|
|
|
TypeColumn,
|
|
|
|
LibraryColumn,
|
|
|
|
NameColumn,
|
|
|
|
SafetyColumn,
|
|
|
|
CommentColumn,
|
|
|
|
ColumnCount
|
|
|
|
};
|
2018-04-23 07:53:35 +00:00
|
|
|
enum Role { ImportDescriptionRole = Qt::UserRole, AddressRole };
|
2018-04-12 06:32:31 +00:00
|
|
|
|
2021-04-13 18:28:38 +00:00
|
|
|
ImportsModel(QObject *parent = nullptr);
|
2018-04-12 06:32:31 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
2018-04-12 06:32:31 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
RVA address(const QModelIndex &index) const override;
|
|
|
|
QString name(const QModelIndex &index) const override;
|
2020-01-25 07:18:53 +00:00
|
|
|
QString libname(const QModelIndex &index) const;
|
2021-04-13 18:28:38 +00:00
|
|
|
void reload();
|
2018-04-12 06:32:31 +00:00
|
|
|
};
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class ImportsProxyModel : public AddressableFilterProxyModel
|
2018-04-23 07:53:35 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
ImportsProxyModel(ImportsModel *sourceModel, QObject *parent = nullptr);
|
2018-04-23 07:53:35 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class ImportsWidget : public ListDockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-05-22 11:49:34 +00:00
|
|
|
explicit ImportsWidget(MainWindow *main);
|
2017-03-29 10:18:37 +00:00
|
|
|
~ImportsWidget();
|
|
|
|
|
2017-05-19 07:45:26 +00:00
|
|
|
private slots:
|
2018-04-12 06:32:31 +00:00
|
|
|
void refreshImports();
|
2021-01-24 14:50:13 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2018-04-23 07:53:35 +00:00
|
|
|
ImportsModel *importsModel;
|
2018-04-24 18:40:40 +00:00
|
|
|
ImportsProxyModel *importsProxyModel;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
|
|
|
void highlightUnsafe();
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IMPORTSWIDGET_H
|