/** * Append our subdirectories to the Application Path for this * application */ bool RegistryTool::setPathInfo() { Glib::ustring fullPath; Glib::ustring path; Glib::ustring exeName; if (!getExeInfo(fullPath, path, exeName)) return false; //printf("full:'%s' path:'%s' exe:'%s'\n", // fullPath.c_str(), path.c_str(), exeName.c_str()); Glib::ustring keyName = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"; keyName.append(exeName); Glib::ustring valueName = ""; Glib::ustring value = fullPath; if (!setStringValue(keyName, valueName, value)) return false; //add our subdirectories Glib::ustring appPath = path; appPath.append("\\python;"); appPath.append(path); appPath.append("\\perl"); valueName = "Path"; value = appPath; if (!setStringValue(keyName, valueName, value)) return false; return true; }
bool CBNCSUtilInterface :: HELP_SID_AUTH_CHECK( bool TFT, string war3Path, string keyROC, string keyTFT, string valueStringFormula, string mpqFileName, BYTEARRAY clientToken, BYTEARRAY serverToken ) { // set m_EXEVersion, m_EXEVersionHash, m_EXEInfo, m_InfoROC, m_InfoTFT string FileWar3EXE = war3Path + "war3.exe"; string FileStormDLL = war3Path + "Storm.dll"; if( !UTIL_FileExists( FileStormDLL ) ) FileStormDLL = war3Path + "storm.dll"; string FileGameDLL = war3Path + "game.dll"; bool ExistsWar3EXE = UTIL_FileExists( FileWar3EXE ); bool ExistsStormDLL = UTIL_FileExists( FileStormDLL ); bool ExistsGameDLL = UTIL_FileExists( FileGameDLL ); if( ExistsWar3EXE && ExistsStormDLL && ExistsGameDLL ) { // todotodo: check getExeInfo return value to ensure 1024 bytes was enough char buf[1024]; uint32_t EXEVersion; getExeInfo( FileWar3EXE.c_str( ), (char *)&buf, 1024, (uint32_t *)&EXEVersion, BNCSUTIL_PLATFORM_X86 ); m_EXEInfo = buf; m_EXEVersion = UTIL_CreateByteArray( EXEVersion, false ); uint32_t EXEVersionHash; checkRevisionFlat( valueStringFormula.c_str( ), FileWar3EXE.c_str( ), FileStormDLL.c_str( ), FileGameDLL.c_str( ), extractMPQNumber( mpqFileName.c_str( ) ), (unsigned long *)&EXEVersionHash ); m_EXEVersionHash = UTIL_CreateByteArray( EXEVersionHash, false ); m_KeyInfoROC = CreateKeyInfo( keyROC, UTIL_ByteArrayToUInt32( clientToken, false ), UTIL_ByteArrayToUInt32( serverToken, false ) ); if( TFT ) m_KeyInfoTFT = CreateKeyInfo( keyTFT, UTIL_ByteArrayToUInt32( clientToken, false ), UTIL_ByteArrayToUInt32( serverToken, false ) ); if( m_KeyInfoROC.size( ) == 36 && ( !TFT || m_KeyInfoTFT.size( ) == 36 ) ) return true; else { if( m_KeyInfoROC.size( ) != 36 ) CONSOLE_Print( "[BNCSUI] unable to create ROC key info - invalid ROC key" ); if( TFT && m_KeyInfoTFT.size( ) != 36 ) CONSOLE_Print( "[BNCSUI] unable to create TFT key info - invalid TFT key" ); } } else { if( !ExistsWar3EXE ) CONSOLE_Print( "[BNCSUI] unable to open [" + FileWar3EXE + "]" ); if( !ExistsStormDLL ) CONSOLE_Print( "[BNCSUI] unable to open [" + FileStormDLL + "]" ); if( !ExistsGameDLL ) CONSOLE_Print( "[BNCSUI] unable to open [" + FileGameDLL + "]" ); } return false; }
bool BNCSHandler::HandleAuthInfo(DWORD LogonType, DWORD UDPValue, FILETIME MPQFileTime, char *MPQFileName, char *ValueString) { switch(LogonType) { case 0: break; case 1: global->logManip.logOutput(LOG_CONN_ERROR, true, "The nls is not supported by this bot.\n"); return false; break; case 2: global->logManip.logOutput(LOG_CONN_ERROR, true, "The nls is not supported by this bot.\n"); return false; break; default: global->logManip.logOutput(LOG_CONN_ERROR, true, "The suggested logon method is not supported by this client!\n"); return false; break; } global->logManip.logOutput(LOG_STARTUP, true, "Checking CD key and file versions...\n"); kd_init(); unsigned int mpqNum = extractMPQNumber(MPQFileName); if(mpqNum < 0) return false; char *annoying1 = new char[global->configManip.getGamefile1().length() +1]; char *annoying2 = new char[global->configManip.getGamefile2().length() +1]; char *annoying3 = new char[global->configManip.getGamefile3().length() +1]; strcpy(annoying1, global->configManip.getGamefile1().c_str()); strcpy(annoying2, global->configManip.getGamefile2().c_str()); strcpy(annoying3, global->configManip.getGamefile3().c_str()); const char* files[] = { annoying1, annoying2, annoying3 }; unsigned long Checksum; if(!checkRevision(ValueString, files, 3, mpqNum, &Checksum)) return false; delete [] annoying1; delete [] annoying2; delete [] annoying3; DWORD exeVer; unsigned int Version; char exeInfo[300]; char *annoying = new char[global->configManip.getGamefile1().length() + 1]; strcpy(annoying, global->configManip.getGamefile1().c_str()); exeVer = getExeInfo(annoying, exeInfo, 256, &Version, 0x1); delete [] annoying; if(!exeVer) { global->logManip.logOutput(LOG_CONN_ERROR, true, "Could not gather game file info!\n"); return false; } global->packetManip.Buff.add(clientToken); global->packetManip.Buff.add(exeVer); global->packetManip.Buff.add(Checksum); global->packetManip.Buff.add((int)0x01); global->packetManip.Buff.add((int)0); CDKeyDecoder decoder(global->configManip.getCDKey().c_str(), global->configManip.getCDKey().length()); if(!decoder.isKeyValid()) { global->logManip.logOutput(LOG_CONN_ERROR, true, "The provided CD key is invalid!\n"); return false; } unsigned long getProd, getVal; getProd = decoder.getProduct(); getVal = decoder.getVal1(); global->packetManip.Buff.add((int)strlen(global->configManip.getCDKey().c_str())); global->packetManip.Buff.add(getProd); global->packetManip.Buff.add(getVal); global->packetManip.Buff.add((int)0x00); int hashLength = decoder.calculateHash(clientToken, serverToken); if(!hashLength) return false; char KeyHash[64]; if(!decoder.getHash(KeyHash)) return false; global->packetManip.Buff.add(KeyHash, 5 * 4); global->packetManip.Buff.add(exeInfo); global->packetManip.Buff.add(global->configManip.getUsername()); global->packetManip.Buff.sendpacket(SID_AUTH_CHECK); return true; }