了解带位旋转的 PowerPC 汇编器函数

发布于 2024-11-30 05:03:43 字数 802 浏览 0 评论 0原文

我试图移植一个遗留应用程序,它有一些基本的位移来解密缓冲区,但我迷失了这个 powerpc 代码 - 我尽力理解它并添加了注释并创建了一个伪 c 函数,但是有些东西显然是不对的。

这是 PPC 函数,它有一个参数,我认为是缓冲区(参数是:void *,int)http://pastebin。 com/RNRAWCpi

这是我的伪 c 所进步的程度:

unsigned long long* data=(unsigned long long*)pBuffer; // file data
unsigned long long crypt = 0x0000;
unsigned long long next_crypt;
unsigned int len = size >> 3;

for(unsigned int i=0; i<len;i++) {
    next_crypt = crypt+data[i]-0x9A6C9A19;      
    data[i] = ((data[i]<<0x18)|(data[i]>>0x14))+0x9A6C9A19;
    data[i] =  (data[i]<<0x3)|(data[i]>>0x29);
    data[i] = data[i] - crypt;
    crypt = next_crypt;     
}

例如,为什么 crypt 分为两个寄存器 r29 和 r29 。 r30

如有任何帮助,我们将不胜感激。

Im trying to port a legacy app which has some basic bit shifting to decrypt a buffer, but im lost with this powerpc code - i tried my best to understand it and added comments and created a pseudo c function however something is obviously not right.

This is the PPC function, it has one argument i think the buffer (params are: void *,int) http://pastebin.com/RNRAWCpi

this is as far as my pseudo c has advanced:

unsigned long long* data=(unsigned long long*)pBuffer; // file data
unsigned long long crypt = 0x0000;
unsigned long long next_crypt;
unsigned int len = size >> 3;

for(unsigned int i=0; i<len;i++) {
    next_crypt = crypt+data[i]-0x9A6C9A19;      
    data[i] = ((data[i]<<0x18)|(data[i]>>0x14))+0x9A6C9A19;
    data[i] =  (data[i]<<0x3)|(data[i]>>0x29);
    data[i] = data[i] - crypt;
    crypt = next_crypt;     
}

For example, why is crypt split into two registers r29 & r30

Any assistance would be greatly appreciated.

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

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

发布评论

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

评论(1

情感失落者 2024-12-07 05:03:43

如果 PowerPC 是 32 位,则需要将“long long”(64 位)拆分为 2 个 32 位寄存器。您还有其他具体问题吗?

If the PowerPC is 32bit then a "long long" (64bits) would need to be split into 2 32bit registers. Do you have any other specific questions?

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