gpt4 book ai didi

c++ - 需要左值作为赋值的左操作数 - LOBYTE/HIBYTE

转载 作者:行者123 更新时间:2023-11-30 17:13:35 29 4
gpt4 key购买 nike

我在以下函数的 LOBYTE/HIBYTE/LODWORD 行上收到需要左值作为左操作数错误:

typedef DWORD _DWORD;
typedef BYTE _BYTE;
typedef WORD _WORD;

signed int __stdcall checkSerial(int serial, int serialLength)
{
int v2; // ecx@1
int v3; // ecx@3
int v4; // ecx@5
int v5; // ecx@7
int v6; // dx@9
signed int v7; // ecx@10
char v8; // dl@11
__int16 v9; // cx@13
signed int result; // eax@21

v2 = 0;
do
{
*(_DWORD *)(v2 + serial) ^= 0x1234567u;
*(_BYTE *)(v2 + serial) &= 0xEu;
v2 += 4;
}
while ( v2 != 8 );
v3 = 0;
do
*(_BYTE *)(serial + 8) += *(_BYTE *)(v3++ + serial);
while ( v3 != serialLength );
v4 = 0;
do
{
*(_DWORD *)(v4 + serial) ^= 0x89ABCDEu;
*(_BYTE *)(v4 + serial) &= 0xEu;
v4 += 4;
}
while ( v4 != 8 );
v5 = 0;
do
*(_BYTE *)(serial + 9) += *(_BYTE *)(v5++ + serial);
while ( v5 != serialLength );
LOBYTE(v6) = *(_BYTE *)(serial + 9);
HIBYTE(v6) = *(_BYTE *)(serial + 8);
if ( v6 != 0x42DE )
goto LABEL_25;
v7 = 9;
do
{
v8 = *(_BYTE *)(v7 + serial) ^ *(_BYTE *)(v7 + serial);
--v7;
}
while ( (_WORD)v7 );
if ( (*(_WORD *)(serial + 8) ^ 0xEEEE) != 0x30AC )
goto LABEL_25;
LOBYTE(v9) = *(_BYTE *)serial;
HIBYTE(v9) = *(_BYTE *)(serial + 1);
if ( v9 != 0xB008u )
goto LABEL_25;
if ( *(_DWORD *)serial != 0x7A81B008 )
goto LABEL_25;
LOWORD(v7) = 0;
do
{
v8 ^= 0xAu;
v7 += 4;
}
while ( v7 <= 12 );
if ( *(_DWORD *)(serial + 4) != 0x388DBF02
|| *(_BYTE *)(serial + 5) != 191
|| *(_BYTE *)(serial + 6) != 141
|| *(_BYTE *)(serial + 5) != 191 )
LABEL_25:
result = 1;
else
result = 0;
return result;
}

LOBYTE(v9) = *(_BYTE *)串行;HIBYTE(v9) = *(_BYTE *)(串行 + 1);

例如这条线导致错误 - 但为什么呢? LOBYTE 被定义为 LOBYTE(x) ((BYTE)(x)) 那么为什么我不能直接转换它?

最佳答案

修改值子集的方法是使用 bool 运算符,例如:

v9 &= ~255; // mask off low byte (set to 0)
v9 |= *(_BYTE*)serial; // or in the new low byte value

但是,由于您要修改 16 位值的两个字节,最简单的方法是在一次操作中对其进行赋值:

v9 = (*(_BYTE*)(*serial + 1) << 8) | (*(_BYTE*)serial);

关于c++ - 需要左值作为赋值的左操作数 - LOBYTE/HIBYTE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30756871/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com