Sidebar and phone session list both rendered from node.processIcons when the session was attached and session.iconPNGData otherwise, with the iconPNGData branch in the sidebar carrying an extra accent-color overlay. That fork made agent-created sessions look subtly off until the node arrived. Drop the live branch, render only from session.iconPNGData, and replace the inline icon-stash copies with a new ProcessSession.adoptIcon helper that performAttach keeps current.
46 lines
1.1 KiB
Swift
46 lines
1.1 KiB
Swift
import Foundation
|
|
import Frida
|
|
|
|
#if canImport(CoreGraphics)
|
|
import CoreGraphics
|
|
import ImageIO
|
|
import UniformTypeIdentifiers
|
|
#endif
|
|
|
|
public extension Icon {
|
|
var pngData: Data? {
|
|
switch self {
|
|
case .png(let bytes):
|
|
return Data(bytes)
|
|
case .rgba:
|
|
#if canImport(CoreGraphics)
|
|
return encodeCGImageAsPNG(cgImage)
|
|
#else
|
|
return nil
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
|
|
public extension ProcessSession {
|
|
mutating func adoptIcon(from process: ProcessDetails) {
|
|
guard iconPNGData == nil, let icon = process.icons.last else { return }
|
|
iconPNGData = icon.pngData
|
|
}
|
|
}
|
|
|
|
#if canImport(CoreGraphics)
|
|
private func encodeCGImageAsPNG(_ image: CGImage) -> Data? {
|
|
let buffer = NSMutableData()
|
|
guard let destination = CGImageDestinationCreateWithData(
|
|
buffer as CFMutableData,
|
|
UTType.png.identifier as CFString,
|
|
1,
|
|
nil
|
|
) else { return nil }
|
|
CGImageDestinationAddImage(destination, image, nil)
|
|
guard CGImageDestinationFinalize(destination) else { return nil }
|
|
return buffer as Data
|
|
}
|
|
#endif
|