如何制作固定的十六进制编辑器?

发布于 2024-08-27 11:30:22 字数 218 浏览 5 评论 0原文

所以。假设我要制作一个十六进制编辑器来编辑...哦...假设一个 .DLL 文件。如何使用 C# 或 C++ 编辑 .DLL 文件的十六进制?对于“固定部分”,我想让它能够从程序中浏览特定的.DLL,在编程的文件上有一些预先编码的按钮,当按下按钮时,它会自动执行请求的操作,这意味着该按钮已被预先编码,以了解在 .DLL 中查找什么以及将其更改为什么。谁能帮我开始做这件事吗?

另外,最好是 C#。谢谢你!

So. Let's say I were to make a hex editor to edit... oh... let's say a .DLL file. How can I edit a .DLL file's hex by using C# or C++? And for the "fixed part", I want to make it so that I can browse from the program for a specific .DLL, have some pre-coded buttons on the programmed file, and when the button is pressed, it will automatically execute the requested action, meaning the button has been pre-coded to know what to look for in the .DLL and what to change it to. Can anyone help me get started on this?

Also, preferably C#. Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神妖 2024-09-03 11:30:22

基础知识非常简单。

DLL 或任何文件都是字节流。

基本文件操作允许您读取和写入文件的任意部分。艺术术语基本上是“随机访问文件操作”。

在 C 语言中,基本操作是 read()、write() 和 lseek()。

read 允许您将字节流读入缓冲区,write 允许您将字节缓冲区写入文件,lseek 允许您将其定位到文件中的任何位置。

示例:

int fd = open("test.dat", O_RDWR);
off_t offset = lseek(fd, 200, SEEK_SET);
if (off_t == -1) {
    printf("Boom!\n");
    exit(1);
}    
char buf[1024];
ssize_t bytes_read = read(fd, buf, 1024);
offset = lseek(fd, 100, SEEK_SET);
ssize_t bytes_written = write(fd, buf, 1024);
flush(fd);
close(fd);

这从文件中读取 1024 个字节,从文件的第 200 个字节开始,然后以 100 个字节将其写回文件。

一旦可以更改文件中的随机字节,就需要选择要更改的字节、如何更改它们以及执行适当的读取/查找/写入来进行更改。

请注意,这些是最原始的 I/O 操作,根据您的语言等,您可能可以使用更好的操作。但它们都基于这些原语。

解释文件的字节、显示它们等等。这是读者的练习。但这些基本的 I/O 功能为您提供了更改文件的基础知识。

The basics are very simple.

A DLL, or any file, is a stream of bytes.

Basic file operations allow you to read and write arbitrary portions of a file. The term of art is basically "Random Access Files Operations".

In C, the fundamental operations are read(), write(), and lseek().

read allows you to read a stream of bytes in to a buffer, write allows you to write a buffers of bytes to a file, lseek allows you to position anywhere you want in the file.

Example:

int fd = open("test.dat", O_RDWR);
off_t offset = lseek(fd, 200, SEEK_SET);
if (off_t == -1) {
    printf("Boom!\n");
    exit(1);
}    
char buf[1024];
ssize_t bytes_read = read(fd, buf, 1024);
offset = lseek(fd, 100, SEEK_SET);
ssize_t bytes_written = write(fd, buf, 1024);
flush(fd);
close(fd);

This reads 1024 bytes from a file, starting at the 200th byte of the file, then writes it back to the file at 100 bytes.

Once you can change random bytes in a file, it's a matter of choosing what bytes to change, how to change them, and doing the appropriate reads/lseeks/writes to make the changes.

Note, those are the most primitive I/O operations, there are likely much better ones you can use depending on your language etc. But they're all based on those primitives.

Interpreting the bytes of a file, displaying them, etc. That's an exercise for the reader. But those basic I/O capabilities give you the fundamentals of changing files.

醉城メ夜风 2024-09-03 11:30:22

如果您的想法是加载十六进制编辑框,您可以使用以下命令: Be.HexEditor
编辑文件的“十六进制”无非就是更改其中的字节。预先编程的更改部分将是更通用的类型。但对于实际查看、查找并可以选择更改任何您想要的内容,Be.HexEditor 是一个不错的选择。我一年多前使用过它,我希望它有一些新功能可以让您的生活更轻松。

If the idea is to load a hex edit box you can use the following: Be.HexEditor
Editing a file's "hex" is nothing more than changing bytes in it. The part of having pre-programmed changes is going to be that more general type. But for actually viewing, finding and then having the option of changing anything you want, Be.HexEditor is a good option. I used it over a year ago, I would hope that it has some new features that will make your life easier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文