From fd655784eb6be7f61888a26fec96758513a29c18 Mon Sep 17 00:00:00 2001 From: micio Date: Fri, 8 Jun 2018 09:54:37 +0000 Subject: [PATCH] Bazaar/ProtectEncrypt : identify executable type on windows git-svn-id: svn://ultimatepp.org/upp/trunk@11985 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/ProtectEncrypt/ProtectEncrypt.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bazaar/ProtectEncrypt/ProtectEncrypt.cpp b/bazaar/ProtectEncrypt/ProtectEncrypt.cpp index c624ba0b2..14fbe133e 100644 --- a/bazaar/ProtectEncrypt/ProtectEncrypt.cpp +++ b/bazaar/ProtectEncrypt/ProtectEncrypt.cpp @@ -319,6 +319,27 @@ CONSOLE_APP_MAIN f.GetAll(buf, size); f.Close(); + // on windows, identify automatically the executable type + // (32 or 64 bit) and configure correctly the XED module + // so it's possible to use any build to encrypt both kinds +#ifdef WIN32 // Tom added + int coffindex=*(unsigned int*)&buf[0x3c]; + unsigned short machine=*(unsigned short*)&buf[coffindex+4]; + switch(machine){ + case 0x14c: //i386 + Cout() << "Processing 32-bit i386 executable\n"; + XED.Set32bitMode(); + break; + case 0x8664: // AMD64 + Cout() << "Processing 64-bit AMD64 executable\n"; + XED.Set64bitMode(); + break; + default: + Cout() << "Unknown executable - Cannot process\n"; + return; + } +#endif + // encrypt the application CryptBuf(buf, buf + size, key);