This commit is contained in:
nganhkhoa 2025-01-13 12:54:05 -06:00
parent 1c495989d4
commit 06bbde2612
7 changed files with 414 additions and 418 deletions

View File

@ -18,4 +18,3 @@ func (action *removeStrings) withFat(ff *FatFile) error {
func NewRemoveStringsAction() *removeStrings { func NewRemoveStringsAction() *removeStrings {
return &removeStrings{} return &removeStrings{}
} }

View File

@ -147,7 +147,7 @@ func (mc *MachoContext) CollectBindSymbolsModern() []*ImportSymbol {
var bind C.int var bind C.int
var ret1 C.ulonglong var ret1 C.ulonglong
var ret2 C.ulonglong var ret2 C.ulonglong
if (fix.format != 2 && fix.format != 6) { if fix.format != 2 && fix.format != 6 {
fmt.Printf("format is %d\n", fix.format) fmt.Printf("format is %d\n", fix.format)
} }

View File

@ -5,8 +5,8 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"io" "io"
"os"
"math/rand" "math/rand"
"os"
"strings" "strings"
"time" "time"
@ -586,7 +586,7 @@ func (mc *MachoContext) RemoveStrings() {
// their reference down too, // their reference down too,
// symtab and dysymtab can be ignored, by removing them lmao // symtab and dysymtab can be ignored, by removing them lmao
var cstring *Section64; var cstring *Section64
for _, command := range mc.commands { for _, command := range mc.commands {
switch command.(type) { switch command.(type) {
case *Segment64: case *Segment64:
@ -653,7 +653,6 @@ func (mc *MachoContext) RemoveStrings() {
secname := make([]byte, 16) secname := make([]byte, 16)
copy(secname, []byte("__secrets")) copy(secname, []byte("__secrets"))
fmt.Printf("segstart %x\n", segstart) fmt.Printf("segstart %x\n", segstart)
fmt.Printf("file_start %x\n", filestart) fmt.Printf("file_start %x\n", filestart)
@ -745,7 +744,6 @@ func (mc *MachoContext) RemoveStrings() {
mc.RewriteHeader() mc.RewriteHeader()
tmp_file := mc.file.Name() tmp_file := mc.file.Name()
// has to reopen file as append // has to reopen file as append
@ -834,7 +832,7 @@ func (mc *MachoContext) RemoveStrings() {
ref_offset := C.add_imm_get(C.uint(inst_add)) ref_offset := C.add_imm_get(C.uint(inst_add))
ref := base + uint64(ref_base+ref_offset) ref := base + uint64(ref_base+ref_offset)
if (!in_cstring(ref)) { if !in_cstring(ref) {
continue continue
} }
@ -867,7 +865,7 @@ func (mc *MachoContext) RemoveStrings() {
// (high8 << 56 | target) - mach_header // (high8 << 56 | target) - mach_header
ref := uint64(symbol.high8<<56 | symbol.target) ref := uint64(symbol.high8<<56 | symbol.target)
if (!in_cstring(ref)) { if !in_cstring(ref) {
continue continue
} }

View File

@ -98,7 +98,6 @@ func (mc *MachoContext) CollectObjectiveCClasses() {
binary.Read(reader, mc.byteorder, &vtable) binary.Read(reader, mc.byteorder, &vtable)
binary.Read(reader, mc.byteorder, &ro) binary.Read(reader, mc.byteorder, &ro)
fmt.Printf("at=0x%x\n", section.Offset()+uint32(i)*mc.pointersize*5) fmt.Printf("at=0x%x\n", section.Offset()+uint32(i)*mc.pointersize*5)
fmt.Printf("isa=0x%x superclass=0x%x\n", isa, superclass) fmt.Printf("isa=0x%x superclass=0x%x\n", isa, superclass)
fmt.Printf("cache=0x%x vtable=0x%x\n", cache, vtable) fmt.Printf("cache=0x%x vtable=0x%x\n", cache, vtable)
@ -115,7 +114,7 @@ func (mc *MachoContext) CollectObjectiveCClasses() {
// is rebase, because ro points to objc_const // is rebase, because ro points to objc_const
// and address is in range // and address is in range
if (bind != 1 && ret1 >= objc_const_start && ret1 < objc_const_end) { if bind != 1 && ret1 >= objc_const_start && ret1 < objc_const_end {
offset := ret1 - objc_const_start offset := ret1 - objc_const_start
objc_const.Seek(int64(offset), 0) objc_const.Seek(int64(offset), 0)