c++filemetadataexecutablefile-storage

Downloading my programs data from a webserver (Its basically just a .exe turned into .txt) but when I put it into a .exe it does not run?


So currently I am using a basic Http request to pull the exe data from my server weblink.com/Program.exe it returns my program in .txt form but when I put it into a file it will not run. I assume this is because I need metadata but have no clue how to find that process or even how to google something as specific as that... So I am either asking for a solution (how to add proper .exe metadata) or if there is a better way to download files like that in C++

*Note I cannot use basic windows functions such as DownloadToFileA or External Library's (Like LibCurl/Curl)

OutFile.open(XorStr("C:\\Users\\Program.exe").c_str(), std::ios::out);
if (OutFile.is_open())
{
     OutFile << Output;
     //Initialize .exe Meta Data???  
}
OutFile.close();

Solution

  • You need to open your file in binary mode otherwise newline translation will screw up your executable:

    OutFile.open(XorStr("C:\\Users\\Program.exe").c_str(), std::ios::out | std::ios::binary);