简体   繁体   English

使用 C++ 修改保存文件的字节(十六进制?)

[英]Modify bytes (Hex?) of a save file with C++

Sorry, I have read a lot of Q&A on this site that are kind of related by due to me essentially just starting C++, only previously coding in C# and Java I have a save file, and with a hex edit program I have found a value that modifys the campaigns save difficulty;对不起,我在这个网站上阅读了很多 Q&A,因为我基本上只是开始 C++,以前只用 C# 和 Java 编码我有一个保存文件,并且使用十六进制编辑程序我找到了一个值修改活动以节省难度; 在此处输入图片说明

the '00' highlighted value is what I wish to change, I have seen examples but nothing that I fully understand enough to manipulate '00' 突出显示的值是我希望改变的,我看过一些例子,但没有什么我完全理解足以操纵

    std::ofstream ofs ("/text.txt", std::ofstream::out);//("/JKSV/Saves/Fire_Emblem__Awakening/hack/", std::ofstream::out);
    //Edit item at 0000000D '00' to '01'
    ofs.close();

I know my question, put to people with proper knowledge of C++ is extremely trivial, but its still quite new to me我知道我的问题,向具有 C++ 适当知识的人提出的问题非常简单,但对我来说仍然很新

You will need to open the file in binary mode so that i/o libraries restrict interpretation of the special characters.您需要以二进制模式打开文件,以便 I/O 库限制对特殊字符的解释。

fstream binaryFile("txt.txt", ios::in | ios::out | ios::binary);

You may want to check the available functions infstream您可能需要检查fstream 中的可用函数

seek to the position where you want to modify the byte value:寻找要修改字节值的位置:

binaryFile.seekp(0x0D/*offsetToWrite*);

Write the byte value:写入字节值:

binaryFile << char(0x01/*ValueToReplace*/);  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM