digitalmars.D.learn - How can I open a Binary EXE with Hexadecimal?
- Baby Beaker (3/3) May 02 2020 I need open a Binary EXE, it can be using "rb" mode and convert
- welkam (16/19) May 02 2020 You dont convert binary data to hexadecimal. You display it as
- wolframw (3/4) May 02 2020 This will not work. To be able to write to a binary file, you
- Baby Beaker (2/6) May 03 2020 kkkkkkkkkkkk sure!
I need open a Binary EXE, it can be using "rb" mode and convert it to Hexadecimal for me make some changes and save as "rb" again. How can I make it? Thank you.
May 02 2020
On Saturday, 2 May 2020 at 21:05:32 UTC, Baby Beaker wrote:I need open a Binary EXE, it can be using "rb" mode and convert it to Hexadecimal for me make some changes and save as "rb" again. How can I make it? Thank you.You dont convert binary data to hexadecimal. You display it as hexadecimal. If you want to print file contents to console in hex do something like this. import std.stdio; import std.algorithm; auto fd = File("filename", "r"); //open file for reading ubyte[] data; //a GC allocated buffer for data fd.rawRead(data); //read the data data[0..50].each!(n => stdout.writef("%X ",n)); /*take 50 elements from array and for each of them call lambda that converts ubyte to string in hex format and prints to the stdout*/ if you want to assign to this data you can do something like this data[0] = Oxff; And then write to file
May 02 2020
On Saturday, 2 May 2020 at 21:05:32 UTC, Baby Beaker wrote:save as "rb" again.This will not work. To be able to write to a binary file, you will have to use "wb".
May 02 2020
On Saturday, 2 May 2020 at 22:26:20 UTC, wolframw wrote:On Saturday, 2 May 2020 at 21:05:32 UTC, Baby Beaker wrote:kkkkkkkkkkkk sure!save as "rb" again.This will not work. To be able to write to a binary file, you will have to use "wb".
May 03 2020