Hey I was wondering if any of you know about IL Assembly. I know the basics but I would like to know about compare operations. If\Then\End If in VB.NET or in C# if (something != notthesame) {} else {} I can call something but I dont know how to react to the function call!!! Thanks, PMR Code: .method public static void main() cil managed { .entrypoint ldstr "Can you write in pure IL Assembly Language?" call void [mscorlib]System.Console::WriteLine(string) ldstr "File-C:\\Windows\\Explorer.exe : Exists? : " call void [mscorlib]System.Console::Write(string) ldstr "C:\\Windows\\Explorer.exe" call bool CheckFile(string) call void [mscorlib]System.Console::WriteLine(bool) ret } .method public static bool CheckFile(string) cil managed { ldarg.0 call bool [mscorlib]System.IO.File::Exists(string) ret } Still a work in progress but i would like to know how to react if CheckFile = False. im going to do a drag and drop super light weight application EDIT: is it br [label] or br.s [label]?
ok after some messing around I got it!!! Code: .method public static void main() cil managed { .locals init([0] string sourceFile, [1] string destFile, [2] bool flag ) .entrypoint ldstr "Can you write in pure IL Assembly Language?" call void [mscorlib]System.Console::WriteLine(string) ldstr "File-D:\\ILCoding\\Exp.exe : Exists? : " call void [mscorlib]System.Console::Write(string) ldstr "D:\\ILCoding\\Exp.exe" stloc.0 ldloc.0 call bool CheckFile(string) stloc.2 ldloc.2 call void [mscorlib]System.Console::WriteLine(bool) ldloc.2 brfalse.s Exit React: ldloc.0 ldstr "D:\\ILCoding\\Exp1.exe" stloc.1 ldloc.1 ldc.i4.1 call void [mscorlib]System.IO.File::Copy(string,string,bool) br Exit Exit: ldstr "Done with your operation..." call void [mscorlib]System.Console::WriteLine(string) ret } .method public static bool CheckFile(string) cil managed { ldarg.0 call bool [mscorlib]System.IO.File::Exists(string) ret } that IL Assembly code translates to this in C# and VB.NET Code: C# public static bool CheckFile(string A_0) { return File.Exists(A_0); } public static void main() { Console.WriteLine("Can you write in pure IL Assembly Language?"); Console.Write("File-C:\\Windows\\Explorer.exe : Exists? : "); string str = "D:\\ILCoding\\Exp.exe"; bool flag = u003cModuleu003e.CheckFile(str); Console.WriteLine(flag); if (flag) { string str1 = "D:\\ILCoding\\Exp1.exe"; File.Copy(str, str1, true); } Console.WriteLine("Done with your operation..."); } VB.NET Public Shared Function CheckFile(ByVal A_0 As String) As Boolean Return File.Exists(A_0) End Function Public Shared Sub main() Console.WriteLine("Can you write in pure IL Assembly Language?") Console.Write("File-C:\Windows\Explorer.exe : Exists? : ") Dim str As String = "D:\ILCoding\Exp.exe" Dim flag As Boolean = u003cModuleu003e.CheckFile(str) Console.WriteLine(flag) If (flag) Then Dim str1 As String = "D:\ILCoding\Exp1.exe" File.Copy(str, str1, True) End If Console.WriteLine("Done with your operation...") End Sub EDIT: I forgot I changed the string around while doing this. It still works but might need to be modded