Esempio n. 1
0
        public static unsafe int Assemble(string cmd, byte *buffer, int length, uint ip = 0)
        {
            AsmModel model = new AsmModel();

            char[] error = new char[1024];
            int    ret   = Kernel32.Assemble(cmd, ip, ref model, 0, 0, error);

            if (ret <= 0)
            {
                throw new Exception(new string(error));
            }

            if (ret > length)
            {
                throw new Exception("Buffer too small!");
            }

            byte *b = &model.Code;

            for (int x = 0; x < ret; x++)
            {
                buffer[x] = b[x];
            }
            return(ret);
        }
Esempio n. 2
0
        public static unsafe byte[] Assemble(string cmd)
        {
            AsmModel model = new AsmModel();

            char[] error = new char[1024];

            int ret = Kernel32.Assemble(cmd, 0, ref model, 0, 0, error);

            if (ret <= 0)
            {
                throw new Exception(new string(error));
            }

            byte[] buff = new byte[ret];
            fixed(byte *a = buff)
            {
                byte *b = &model.Code;

                for (int x = 0; x < ret; x++)
                {
                    a[x] = b[x];
                }
            }

            return(buff);
        }
Esempio n. 3
0
 public static extern int Assemble([MarshalAs(UnmanagedType.LPStr)] string cmd, uint ip, ref AsmModel model, int attempt, int constsize, char[] errtext);
Esempio n. 4
0
        public static unsafe int Assemble(string cmd, byte* buffer, int length, uint ip = 0)
        {
            AsmModel model = new AsmModel();
            char[] error = new char[1024];
            int ret = Kernel32.Assemble(cmd, ip, ref model, 0, 0, error);
            if (ret <= 0)
                throw new Exception(new string(error));

            if (ret > length)
                throw new Exception("Buffer too small!");

            byte* b = &model.Code;
            for (int x = 0; x < ret; x++)
                buffer[x] = b[x];
            return ret;
        }
Esempio n. 5
0
        public static unsafe byte[] Assemble(string cmd)
        {
            AsmModel model = new AsmModel();
            char[] error = new char[1024];

            int ret = Kernel32.Assemble(cmd, 0, ref model, 0, 0, error);
            if (ret <= 0)
                throw new Exception(new string(error));

            byte[] buff = new byte[ret];
            fixed (byte* a = buff)
            {
                byte* b = &model.Code;
                for (int x = 0; x < ret; x++)
                    a[x] = b[x];
            }

            return buff;
        }
Esempio n. 6
0
 public static extern int Assemble([MarshalAs(UnmanagedType.LPStr)]string cmd, uint ip, ref AsmModel model, int attempt, int constsize, char[] errtext);