From 4ce96f7e2388a05e9d10d2a99e05b84518114efe Mon Sep 17 00:00:00 2001 From: lordmulder Date: Thu, 2 Feb 2012 04:12:58 +0100 Subject: [PATCH] Check binary type of all tools. --- src/win_main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/win_main.cpp b/src/win_main.cpp index d52a9d4..40b6a1e 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -330,6 +330,18 @@ void MainWindow::init(void) QFile *file = new QFile(QString("%1/toolset/%2").arg(m_appDir, current)); if(file->open(QIODevice::ReadOnly)) { + bool binaryTypeOkay = false; + DWORD binaryType; + if(GetBinaryType(QWCHAR(file->fileName()), &binaryType)) + { + binaryTypeOkay = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY); + } + if(!binaryTypeOkay) + { + QMessageBox::critical(this, tr("Invalid File!"), tr("At least on required tool is not a valid Win32 binary:
%1

Please re-install the program in order to fix the problem!
").arg(QDir::toNativeSeparators(QString("%1/toolset/%2").arg(m_appDir, current))).replace("-", "−")); + qFatal(QString("Binary is invalid: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData()); + close(); qApp->exit(-1); return; + } m_toolsList << file; } else