Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Qt/HyperDecode.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = HyperDecode
QT += core widgets gui
QT += core widgets gui concurrent
CONFIG += c++11 console

# Force MinGW to avoid toolchain mismatch.
Expand All @@ -11,6 +11,7 @@ QMAKE_CXX = g++
INCLUDEPATH += ../core/include
INCLUDEPATH += C:/msys64/ucrt64/include/glib-2.0
INCLUDEPATH += C:/msys64/ucrt64/lib/glib-2.0/include
INCLUDEPATH += C:/msys64/ucrt64/include/json-glib-1.0

# Core sources
SOURCES += \
Expand All @@ -24,15 +25,19 @@ SOURCES += \
../core/src/crash_handler.c \
../core/src/score.c \
../core/src/buffer.c \
../core/src/pipeline.c
../core/src/pipeline.c \
../core/src/recipe.c

# Plugins
SOURCES += \
../core/plugins/aes_plugin.c \
../core/plugins/atbash_plugin.c \
../core/plugins/base64_plugin.c \
../core/plugins/caesar_plugin.c \
../core/plugins/gzip_plugin.c \
../core/plugins/rot13_plugin.c \
../core/plugins/scramble_plugin.c \
../core/plugins/sha256_plugin.c \
../core/plugins/url_plugin.c \
../core/plugins/xor_plugin.c

Expand All @@ -45,15 +50,23 @@ SOURCES += \
history_manager.cpp \
history_tab.cpp \
notification_widget.cpp \
notification_manager.cpp
notification_manager.cpp \
recipe_manager.cpp \
recipe_tab.cpp \
arg_editor_dialog.cpp \
batch_processor.cpp

HEADERS += \
mainwindow.h \
console_manager.h \
history_manager.h \
history_tab.h \
notification_widget.h \
notification_manager.h
notification_manager.h \
recipe_manager.h \
recipe_tab.h \
arg_editor_dialog.h \
batch_processor.h

RESOURCES += resources.qrc
RC_ICONS = icons/app.ico
Expand All @@ -62,7 +75,10 @@ RC_ICONS = icons/app.ico
QMAKE_CFLAGS += -Wno-cast-function-type

# Link GLib from the local MSYS2 UCRT64 environment.
LIBS += -LC:/msys64/ucrt64/lib -lglib-2.0 -lintl -liconv
LIBS += -LC:/msys64/ucrt64/lib -lglib-2.0 -lgobject-2.0 -lintl -liconv -ljson-glib-1.0

# Link OpenSSL and zlib for crypto plugins
LIBS += -lssl -lcrypto -lz

# Debug / Release
CONFIG(debug, debug|release) {
Expand Down
2 changes: 1 addition & 1 deletion Qt/HyperDecode_resource.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <windows.h>

IDI_ICON1 ICON "C:\\Users\\Administrator\\Desktop\\my_project\\auto_decoder\\Qt\\icons\\app.ico"
IDI_ICON1 ICON "C:/Users/Administrator/Desktop/my_project/auto_decoder2/Qt/icons/app.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
Expand Down
36 changes: 18 additions & 18 deletions Qt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Generated by qmake (3.1) (Qt 6.10.1)
# Project: HyperDecode.pro
# Template: app
# Command: C:\msys64\ucrt64\bin\qmake.exe -o Makefile HyperDecode.pro
# Command: C:/msys64/ucrt64/bin/qmake.exe -o Makefile HyperDecode.pro
#############################################################################

MAKEFILE = Makefile
Expand All @@ -13,29 +13,29 @@ EQ = =
first: release
install: release-install
uninstall: release-uninstall
QMAKE = C:\msys64\ucrt64\bin\qmake.exe
DEL_FILE = del
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
COPY = copy /y
COPY_FILE = copy /y
COPY_DIR = xcopy /s /q /y /i
INSTALL_FILE = copy /y
INSTALL_PROGRAM = copy /y
INSTALL_DIR = xcopy /s /q /y /i
QINSTALL = C:\msys64\ucrt64\bin\qmake.exe -install qinstall
QINSTALL_PROGRAM = C:\msys64\ucrt64\bin\qmake.exe -install qinstall -exe
DEL_FILE = del
QMAKE = C:/msys64/ucrt64/bin/qmake.exe
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
COPY = cp -f
COPY_FILE = cp -f
COPY_DIR = cp -f -R
INSTALL_FILE = cp -f
INSTALL_PROGRAM = cp -f
INSTALL_DIR = cp -f -R
QINSTALL = C:/msys64/ucrt64/bin/qmake.exe -install qinstall
QINSTALL_PROGRAM = C:/msys64/ucrt64/bin/qmake.exe -install qinstall -exe
DEL_FILE = rm -f
SYMLINK = $(QMAKE) -install ln -f -s
DEL_DIR = rmdir
MOVE = move
MOVE = mv -f
IDC = idc
IDL = widl
ZIP = zip -r -9
ZIP =
DEF_FILE =
RES_FILE = HyperDecode_resource_res.o
SED = $(QMAKE) -install sed
MOVE = move
SED = sed
MOVE = mv -f
SUBTARGETS = \
release \
debug
Expand Down
367 changes: 250 additions & 117 deletions Qt/Makefile.Debug

Large diffs are not rendered by default.

367 changes: 250 additions & 117 deletions Qt/Makefile.Release

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions Qt/arg_editor_dialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "arg_editor_dialog.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QJsonObject>

ArgEditorDialog::ArgEditorDialog(const QJsonObject &op, QWidget *parent)
: QDialog(parent), m_args(op["args"].toObject())
{
setWindowTitle(op["name"].toString() + " - Edit Arguments");
setMinimumWidth(300);

QVBoxLayout *layout = new QVBoxLayout(this);

QLabel *title = new QLabel(op["name"].toString());
title->setStyleSheet("font-weight: bold; font-size: 14px;");
layout->addWidget(title);

// For AES example - key field
if (op["name"].toString().contains("AES", Qt::CaseInsensitive)) {
QLabel *keyLabel = new QLabel("Key (hex):");
QLineEdit *keyEdit = new QLineEdit;
keyEdit->setText(m_args["key"].toString());
layout->addWidget(keyLabel);
layout->addWidget(keyEdit);

connect(keyEdit, &QLineEdit::textChanged, [this, keyEdit]() {
m_args["key"] = keyEdit->text();
});
}

// Generic args for other ops
QJsonObject::const_iterator it = m_args.constBegin();
while (it != m_args.constEnd()) {
QLabel *label = new QLabel(QString("%1:").arg(it.key()));
QLineEdit *edit = new QLineEdit(it.value().toString());
layout->addWidget(label);
layout->addWidget(edit);

QString key = it.key();
connect(edit, &QLineEdit::textChanged, [this, key](const QString &text) {
m_args[key] = text;
});
++it;
}

QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
layout->addWidget(buttons);
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
}

QJsonObject ArgEditorDialog::getArgs() const
{
return m_args;
}

18 changes: 18 additions & 0 deletions Qt/arg_editor_dialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef ARG_EDITOR_DIALOG_H
#define ARG_EDITOR_DIALOG_H

#include <QDialog>
#include <QJsonObject>

class ArgEditorDialog : public QDialog
{
public:
ArgEditorDialog(const QJsonObject &op, QWidget *parent = nullptr);
QJsonObject getArgs() const;

private:
QJsonObject m_args;
};

#endif

92 changes: 92 additions & 0 deletions Qt/batch_processor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include "batch_processor.h"
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QtConcurrent>
#include <QFuture>
#include <QThreadPool>
#include <QMutex>
#include <QAtomicInt>
#include "decoder_engine.h"
#include "console_manager.h"

void BatchProcessor::processDir(const QString &dirPath, const QString &recipeJson, const QString &outDir) {
QDir dir(dirPath);
if (!dir.exists()) {
emit statusUpdated("Input directory does not exist");
return;
}

QDir out(outDir);
if (!out.exists() && !out.mkpath(".")) {
emit statusUpdated("Cannot create output directory: " + outDir);
return;
}

QJsonDocument doc = QJsonDocument::fromJson(recipeJson.toUtf8());
if (!doc.isObject()) {
emit statusUpdated("Invalid recipe JSON");
return;
}
QJsonObject recipe = doc.object();

QFileInfoList files = dir.entryInfoList(QStringList() << "*.*", QDir::Files);
int total = files.size();
QAtomicInt processed(0);
QMutex progressMutex;

emit statusUpdated(QString("Processing %1 files in parallel...").arg(total));

// Parallel batch processing using QtConcurrent
QList<QFuture<void>> futures;

for (const QFileInfo &fileInfo : files) {
QFuture<void> future = QtConcurrent::run([=, &processed, &progressMutex, this]() {
QString inputFile = fileInfo.absoluteFilePath();
QString outputFile = out.absoluteFilePath(fileInfo.fileName());

// Read input
QFile input(inputFile);
if (!input.open(QIODevice::ReadOnly)) {
processed.fetchAndAddRelaxed(1);
return;
}
QString content = QString::fromUtf8(input.readAll());
input.close();

// Apply recipe via engine
DecoderEngine &engine = DecoderEngine::instance();
QJsonDocument recipeDoc(recipe);
QString recipeJsonStr = QString::fromUtf8(recipeDoc.toJson(QJsonDocument::Compact));
auto result = engine.executeRecipe(recipeJsonStr, content);

// Write output
QFile output(outputFile);
if (result.success && output.open(QIODevice::WriteOnly)) {
output.write(result.output.toUtf8());
output.close();
}

int current = processed.fetchAndAddRelaxed(1) + 1;
int percent = (current * 100) / total;

QMutexLocker locker(&progressMutex);
emit progressUpdated(percent);
emit statusUpdated(QString("Processed %1/%2: %3").arg(current).arg(total).arg(fileInfo.fileName()));
});

futures.append(future);
}

// Wait for all tasks to complete
for (auto &future : futures) {
future.waitForFinished();
}

emit finished(QString("%1 files processed to %2").arg(processed.loadRelaxed()).arg(outDir));
}

19 changes: 19 additions & 0 deletions Qt/batch_processor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef BATCH_PROCESSOR_H
#define BATCH_PROCESSOR_H

#include <QObject>
#include <QString>

class BatchProcessor : public QObject {
Q_OBJECT

public:
void processDir(const QString &dirPath, const QString &recipeJson, const QString &outDir);

signals:
void progressUpdated(int percent);
void statusUpdated(const QString &message);
void finished(const QString &summary);
};

#endif
11 changes: 11 additions & 0 deletions Qt/debug/object_script.HyperDecode.Debug
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ debug/crash_handler.o
debug/score.o
debug/buffer.o
debug/pipeline.o
debug/recipe.o
debug/aes_plugin.o
debug/atbash_plugin.o
debug/base64_plugin.o
debug/caesar_plugin.o
debug/gzip_plugin.o
debug/rot13_plugin.o
debug/scramble_plugin.o
debug/sha256_plugin.o
debug/url_plugin.o
debug/xor_plugin.o
debug/main.o
Expand All @@ -25,8 +29,15 @@ debug/history_manager.o
debug/history_tab.o
debug/notification_widget.o
debug/notification_manager.o
debug/recipe_manager.o
debug/recipe_tab.o
debug/arg_editor_dialog.o
debug/batch_processor.o
debug/qrc_resources.o
debug/moc_mainwindow.o
debug/moc_history_tab.o
debug/moc_notification_widget.o
debug/moc_notification_manager.o
debug/moc_recipe_manager.o
debug/moc_recipe_tab.o
debug/moc_batch_processor.o
Loading