Bazaar/ProtectEncrypt : identify executable type on windows

git-svn-id: svn://ultimatepp.org/upp/trunk@11985 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2018-06-08 09:54:37 +00:00
parent faba768601
commit fd655784eb

View file

@ -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);