mirror of
https://github.com/altlinux/admc.git
synced 2025-02-03 05:47:02 +03:00
gpgui sources imported
This commit is contained in:
parent
280a98f225
commit
a59f129613
94
gpgui/CMakeLists.txt
Normal file
94
gpgui/CMakeLists.txt
Normal file
@ -0,0 +1,94 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(gpgui VERSION 0.0.1)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Suppress warnings on FindDoxygen.cmake
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
add_subdirectory(libgptbackend)
|
||||
|
||||
if(SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
message(STATUS "Using external libiconv for FreeBSD")
|
||||
include_directories(/usr/local/lib)
|
||||
link_directories(/usr/local/lib)
|
||||
set(Iconv_IS_BUILT_IN FALSE)
|
||||
endif()
|
||||
|
||||
find_package(Qt5 COMPONENTS Core Widgets REQUIRED) # GUI
|
||||
if(NOT Iconv_IS_BUILT_IN)
|
||||
find_package(Iconv) # For libgptbackend
|
||||
endif()
|
||||
find_package(Doxygen) # Code documentation
|
||||
|
||||
set(GPGUI_GUI_HEADER_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gui/include
|
||||
)
|
||||
|
||||
set(GPGUI_GUI_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gui/MainWindow.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gui/REG_DWORD_Dialog.cpp
|
||||
)
|
||||
|
||||
set(GPGUI_HEADER_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
set(GPGUI_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Runner.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gpgui.qrc
|
||||
)
|
||||
|
||||
# Definitions for configuration file
|
||||
set(GPGUI_APPLICATION_NAME "GPGUI")
|
||||
set(GPGUI_APPLICATION_DISPLAY_NAME "GPGUI")
|
||||
set(GPGUI_ORGANIZATION "BaseALT")
|
||||
set(GPGUI_ORGANIZATION_DOMAIN "basealt.ru")
|
||||
|
||||
configure_file("config.h.in" "config.h")
|
||||
|
||||
add_definitions(${QT5_DEFINITIONS})
|
||||
add_executable(gpgui
|
||||
${GPGUI_SOURCES}
|
||||
${GPGUI_GUI_SOURCES}
|
||||
)
|
||||
|
||||
doxygen_add_docs(gpgui_doc
|
||||
${GPGUI_HEADER_DIRS}
|
||||
${GPGUI_GUI_HEADER_DIRS}
|
||||
COMMENT
|
||||
"Group Policy Editor GUI documentation"
|
||||
)
|
||||
|
||||
if(SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
target_link_libraries(gpgui
|
||||
Iconv::Iconv
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(gpgui
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
gptbackend
|
||||
)
|
||||
|
||||
target_include_directories(gpgui
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${GPGUI_HEADER_DIRS}
|
||||
${GPGUI_GUI_HEADER_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libgptbackend/preg/include
|
||||
)
|
||||
|
||||
install(TARGETS gpgui)
|
||||
|
66
gpgui/Runner.cpp
Normal file
66
gpgui/Runner.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include "Runner.h"
|
||||
|
||||
Runner::Runner(int argc, char **argv, QString dispname, QString appname,
|
||||
QString appver, QString orgname, QString orgdomain) {
|
||||
Q_INIT_RESOURCE(gpgui); // Initialize gpgui.qrc metadata.
|
||||
|
||||
/* Please ensure argc and argv lifetime is enough otherwise
|
||||
* the application will segfault on attempt to access
|
||||
* qApp->arguments() because of NULL pointer */
|
||||
this->argc = argc;
|
||||
this->argv = argv;
|
||||
|
||||
this->app = new QApplication(this->argc, this->argv);
|
||||
this->app->setApplicationDisplayName(dispname);
|
||||
this->app->setApplicationName(appname);
|
||||
this->app->setApplicationVersion(appver);
|
||||
this->app->setOrganizationName(orgname);
|
||||
this->app->setOrganizationDomain(orgdomain);
|
||||
}
|
||||
|
||||
void Runner::arg_parser() {
|
||||
QCommandLineParser cli_parser;
|
||||
cli_parser.setApplicationDescription(QCoreApplication::applicationName());
|
||||
cli_parser.addHelpOption();
|
||||
cli_parser.addVersionOption();
|
||||
const QStringList arg_list = qApp->arguments();
|
||||
cli_parser.process(arg_list);
|
||||
}
|
||||
|
||||
int Runner::run() {
|
||||
this->arg_parser();
|
||||
|
||||
qgui::MainWindow mainWin;
|
||||
mainWin.show();
|
||||
|
||||
return app->exec();
|
||||
}
|
20
gpgui/config.h.in
Normal file
20
gpgui/config.h.in
Normal file
@ -0,0 +1,20 @@
|
||||
#if !defined(__GPGUI_CONFIG_H)
|
||||
# define __GPGUI_CONFIG_H 1
|
||||
|
||||
#define _XOPEN_SOURCE 700
|
||||
#define _C99_SOURCE 1
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
# define _BSD_VISIBLE 1
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
# define GPGUI_VERSION "${PROJECT_VERSION}"
|
||||
# define GPGUI_APPLICATION_NAME "${GPGUI_APPLICATION_NAME}"
|
||||
# define GPGUI_APPLICATION_DISPLAY_NAME "${GPGUI_APPLICATION_DISPLAY_NAME}"
|
||||
# define GPGUI_ORGANIZATION "${GPGUI_ORGANIZATION}"
|
||||
# define GPGUI_ORGANIZATION_DOMAIN "${GPGUI_ORGANIZATION_DOMAIN}"
|
||||
|
||||
#endif /* __GPGUI_CONFIG_H */
|
||||
|
7
gpgui/gpgui.pro
Normal file
7
gpgui/gpgui.pro
Normal file
@ -0,0 +1,7 @@
|
||||
TEMPLATE = gpgui
|
||||
TARGET = gpgui
|
||||
QT += core qui
|
||||
HEADERS += gui/include/MainWindow.h
|
||||
SOURCES += main.cpp gui/MainWindow.cpp
|
||||
RESOURCES = gpgui.qrc
|
||||
|
4
gpgui/gpgui.qrc
Normal file
4
gpgui/gpgui.qrc
Normal file
@ -0,0 +1,4 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
</RCC>
|
||||
|
221
gpgui/gui/MainWindow.cpp
Normal file
221
gpgui/gui/MainWindow.cpp
Normal file
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QFrame>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QHeaderView>
|
||||
#include <QTabWidget>
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include "preg_writer.h"
|
||||
|
||||
namespace {
|
||||
|
||||
QStringList regtype_list{"REG_NONE",
|
||||
"REG_SZ",
|
||||
"REG_EXPAND_SZ",
|
||||
"REG_BINARY",
|
||||
"REG_DWORD_LITTLE_ENDIAN",
|
||||
"REG_DWORD_BIG_ENDIAN",
|
||||
"REG_LINK",
|
||||
"REG_MULTI_SZ",
|
||||
"REG_RESOURCE_LIST",
|
||||
"REG_FULL_RESOURCE_DESCRIPTOR",
|
||||
"REG_RESOURCE_REQUIREMENTS_LIST",
|
||||
"REG_QWORD",
|
||||
"REG_QWORD_LITTLE_ENDIAN"};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
void qgui::MainWindow::create_menu_bar() {
|
||||
file_menu = menuBar()->addMenu(tr("&File"));
|
||||
help_menu = menuBar()->addMenu(tr("&Help"));
|
||||
|
||||
QAction *open_preg_action = file_menu->addAction(
|
||||
tr("&Open PReg file"), this, &qgui::MainWindow::open_preg);
|
||||
open_preg_action->setStatusTip(tr("Open PReg file for editing"));
|
||||
QAction *save_preg_action = file_menu->addAction(
|
||||
tr("&Save PReg file"), this, &qgui::MainWindow::save_preg);
|
||||
save_preg_action->setStatusTip(tr("Save active PReg file"));
|
||||
QAction *save_reg_action = file_menu->addAction(
|
||||
tr("&Save REG file"), this, &qgui::MainWindow::save_dotreg);
|
||||
save_reg_action->setStatusTip(tr("Save active PReg file as REG"));
|
||||
QAction *exit_action =
|
||||
file_menu->addAction(tr("&Exit"), this, &QWidget::close);
|
||||
exit_action->setStatusTip(tr("Exit GPGUI"));
|
||||
|
||||
QAction *about_action =
|
||||
help_menu->addAction(tr("&About"), this, &qgui::MainWindow::about);
|
||||
about_action->setStatusTip(tr("About GPGUI"));
|
||||
}
|
||||
|
||||
void qgui::MainWindow::create_status_bar() {
|
||||
this->statusBar()->showMessage(tr("Ready"));
|
||||
}
|
||||
|
||||
qgui::MainWindow::MainWindow(QWidget *parent)
|
||||
//: QMainWindow(parent)
|
||||
{
|
||||
this->preg_open_dialog = new QFileDialog(
|
||||
this, tr("Select PReg file to edit"), QDir::currentPath(),
|
||||
"PReg files (*.pol);;All files (*.*)");
|
||||
this->preg_open_dialog->setFileMode(QFileDialog::ExistingFile);
|
||||
|
||||
this->preg_save_dialog = new QFileDialog(
|
||||
this, tr("Select PReg file to save"), QDir::currentPath(),
|
||||
"PReg files (*.pol);;All files (*.*)");
|
||||
this->preg_save_dialog->setFileMode(QFileDialog::AnyFile);
|
||||
|
||||
QVBoxLayout *layout_regpol_editor = new QVBoxLayout;
|
||||
QVBoxLayout *layout_gpo_editor = new QVBoxLayout;
|
||||
|
||||
QTabWidget *tw = new QTabWidget;
|
||||
tw->addTab(new QWidget, tr("PReg editor"));
|
||||
tw->addTab(new QWidget, tr("GPO editor"));
|
||||
tw->addTab(new QWidget, tr("Domain Control"));
|
||||
|
||||
this->regpol_table = new QTableWidget(0, 4, this);
|
||||
QStringList labels{"Value name", "Key name", "Type", "Value"};
|
||||
this->regpol_table->setHorizontalHeaderLabels(labels);
|
||||
this->regpol_table->horizontalHeader()->setStretchLastSection(true);
|
||||
tw->widget(0)->setLayout(layout_regpol_editor);
|
||||
layout_regpol_editor->addWidget(regpol_table);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(tw);
|
||||
|
||||
QFrame *frame = new QFrame;
|
||||
frame->setLayout(layout);
|
||||
frame->setFixedSize(800, 500);
|
||||
setCentralWidget(frame);
|
||||
this->adjustSize();
|
||||
|
||||
this->create_menu_bar();
|
||||
this->create_status_bar();
|
||||
|
||||
/* Create dialog windows */
|
||||
this->reg_dword_dialog = new qgui::REG_DWORD_Dialog();
|
||||
}
|
||||
|
||||
qgui::MainWindow::~MainWindow() {}
|
||||
|
||||
void qgui::MainWindow::closeEvent(QCloseEvent *event) { event->accept(); }
|
||||
|
||||
void qgui::MainWindow::about() {
|
||||
QMessageBox::about(this, tr("About GPGUI"), tr("GPGUI about"));
|
||||
}
|
||||
|
||||
void qgui::MainWindow::preg_entry2table(preg::entry &pentry) {
|
||||
std::string regtype = std::string(preg::regtype2str(pentry.type));
|
||||
std::string val = "0"; //std::to_string(pentry.value);
|
||||
|
||||
QComboBox *regtype_box = new QComboBox();
|
||||
regtype_box->addItems(regtype_list);
|
||||
regtype_box->setEditable(false);
|
||||
regtype_box->setMaxVisibleItems(6);
|
||||
regtype_box->setCurrentIndex(static_cast<int>(pentry.type));
|
||||
|
||||
QTableWidgetItem *vname = new QTableWidgetItem(pentry.value_name.c_str());
|
||||
QTableWidgetItem *kname = new QTableWidgetItem(pentry.key_name.c_str());
|
||||
QTableWidgetItem *vtype = new QTableWidgetItem(regtype.c_str());
|
||||
QTableWidgetItem *vval = new QTableWidgetItem(val.c_str());
|
||||
|
||||
this->regpol_table->insertRow(regpol_table->rowCount());
|
||||
|
||||
this->regpol_table->setItem(this->regpol_table->rowCount() - 1, 0, vname);
|
||||
this->regpol_table->setItem(this->regpol_table->rowCount() - 1, 1, kname);
|
||||
this->regpol_table->setCellWidget(this->regpol_table->rowCount() - 1, 2, regtype_box);
|
||||
this->regpol_table->setItem(this->regpol_table->rowCount() - 1, 3, vval);
|
||||
}
|
||||
|
||||
void qgui::MainWindow::open_preg() {
|
||||
QStringList preg_file_name;
|
||||
/* Using exec() is not recommended by Qt documentation but it
|
||||
* is easy to perform synchronous call */
|
||||
if (this->preg_open_dialog->exec()) {
|
||||
preg_file_name = this->preg_open_dialog->selectedFiles();
|
||||
|
||||
std::string file_name = preg_file_name[0].toStdString();
|
||||
preg::preg_parser *test_regpol =
|
||||
new preg::preg_parser(file_name);
|
||||
this->regpol_table->setRowCount(0);
|
||||
|
||||
try {
|
||||
while (1) {
|
||||
preg::entry pentry = test_regpol->get_next_entry();
|
||||
this->preg_entry2table(pentry);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
std::cout << "Caught exception" << std::endl;
|
||||
}
|
||||
|
||||
this->statusBar()->showMessage(tr("Loaded PReg file"));
|
||||
|
||||
this->regpol_table->horizontalHeader()->sectionResizeMode(QHeaderView::Stretch);
|
||||
this->regpol_table->resizeColumnsToContents();
|
||||
}
|
||||
}
|
||||
|
||||
void qgui::MainWindow::save_preg() {
|
||||
QStringList preg_file_name;
|
||||
/* Using exec() is not recommended by Qt documentation but it
|
||||
* is easy to perform synchronous call */
|
||||
if (this->preg_save_dialog->exec()) {
|
||||
preg_file_name = this->preg_save_dialog->selectedFiles();
|
||||
|
||||
std::string file_name = preg_file_name[0].toStdString();
|
||||
|
||||
preg::preg_writer pw(file_name);
|
||||
for (size_t rowid = 0; rowid < this->regpol_table->rowCount(); rowid++) {
|
||||
QTableWidgetItem *qvname = this->regpol_table->item(rowid, 0);
|
||||
QTableWidgetItem *qkname = this->regpol_table->item(rowid, 1);
|
||||
QComboBox *qtype = qobject_cast<QComboBox*>(this->regpol_table->cellWidget(rowid, 2));
|
||||
QTableWidgetItem *qval = this->regpol_table->item(rowid, 3);
|
||||
|
||||
preg::entry pe;
|
||||
pe.value_name = const_cast<char*>(qvname->data(Qt::DisplayRole).toString().toStdString().c_str());
|
||||
pe.key_name = const_cast<char*>(qkname->data(Qt::DisplayRole).toString().toStdString().c_str());
|
||||
pe.type = qtype->currentIndex();
|
||||
pe.size = 4;
|
||||
pe.value = const_cast<char*>(qval->data(Qt::DisplayRole).toString().toStdString().c_str());
|
||||
|
||||
pw.add_entry(pe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void qgui::MainWindow::save_dotreg() {}
|
||||
|
||||
void qgui::MainWindow::edit_reg_dword_dialog() {
|
||||
}
|
||||
|
24
gpgui/gui/REG_DWORD_Dialog.cpp
Normal file
24
gpgui/gui/REG_DWORD_Dialog.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "REG_DWORD_Dialog.h"
|
||||
|
||||
qgui::REG_DWORD_Dialog::REG_DWORD_Dialog() {
|
||||
|
||||
} /* qgui::REG_DWORD_Dialog::REG_DWORD_Dialog() */
|
||||
|
74
gpgui/gui/include/MainWindow.h
Normal file
74
gpgui/gui/include/MainWindow.h
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_MAINWINDOW_H)
|
||||
#define __GPGUI_MAINWINDOW_H 1
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QtWidgets>
|
||||
#include <QTableWidget>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "REG_DWORD_Dialog.h"
|
||||
|
||||
#include "preg_parser.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMenu;
|
||||
class QFileDialog;
|
||||
class QTableWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace qgui {
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
// Q_OBJECT
|
||||
QMenu *file_menu;
|
||||
QMenu *help_menu;
|
||||
|
||||
QFileDialog *preg_open_dialog;
|
||||
QFileDialog *preg_save_dialog;
|
||||
|
||||
QTableWidget *regpol_table;
|
||||
|
||||
REG_DWORD_Dialog *reg_dword_dialog;
|
||||
|
||||
void create_menu_bar();
|
||||
void create_status_bar();
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
void edit_reg_dword_dialog();
|
||||
|
||||
private slots:
|
||||
void about();
|
||||
void open_preg();
|
||||
void save_preg();
|
||||
void save_dotreg();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
void preg_entry2table(preg::entry &pentry);
|
||||
}; /* class MainWindow */
|
||||
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_MAINWINDOW_H */
|
25
gpgui/gui/include/REG_BINARY_Dialog.h
Normal file
25
gpgui/gui/include/REG_BINARY_Dialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_BINARY_DIALOG)
|
||||
# define __GPGUI_REG_BINARY_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_BINARY_DIALOG */
|
26
gpgui/gui/include/REG_DWORD_BE_Dialog.h
Normal file
26
gpgui/gui/include/REG_DWORD_BE_Dialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_DWORD_BE_DIALOG)
|
||||
# define __GPGUI_REG_DWORD_BE_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_DWORD_BE_DIALOG */
|
||||
|
36
gpgui/gui/include/REG_DWORD_Dialog.h
Normal file
36
gpgui/gui/include/REG_DWORD_Dialog.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_DWORD_DIALOG)
|
||||
# define __GPGUI_REG_DWORD_DIALOG 1
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QDialog>
|
||||
|
||||
namespace qgui {
|
||||
|
||||
class REG_DWORD_Dialog : public QDialog {
|
||||
// Q_OBJECT
|
||||
public:
|
||||
REG_DWORD_Dialog();
|
||||
}; /* class REG_DWORD_Dialog */
|
||||
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_DWORD_DIALOG */
|
||||
|
26
gpgui/gui/include/REG_EXPAND_SZ_Dialog.h
Normal file
26
gpgui/gui/include/REG_EXPAND_SZ_Dialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_EXPAND_SZ_DIALOG)
|
||||
#define __GPGUI_REG_EXPAND_SZ_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_EXPAND_SZ_DIALOG */
|
||||
|
26
gpgui/gui/include/REG_LINK_Dialog.h
Normal file
26
gpgui/gui/include/REG_LINK_Dialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_LINK_DIALOG)
|
||||
# define __GPGUI_REG_LINK_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_LINK_DIALOG */
|
||||
|
26
gpgui/gui/include/REG_MULTI_SZ_Dialog.h
Normal file
26
gpgui/gui/include/REG_MULTI_SZ_Dialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_MULTI_SZ_DIALOG)
|
||||
# define __GPGUI_REG_MULTI_SZ_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_MULTI_SZ_DIALOG */
|
||||
|
26
gpgui/gui/include/REG_NONE_Dialog.h
Normal file
26
gpgui/gui/include/REG_NONE_Dialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_NONE_DIALOG)
|
||||
# define __GPGUI_REG_NONE_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_NONE_DIALOG */
|
||||
|
26
gpgui/gui/include/REG_QWORD_Dialog.h
Normal file
26
gpgui/gui/include/REG_QWORD_Dialog.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_QWORD_DIALOG)
|
||||
# define __GPGUI_REG_QWORD_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_QWORD_DIALOG */
|
||||
|
25
gpgui/gui/include/REG_QWORD_LE_Dialog.h
Normal file
25
gpgui/gui/include/REG_QWORD_LE_Dialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_QWORD_LE_DIALOG)
|
||||
# define __GPGUI_REG_QWORD_LE_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
}
|
||||
|
||||
#endif /* __GPGUI_REG_QWORD_LE_DIALOG */
|
25
gpgui/gui/include/REG_RESOURCE_LIST_Dialog.h
Normal file
25
gpgui/gui/include/REG_RESOURCE_LIST_Dialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_RESOURCE_LIST_DIALOG)
|
||||
# define __GPGUI_REG_RESOURCE_LIST_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_RESOURCE_LIST_DIALOG */
|
25
gpgui/gui/include/REG_RESOURCE_REQ_LIST_Dialog.h
Normal file
25
gpgui/gui/include/REG_RESOURCE_REQ_LIST_Dialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_RESOURCE_REQ_LIST_DIALOG)
|
||||
# define __GPGUI_REG_RESOURCE_REQ_LIST_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_RESOURCE_REQ_LIST_DIALOG */
|
25
gpgui/gui/include/REG_SZ_Dialog.h
Normal file
25
gpgui/gui/include/REG_SZ_Dialog.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_REG_SZ_DIALOG)
|
||||
# define __GPGUI_REG_SZ_DIALOG 1
|
||||
|
||||
namespace qgui {
|
||||
} /* namespace qgui */
|
||||
|
||||
#endif /* __GPGUI_REG_SZ_DIALOG */
|
37
gpgui/include/Runner.h
Normal file
37
gpgui/include/Runner.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPGUI_RUNNER_H)
|
||||
#define __GPGUI_RUNNER_H 1
|
||||
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
|
||||
class Runner {
|
||||
QApplication *app;
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
public:
|
||||
Runner(int argc, char **argv, QString dispname, QString appname,
|
||||
QString appver, QString orgname, QString orgdomain);
|
||||
void arg_parser();
|
||||
int run();
|
||||
};
|
||||
|
||||
#endif /* __GPGUI_RUNNER_H */
|
102
gpgui/libgptbackend/CMakeLists.txt
Normal file
102
gpgui/libgptbackend/CMakeLists.txt
Normal file
@ -0,0 +1,102 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(gptbackend VERSION 0.0.1)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
set(CMAKE_AUTOMOC OFF)
|
||||
set(CMAKE_AUTOUIC OFF)
|
||||
set(CMAKE_AUTORCC OFF)
|
||||
|
||||
# Suppress warnings on FindDoxygen.cmake
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
if(SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
link_directories(/usr/local/lib)
|
||||
set(Iconv_IS_BUILT_IN FALSE)
|
||||
find_package(Iconv) # PReg key name charset conversion
|
||||
endif()
|
||||
|
||||
#find_package(Catch2 REQUIRED) # Unit tests
|
||||
find_package(Doxygen) # Documentation
|
||||
#find_package(PkgConfig)
|
||||
# There is XML registry format produced by python-samba. This library is
|
||||
# a dependency for producing XML files of this format.
|
||||
#pkg_check_modules(PUGIXML REQUIRED IMPORTED_TARGET pugixml)
|
||||
#pkg_check_modules(CATCH2 REQUIRED IMPORTED_TARGET catch)
|
||||
|
||||
set(PREG_PARSER_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preg/iconv_wrapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preg/preg_data.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preg/preg_parser.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preg/preg_writer.cpp
|
||||
)
|
||||
|
||||
set(GPTBACKEND_HEADER_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/preg/include
|
||||
)
|
||||
|
||||
set(GPTBACKEND_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
)
|
||||
|
||||
set(TEST_GPTBACKEND_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/test_preg_data.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/test_preg_writer.cpp
|
||||
)
|
||||
|
||||
# Definitions for configuration file
|
||||
configure_file("config.h.in" "config.h")
|
||||
|
||||
#add_executable(gptbackend_test
|
||||
# ${TEST_GPTBACKEND_SOURCES}
|
||||
# ${PREG_PARSER_SOURCES}
|
||||
#)
|
||||
|
||||
add_library(gptbackend SHARED
|
||||
${GPTBACKEND_SOURCES}
|
||||
${PREG_PARSER_SOURCES}
|
||||
)
|
||||
|
||||
doxygen_add_docs(gptbackend_doc
|
||||
${GPTBACKEND_HEADER_DIRS}
|
||||
COMMENT
|
||||
"libgptbackend documentation"
|
||||
)
|
||||
|
||||
#target_include_directories(gptbackend_test
|
||||
# PUBLIC
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# ${GPTBACKEND_HEADER_DIRS}
|
||||
#)
|
||||
|
||||
target_include_directories(gptbackend
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${GPTBACKEND_HEADER_DIRS}
|
||||
)
|
||||
|
||||
include(CTest)
|
||||
#include(ParseAndAddCatchTests)
|
||||
#ParseAndAddCatchTests(gptbackend_test)
|
||||
|
||||
#target_link_libraries(gptbackend_test
|
||||
#PkgConfig::CATCH2
|
||||
#Catch2::Catch2
|
||||
# gptbackend
|
||||
#Iconv::Iconv
|
||||
#)
|
||||
|
||||
target_link_libraries(gptbackend PUBLIC
|
||||
#Iconv::Iconv
|
||||
)
|
||||
|
||||
install(TARGETS gptbackend)
|
||||
#install(TARGETS gptbackend_test RUNTIME DESTINATION ${CMAKE_BINARY_DIR})
|
||||
|
29
gpgui/libgptbackend/LICENSE
Normal file
29
gpgui/libgptbackend/LICENSE
Normal file
@ -0,0 +1,29 @@
|
||||
Copyright (c) 2019 Igor Chudov <nir@sarfsc.ru>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the Igor Chudov nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
27
gpgui/libgptbackend/README.md
Normal file
27
gpgui/libgptbackend/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# libgptbackend - library to work with Windows AD GPO file formats
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Prerequisites](#prerequisites)
|
||||
|
||||
* * *
|
||||
|
||||
## Introduction
|
||||
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
# ALT Linux
|
||||
|
||||
* libpugixml-devel
|
||||
* catch2-devel
|
||||
* libiconv
|
||||
* doxygen
|
||||
|
||||
# FreeBSD
|
||||
|
||||
* iconv - Convert PReg key names from UTF16-LE
|
||||
* pugixml - Samba's python-samba XML file format
|
||||
* catch - Unit tests
|
||||
* doxygen - Documentation
|
||||
|
14
gpgui/libgptbackend/config.h.in
Normal file
14
gpgui/libgptbackend/config.h.in
Normal file
@ -0,0 +1,14 @@
|
||||
#if !defined (__GPTBACKEND_CONFIG_H)
|
||||
# define __GPTBACKEND_CONFIG_H 1
|
||||
|
||||
#define _XOPEN_SOURCE 700
|
||||
#define _C99_SOURCE 1
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
# define _BSD_VISIBLE 1
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#endif /* __GPTBACKEND_CONFIG_H */
|
||||
|
43
gpgui/libgptbackend/include/registry.h
Normal file
43
gpgui/libgptbackend/include/registry.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_REGISTRY_H)
|
||||
#define __GPTBACKEND_REGISTRY_H 1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
const char *regtype2str(uint32_t ®type);
|
||||
uint32_t str2regtype(const char *regtype);
|
||||
|
||||
struct registry_entry {
|
||||
char *keyname;
|
||||
char *valuename;
|
||||
uint32_t regtype;
|
||||
char *data;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GPTBACKEND_REGISTRY_H */
|
40
gpgui/libgptbackend/main.cpp
Normal file
40
gpgui/libgptbackend/main.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "registry.h"
|
||||
|
||||
#include "preg_data.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
const char *regtype2str(uint32_t ®type) {
|
||||
return preg::regtype2str(regtype).c_str();
|
||||
}
|
||||
|
||||
uint32_t str2regtype(const char *regtype) {
|
||||
std::string reg_name(regtype);
|
||||
return preg::str2regtype(reg_name);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
134
gpgui/libgptbackend/preg/iconv_wrapper.cpp
Normal file
134
gpgui/libgptbackend/preg/iconv_wrapper.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "iconv_wrapper.h"
|
||||
#include "config.h"
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <climits>
|
||||
#include <stdexcept>
|
||||
#include <system_error>
|
||||
|
||||
#include <vector>
|
||||
|
||||
gptbackend::iconv_wrapper::iconv_wrapper(std::string from_encoding,
|
||||
std::string to_encoding) {
|
||||
this->from_encoding = from_encoding;
|
||||
this->to_encoding = to_encoding;
|
||||
this->conv =
|
||||
iconv_open(this->to_encoding.c_str(), this->from_encoding.c_str());
|
||||
if (this->invalid_open == this->conv) {
|
||||
throw std::system_error(errno, std::system_category());
|
||||
}
|
||||
}
|
||||
|
||||
gptbackend::iconv_wrapper::~iconv_wrapper() {
|
||||
if (this->invalid_open != this->conv) {
|
||||
int result = iconv_close(this->conv);
|
||||
this->conv = this->invalid_open;
|
||||
if (0 != result) {
|
||||
std::cout << "Error on iconv_close " << errno << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string gptbackend::iconv_wrapper::convert(std::string from) {
|
||||
/*
|
||||
Copyright (c) 2011, Yuya Unno
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Yuya Unno nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
bool ignore_error_ = true;
|
||||
/* Values like INT_MAX cause awful slowdown */
|
||||
size_t buf_size_ = 1024;
|
||||
// copy the string to a buffer as iconv function requires a non-const char
|
||||
// pointer.
|
||||
std::vector<char> in_buf(from.begin(), from.end());
|
||||
char *src_ptr = &in_buf[0];
|
||||
size_t src_size = from.size();
|
||||
|
||||
std::vector<char> buf(buf_size_);
|
||||
std::string dst;
|
||||
while (0 < src_size) {
|
||||
char *dst_ptr = &buf[0];
|
||||
size_t dst_size = buf.size();
|
||||
size_t res =
|
||||
::iconv(this->conv, &src_ptr, &src_size, &dst_ptr, &dst_size);
|
||||
if (res == (size_t)-1) {
|
||||
if (errno == E2BIG) {
|
||||
// ignore this error
|
||||
} else if (ignore_error_) {
|
||||
// skip character
|
||||
++src_ptr;
|
||||
--src_size;
|
||||
} else {
|
||||
this->check_conversion_error();
|
||||
}
|
||||
}
|
||||
dst.append(&buf[0], buf.size() - dst_size);
|
||||
}
|
||||
std::string output;
|
||||
dst.swap(output);
|
||||
return output;
|
||||
}
|
||||
|
||||
void gptbackend::iconv_wrapper::check_conversion_error() {
|
||||
switch (errno) {
|
||||
case EBADF: {
|
||||
std::cout << "EBADF" << std::endl;
|
||||
break;
|
||||
}
|
||||
case E2BIG: {
|
||||
std::cout << "E2BIG" << std::endl;
|
||||
break;
|
||||
}
|
||||
case EILSEQ: {
|
||||
std::cout << "EILSEQ" << std::endl;
|
||||
break;
|
||||
}
|
||||
case EINVAL: {
|
||||
std::cout << "EINVAL" << std::endl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
std::cout << "Unknown error " << errno << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
63
gpgui/libgptbackend/preg/include/iconv_wrapper.h
Normal file
63
gpgui/libgptbackend/preg/include/iconv_wrapper.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_ICONV_WRAPPER)
|
||||
#define __GPTBACKEND_ICONV_WRAPPER 1
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <iconv.h>
|
||||
|
||||
namespace gptbackend {
|
||||
|
||||
/**
|
||||
* Wrapper for POSIX iconv functionality to ease the access from C++
|
||||
* and provide a convenient way to operate on std::string buffers.
|
||||
*/
|
||||
class iconv_wrapper {
|
||||
/* C++ reinterpret_cast<> and static_cast<> can't be used in
|
||||
* this case */
|
||||
const iconv_t invalid_open = (iconv_t)-1;
|
||||
|
||||
/* Disable copy since iconv_t can't duplicate */
|
||||
iconv_wrapper(iconv_wrapper const &) = delete;
|
||||
iconv_wrapper &operator=(iconv_wrapper const &) = delete;
|
||||
|
||||
iconv_t conv;
|
||||
std::string from_encoding;
|
||||
std::string to_encoding;
|
||||
|
||||
public:
|
||||
iconv_wrapper(std::string from_encoding, std::string to_encoding);
|
||||
~iconv_wrapper();
|
||||
|
||||
/**
|
||||
* Convert std::string to another format.
|
||||
*/
|
||||
std::string convert(std::string from);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Check if there were conversion errors.
|
||||
*/
|
||||
void check_conversion_error();
|
||||
}; /* class iconv_wrapper */
|
||||
|
||||
} /* namespace gptbackend */
|
||||
|
||||
#endif /* __GPTBACKEND_ICONV_WRAPPER */
|
93
gpgui/libgptbackend/preg/include/preg_data.h
Normal file
93
gpgui/libgptbackend/preg/include/preg_data.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_PREG_DATA)
|
||||
#define __GPTBACKEND_PREG_DATA 1
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <exception>
|
||||
|
||||
namespace preg {
|
||||
|
||||
/* Same as REG_BINARY */
|
||||
const uint32_t REG_NONE = 0;
|
||||
|
||||
/* Null-terminated-string */
|
||||
const uint32_t REG_SZ = 1;
|
||||
|
||||
/* A null-terminated UTF16-LE or ANSI string that contains unexpanded
|
||||
* references to environment variables. */
|
||||
const uint32_t REG_EXPAND_SZ = 2;
|
||||
|
||||
/* Any kind of binary data */
|
||||
const uint32_t REG_BINARY = 3;
|
||||
|
||||
/* 32-bit number */
|
||||
const uint32_t REG_DWORD_LITTLE_ENDIAN = 4;
|
||||
|
||||
/* 32-bit number in NBO format */
|
||||
const uint32_t REG_DWORD_BIG_ENDIAN = 5;
|
||||
|
||||
/* A null-terminated Unicode string that contains the target path of a
|
||||
* symbolic link. */
|
||||
const uint32_t REG_LINK = 6;
|
||||
|
||||
/* Sequence of null-terminated strings terminated by null-terminator */
|
||||
const uint32_t REG_MULTI_SZ = 7;
|
||||
const uint32_t REG_RESOURCE_LIST = 8;
|
||||
const uint32_t REG_FULL_RESOURCE_DESCRIPTOR = 9;
|
||||
const uint32_t REG_RESOURCE_REQUIREMENTS_LIST = 10;
|
||||
const uint32_t REG_QWORD = 11;
|
||||
const uint32_t REG_QWORD_LITTLE_ENDIAN = 12;
|
||||
|
||||
struct entry {
|
||||
std::string value_name;
|
||||
std::string key_name;
|
||||
uint32_t type;
|
||||
uint32_t size;
|
||||
char *value;
|
||||
};
|
||||
|
||||
class invalid_magic: public std::exception {
|
||||
virtual const char *what() const throw();
|
||||
}; /* class invalid_magic */
|
||||
|
||||
class invalid_version: public std::exception {
|
||||
virtual const char *what() const throw();
|
||||
}; /* class invalid_version */
|
||||
|
||||
class no_more_entries: public std::exception {
|
||||
virtual const char *what() const throw();
|
||||
}; /* class no_more_entries */
|
||||
|
||||
/**
|
||||
* Convert PReg type value from DWORD into string representation. May
|
||||
* be useful when operating on PReg files from GUI.
|
||||
*/
|
||||
std::string regtype2str(uint32_t ®type);
|
||||
|
||||
/**
|
||||
* Convert PReg type string representation into DWORD. May be useful
|
||||
* when serializing data.
|
||||
*/
|
||||
uint32_t str2regtype(std::string ®type);
|
||||
|
||||
} /* namespace preg */
|
||||
|
||||
#endif /* __GPTBACKEND_PREG_DATA */
|
71
gpgui/libgptbackend/preg/include/preg_parser.h
Normal file
71
gpgui/libgptbackend/preg/include/preg_parser.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_PREG_PARSER)
|
||||
#define __GPTBACKEND_PREG_PARSER 1
|
||||
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "preg_data.h"
|
||||
|
||||
namespace preg {
|
||||
|
||||
/* This thing contains offsets for PReg file pointing to '[' and ']'
|
||||
* characters. This structure is internal to preg_parser. */
|
||||
struct key_entry {
|
||||
size_t start_offset;
|
||||
size_t end_offset;
|
||||
};
|
||||
|
||||
uint16_t buffer2uint16(const char *type_buffer);
|
||||
uint32_t buffer2uint32(const char *type_buffer);
|
||||
uint32_t parse_type(const char *type_buffer);
|
||||
|
||||
class preg_parser {
|
||||
std::ifstream polfile;
|
||||
std::string file_path;
|
||||
size_t raw_file_size = 0;
|
||||
char header[4];
|
||||
char version[4];
|
||||
size_t next_entry_start_offset = 8;
|
||||
|
||||
public:
|
||||
preg_parser(std::string &file_path);
|
||||
entry get_next_entry();
|
||||
|
||||
protected:
|
||||
void load_regpol(std::string &file_path);
|
||||
void read_header();
|
||||
void read_version();
|
||||
void check_header();
|
||||
void check_version();
|
||||
char read_byte(size_t abs_file_start_offset);
|
||||
size_t seek_next_separator(size_t abs_file_start_offset);
|
||||
key_entry get_next_key_entry();
|
||||
entry read_entry(key_entry kentry);
|
||||
std::string strip_square_braces(key_entry kentry);
|
||||
std::vector<std::string> split_entry(key_entry kentry);
|
||||
};
|
||||
|
||||
} /* namespace preg */
|
||||
|
||||
#endif /* __GPTBACKEND_PREG_PARSER */
|
51
gpgui/libgptbackend/preg/include/preg_writer.h
Normal file
51
gpgui/libgptbackend/preg/include/preg_writer.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_PREG_WRITER)
|
||||
#define __GPTBACKEND_PREG_WRITER 1
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "preg_data.h"
|
||||
|
||||
namespace preg {
|
||||
|
||||
class preg_writer {
|
||||
std::ofstream preg_file;
|
||||
char preg_magic[4]{ 'P', 'R', 'e', 'g' };
|
||||
char preg_version[4]{ '\x01', '\x00', '\x00', '\x00' };
|
||||
|
||||
public:
|
||||
preg_writer(std::string &preg_file);
|
||||
~preg_writer();
|
||||
|
||||
void add_entry(preg::entry &pentry);
|
||||
|
||||
void close();
|
||||
|
||||
private:
|
||||
void preg_type2buf(uint16_t type);
|
||||
}; /* class preg_writer */
|
||||
|
||||
} /* namespace preg */
|
||||
|
||||
#endif /* namespace preg */
|
||||
|
144
gpgui/libgptbackend/preg/preg_data.cpp
Normal file
144
gpgui/libgptbackend/preg/preg_data.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "preg_data.h"
|
||||
#include "config.h"
|
||||
|
||||
std::string preg::regtype2str(uint32_t ®type) {
|
||||
std::string result = "UNKNOWN";
|
||||
|
||||
switch (regtype) {
|
||||
case preg::REG_NONE: {
|
||||
result = "REG_NONE";
|
||||
break;
|
||||
}
|
||||
case preg::REG_SZ: {
|
||||
result = "REG_SZ";
|
||||
break;
|
||||
}
|
||||
case preg::REG_EXPAND_SZ: {
|
||||
result = "REG_EXPAND_SZ";
|
||||
break;
|
||||
}
|
||||
case preg::REG_BINARY: {
|
||||
result = "REG_BINARY";
|
||||
break;
|
||||
}
|
||||
case preg::REG_DWORD_LITTLE_ENDIAN: {
|
||||
result = "REG_DWORD_LITTLE_ENDIAN";
|
||||
break;
|
||||
}
|
||||
case preg::REG_DWORD_BIG_ENDIAN: {
|
||||
result = "REG_DWORD_BIG_ENDIAN";
|
||||
break;
|
||||
}
|
||||
case preg::REG_LINK: {
|
||||
result = "REG_LINK";
|
||||
break;
|
||||
}
|
||||
case preg::REG_MULTI_SZ: {
|
||||
result = "REG_MULTI_SZ";
|
||||
break;
|
||||
}
|
||||
case preg::REG_RESOURCE_LIST: {
|
||||
result = "REG_RESOURCE_LIST";
|
||||
break;
|
||||
}
|
||||
case preg::REG_FULL_RESOURCE_DESCRIPTOR: {
|
||||
result = "REG_FULL_RESOURCE_DESCRIPTOR";
|
||||
break;
|
||||
}
|
||||
case preg::REG_RESOURCE_REQUIREMENTS_LIST: {
|
||||
result = "REG_RESOURCE_REQUIREMENTS_LIST";
|
||||
break;
|
||||
}
|
||||
case preg::REG_QWORD: {
|
||||
result = "REG_QWORD";
|
||||
break;
|
||||
}
|
||||
case preg::REG_QWORD_LITTLE_ENDIAN: {
|
||||
result = "REG_QWORD_LITTLE_ENDIAN";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
result = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
} /* switch (regtype) */
|
||||
|
||||
return result;
|
||||
} /* std::string preg::regtype2str(uint16_t ®type) */
|
||||
|
||||
uint32_t preg::str2regtype(std::string ®type) {
|
||||
uint32_t result = 0;
|
||||
|
||||
if ("REG_NONE" == regtype) {
|
||||
result = preg::REG_NONE;
|
||||
}
|
||||
if ("REG_SZ" == regtype) {
|
||||
result = preg::REG_SZ;
|
||||
}
|
||||
if ("REG_EXPAND_SZ" == regtype) {
|
||||
result = preg::REG_EXPAND_SZ;
|
||||
}
|
||||
if ("REG_BINARY" == regtype) {
|
||||
result = preg::REG_BINARY;
|
||||
}
|
||||
if ("REG_DWORD_LITTLE_ENDIAN" == regtype || "REG_DWORD" == regtype) {
|
||||
result = preg::REG_DWORD_LITTLE_ENDIAN;
|
||||
}
|
||||
if ("REG_DWORD_BIG_ENDIAN" == regtype) {
|
||||
result = preg::REG_DWORD_BIG_ENDIAN;
|
||||
}
|
||||
if ("REG_LINK" == regtype) {
|
||||
result = preg::REG_LINK;
|
||||
}
|
||||
if ("REG_MULTI_SZ" == regtype) {
|
||||
result = preg::REG_MULTI_SZ;
|
||||
}
|
||||
if ("REG_RESOURCE_LIST" == regtype) {
|
||||
result = preg::REG_RESOURCE_LIST;
|
||||
}
|
||||
if ("REG_FULL_RESOURCE_DESCRIPTOR" == regtype) {
|
||||
result = preg::REG_FULL_RESOURCE_DESCRIPTOR;
|
||||
}
|
||||
if ("REG_RESOURCE_REQUIREMENTS_LIST" == regtype) {
|
||||
result = preg::REG_RESOURCE_REQUIREMENTS_LIST;
|
||||
}
|
||||
if ("REG_QWORD" == regtype) {
|
||||
result = preg::REG_QWORD;
|
||||
}
|
||||
if ("REG_QWORD_LITTLE_ENDIAN" == regtype) {
|
||||
result = preg::REG_QWORD_LITTLE_ENDIAN;
|
||||
}
|
||||
|
||||
return result;
|
||||
} /* uint16_t preg::str2regtype(std::string ®type) */
|
||||
|
||||
const char *preg::invalid_magic::what() const throw() {
|
||||
return "Invalid PReg file magic value";
|
||||
}
|
||||
|
||||
const char *preg::invalid_version::what() const throw() {
|
||||
return "Invalid PReg file version";
|
||||
}
|
||||
|
||||
const char *preg::no_more_entries::what() const throw() {
|
||||
return "No more PReg entries";
|
||||
}
|
||||
|
256
gpgui/libgptbackend/preg/preg_parser.cpp
Normal file
256
gpgui/libgptbackend/preg/preg_parser.cpp
Normal file
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "preg_parser.h"
|
||||
#include "config.h"
|
||||
#include "iconv_wrapper.h"
|
||||
|
||||
uint16_t preg::buffer2uint16(const char *type_buffer) {
|
||||
uint16_t num =
|
||||
static_cast<uint16_t>(static_cast<unsigned char>(type_buffer[1]) << 8 |
|
||||
static_cast<unsigned char>(type_buffer[0]));
|
||||
return num;
|
||||
}
|
||||
|
||||
uint32_t preg::buffer2uint32(const char *type_buffer) {
|
||||
uint32_t num =
|
||||
static_cast<uint32_t>(static_cast<unsigned char>(type_buffer[3]) << 24 |
|
||||
static_cast<unsigned char>(type_buffer[2]) << 16 |
|
||||
static_cast<unsigned char>(type_buffer[1]) << 8 |
|
||||
static_cast<unsigned char>(type_buffer[0]));
|
||||
return num;
|
||||
}
|
||||
uint32_t preg::parse_type(const char *type_buffer) {
|
||||
return preg::buffer2uint32(type_buffer);
|
||||
}
|
||||
|
||||
preg::preg_parser::preg_parser(std::string &file_path) {
|
||||
this->file_path = file_path;
|
||||
|
||||
this->load_regpol(this->file_path);
|
||||
}
|
||||
|
||||
void preg::preg_parser::load_regpol(std::string &file_path) {
|
||||
this->polfile.open(file_path,
|
||||
std::ios::in | std::ios::binary | std::ios::ate);
|
||||
if (this->polfile.good()) {
|
||||
this->polfile.seekg(0, std::ios::end); /* Go to the end of file */
|
||||
this->raw_file_size = this->polfile.tellg(); /* Get file length */
|
||||
|
||||
this->polfile.seekg(0,
|
||||
std::ios::beg); /* Set file position to beginning */
|
||||
|
||||
this->read_header();
|
||||
this->read_version();
|
||||
}
|
||||
}
|
||||
|
||||
void preg::preg_parser::read_header() {
|
||||
if (this->polfile.good() && 4 < this->raw_file_size) {
|
||||
this->polfile.seekg(0,
|
||||
std::ios::beg); /* Set file position to beginning */
|
||||
this->polfile.read(this->header, 4); /* Read first 4 bytes */
|
||||
}
|
||||
this->check_header();
|
||||
}
|
||||
|
||||
void preg::preg_parser::read_version() {
|
||||
if (this->polfile.good() && 8 < this->raw_file_size) {
|
||||
/* Read bytes 4-7 of the file */
|
||||
this->polfile.seekg(4, std::ios::beg);
|
||||
this->polfile.read(this->version, 4);
|
||||
}
|
||||
this->check_version();
|
||||
}
|
||||
|
||||
void preg::preg_parser::check_header() {
|
||||
if ('P' == this->header[0] && 'R' == this->header[1] &&
|
||||
'e' == this->header[2] && 'g' == this->header[3]) {
|
||||
std::cout << "Preg success" << std::endl;
|
||||
} else {
|
||||
throw preg::invalid_magic();
|
||||
}
|
||||
}
|
||||
|
||||
void preg::preg_parser::check_version() {
|
||||
if (1 == this->version[0] && 0 == this->version[1] &&
|
||||
0 == this->version[2] && 0 == this->version[3]) {
|
||||
std::cout << "Version correct" << std::endl;
|
||||
} else {
|
||||
throw preg::invalid_version();
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool is_range_start(char symbol) {
|
||||
if ('[' == symbol) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_range_end(char symbol) {
|
||||
if (']' == symbol) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_preg_entry_separator(char symbol) {
|
||||
if (';' == symbol) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
char preg::preg_parser::read_byte(size_t abs_file_start_offset) {
|
||||
char symbol;
|
||||
if (abs_file_start_offset < this->raw_file_size) {
|
||||
this->polfile.seekg(abs_file_start_offset, std::ios::beg);
|
||||
this->polfile.read(&symbol, 1);
|
||||
}
|
||||
// FIXME: Else throw exception.
|
||||
return symbol;
|
||||
}
|
||||
|
||||
size_t preg::preg_parser::seek_next_separator(size_t abs_file_start_offset) {
|
||||
size_t end_offset = abs_file_start_offset;
|
||||
if (abs_file_start_offset < this->raw_file_size) {
|
||||
char sym_buf;
|
||||
for (size_t abs_file_offset = abs_file_start_offset;
|
||||
abs_file_offset <= this->raw_file_size; abs_file_offset++) {
|
||||
sym_buf = this->read_byte(abs_file_offset);
|
||||
if (is_range_start(sym_buf) || is_preg_entry_separator(sym_buf) ||
|
||||
is_range_end(sym_buf) ||
|
||||
abs_file_offset == this->raw_file_size) {
|
||||
|
||||
end_offset = abs_file_offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
end_offset = this->raw_file_size;
|
||||
}
|
||||
return end_offset;
|
||||
}
|
||||
|
||||
preg::key_entry preg::preg_parser::get_next_key_entry() {
|
||||
preg::key_entry entry;
|
||||
entry.start_offset = this->next_entry_start_offset;
|
||||
entry.end_offset = this->next_entry_start_offset;
|
||||
|
||||
std::cout << "Starting at " << this->next_entry_start_offset
|
||||
<< " and the next separator is at "
|
||||
<< this->seek_next_separator(this->next_entry_start_offset)
|
||||
<< std::endl;
|
||||
|
||||
/* Check if we're not at the end of file */
|
||||
if (this->next_entry_start_offset < this->raw_file_size) {
|
||||
char range_init = this->read_byte(this->next_entry_start_offset);
|
||||
|
||||
/* Check that we're at the beginning of the entry we
|
||||
* want to parse */
|
||||
if (is_range_start(range_init)) {
|
||||
std::cout << "Range start found at "
|
||||
<< this->next_entry_start_offset << std::endl;
|
||||
char sym_buf;
|
||||
|
||||
/* Read file byte by byte seeking for the end of entry */
|
||||
for (size_t offset = this->next_entry_start_offset + 1;
|
||||
offset <= this->raw_file_size; offset++) {
|
||||
sym_buf = this->read_byte(offset);
|
||||
|
||||
/* Build and return the entry if we're found its end */
|
||||
if (is_range_end(sym_buf)) {
|
||||
std::cout << "Found range end at position: " << offset
|
||||
<< std::endl;
|
||||
entry.end_offset = offset + 2;
|
||||
this->next_entry_start_offset = offset + 2;
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw preg::no_more_entries();
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
preg::entry preg::preg_parser::read_entry(preg::key_entry kentry) {
|
||||
preg::entry appentry;
|
||||
std::vector<std::string> results = this->split_entry(kentry);
|
||||
std::cout << "Elements in split entry: " << (int)results.size()
|
||||
<< std::endl;
|
||||
|
||||
/* We also need converter from UTF-16 to UTF-8 */
|
||||
gptbackend::iconv_wrapper iwrapper("UTF-16LE", "UTF-8");
|
||||
|
||||
std::string vn = iwrapper.convert(results.at(0));
|
||||
std::string kn = iwrapper.convert(results.at(1));
|
||||
appentry.value_name = std::string(vn, 0, vn.length() - 1);
|
||||
appentry.key_name = std::string(kn, 0, kn.length() - 1);
|
||||
std::cout << "Value name " << appentry.value_name << std::endl;
|
||||
std::cout << "Key name " << appentry.key_name << std::endl;
|
||||
appentry.type = preg::parse_type(results.at(2).c_str());
|
||||
std::cout << "Type " << preg::regtype2str(appentry.type) << std::endl;
|
||||
appentry.size = preg::buffer2uint32(results.at(3).c_str());
|
||||
appentry.value = const_cast<char*>(results.at(4).c_str());
|
||||
std::cout << "Size " << appentry.size << std::endl;
|
||||
std::cout << "Value " << appentry.value << std::endl;
|
||||
|
||||
return appentry;
|
||||
}
|
||||
|
||||
preg::entry preg::preg_parser::get_next_entry() {
|
||||
return this->read_entry(this->get_next_key_entry());
|
||||
}
|
||||
|
||||
std::string preg::preg_parser::strip_square_braces(preg::key_entry kentry) {
|
||||
size_t entry_size = (kentry.end_offset - 2) - (kentry.start_offset + 2);
|
||||
char *entry_buffer = new char[entry_size];
|
||||
this->polfile.seekg((kentry.start_offset + 2));
|
||||
this->polfile.read(entry_buffer, entry_size);
|
||||
std::string bufstring(entry_buffer, entry_size);
|
||||
return bufstring;
|
||||
}
|
||||
|
||||
std::vector<std::string>
|
||||
preg::preg_parser::split_entry(preg::key_entry kentry) {
|
||||
std::string bufstring = this->strip_square_braces(kentry);
|
||||
const char *raw_buffer = bufstring.c_str();
|
||||
std::vector<std::string> results;
|
||||
|
||||
size_t offset = 0;
|
||||
for (size_t i = 0; i <= bufstring.length(); i++) {
|
||||
// std::cout << "[" << i << "] = (" << (int)raw_buffer[i] << "] " <<
|
||||
// raw_buffer[i] << std::endl;
|
||||
if (is_preg_entry_separator(raw_buffer[i]) || i == bufstring.length()) {
|
||||
size_t split_length = i - offset;
|
||||
std::string buf = std::string(bufstring, offset, split_length);
|
||||
results.push_back(buf);
|
||||
offset = i + 2; // Skip separator
|
||||
/*if (is_range_end(raw_buffer[i]) || i == bufstring.length()) {
|
||||
break;
|
||||
}*/
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
83
gpgui/libgptbackend/preg/preg_writer.cpp
Normal file
83
gpgui/libgptbackend/preg/preg_writer.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "preg_writer.h"
|
||||
#include "iconv_wrapper.h"
|
||||
|
||||
preg::preg_writer::preg_writer(std::string &preg_file) {
|
||||
this->preg_file = std::ofstream(preg_file, std::ios::out | std::ios::binary);
|
||||
this->preg_file.write(this->preg_magic, 4);
|
||||
this->preg_file.write(this->preg_version, 4);
|
||||
// FIXME: Throw exception if not this->preg_file.good()
|
||||
} /* preg::preg_writer::preg_writer() */
|
||||
|
||||
preg::preg_writer::~preg_writer() {
|
||||
this->close();
|
||||
} /* preg::preg_writer::~preg_writer() */
|
||||
|
||||
void preg::preg_writer::close() {
|
||||
if (this->preg_file) {
|
||||
this->preg_file.close();
|
||||
}
|
||||
} /* preg::preg_writer::close() */
|
||||
|
||||
void preg::preg_writer::add_entry(preg::entry &pentry) {
|
||||
char null_terminator[2]{ '\x00', '\x00' };
|
||||
char separator[2]{ ';', '\x00' };
|
||||
char range_start[2]{ '[', '\x00' };
|
||||
char range_end[2]{ ']', '\x00' };
|
||||
|
||||
gptbackend::iconv_wrapper iw("UTF-8", "UTF-16LE");
|
||||
|
||||
std::string conv_value_name = iw.convert(pentry.value_name);
|
||||
std::string conv_key_name = iw.convert(pentry.key_name);
|
||||
|
||||
const char *value_name = conv_value_name.c_str();
|
||||
size_t value_name_size = conv_value_name.length() * sizeof(char);
|
||||
|
||||
const char *key_name = conv_key_name.c_str();
|
||||
size_t key_name_size = conv_key_name.length() * sizeof(char);
|
||||
|
||||
char type[2];
|
||||
type[0] = pentry.type & 0xFF;
|
||||
type[1] = pentry.type >> 8;
|
||||
|
||||
char size[4];
|
||||
size[0] = pentry.size & 0xFF;
|
||||
size[1] = pentry.size >> 8;
|
||||
size[2] = pentry.size >> 16;
|
||||
size[3] = pentry.size >> 24;
|
||||
|
||||
// FIXME: Make streambuf out of data and then write it at once.
|
||||
this->preg_file.write(range_start, 2);
|
||||
this->preg_file.write(value_name, value_name_size);
|
||||
this->preg_file.write(null_terminator, 2);
|
||||
this->preg_file.write(separator, 2);
|
||||
this->preg_file.write(key_name, key_name_size);
|
||||
this->preg_file.write(null_terminator, 2);
|
||||
this->preg_file.write(separator, 2);
|
||||
this->preg_file.write(type, 2);
|
||||
this->preg_file.write(null_terminator, 2);
|
||||
this->preg_file.write(separator, 2);
|
||||
this->preg_file.write(size, 4);
|
||||
this->preg_file.write(separator, 2);
|
||||
this->preg_file.write(pentry.value, pentry.size);
|
||||
this->preg_file.write(range_end, 2);
|
||||
} /* void preg::preg_writer::add_entry() */
|
||||
|
34
gpgui/libgptbackend/reg/include/reg.h
Normal file
34
gpgui/libgptbackend/reg/include/reg.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_REG_H)
|
||||
#define __GPTBACKEND_REG_H 1
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace reg {
|
||||
|
||||
class reg_writer {
|
||||
public:
|
||||
reg_writer(std::string file_path);
|
||||
};
|
||||
|
||||
} /* namespace reg */
|
||||
|
||||
#endif /* __GPTBACKEND_REG_H */
|
||||
|
22
gpgui/libgptbackend/reg/reg.cpp
Normal file
22
gpgui/libgptbackend/reg/reg.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "reg.h"
|
||||
#include "config.h"
|
||||
|
||||
reg::reg_writer::reg_writer(std::string file_path) {}
|
26
gpgui/libgptbackend/sambaxml/include/preg_xml.h
Normal file
26
gpgui/libgptbackend/sambaxml/include/preg_xml.h
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if !defined(__GPTBACKEND_PREG_XML)
|
||||
# define __GPTBACKEND_PREG_XML 1
|
||||
|
||||
namespace preg {
|
||||
};
|
||||
|
||||
#endif /* __GPTBACKEND_PREG_XML */
|
||||
|
18
gpgui/libgptbackend/sambaxml/preg_xml.cpp
Normal file
18
gpgui/libgptbackend/sambaxml/preg_xml.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
BIN
gpgui/libgptbackend/test/Registry.pol
Normal file
BIN
gpgui/libgptbackend/test/Registry.pol
Normal file
Binary file not shown.
60
gpgui/libgptbackend/test/main.cpp
Normal file
60
gpgui/libgptbackend/test/main.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "config.h"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "iconv_wrapper.h"
|
||||
#include "preg_parser.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
TEST_CASE("It is possible to convert UTF-8 string to UTF-16LE",
|
||||
"[iconv_wrapper]") {
|
||||
std::string test_str_utf8 = "Software\\BaseALT\\Policies\\Control";
|
||||
std::string test_str_utf16le{
|
||||
'S', '\x00', 'o', '\x00', 'f', '\x00', 't', '\x00', 'w', '\x00',
|
||||
'a', '\x00', 'r', '\x00', 'e', '\x00', '\\', '\x00', 'B', '\x00',
|
||||
'a', '\x00', 's', '\x00', 'e', '\x00', 'A', '\x00', 'L', '\x00',
|
||||
'T', '\x00', '\\', '\x00', 'P', '\x00', 'o', '\x00', 'l', '\x00',
|
||||
'i', '\x00', 'c', '\x00', 'i', '\x00', 'e', '\x00', 's', '\x00',
|
||||
'\\', '\x00', 'C', '\x00', 'o', '\x00', 'n', '\x00', 't', '\x00',
|
||||
'r', '\x00', 'o', '\x00', 'l', '\x00'};
|
||||
{
|
||||
gptbackend::iconv_wrapper iwrapper("UTF-8", "UTF-16LE");
|
||||
REQUIRE(test_str_utf16le == iwrapper.convert(test_str_utf8));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("It is possile to convert UTF-16LE string to UTF-8",
|
||||
"[iconv_wrapper]") {
|
||||
std::string test_str_utf8 = "Software\\BaseALT\\Policies\\Control";
|
||||
std::string test_str_utf16le{
|
||||
'S', '\x00', 'o', '\x00', 'f', '\x00', 't', '\x00', 'w', '\x00',
|
||||
'a', '\x00', 'r', '\x00', 'e', '\x00', '\\', '\x00', 'B', '\x00',
|
||||
'a', '\x00', 's', '\x00', 'e', '\x00', 'A', '\x00', 'L', '\x00',
|
||||
'T', '\x00', '\\', '\x00', 'P', '\x00', 'o', '\x00', 'l', '\x00',
|
||||
'i', '\x00', 'c', '\x00', 'i', '\x00', 'e', '\x00', 's', '\x00',
|
||||
'\\', '\x00', 'C', '\x00', 'o', '\x00', 'n', '\x00', 't', '\x00',
|
||||
'r', '\x00', 'o', '\x00', 'l', '\x00'};
|
||||
{
|
||||
gptbackend::iconv_wrapper iwrapper2("UTF-16LE", "UTF-8");
|
||||
REQUIRE(test_str_utf8 == iwrapper2.convert(test_str_utf16le));
|
||||
}
|
||||
}
|
8
gpgui/libgptbackend/test/print_binfile
Executable file
8
gpgui/libgptbackend/test/print_binfile
Executable file
@ -0,0 +1,8 @@
|
||||
#! /usr/bin/env python3.6
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open("Registry.pol", 'rb') as f:
|
||||
byte = None
|
||||
while byte != b'':
|
||||
byte = f.read(1)
|
||||
print('[{}] {}'.format(ord(byte), str(byte)))
|
165
gpgui/libgptbackend/test/test_preg_data.cpp
Normal file
165
gpgui/libgptbackend/test/test_preg_data.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "preg_data.h"
|
||||
|
||||
TEST_CASE("Convert 0 to REG_NONE", "[regtype2str]") {
|
||||
uint32_t regtype = 0;
|
||||
REQUIRE("REG_NONE" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 1 to REG_SZ", "[regtype2str]") {
|
||||
uint32_t regtype = 1;
|
||||
REQUIRE("REG_SZ" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 2 to REG_EXPAND_SZ", "[regtype2str]") {
|
||||
uint32_t regtype = 2;
|
||||
REQUIRE("REG_EXPAND_SZ" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 3 to REG_BINARY", "[regtype2str]") {
|
||||
uint32_t regtype = 3;
|
||||
REQUIRE("REG_BINARY" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 4 to REG_DWORD_LITTLE_ENDIAN", "[regtype2str]") {
|
||||
uint32_t regtype = 4;
|
||||
REQUIRE("REG_DWORD_LITTLE_ENDIAN" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 5 to REG_DWORD_BIG_ENDIAN", "[regtype2str]") {
|
||||
uint32_t regtype = 5;
|
||||
REQUIRE("REG_DWORD_BIG_ENDIAN" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 6 to REG_LINK", "[regtype2str]") {
|
||||
uint32_t regtype = 6;
|
||||
REQUIRE("REG_LINK" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 7 to REG_MULTI_SZ", "[regtype2str]") {
|
||||
uint32_t regtype = 7;
|
||||
REQUIRE("REG_MULTI_SZ" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 8 to REG_RESOURCE_LIST", "[regtype2str]") {
|
||||
uint32_t regtype = 8;
|
||||
REQUIRE("REG_RESOURCE_LIST" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 9 to REG_FULL_RESOURCE_DESCRIPTOR", "[regtype2str]") {
|
||||
uint32_t regtype = 9;
|
||||
REQUIRE("REG_FULL_RESOURCE_DESCRIPTOR" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 10 to REG_RESOURCE_REQUIREMENTS_LIST", "[regtype2str]") {
|
||||
uint32_t regtype = 10;
|
||||
REQUIRE("REG_RESOURCE_REQUIREMENTS_LIST" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 11 to REG_QWORD", "[regtype2str]") {
|
||||
uint32_t regtype = 11;
|
||||
REQUIRE("REG_QWORD" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert 12 to REG_QWORD_LITTLE_ENDIAN", "[regtype2str]") {
|
||||
uint32_t regtype = 12;
|
||||
REQUIRE("REG_QWORD_LITTLE_ENDIAN" == preg::regtype2str(regtype));
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_NONE to 0", "[str2regtype]") {
|
||||
const uint32_t regtype = 0;
|
||||
std::string regname = "REG_NONE";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_SZ to 1", "[str2regtype]") {
|
||||
const uint32_t regtype = 1;
|
||||
std::string regname = "REG_SZ";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_EXPAND_SZ to 2", "[str2regtype]") {
|
||||
const uint32_t regtype = 2;
|
||||
std::string regname = "REG_EXPAND_SZ";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_BINARY to 3", "[str2regtype]") {
|
||||
const uint32_t regtype = 3;
|
||||
std::string regname = "REG_BINARY";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_DWORD_LITTLE_ENDIAN to 4", "[str2regtype]") {
|
||||
const uint32_t regtype = 4;
|
||||
std::string regname = "REG_DWORD_LITTLE_ENDIAN";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_DWORD_BIG_ENDIAN to 5", "[str2regtype]") {
|
||||
const uint32_t regtype = 5;
|
||||
std::string regname = "REG_DWORD_BIG_ENDIAN";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_LINK to 6", "[str2regtype]") {
|
||||
const uint32_t regtype = 6;
|
||||
std::string regname = "REG_LINK";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_MULTI_SZ to 7", "[str2regtype]") {
|
||||
const uint32_t regtype = 7;
|
||||
std::string regname = "REG_MULTI_SZ";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_RESOURCE_LIST to 8", "[str2regtype]") {
|
||||
const uint32_t regtype = 8;
|
||||
std::string regname = "REG_RESOURCE_LIST";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_FULL_RESOURCE_DESCRIPTOR to 9", "[regtype2str]") {
|
||||
const uint32_t regtype = 9;
|
||||
std::string regname = "REG_FULL_RESOURCE_DESCRIPTOR";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_RESOURCE_REQUIREMENTS_LIST to 10", "[str2regtype]") {
|
||||
const uint32_t regtype = 10;
|
||||
std::string regname = "REG_RESOURCE_REQUIREMENTS_LIST";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_QWORD to 11", "[str2regtype]") {
|
||||
const uint32_t regtype = 11;
|
||||
std::string regname = "REG_QWORD";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
||||
|
||||
TEST_CASE("Convert REG_QWORD_LITTLE_ENDIAN to 12", "[str2regtype]") {
|
||||
const uint32_t regtype = 12;
|
||||
std::string regname = "REG_QWORD_LITTLE_ENDIAN";
|
||||
REQUIRE(preg::str2regtype(regname) == regtype);
|
||||
}
|
37
gpgui/libgptbackend/test/test_preg_writer.cpp
Normal file
37
gpgui/libgptbackend/test/test_preg_writer.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <catch2/catch.hpp>
|
||||
#include "preg_writer.h"
|
||||
|
||||
TEST_CASE("Test if PReg file may be written to disk", "[preg_writer]" /*"[!hide]"*/) {
|
||||
preg::entry pe;
|
||||
pe.value_name = "Software\\BaseALT\\Policies\\Control";
|
||||
pe.key_name = "sudo";
|
||||
pe.type = 4;
|
||||
pe.size = 5;
|
||||
pe.value = new char[5]{ 'T', 'e', 's', 't', '1' };
|
||||
|
||||
std::string preg_path = "test.pol";
|
||||
|
||||
{
|
||||
preg::preg_writer pw(preg_path);
|
||||
pw.add_entry(pe);
|
||||
}
|
||||
}
|
||||
|
31
gpgui/main.cpp
Normal file
31
gpgui/main.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* GPGUI - Group Policy Editor GUI
|
||||
*
|
||||
* Copyright (C) 2020 BaseALT Ltd.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Runner.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::unique_ptr<Runner> app(new Runner(
|
||||
argc, argv, GPGUI_APPLICATION_DISPLAY_NAME, GPGUI_APPLICATION_NAME,
|
||||
GPGUI_VERSION, GPGUI_ORGANIZATION, GPGUI_ORGANIZATION_DOMAIN));
|
||||
return app->run();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user