c++ - lvalue required as left operand of assignment - LOBYTE / HIBYTE -


i'm receiving lvalue required left operand error on lobyte/hibyte/lodword lines in function below:

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;     {     *(_dword *)(v2 + serial) ^= 0x1234567u;     *(_byte *)(v2 + serial) &= 0xeu;     v2 += 4;   }   while ( v2 != 8 );   v3 = 0;       *(_byte *)(serial + 8) += *(_byte *)(v3++ + serial);   while ( v3 != seriallength );   v4 = 0;     {     *(_dword *)(v4 + serial) ^= 0x89abcdeu;     *(_byte *)(v4 + serial) &= 0xeu;     v4 += 4;   }   while ( v4 != 8 );   v5 = 0;       *(_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;     {     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;     {     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 *)serial; hibyte(v9) = *(_byte *)(serial + 1);

e.g. lines causing error - why? lobyte defined lobyte(x) ((byte)(x)) why can't cast it?

the way modify subset of value using boolean operators, e.g.:

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

but since you're modifying both bytes of 16 bit value easiest way assign in 1 operation:

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

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -