0

I'm trying to run the hardcoded base64 .exe file in a Detached process.

What I'm trying now is:

void Read(QString file){
    QProcess process;
    process.startDetached(file);

}
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QByteArray exe = QByteArray::fromBase64("TVqQAAMAAAAEAAAA...."); //base64 of .exe file

    QString s = exe.data();
    qDebug() << s ;
    Read(s);
    return a.exec();
}

not working, debug shows : "MZ?"

xoom
  • 63
  • 1
  • 9
  • QProcess runs an executable based on its *filename*, not the binary data in the executable itself. Even if it did, you can't convert arbitrary binary data into a QString -- there's no reason to assume your binary would be valid UTF-16 encoding. – MrEricSir Jul 15 '15 at 01:00
  • Thank you for the info, is there any way to run/invoke the binary base64 code on the program startup ? – xoom Jul 15 '15 at 01:05
  • You could certainly write it out to a file and execute it. – MrEricSir Jul 15 '15 at 01:21
  • yes, but the main idea is i want to execute without writing to disk. – xoom Jul 15 '15 at 01:30
  • That's not possible with the standard Qt framework. You probably would have to create a RAM disk and run off of that. Not sure though... – mrg95 Jul 15 '15 at 08:14
  • If it's about base64, just use `QByteArray::toBase64` and `QByteArray::fromBase64`. Otherwise, it's tricky and platform-dependent. See [this answer](http://stackoverflow.com/a/305319/344347), for example. – Pavel Strakhov Jul 15 '15 at 12:19
  • @PavelStrakhov Thank you, that is very useful info. – xoom Jul 15 '15 at 15:25

0 Answers0