进步就是否定自己,这样才能变得更好,但长此以往就容易人格扭曲,变得高傲自负,甚至连亲朋好友都不放在心上。(开玩笑 😂)
我必须拿一些现在有把握的东西自我娱乐一下。
Forwarded from duangsuse::Echo
我要尝试给 debuggable 标签正名,所以必有一点是必须做的:
在这个部分插入翻转后的 DEBUGGABLE_ATTR (
就是
在这个部分插入翻转后的 DEBUGGABLE_ATTR (
0x0101000f)就是
0x0f000101
duangsuse::Echo
#reveng #recommend https://github.com/fourbrother/AXMLEditor
我们要重写的就是这个,考虑到没必要的原因,就不写 Reader/Writer 部分了 不,写,用 Kotlin multi-platform
interface ByteReader {
fun read(): Byte
fun readTo(buffer: Buffer)
fun readTo(buffer: Buffer, indices: IdxRange)
}
interface ByteWriter {
fun write(byte: Byte)
fun writeFrom(buffer: Buffer)
fun writeFrom(buffer: Buffer, indices: IdxRange)
}
interface Reader: ReadControl, DataReader
interface Writer: WriteControl, DataWriter
interface MarkReset {
fun mark() fun reset()
}
interface ReadControl: MarkReset, Closeable {
val position: Cnt; val estimate: Cnt
fun skip(n: Cnt)
}
interface WriteControl: Flushable, Colseable
interface DataReader {
fun readNat8():Nat8 fun readNat16():Nat16
fun readChar16():Char16
fun readInt8():Int8 fun readInt16():Int16
fun readInt32():Int32 fun readInt64():Int64
fun readRat32():Rat32 fun readRat64():Rat64
}
interface DataWriter {
fun writeNat8(x:Nat8) fun writeNat16(x:Nat16)
fun writeChar16(x:Char16)
fun writeInt8(x:Int8) fun writeInt16(x:Int16)
fun writeInt32(x:Int32) fun writeInt64(x:Int64)
fun writeRat32(x:Rat32) fun writeRat64(x:Rat64)
}
enum class ByteOrder {
BigEndian, LittleEndian
}
interface ByteOrdered {
var byteOrder: ByteOrder
}
interface Sized {
val size: Cnt
}
abstract class Tuple<E>(override val size: Cnt): Size {
protected abstract val items: Array<E>
operator fun get(index: Idx) = items[index]
operator fun set(index: Idx, value: E) { items[index] = value }
protected fun <T> index(idx: Idx) = object {
operator fun getValue(_p: KProperty<*>, self: Tuple<out T>) = self[idx]
operator fun setValue(_p: KProperty<*>, self: Tuple<in T>, value: T) { self[idx] = value }
}
}
fun <E> Tuple<T>.component1() = this[0]
fun <E> Tuple<T>.component2() = this[1]
fun <E> Tuple<T>.component3() = this[2]
fun <E> Tuple<T>.component4() = this[3]
inline fun <T, I, R> intBitwise(crossinline to: (T) -> I, crossinline op: I.(I) -> I, crossinline from: (I) -> R): T.(T) -> R删掉算了
= { to(this).op(to(it)).let(from) }
inline fun <T, I, R> intByteBitwise(crossinline to: (T) -> I, crossinline op: I.(Byte) -> I, crossinline from: (I) -> R): T.(Byte) -> R
= { b -> to(this).op(b).let(from) }
internal fun Int.or(byte: Byte): Int = or(byte.toInt())
我有个坏习惯,就是不擅长把一个抽象的复用库单独写。我喜欢与某些特定的应用实例一起设计,然后再把它们单独提取公开出来。