我最近从内联汇编迁移到高级语言 (C++),我想将结果从 a 设置value^0x1A3C
为短类型指针 (WORD PTR),但出现以下错误:
int 类型的值不能用于初始化 short* 类型的实体
将 int 类型传递给 short* 时出现问题:
void PacketEncrypt(Packet* packet, int sizeofpacket)
{
char* pointer;
pointer = ((char*)packet+sizeofpacket) -2;
short *pointer = packet->PacketSize^0x1A3C;
packet->Type += 0x0FFF7;
}
我希望编译器做什么:
0041585E 8B45 0C MOV EAX,DWORD PTR SS:[EBP+C]
00415861 8B4D 08 MOV ECX,DWORD PTR SS:[EBP+8]
00415864 8D5401 FE LEA EDX,DWORD PTR DS:[ECX+EAX-2]
00415868 8955 F8 MOV DWORD PTR SS:[EBP-8],EDX
0041586B 8B45 08 MOV EAX,DWORD PTR SS:[EBP+8]
0041586E 0FBF08 MOVSX ECX,WORD PTR DS:[EAX]
00415871 81F1 3C1A0000 XOR ECX,1A3C
00415877 8B55 F8 MOV EDX,DWORD PTR SS:[EBP-8]
0041587A 880A MOV WORD PTR DS:[EDX],CX