/////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Overwrite the expiration date for evaluation copies</summary> /// <param name="exePath">The path to the EXE file to modify</param> /// <param name="expirationDate">The date the game stops working</param> /////////////////////////////////////////////////////////////////////////////////////////// public void SetMacExpirationDate(string exePath, DateTime expirationDate) { FileStream exeFileStream = File.OpenWrite(exePath); BinaryWriter writer = new BinaryWriter(exeFileStream); try { CharByteOrder = CharacterByteOrder.LittleEndian; exeFileStream.Seek(m_MacEvalExpirationDateOffset.PPC, SeekOrigin.Begin); SetExpirationDate(writer, expirationDate); CharByteOrder = CharacterByteOrder.BigEndian; exeFileStream.Seek(m_MacEvalExpirationDateOffset.x86, SeekOrigin.Begin); SetExpirationDate(writer, expirationDate); exeFileStream.Seek(m_MacEvalExpirationDateOffset.x64, SeekOrigin.Begin); SetExpirationDate(writer, expirationDate); } finally { CharByteOrder = CharacterByteOrder.BigEndian; } exeFileStream.Close(); }
/////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Overwrite the title screen or custom picture message for a Mac application</summary> /// <param name="exePath">The path to the EXE file to modify</param> /// <param name="msgDataOffset">The offset within the EXE file of the message data </param> /// <param name="msg">The new message to display</param> /////////////////////////////////////////////////////////////////////////////////////////// public void OverwriteMacMsg(string exePath, long ppcOffset, long x86Offset, long x64Offset, string msg) { WcharSize = 4; CharByteOrder = CharacterByteOrder.LittleEndian; OverwriteMsg(exePath, ppcOffset, msg); CharByteOrder = CharacterByteOrder.BigEndian; OverwriteMsg(exePath, x86Offset, msg); OverwriteMsg(exePath, x64Offset, msg); WcharSize = 2; }
/////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Overwrite the key value in the Mac application file using the offset and /// padding value loaded from file</summary> /////////////////////////////////////////////////////////////////////////////////////////// public void OverwriteMacKey(string exePath, UInt64 keyValue) { try { CharByteOrder = CharacterByteOrder.LittleEndian; OverwriteValueInEXE(exePath, keyValue, m_MacPPCKey); CharByteOrder = CharacterByteOrder.BigEndian; OverwriteValueInEXE(exePath, keyValue, m_Macx86Key); OverwriteValueInEXE(exePath, keyValue, m_Macx64Key); } finally { CharByteOrder = CharacterByteOrder.BigEndian; } }
/////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Break a 64-bit integer into an 8 byte array. Array index 0 of the returned array is the /// LSB. /// </summary> /// <param name="val">The 64-bit integer to break into its component bytes</param> /// <returns>An 8 byte array representing the 64-bit value with the LSB at index 0</returns> /////////////////////////////////////////////////////////////////////////////////////////// public static byte[] UInt64ToArray(UInt64 val, CharacterByteOrder byteOrder) { byte[] retVals = new byte[8]; // Store the values for (int byteIndex = 0; byteIndex < 8; ++byteIndex) { if (byteOrder == CharacterByteOrder.BigEndian) { retVals[byteIndex] = (byte)((val >> (byteIndex * 8)) & 0xFF); } else { retVals[7 - byteIndex] = (byte)((val >> (byteIndex * 8)) & 0xFF); } } return(retVals); }
/////////////////////////////////////////////////////////////////////////////////////////// /// <summary>Overwrite the small message under the custom picture using the message offset /// loaded from file</summary> /// <param name="exePath">The path to the EXE file to modify</param> /// <param name="msg">The new message to display</param> /////////////////////////////////////////////////////////////////////////////////////////// public void OverwriteMacCustomPicMsg(string exePath, string msg) { try { WcharSize = 4; CharByteOrder = CharacterByteOrder.LittleEndian; OverwriteMsg(exePath, m_MacPicMsgOffset.PPC, msg); CharByteOrder = CharacterByteOrder.BigEndian; OverwriteMsg(exePath, m_MacPicMsgOffset.x86, msg); OverwriteMsg(exePath, m_MacPicMsgOffset.x64, msg); } finally { WcharSize = 2; CharByteOrder = CharacterByteOrder.BigEndian; } }