stoneharry

Untitled

Apr 6th, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. unsigned char data[24] = {
  2.     0x18, 0x00, 0x04, 0x01,
  3.     0x00, 0x00, 0x00, 0x00,
  4.     0x5E, 0x00, 0x00, 0x00,
  5.     0x00, 0x00, 0x00, 0x00,
  6.     0x00, 0x00, 0x00, 0x00
  7. };
  8.  
  9. struct UpdateFileHeader
  10. {
  11.    UINT16 HdrSize; // always 0x0018
  12.    BYTE override; // 0x01 => override with new file; 0x04 => update file (bsdiff)
  13.    BYTE version; // always 0x04
  14.    UINT32 unknown3;
  15.    UINT32 OldFileSize; // file size before the update (uncompressed)
  16.    UINT32 NewFileSize; // size of the entire file after the update is applied (uncompressed)
  17.    UINT32 unknown6; // always 0
  18.    UINT32 unknown7; // always 0
  19. };
  20.  
  21. Hardcoded values work:
  22.             const char* output = reinterpret_cast<const char*>(data);
  23.  
  24.             OutFile.write(output, 24)
  25.  
  26.  
  27. Trying to use structure to write variable data:
  28.             OutFile.write(reinterpret_cast<const char*>(test.HdrSize), sizeof(UINT16));
  29.             OutFile.write(reinterpret_cast<const char*>(test.override), sizeof(BYTE));
  30.             OutFile.write(reinterpret_cast<const char*>(test.version), sizeof(BYTE));
  31.             OutFile.write(reinterpret_cast<const char*>(test.unknown3), sizeof(UINT32));
  32.             OutFile.write(reinterpret_cast<const char*>(test.OldFileSize), sizeof(UINT32));
  33.             OutFile.write(reinterpret_cast<const char*>(test.NewFileSize), sizeof(UINT32));
  34.             OutFile.write(reinterpret_cast<const char*>(test.unknown6), sizeof(UINT32));
  35.             OutFile.write(reinterpret_cast<const char*>(test.unknown7), sizeof(UINT32));
Advertisement
Add Comment
Please, Sign In to add comment