All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.unidbg.ios.struct.MachHeader Maven / Gradle / Ivy

The newest version!
package com.github.unidbg.ios.struct;

import com.github.unidbg.pointer.UnidbgStructure;
import com.sun.jna.Pointer;
import io.kaitai.MachO;

import java.util.Arrays;
import java.util.List;

public class MachHeader extends UnidbgStructure {

    public MachHeader(Pointer p) {
        super(p);
    }

    public int magic;
    public int cpuType;
    public int cpuSubType;
    public int fileType;
    public int ncmds;
    public int sizeOfCmds;
    public int flags;

    @Override
    protected List getFieldOrder() {
        return Arrays.asList("magic", "cpuType", "cpuSubType", "fileType", "ncmds", "sizeOfCmds", "flags");
    }

    private int backupFileType;

    public boolean setExecutable() {
        if (fileType != MachO.FileType.EXECUTE.id()) {
            backupFileType = fileType;
            fileType = (int) MachO.FileType.EXECUTE.id();
            this.pack();
            return true;
        } else {
            return false;
        }
    }

    public void resetFileType() {
        fileType = backupFileType;
        this.pack();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy