(string cachePath, byte[] patchedPayload, byte[] iv)
| 828 | } |
| 829 | |
| 830 | void ReEncryptAndWrite(string cachePath, byte[] patchedPayload, byte[] iv) |
| 831 | { |
| 832 | // Reuse original IV: SteamTools does the same; new IV would break cache validation. |
| 833 | Log(" Re-encrypting.."); |
| 834 | using var compMs = new MemoryStream(); |
| 835 | using (var zOut = new ZLibStream(compMs, CompressionLevel.Optimal, leaveOpen: true)) |
| 836 | zOut.Write(patchedPayload, 0, patchedPayload.Length); |
| 837 | |
| 838 | var blob = new byte[4 + compMs.Length]; |
| 839 | BitConverter.TryWriteBytes(blob.AsSpan(0, 4), patchedPayload.Length); |
| 840 | compMs.GetBuffer().AsSpan(0, (int)compMs.Length).CopyTo(blob.AsSpan(4)); |
| 841 | |
| 842 | var newCt = PayloadCrypto.AesCbcEncrypt(blob, AesKey, iv); |
| 843 | var output = new byte[16 + newCt.Length]; |
| 844 | iv.CopyTo(output, 0); |
| 845 | newCt.CopyTo(output, 16); |
| 846 | FileUtils.AtomicWriteAllBytes(cachePath, output); |
| 847 | _cachedPayload = null; |
| 848 | } |
| 849 | |
| 850 | // Build the cave with caller-relative displacements. |
| 851 | static byte[] BuildDynamicCloudRedirectCave(int caveRva, int sendPktRva, |
nothing calls this directly
no test coverage detected