我在以下功能的LOBYTE / HIBYTE / LODWORD行上收到lvalue required as left operand error

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)),所以为什么我不能只转换它?

最佳答案

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

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/

10-10 17:37