PDA

View Full Version : سوال: ساخت exe از داخل برنامه



mirage041
جمعه 22 مرداد 1389, 11:46 صبح
سلام
چطوری می شه از داخل برنامه exe تولید کرد ؟
مثله این کیلاگر ها که با انتخاب و ... فایل exe تولید کرد ؟

sinashahab
جمعه 22 مرداد 1389, 12:03 عصر
بستگی داره به این که اون اگزه چی باشه !!

اگه مخلوطی از دو تا اگزه ی دیگه باشه شدنی هست .
اگه بخوای یه exe که توی برنامه ات ذخیره کردی رو یه جای دیگه مثل پوشه ی برنامه ات سیو کنی ، اینم شدنی هست!!

ولی تا اونجا که من میدونم(هیچی نمیدونم:لبخند:) اگه بخوای همون زمان اجرا کد exe رو بنویسی و بعدش تولید کنی نه نمیشه .(البته چند بار بهش بر خورده بودم ولی آخرش زیاد جالب نبودن.:اشتباه:)

اگه این مورد آخرش رو منظورت هست باید تا سال 2012 یا بعدش صبر کنی تا C# ورژن 5 هم بیاد

mirage041
جمعه 22 مرداد 1389, 12:26 عصر
الان این کیلاگرها چطوری فایل .exe رو می سازن ؟
ما یک کیلاگر رو انتخاب می کنیم . تنظیمات دلخواه رو روشون انجام می دیم . اخرشم make رو می زنیم . فایلمون امادست. منظوره من اینه ؟

cardano7
جمعه 22 مرداد 1389, 14:29 عصر
اگه این مورد آخرش رو منظورت هست باید تا سال 2012 یا بعدش صبر کنی تا C#‎ ورژن 5 هم بیاد

عذر می خوام میون کلوم شما اساتید حرف می زنم. اما تا اونجا که من به یادم میاد در ایام جوانی از این روش استفاده می کردیم:
http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.aspx

حالا منظور شما رو دقیق نمی دونم. فقط می دونم مسئله به اون پیچیدگی ها نیست.

mirage041
شنبه 23 مرداد 1389, 08:45 صبح
در حقیقت من یک فایل exe می سازم که کاربر از این فایل exe یک فایل exe دیگه می سازه . دوستان می گفتند باید از روش ری سورس استفاده کنی !!!!

exlord
شنبه 23 مرداد 1389, 09:58 صبح
در حقیقت من یک فایل exe می سازم که کاربر از این فایل exe یک فایل exe دیگه می سازه . دوستان می گفتند باید از روش ری سورس استفاده کنی !!!!

خوی فایل exe مگه چجوری ساخته میشه ... یه سری کد نوشته میشه و ارسال میشه به کامپایلر اونم exe رو میسازه ...
قبلا هم همینجا بحث شده .... یه سرچی بزنی حتما پیدا میکنی ...
کلا روش کار اینه که کد هاتو generate میکنی و تو یه فایل .cs ذخیره میکنی و این فایل رو کامپایل میکنی ..

Reza_Yarahmadi
شنبه 23 مرداد 1389, 11:20 صبح
راهنمایی دوستمون cardano7 (http://barnamenevis.org/forum/member.php?u=145181) کامل بود.
فضای نام CodeDom برای همین کار در نظر گرفته شده. کدهای مورد نظرتون به صورت String به این کلاس پاس داده و تنظیم مربوط بهش انجام میشه و در نهایت با اجرای برنامه شما فایل exe جدید ساخته میشه.
لینک زیر توضیح مختصری در این رابطه داده:
http://vahidnasiri.blogspot.com/2009/09/blog-post_16.html

mirage041
شنبه 23 مرداد 1389, 11:39 صبح
متاسفانه بنده تازه کارم و متوجه نشدم .

mirage041
یک شنبه 24 مرداد 1389, 17:03 عصر
قضیه این resourse کردن چیه ؟

mirage041
سه شنبه 30 شهریور 1389, 09:41 صبح
خب من کلی گشتم در این مورد یه چیزایی سرم شد .
الان این سورس رو در نظر بگیرید :


using System;
using System.Collections.Generic;
//دو فضاي نامي كه براي اين منظور اضافه شده‌اند
using Microsoft.CSharp;
using System.CodeDom.Compiler;

namespace compilerTest
{
class Program
{
static void compileIt1()
{
//سورس كد ما جهت كامپايل
string source =
@"
namespace Foo
{
public class Bar
{
static void Main(string[] args)
{
Bar.SayHello();
}

public static void SayHello()
{
System.Console.WriteLine(""Hello World"");
}
}
}
";

//تعيين نگارش كامپايلر مورد استفاده
Dictionary<string, string> providerOptions = new Dictionary<string, string>
{
{"CompilerVersion", "v3.5"}
};
//تعيين اينكه كد ما سي شارپ است
CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);

//تعيين اينكه خروجي يك فايل اجرايي است بعلاوه مشخص سازي محل ذخيره سازي فايل نهايي
CompilerParameters compilerParams = new CompilerParameters
{
OutputAssembly = "D:\\Foo.EXE",
GenerateExecutable = true
};

//عمليات كامپايل در اينجا صورت مي‌گيرد
CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, source);

//اگر خطايي وجود داشته باشد نمايش داده خواهد شد
Console.WriteLine("Number of Errors: {0}", results.Errors.Count);
foreach (CompilerError err in results.Errors)
{
Console.WriteLine("ERROR {0}", err.ErrorText);
}
}

static void Main(string[] args)
{
compileIt1();

Console.WriteLine("Press a key...");
Console.ReadKey();
}
}
}





این سورس برای کنسول نوشته شده چطوری می تونم از این تو فرم ویندوز استفاده کنم .
در ضمن من می خوام فایل تولید شده یک تصویر رو نشون بده . ( یعنی بعد از تولید فایل اجرایی این فایل با کلیک روش یک تصویر رو نشون بده یا یک متنی رو نمایش بده و ... ) برای این کار باید چیکار کنم .

sinashahab
سه شنبه 30 شهریور 1389, 10:29 صبح
این سورس برای کنسول نوشته شده چطوری می تونم از این تو فرم ویندوز استفاده کنم .

خیلی سادس . اگه وقت کردم برات درست می کنم:چشمک:.


در ضمن من می خوام فایل تولید شده یک تصویر رو نشون بده . ( یعنی بعد از تولید فایل اجرایی این فایل با کلیک روش یک تصویر رو نشون بده یا یک متنی رو نمایش بده و ... ) برای این کار باید چیکار کنم .

خیلی تلاش کردم ولی هر کاری کردم فقط می شد باهاش یه برنامه ی Console درست کرد.

اگه تونست غیر Console تولید کنه خیلی جالب میشه.

من سورس رو اینطوریش کردم:

string source =
@"

namespace Thread
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[System.STAThread]
static void Main()
{
System.Windows.Forms.Application.EnableVisualStyle s();
System.Windows.Forms.Application.SetCompatibleText RenderingDefault(false);
System.Windows.Forms.Application.Run(new Form1());
}
}
public partial class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
}
}
}


";

مشکل اینجاست که کلاس فرم رو اصلا نمیشناسه:لبخند:.

Reza_Yarahmadi
سه شنبه 30 شهریور 1389, 11:21 صبح
اين يه نمونه ساده است بايد يك مقدار دستكاريش كنيد

Source1 = @"using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace test
{
static class Program
{
[STAThread]
static void Main()
{
Process.GetCurrentProcess().StartInfo.CreateNoWind ow = false;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new MainForm());
}
}

public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}

private void txbPass_KeyPress(object sender, KeyPressEventArgs e)
{

}

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{

}
}
partial class MainForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txbPass = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);" +
"this.label1.Name = \"label1\";" +
"this.label1.Size = new System.Drawing.Size(137, 13);" +
"this.label1.TabIndex = 0;" +
"this.label1.Text = \"Please enter your password\";" +
@"this.txbPass.Location = new System.Drawing.Point(12, 25);" +
"this.txbPass.Name = \"txbPass\";" +
@"this.txbPass.Size = new System.Drawing.Size(233, 20);
this.txbPass.TabIndex = 1;
this.txbPass.UseSystemPasswordChar = true;
this.txbPass.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txb Pass_KeyPress);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(257, 65);
this.Controls.Add(this.txbPass);
this.Controls.Add(this.label1);
this.MaximizeBox = false;" +
"this.Name = \"MainForm\";" +
"this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;" +
"this.Text = \"Password protected file\";" +
"this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this. MainForm_FormClosing);" +
@"this.ResumeLayout(false);
this.PerformLayout();

}
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txbPass;
}
}";

Dictionary<string, string> providerOptions = new Dictionary<string, string>
{
{"CompilerVersion", "v3.5"}
};

CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);

string[] references = new string[] { @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Windows.Forms.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Drawing.dll",
@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dl l",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Deployment.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Xml.dll",
@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Lin q.dll",
@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Da taSetExtensions.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Data.dll"
};

CompilerParameters compilerParams = new CompilerParameters(references)
{
OutputAssembly = "D:\\test.EXE",
GenerateExecutable = true,
MainClass = "test.Program",
};

CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, Source1);

mirage041
سه شنبه 30 شهریور 1389, 11:33 صبح
میشه توضیحم بدید .....
مثله بالایی که تو هر مرحله چیکار کردید ....

mirage041
سه شنبه 30 شهریور 1389, 11:58 صبح
یه سورس دیگه هم هست که من باز سر در نمی یارم ازش و نیاز به توضیح داره :


using System.CodeDom;
using System.CodeDom.Compiler;
using System;
using System.IO;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

class CodeDomExample
{
// Build a Hello World program graph using
// System.CodeDom types.
public static CodeCompileUnit BuildHelloWorldGraph()
{
// Create a new CodeCompileUnit to contain
// the program graph.
CodeCompileUnit compileUnit = new CodeCompileUnit();

// Declare a new namespace called Samples.
CodeNamespace samples = new CodeNamespace("Samples");
// Add the new namespace to the compile unit.
compileUnit.Namespaces.Add(samples);

// Add the new namespace import for the System namespace.
samples.Imports.Add(new CodeNamespaceImport("System"));

// Declare a new type called Class1.
CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1");
// Add the new type to the namespace type collection.
samples.Types.Add(class1);

// Declare a new code entry point method.
CodeEntryPointMethod start = new CodeEntryPointMethod();

// Create a type reference for the System.Console class.
CodeTypeReferenceExpression csSystemConsoleType = new CodeTypeReferenceExpression("System.Console");

// Build a Console.WriteLine statement.
CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression(
csSystemConsoleType, "WriteLine",
new CodePrimitiveExpression("Hello World!"));

// Add the WriteLine call to the statement collection.
start.Statements.Add(cs1);

// Build another Console.WriteLine statement.
CodeMethodInvokeExpression cs2 = new CodeMethodInvokeExpression(
csSystemConsoleType, "WriteLine",
new CodePrimitiveExpression("Press the Enter key to continue."));

// Add the WriteLine call to the statement collection.
start.Statements.Add(cs2);

// Build a call to System.Console.ReadLine.
CodeMethodInvokeExpression csReadLine = new CodeMethodInvokeExpression(
csSystemConsoleType, "ReadLine");

// Add the ReadLine statement.
start.Statements.Add(csReadLine);

// Add the code entry point method to
// the Members collection of the type.
class1.Members.Add(start);

return compileUnit;
}

public static void GenerateCode(CodeDomProvider provider,
CodeCompileUnit compileunit)
{
// Build the source file name with the appropriate
// language extension.
String sourceFile;
if (provider.FileExtension[0] == '.')
{
sourceFile = "TestGraph" + provider.FileExtension;
}
else
{
sourceFile = "TestGraph." + provider.FileExtension;
}

// Create an IndentedTextWriter, constructed with
// a StreamWriter to the source file.
IndentedTextWriter tw = new IndentedTextWriter(new StreamWriter(sourceFile, false), " ");
// Generate source code using the code generator.
provider.GenerateCodeFromCompileUnit(compileunit, tw, new CodeGeneratorOptions());
// Close the output file.
tw.Close();
}

public static CompilerResults CompileCode(CodeDomProvider provider,
String sourceFile,
String exeFile)
{
// Configure a CompilerParameters that links System.dll
// and produces the specified executable file.
String[] referenceAssemblies = { "System.dll" };
CompilerParameters cp = new CompilerParameters(referenceAssemblies,
exeFile, false);
// Generate an executable rather than a DLL file.
cp.GenerateExecutable = true;

// Invoke compilation.
CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile);
// Return the results of compilation.
return cr;
}
}

public class CodeDomExampleForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button run_button = new System.Windows.Forms.Button();
private System.Windows.Forms.Button compile_button = new System.Windows.Forms.Button();
private System.Windows.Forms.Button generate_button = new System.Windows.Forms.Button();
private System.Windows.Forms.TextBox textBox1 = new System.Windows.Forms.TextBox();
private System.Windows.Forms.ComboBox comboBox1 = new System.Windows.Forms.ComboBox();
private System.Windows.Forms.Label label1 = new System.Windows.Forms.Label();

private void generate_button_Click(object sender, System.EventArgs e)
{
CodeDomProvider provider = GetCurrentProvider();
CodeDomExample.GenerateCode(provider, CodeDomExample.BuildHelloWorldGraph());

// Build the source file name with the appropriate
// language extension.
String sourceFile;
if (provider.FileExtension[0] == '.')
{
sourceFile = "TestGraph" + provider.FileExtension;
}
else
{
sourceFile = "TestGraph." + provider.FileExtension;
}

// Read in the generated source file and
// display the source text.
StreamReader sr = new StreamReader(sourceFile);
textBox1.Text = sr.ReadToEnd();
sr.Close();
}

private void compile_button_Click(object sender, System.EventArgs e)
{
CodeDomProvider provider = GetCurrentProvider();

// Build the source file name with the appropriate
// language extension.
String sourceFile;
if (provider.FileExtension[0] == '.')
{
sourceFile = "TestGraph" + provider.FileExtension;
}
else
{
sourceFile = "TestGraph." + provider.FileExtension;
}

// Compile the source file into an executable output file.
CompilerResults cr = CodeDomExample.CompileCode(provider,
sourceFile,
"TestGraph.exe");

if (cr.Errors.Count > 0)
{
// Display compilation errors.
textBox1.Text = "Errors encountered while building " +
sourceFile + " into " + cr.PathToAssembly + ": \r\n\n";
foreach (CompilerError ce in cr.Errors)
textBox1.AppendText(ce.ToString() + "\r\n");
run_button.Enabled = false;
}
else
{
textBox1.Text = "Source " + sourceFile + " built into " +
cr.PathToAssembly + " with no errors.";
run_button.Enabled = true;
}
}

private void run_button_Click(object sender,
System.EventArgs e)
{
Process.Start("TestGraph.exe");
}

private CodeDomProvider GetCurrentProvider()
{
CodeDomProvider provider;
switch ((string)this.comboBox1.SelectedItem)
{
case "CSharp":
provider = CodeDomProvider.CreateProvider("CSharp");
break;
case "Visual Basic":
provider = CodeDomProvider.CreateProvider("VisualBasic");
break;
case "JScript":
provider = CodeDomProvider.CreateProvider("JScript");
break;
default:
provider = CodeDomProvider.CreateProvider("CSharp");
break;
}
return provider;
}

public CodeDomExampleForm()
{
this.SuspendLayout();
// Set properties for label1
this.label1.Location = new System.Drawing.Point(395, 20);
this.label1.Size = new Size(180, 22);
this.label1.Text = "Select a programming language:";
// Set properties for comboBox1
this.comboBox1.Location = new System.Drawing.Point(560, 16);
this.comboBox1.Size = new Size(190, 23);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Items.AddRange(new string[] { "CSharp", "Visual Basic", "JScript" });
this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Left
| System.Windows.Forms.AnchorStyles.Right
| System.Windows.Forms.AnchorStyles.Top;
this.comboBox1.SelectedIndex = 0;
// Set properties for generate_button.
this.generate_button.Location = new System.Drawing.Point(8, 16);
this.generate_button.Name = "generate_button";
this.generate_button.Size = new System.Drawing.Size(120, 23);
this.generate_button.Text = "Generate Code";
this.generate_button.Click += new System.EventHandler(this.generate_button_Click);
// Set properties for compile_button.
this.compile_button.Location = new System.Drawing.Point(136, 16);
this.compile_button.Name = "compile_button";
this.compile_button.Size = new System.Drawing.Size(120, 23);
this.compile_button.Text = "Compile";
this.compile_button.Click += new System.EventHandler(this.compile_button_Click);
// Set properties for run_button.
this.run_button.Enabled = false;
this.run_button.Location = new System.Drawing.Point(264, 16);
this.run_button.Name = "run_button";
this.run_button.Size = new System.Drawing.Size(120, 23);
this.run_button.Text = "Run";
this.run_button.Click += new System.EventHandler(this.run_button_Click);
// Set properties for textBox1.
this.textBox1.Anchor = (System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom
| System.Windows.Forms.AnchorStyles.Left
| System.Windows.Forms.AnchorStyles.Right);
this.textBox1.Location = new System.Drawing.Point(8, 48);
this.textBox1.Multiline = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(744, 280);
this.textBox1.Text = "";
// Set properties for the CodeDomExampleForm.
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(768, 340);
this.MinimumSize = new System.Drawing.Size(750, 340);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox1,
this.run_button, this.compile_button, this.generate_button,
this.comboBox1, this.label1 });
this.Name = "CodeDomExampleForm";
this.Text = "CodeDom Hello World Example";
this.ResumeLayout(false);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}

[STAThread]
static void Main()
{
Application.Run(new CodeDomExampleForm());
}
}

Reza_Yarahmadi
سه شنبه 30 شهریور 1389, 23:32 عصر
میشه توضیحم بدید .....
کدی که قراره کامپایل بشه معلومه چیه.
مراحل کامپایل مثل همون مثال شماست فقط بخشهای زیر فرق داره

string[] references = new string[] { @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.dll",...
رفرنسهای مورد نیاز رو بهش میدید. توی مثال رفرنسهای پیش فرض VS رو بهش دادم.

MainClass = "test.Program"
اسم کلاسی که متد Main توی اون تعریف شده.

یه سورس دیگه هم هست که من باز سر در نمی یارم ازش و نیاز به توضیح داره :
طریقه عمل کردن کد شما با کد من یکی است فقط کد شما برای تولید کد از CodeGenerator استفاده میکنه و کدی که من نوشتم دستی این کار رو انجام میده. در واقع کلاس CodeDomExample کدی که من بصورت دستی نوشتم رو تولید و توی یک فایل با پسوند cs vb js ذخیره میکنه.
کلاس CodeDomExampleForm هم فرمی است که نمایش داده میشه.
اگر کد خودتون رو بصورت زیر تغییر بدید میتونید فرم درست کنید.
class CodeDomExample
{
public static CodeCompileUnit BuildHelloWorldGraph()
{
CodeCompileUnit compileUnit = new CodeCompileUnit();
CodeNamespace samples = new CodeNamespace("Samples");
compileUnit.Namespaces.Add(samples);
samples.Imports.Add(new CodeNamespaceImport("System"));
samples.Imports.Add(new CodeNamespaceImport("System.Drawing"));
samples.Imports.Add(new CodeNamespaceImport("System.Windows.Forms"));
CodeTypeDeclaration f1 = new CodeTypeDeclaration("Form1");
f1.BaseTypes.Add("Form");
samples.Types.Add(f1);
CodeEntryPointMethod start = new CodeEntryPointMethod();
CodeTypeReferenceExpression formType = new CodeTypeReferenceExpression("Application");
CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression(
formType, "Run",
new CodeVariableReferenceExpression("new Form1()"));
start.Statements.Add(cs1);
f1.Members.Add(start);
return compileUnit;
}

public static void GenerateCode(CodeDomProvider provider, CodeCompileUnit compileunit)
{
String sourceFile;
if (provider.FileExtension[0] == '.')
{
sourceFile = "TestGraph" + provider.FileExtension;
}
else
{
sourceFile = "TestGraph." + provider.FileExtension;
}
IndentedTextWriter tw = new IndentedTextWriter(new StreamWriter(sourceFile, false), " ");
provider.GenerateCodeFromCompileUnit(compileunit, tw, new CodeGeneratorOptions());
tw.Close();
}

public static CompilerResults CompileCode(CodeDomProvider provider, String sourceFile, String exeFile)
{
String[] referenceAssemblies = { "System.dll", @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Drawing.dll", @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Windows.Forms.dll" };
CompilerParameters cp = new CompilerParameters(referenceAssemblies, exeFile, false );
cp.GenerateExecutable = true;

CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile);
return cr;
}
}
ولی اگر میخواید یک فرم تقریبا ثابت رو درست کنید راحتترین کار دستی درست کردنش
میتونید اول یک با مشخصات خودتون درست کنید و بعد کدهاشو توی یک متغیر رشته ای بریزید.
فقط مشکلی که هست اینه که فرم رو به همراه یک پنجره command باز میکنه. راستش نمیدنم چطور باید کاری کرد اون نمایش داده نشه.

mirage041
چهارشنبه 10 آذر 1389, 16:33 عصر
اين يه نمونه ساده است بايد يك مقدار دستكاريش كنيد

Source1 = @"using System;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace test
{
static class Program
{
[STAThread]
static void Main()
{
Process.GetCurrentProcess().StartInfo.CreateNoWind ow = false;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new MainForm());
}
}

public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}

private void txbPass_KeyPress(object sender, KeyPressEventArgs e)
{

}

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{

}
}
partial class MainForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txbPass = new System.Windows.Forms.TextBox();
this.SuspendLayout();
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);" +
"this.label1.Name = \"label1\";" +
"this.label1.Size = new System.Drawing.Size(137, 13);" +
"this.label1.TabIndex = 0;" +
"this.label1.Text = \"Please enter your password\";" +
@"this.txbPass.Location = new System.Drawing.Point(12, 25);" +
"this.txbPass.Name = \"txbPass\";" +
@"this.txbPass.Size = new System.Drawing.Size(233, 20);
this.txbPass.TabIndex = 1;
this.txbPass.UseSystemPasswordChar = true;
this.txbPass.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txb Pass_KeyPress);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(257, 65);
this.Controls.Add(this.txbPass);
this.Controls.Add(this.label1);
this.MaximizeBox = false;" +
"this.Name = \"MainForm\";" +
"this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScree n;" +
"this.Text = \"Password protected file\";" +
"this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this. MainForm_FormClosing);" +
@"this.ResumeLayout(false);
this.PerformLayout();

}
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txbPass;
}
}";

Dictionary<string, string> providerOptions = new Dictionary<string, string>
{
{"CompilerVersion", "v3.5"}
};

CSharpCodeProvider provider = new CSharpCodeProvider(providerOptions);

string[] references = new string[] { @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Windows.Forms.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Drawing.dll",
@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dl l",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Deployment.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Xml.dll",
@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Lin q.dll",
@"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Da taSetExtensions.dll",
@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Syst em.Data.dll"
};

CompilerParameters compilerParams = new CompilerParameters(references)
{
OutputAssembly = "D:\\test.EXE",
GenerateExecutable = true,
MainClass = "test.Program",
};

CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, Source1);


این سورس جواب میده فقط چند تا سوال :
1- قسمت سورس 1 سورس کدوم فایله : form یا program یا ... .
2- قسمت های مثله این خطا می دن :
text.boxt="salam";
به دلیل اون ""اا می دن چطوری باید رفعش کرد .
3- و صفحه سیاه هم که هست .

Felony
چهارشنبه 10 آذر 1389, 17:49 عصر
الان این کیلاگرها چطوری فایل .exe رو می سازن ؟
ما یک کیلاگر رو انتخاب می کنیم . تنظیمات دلخواه رو روشون انجام می دیم . اخرشم make رو می زنیم . فایلمون امادست. منظوره من اینه ؟

اونهایی که میبینید اصولا یه فایل exe از پیش تهیه شده هستن و داخل برنامه به صورت Resource ذخیره شدن ، و اون تنضیماتی که انتخاب میکنید به صورت Stream در آخر اون فایل exe نوشته میشه و فایل در جایی که شما مایل هستید کپی میشه ( ساخته نمیشه ، بلکه از حالت ریسورس خارج میشه ) ، برنامه کپی شده موق اجرا تنضیماتی که به صورت Stream در آخرش نوشته شده رو میخونه و اجرا میشه و شما فکر میکنید که یه فایل exe ساخته .

$M03N$
چهارشنبه 10 آذر 1389, 18:40 عصر
اونهایی که میبینید اصولا یه فایل exe از پیش تهیه شده هستن و داخل برنامه به صورت Resource ذخیره شدن ، و اون تنضیماتی که انتخاب میکنید به صورت Stream در آخر اون فایل exe نوشته میشه و فایل در جایی که شما مایل هستید کپی میشه ( ساخته نمیشه ، بلکه از حالت ریسورس خارج میشه ) ، برنامه کپی شده موق اجرا تنضیماتی که به صورت Stream در آخرش نوشته شده رو میخونه و اجرا میشه و شما فکر میکنید که یه فایل exe ساخته .

خوب این روشی که میگین چطوری میشه پیادش کرد ؟ ؟ ؟

اگه میشه یه مثال بزنید:متفکر:

c-sharp_South
سه شنبه 25 تیر 1392, 12:34 عصر
این کد ها رو بیخیال :کف:
یکی بیاد این رو توضیح بده چی شده که تاپیک کامل بسته بشه.
توی فایلی که گذاشتم از همین تالار چند مدت پیش دانلود کردم . یکی از دوستان زحمتشو کشیده بود.
دو تا سورس برنامه هست . یکی از برنامه ها اون برنامه ای است ( شما فرض کنید دستورات و کدهای مخرب ویروس ) .
توی سورس دوم یک برنامه است که باهاش یک سری ویژگی های ویروس رو تغییر میدیم و Make EXE میزنیم و برنامه EXE جدید با ویژگی های جدید ساخته میشه :کف:
توش از چند تا فایل dat استفاده شده که بنده هیچ سر در نیاوردم هرچی روشون کار کردم .
یکی لطف کنه و توضیح بده :گیج:
دانلود (http://s2.picofile.com/file/7848289993/Make_Exe_Create_Exe.rar.html)
بی صبرانه منتظر پاسخ های شما هستیم :بوس: :کف: :خجالت: