I have the following code
void PacketEncrypt(Packet* packet, int sizeofpacket)
{
int* pointer;
pointer = ((int*)packet+sizeofpacket)-2;
(int)*pointer = packet->PacketSize^0x1A3C;
packet->Type += 0x0FFF7;
}
Problem is when i debug it compiler set it as:
0041585E 8B45 0C MOV EAX,DWORD PTR SS:[EBP+C]
00415861 8B4D 08 MOV ECX,DWORD PTR SS:[EBP+8]
00415864 8D5481 F8 LEA EDX,DWORD PTR DS:[ECX+EAX*4-8]
But what i really want is:
0041585E 8B45 0C MOV EAX,DWORD PTR SS:[EBP+C]
00415861 8B4D 08 MOV ECX,DWORD PTR SS:[EBP+8]
00415864 8D5481 F8 LEA EDX,DWORD PTR DS:[ECX+EAX-2]
I am kind of new into C++, so can you help me on what i am doing wrong, or why the compiler is adding scalar *4? thanks !
intpointer has size of4 byteson your machine and can be shifted only by4*nbytes. If you need to move pointer by2 bytescast it tochar, sincesizeof(char) = 1EDIT
(short*)pointer = something.– You can’t assign torvalue. I think you meant:Or if you need
shortpointer: