简体   繁体   English

从网络服务器下载我的程序数据(它基本上只是 a.exe 变成了.txt)但是当我把它放入 a.exe 时它不运行?

[英]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.所以目前我正在使用基本的 Http 请求从我的服务器 weblink.com/Program.exe 中提取 exe 数据,它以 .txt 形式返回我的程序,但是当我将它放入文件中时,它不会运行。 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++我认为这是因为我需要元数据,但不知道如何找到该过程,甚至不知道如何用谷歌搜索如此具体的东西......所以我要么寻求解决方案(如何添加 proper.exe 元数据),要么是否有是下载类似 C++ 中的文件的更好方法

*Note I cannot use basic windows functions such as DownloadToFileA or External Library's (Like LibCurl/Curl) *注意我不能使用基本的 windows 功能,例如 DownloadToFileA 或外部库(如 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();

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM