【问题标题】:I don't Understand - *(uint*)((byte*)p + Offset)我不明白 - *(uint*)((byte*)p + Offset)
【发布时间】:2019-09-03 01:55:50
【问题描述】:

我无法理解这段代码,希望得到一个好的解释。

以下函数接受一个 hex 文件并修改地址而不覆盖其他所有内容。

有人可以向我解释一下它是如何做到的吗?

unsafe void WriteUint32(void* p, int Offset, uint value)
        {
            *(uint*)((byte*)p + Offset) = value;
        }

【问题讨论】:

  • 怎么样你明白了吗?
  • (uint)((byte*)p

标签: hex byte uint


【解决方案1】:

如果我们忽略Offset,你有

*(uint*)((byte*)p) = value;

这只是将value 分配给p 指向的内容,解释为uint

添加Offset 只是将指针更改为分配value 的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-13
    • 2011-02-17
    相关资源
    最近更新 更多