void Interface::CommandThreadReceive(bool steam) { try { pipeClient->SetPipeAttributes("BethesdaClient", PIPE_LENGTH); pipeClient->CreateServer(); pipeClient->ConnectToServer(); pipeServer->SetPipeAttributes("BethesdaServer", PIPE_LENGTH); while (!pipeServer->ConnectToServer() && !endThread); unsigned char buffer[PIPE_LENGTH]; buffer[0] = steam; pipeClient->Send(buffer); if (!endThread) { unsigned char code; while (!endThread) { ZeroMemory(buffer, sizeof(buffer)); pipeClient->Receive(buffer); code = buffer[0]; if (code == PIPE_OP_RETURN || code == PIPE_OP_RETURN_BIG || code == PIPE_OP_RETURN_RAW) { vector<CommandResult> result = API::Translate(buffer); for (CommandResult& _result : result) { resultHandler(get<0>(_result), get<1>(_result), get<2>(_result), get<3>(_result)); if (endThread) break; } } else if (code == PIPE_SYS_WAKEUP) { wakeup = true; #ifdef VAULTMP_DEBUG if (debug) debug->Print("vaultmp process waked up (game patched)", true); #endif } else if (code == PIPE_ERROR_CLOSE) { if (!endThread) throw VaultException("Error in vaultmp.dll"); } else if (code) throw VaultException("Unknown pipe code identifier %02X", code); else endThread = true; } } } catch (exception& e) { try { VaultException& vaulterror = dynamic_cast<VaultException&>(e); vaulterror.Message(); } catch (bad_cast& no_vaulterror) { VaultException vaulterror(e.what()); vaulterror.Message(); } #ifdef VAULTMP_DEBUG if (debug) debug->Print("Receive thread is going to terminate (ERROR)", true); #endif } endThread = true; }
DWORD WINAPI Interface::CommandThreadReceive( LPVOID data ) { try { pipeClient->SetPipeAttributes( "BethesdaClient", PIPE_LENGTH ); pipeClient->CreateServer(); pipeClient->ConnectToServer(); pipeServer->SetPipeAttributes( "BethesdaServer", PIPE_LENGTH ); while ( !pipeServer->ConnectToServer() && !endThread ); char buffer[PIPE_LENGTH]; char code; if ( !endThread ) { do { ZeroMemory( buffer, sizeof( buffer ) ); pipeClient->Receive( buffer ); code = buffer[0]; char* content = buffer + 1; if ( code == PIPE_OP_RETURN || code == PIPE_OP_RETURN_BIG ) { vector<CommandResult> result = API::Translate( buffer ); vector<CommandResult>::iterator it; for ( it = result.begin(); it != result.end(); ++it ) resultHandler( it->first.first.first, it->first.first.second, it->first.second, it->second ); } else if ( code == PIPE_SYS_WAKEUP ) { wakeup = true; #ifdef VAULTMP_DEBUG if ( debug != NULL ) debug->Print( "vaultmp process waked up (game patched)", true ); #endif } else if ( code ) throw VaultException( "Unknown pipe code identifier %02X", code ); if ( lookupProgramID( ( char* ) data ) == 0 ) { endThread = true; #ifdef VAULTMP_DEBUG if ( debug != NULL ) debug->Print( "Game process missing, shutting down", true ); #endif } } while ( code != PIPE_ERROR_CLOSE && !endThread ); } // kill game process if running } catch ( std::exception& e ) { try { VaultException& vaulterror = dynamic_cast<VaultException&>( e ); vaulterror.Message(); } catch ( std::bad_cast& no_vaulterror ) { VaultException vaulterror( e.what() ); vaulterror.Message(); } #ifdef VAULTMP_DEBUG if ( debug != NULL ) debug->Print( "Receive thread is going to terminate (ERROR)", true ); #endif endThread = true; return ( ( DWORD ) data ); } #ifdef VAULTMP_DEBUG if ( debug != NULL ) debug->Print( "Receive thread is going to terminate", true ); #endif endThread = true; return ( ( DWORD ) data ); }
void tableName (std::string tableName) throw () {if (resultHandler() || __tableName == "") __tableName = tableName;}