I'm having problems with an auto-update program of mine
It's supposed to download & save an update from a website, but the problem is(And I'm sure that this happens alot yet I couldn't phrase the keywords that would get me the answer on google) it saves the .exe data it receives not as it's supposed to. It saves the bytes in acsi... let me illustrate that:
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F
00000000 4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00 MZ ÿÿ
00000010 B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ¸ @
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000030 00 00 00 00 00 00 00 00 00 00 00 00 B0 00 00 00 °
This data, (which is the correct data) Looks like this in the new program:
Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F
00000000 0D 0A 34 44 35 41 39 30 30 30 30 33 30 30 30 30 4D5A9000030000
00000010 30 30 30 34 30 30 30 30 30 30 46 46 46 46 30 30 0004000000FFFF00
00000020 30 30 42 38 30 30 30 30 30 30 30 30 30 30 30 30 00B8000000000000
00000030 30 30 34 30 30 30 30 30 30 30 30 30 30 30 30 30 0040000000000000
As you can see it writes the codebytes as ascii values... This is the code I'm using
The receiving part:
char szRecvBuff[10000] = "" ;
string szRecvHolder = "" ;
int iLastCharacter = 0;
recv(Socket, szRecvBuff, sizeof(szRecvBuff), 0);
szRecvHolder = szRecvBuff;
iLastCharacter = szRecvHolder.find_last_of("\n");
if(iLastCharacter < szRecvHolder.size() && iLastCharacter > 0 ){
szRecvHolder.erase(iLastCharacter);
}
return szRecvHolder;
}
...
...
{
...
...
Recv();
string Edat = Recv();
std::ofstream put("Eprog.exe", ios::hex );
put << Edat.c_str();
put.close();
Does anyone know how to go about it, I've tried using google, but I couldn't phrase a question that would give me proper results