duangsuse::Echo
717 subscribers
4.26K photos
130 videos
583 files
6.47K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
心累,想休息。想成功,进步太累了,我不是少年番主角,我想划水、我想看番……
进步就是否定自己,这样才能变得更好,但长此以往就容易人格扭曲,变得高傲自负,甚至连亲朋好友都不放在心上。(开玩笑 😂
我必须拿一些现在有把握的东西自我娱乐一下。
比如说,一年前逆向 drakeet 的纯纯写作的时候,我试过解决 AXML 文件格式读写的问题,现在可以拿出来重写一遍。
Forwarded from duangsuse::Echo
我要尝试给 debuggable 标签正名,所以必有一点是必须做的:
在这个部分插入翻转后的 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]

完全捏造,已交 Kotlinc 编译
This media is not supported in your browser
VIEW IN TELEGRAM
好程序就是要随手能写出来,自己都写不出来别人怎么能看懂?
我亏了 #Kotlin
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())
删掉算了
#Kotlin 的自动类型推导实在是太艹了!如此简单的多态都分不清如何选择
项目结构,得先测试啊……
This media is not supported in your browser
VIEW IN TELEGRAM
可我真的不知道测试该怎么写,明天再写吧。
我有个坏习惯,就是不擅长把一个抽象的复用库单独写。我喜欢与某些特定的应用实例一起设计,然后再把它们单独提取公开出来。
from struct import pack, unpack
基于 Python 生成二进制测试数据
This media is not supported in your browser
VIEW IN TELEGRAM
越设计越发现自己的愚蠢和 Kotlin 的高明