Exemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            byte[] b      = new byte[0];
            Int32  offset = 0x401000;

            if (CAssembler.Asm("jmp 0x401234", offset, ref b) > 0)
            {
                rtf.Text = "Asm( jmp 0x401234, 0x401000)  -> \n"
                           + "\tLength: " + b.Length + "\n"
                           + "\tBytes:  " + dz.HexDumper.HexDump(b)
                           + "\n\n";
            }

            CInstruction ci = CDisassembler.Dsm(b, 0, offset);

            if (ci.instLen > 0)
            {
                rtf.Text += "Disasm(buf) -> \n"
                            + "\tLen:  " + ci.instLen + "\n"
                            + "\tDump: " + ci.dump + "\n"
                            + "\tCmd:  " + ci.command;
            }
            else
            {
                rtf.Text += "\n Disasm(buf) -> Error";
            }
        }
Exemplo n.º 2
0
        //todo error handling and more prototypes...
        public static unsafe CInstruction Dsm(byte[] buf, Int32 bufOffset, Int32 va)
        {
            t_Disasm dsm;
            CInstruction ci = new CInstruction();

            fixed (byte* pByte = &buf[bufOffset])
            {
                IntPtr ipBuf = new IntPtr((void*)pByte);
                Int32 x = Disasm(ipBuf, buf.Length, va, out dsm, disasmMode.DISASM_CODE);
                ci.instLen = x;
                ci.offset = va;
                ci.dump = dsm.dump;
                ci.command = dsm.result;
                return ci;
            }
        }
Exemplo n.º 3
0
        //todo error handling and more prototypes...
        public static unsafe CInstruction Dsm(byte[] buf, Int32 bufOffset, Int32 va)
        {
            t_Disasm     dsm;
            CInstruction ci = new CInstruction();

            fixed(byte *pByte = &buf[bufOffset])
            {
                IntPtr ipBuf = new IntPtr((void *)pByte);
                Int32  x     = Disasm(ipBuf, buf.Length, va, out dsm, disasmMode.DISASM_CODE);

                ci.instLen = x;
                ci.offset  = va;
                ci.dump    = dsm.dump;
                ci.command = dsm.result;
                return(ci);
            }
        }
Exemplo n.º 4
0
        public static List <CInstruction> DsmBlock(byte[] buf, Int32 va)
        {
            int bufOffset           = 0;
            int curVa               = va;
            List <CInstruction> ret = new List <CInstruction>();

            while (bufOffset < buf.Length)
            {
                CInstruction ci = Dsm(buf, bufOffset, curVa);
                if (ci.instLen == 0)
                {
                    break;
                }
                curVa     += ci.instLen;
                bufOffset += ci.instLen;
                ret.Add(ci);
            }

            return(ret);
        }