Пример #1
0
        private string MakeCall(Helper.ExportInfo e, int index)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                string def     = e.Definition.Replace(";", "").Replace(e.Name, Options.prefix + e.Name);
                int    namepos = def.IndexOf(Options.prefix + e.Name);
                def = def.Substring(namepos, def.Length - namepos);
                string   argstr  = def.Split('(')[1].Split(')')[0];
                string[] args    = argstr.Split(',');
                string   argcall = "";
                string   argdef  = "";
                int      acount  = 1;
                if (argstr.Trim() == "")
                {
                    args = new string[0];
                }
                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i].ToLower().Replace(" ", "") == "void*")
                    {
                        if (header.Is32BitHeader)
                        {
                            args[i] = "int ";
                        }
                        else
                        {
                            args[i] = "long ";
                        }
                        args[i] += "a" + (acount++);
                    }
                    string[] argparts = args[i].Trim().Split(' ');
                    if (argparts.Length == 1)
                    {
                        argparts = new List <string>()
                        {
                            argparts[0], "a" + (acount++)
                        }
                    }
                    .ToArray();
                    if (argparts.Length > 2)
                    {
                        StringBuilder sb2 = new StringBuilder();
                        for (int j = 0; j < argparts.Length - 1; j++)
                        {
                            sb2.Append(argparts[j] + " ");
                        }
                        argparts = new List <string>()
                        {
                            sb2.ToString(), argparts[argparts.Length - 1]
                        }.ToArray();
                    }
                    argcall += argparts[argparts.Length - 1].Replace("*", "").Trim() + ", ";
                    argdef  += argparts[0] + " " + argparts[1] + ", ";
                }
Пример #2
0
        private string MakeAsmJump(Helper.ExportInfo e, int index)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("extern \"C\" __declspec(naked) void " + Options.prefix + e.Name + "()");
            sb.AppendLine("{");
            sb.AppendLine(" __asm");
            sb.AppendLine(" {");
            sb.AppendLine("     jmp p[" + index + "*4];");
            sb.AppendLine(" }");
            sb.AppendLine("}");
            return(sb.ToString());
        }
Пример #3
0
 private void withCallsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndices.Count == 0)
     {
         for (int i = 0; i < listBox1.Items.Count; i++)
         {
             listBox1.SetSelected(i, true);
         }
     }
     for (int i = 0; i < listBox1.SelectedIndices.Count; i++)
     {
         Helper.ExportInfo ex = exportlist[listBox1.SelectedIndices[i]];
         ex.WayOfExport = 2;
         exportlist[listBox1.SelectedIndices[i]] = ex;
     }
     RefreshExportList();
 }
Пример #4
0
        private void loadDefinitionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.c;*.h;*.txt|*.c;*.h;*.txt";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string[]      input = File.ReadAllLines(d.FileName);
                StringBuilder sb    = new StringBuilder();
                for (int i = 0; i < exportlist.Count; i++)
                {
                    if (exportlist[i].WayOfExport == 2)
                    {
                        bool found = false;
                        foreach (string line in input)
                        {
                            if (line.Contains(exportlist[i].Name + "("))
                            {
                                Helper.ExportInfo info = exportlist[i];
                                info.Definition = line.Trim();
                                exportlist[i]   = info;
                                found           = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            sb.AppendLine(exportlist[i].Name);
                            Helper.ExportInfo ex = exportlist[i];
                            ex.WayOfExport = 0;
                            exportlist[i]  = ex;
                        }
                    }
                }
                RefreshExportList();
                if (sb.Length != 0)
                {
                    MessageBox.Show("Error: no definition(s) found for:\n" + sb.ToString() + "\n please use \"asm jmp\" or \"link\" as method for those exports");
                }
            }
        }