none
[HELP] Write hex in file RRS feed

  • Question

  • How can i write this in file starting in offset 1AC?

    In winhex i see:

    Hex values:
    508955DCC818D478FFE70BE2B924CE98B14A6B4169BE0CA743EC6652670618B72F6A82E4F120A1DB0283A1759CDE3729B300934FE0DF721474CA49F6F1F4DEAAE3C1C74F128ED168F1B2C83A026773CF0C91D3859C89709352950C798B3F2571AB7D3BD9DA5C7E3A42B6DA1FAEB15DD1B8D0AE1B5E307272285966384D0F9F68


    How can i write this without using this way? (Starting in offset 1AC)

    Dim fs As New IO.FileStream(fileDialogBox.FileName, FileMode.Open, FileAccess.ReadWrite)
                    fs.Position = &H1AC
                    fs.WriteByte(&H50)
                    fs.WriteByte(&H89)
                    fs.WriteByte(&H55)
                    fs.WriteByte(&HDC)
                    ...

    I want something like that:

    fs.Position = &H1AC
    fs.WriteByte(&H508955DCC818D478FFE70BE2B924CE98B14A6B4169BE0CA743EC6652670618B72F6A82E4F120A1DB0283A1759CDE3729B300934FE0DF721474CA49F6F1F4DEAAE3C1C74F128ED168F1B2C83A026773CF0C91D3859C89709352950C798B3F2571AB7D3BD9DA5C7E3A42B6DA1FAEB15DD1B8D0AE1B5E307272285966384D0F9F68)




    • Edited by extream87 Thursday, May 1, 2014 1:52 AM
    Thursday, May 1, 2014 1:50 AM

Answers

All replies

  • How can i write this in file starting in offset 1AC?

    You can't write a string as a series of bytes without converting it first.   The write command you are looking for is this one:
    http://msdn.microsoft.com/en-au/library/system.io.filestream.write.aspx

    So the task is actually how to convert your string to an array of bytes.   That will depend on what that string represents.  If the string is the hex representation of a value then each pair of hex characters needs to be converted to its byte value equivalent:
        80, 137, 85, 220, ...

    Is that what should be written? See:
    http://code.msdn.microsoft.com/windowsdesktop/VBHexStringByteArrayConvert-be271820

    Thursday, May 1, 2014 2:10 AM
  • The computer does not work with hex values. A hex value is only a representation of a digital value for humans for whom are the real binary values impossible direct to understand if it is more than about 1000000. 

    Because the word format of an intel based computer (has nothing to do with ms word or whatever word) is 8 bits. A byte is mostly made presentable in Hex code. 

    In that means an A a for instance 1010 in binary format. 

    Therefore, what you see is an encoded representation not something that should really be stored


    Success
    Cor

    Thursday, May 1, 2014 3:58 AM