Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 02, 2020 How can I open a Binary EXE with Hexadecimal? | ||||
---|---|---|---|---|
| ||||
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 Re: How can I open a Binary EXE with Hexadecimal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Baby Beaker | 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 Re: How can I open a Binary EXE with Hexadecimal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Baby Beaker | 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 03, 2020 Re: How can I open a Binary EXE with Hexadecimal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to wolframw | 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:
>> save as "rb" again.
>
> This will not work. To be able to write to a binary file, you will have to use "wb".
kkkkkkkkkkkk sure!
|
Copyright © 1999-2021 by the D Language Foundation