#include <stdio.h> typedef unsigned int DWORD; #define SET_MEM_32( addr, val) \ ( *(DWORD* )(addr) = (val) ) #define GET_MEM_32( addr) (*(DWORD* )(addr)) #define MODIFY_MEM_32( addr, mask, val) \ ( *(DWORD* )(addr) = GET_MEM_32(addr) & ~(mask) | (val) & (mask) ) int main() { unsigned char arr[10]={0,1,2,3,4,5,6,7,8,9}; SET_MEM_32(arr, 0x22334455); printf("%x\n",GET_MEM_32(arr)); MODIFY_MEM_32(arr, 0xff0000, 0x770000); printf("%x\n",GET_MEM_32(arr)); return 0; }
--------------執行結果--------------
22334455
22774455
沒有留言:
張貼留言