/// <summary> /// 写2字节内存 /// </summary> /// <param name="hwnd"></param> /// <param name="hAddr"></param> /// <param name="inData"></param> /// <returns></returns> public bool Write2Byte(IntPtr hwnd, int hAddr, UInt16 inData) { byte[] temp_byte = new byte[2]; temp_byte[0] = (byte)inData; temp_byte[1] = (byte)(inData >> 8); int ip = 0; int o_sta = W_API.WriteProcessMemory(hwnd, hAddr, temp_byte, 2, out ip); if (o_sta == 0) { return(false); } return(true); }
/// <summary> /// 写4字节内存 /// </summary> /// <param name="hwnd"></param> /// <param name="hAddr"></param> /// <param name="inData"></param> /// <returns></returns> public bool Write4Byte(IntPtr hwnd, int hAddr, Int32 inData) { byte[] temp_byte = new byte[4]; temp_byte[0] = (byte)inData; temp_byte[1] = (byte)(inData >> 8); temp_byte[2] = (byte)(inData >> 16); temp_byte[3] = (byte)(inData >> 24); int ip = 0; int o_sta = W_API.WriteProcessMemory(hwnd, hAddr, temp_byte, 4, out ip); if (o_sta == 0) { return(false); } return(true); }