forked from Public-Mirror/Textractor
automatically check for new updates
This commit is contained in:
parent
651cd486eb
commit
c92a67dbe3
@ -18,6 +18,6 @@ set(gui_SRCS
|
||||
${RESOURCE_FILES}
|
||||
)
|
||||
add_executable(${PROJECT_NAME} WIN32 ${gui_SRCS})
|
||||
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
|
||||
target_link_libraries(${PROJECT_NAME} Qt5::Widgets winhttp)
|
||||
|
||||
install_qt5_libs(${PROJECT_NAME})
|
||||
|
@ -31,6 +31,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
[&](TextThread* thread, std::wstring& output) { return SentenceReceived(thread, output); }
|
||||
);
|
||||
Host::AddConsoleOutput(ABOUT);
|
||||
std::thread([] { if (UpdateAvailable(CURRENT_VERSION)) Host::AddConsoleOutput(UPDATE_AVAILABLE); }).detach();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
19
GUI/misc.cpp
19
GUI/misc.cpp
@ -2,6 +2,7 @@
|
||||
#include "const.h"
|
||||
#include "host/util.h"
|
||||
#include <Psapi.h>
|
||||
#include <Winhttp.h>
|
||||
#include <QTextStream>
|
||||
|
||||
QMultiHash<QString, DWORD> GetAllProcesses()
|
||||
@ -248,3 +249,21 @@ QString GenerateCode(HookParam hp, DWORD processId)
|
||||
if (hp.type & DIRECT_READ) return GenerateRCode(hp);
|
||||
else return GenerateHCode(hp, processId);
|
||||
}
|
||||
|
||||
bool UpdateAvailable(std::string currentVersion)
|
||||
{
|
||||
// Queries GitHub releases API https://developer.github.com/v3/repos/releases/ and checks the last release tag to check if it's the same
|
||||
struct InternetHandleCloser { void operator()(void* h) { WinHttpCloseHandle(h); } };
|
||||
if (AutoHandle<InternetHandleCloser> internet = WinHttpOpen(L"Mozilla/5.0 Textractor", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, NULL, NULL, 0))
|
||||
if (AutoHandle<InternetHandleCloser> connection = WinHttpConnect(internet, L"api.github.com", INTERNET_DEFAULT_HTTPS_PORT, 0))
|
||||
if (AutoHandle<InternetHandleCloser> request = WinHttpOpenRequest(connection, L"GET", L"/repos/Artikash/Textractor/releases", NULL, NULL, NULL, WINHTTP_FLAG_SECURE))
|
||||
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
||||
{
|
||||
DWORD bytesRead;
|
||||
char buffer[1000] = {};
|
||||
WinHttpReceiveResponse(request, NULL);
|
||||
WinHttpReadData(request, buffer, 1000, &bytesRead);
|
||||
if (abs(strstr(buffer, "/tag/") - strstr(buffer, currentVersion.c_str())) > 10) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -15,3 +15,4 @@ private:
|
||||
QMultiHash<QString, DWORD> GetAllProcesses();
|
||||
std::optional<HookParam> ParseCode(QString HCode);
|
||||
QString GenerateCode(HookParam hp, DWORD processId);
|
||||
bool UpdateAvailable(std::string currentVersion);
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define CURRENT_VERSION "3.5.1"
|
||||
constexpr auto SELECT_PROCESS = u8"Select Process";
|
||||
constexpr auto ATTACH_INFO = u8"If you don't see the process you want to attach, try running with admin rights\r\n"
|
||||
"You can also type in the process id";
|
||||
@ -20,11 +21,13 @@ constexpr auto UNHOOK = u8"Unhook";
|
||||
constexpr auto REMOVE_HOOK = u8"Which hook to remove?";
|
||||
constexpr auto SELECT_EXTENSION = u8"Select Extension";
|
||||
constexpr auto EXTENSIONS = u8"Extensions (*.dll)";
|
||||
constexpr auto ABOUT = L"Textractor beta v3.5.0 (project homepage: https://github.com/Artikash/Textractor)\r\n"
|
||||
"Made with love by Artikash (email: akashmozumdar@gmail.com)\r\n"
|
||||
"Please contact Artikash with any problems, feature requests, or questions relating to Textractor\r\n"
|
||||
constexpr auto ABOUT = L"Textractor beta v" CURRENT_VERSION " (project homepage: https://github.com/Artikash/Textractor)\r\n"
|
||||
"Made by me: Artikash (email: akashmozumdar@gmail.com)\r\n"
|
||||
"Please contact me with any problems, feature requests, or questions relating to Textractor\r\n"
|
||||
"You can do so via the project homepage (issues section) or via email\r\n"
|
||||
"Source code available under GPLv3 at project homepage";
|
||||
"Source code available under GPLv3 at project homepage\r\n"
|
||||
"I'm currently on the job market: please email me if you're hiring US software engineers";
|
||||
constexpr auto UPDATE_AVAILABLE = L"Update available: download it from https://github.com/Artikash/Textractor/releases";
|
||||
constexpr auto ALREADY_INJECTED = L"Textractor: already injected";
|
||||
constexpr auto ARCHITECTURE_MISMATCH = L"Textractor: architecture mismatch: try 32 bit Textractor instead";
|
||||
constexpr auto INJECT_FAILED = L"Textractor: couldn't inject";
|
||||
|
Loading…
x
Reference in New Issue
Block a user