![]() |
|
[C#] CodeDom Compiler | Add & Read Resources | Change Icon + Guide - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] CodeDom Compiler | Add & Read Resources | Change Icon + Guide (/showthread.php?tid=3557696) |
CodeDom Compiler | Add & Read Resources | Change Icon + Guide - xQQ - Jun 17, 2013 Hello again, today I felt like sharing my custom CodeDom Compiler class that comes with few good features. It's fully Object Oriented, so it's easy to use and won't need a further edit. Features: -Compile C# Sourcecode -Add an Icon to the compiled .exe -Add resources and grab them in runtime (explained below) -Enable Debug-Mode to figure out whats not working (properly) Source: Code using System.CodeDom.Compiler;Usage: This is just a HowTo use this Compiler. I will not go into detail on how things actually work, if you are interested head to msdn. The easiest way is just calling the constructor Code QCompiler Compiler = new QCompiler(source);Code QCompiler Compiler = new QCompiler(source, "FileName.exe", IconPath)Resource Compiling with CodeDom has one big disadvantage: Is has limit for the maximum chars per line. Most people use codedom for their binders and crypters, so if you need to read the bytes of a .exe, they will be stored as only one line. This is unhandy as you need to split this string of bytes first into mayn lines. Using resources can bypass this. So how we gonna add a resource? In our Builder we need to create a .resources file first, which later will be included in our stub: Code System.Resources.ResourceWriter ResWriter = new System.Resources.ResourceWriter("PathWhereToSave.resources");The next thing we need to do is enabling the matching feature in the compiler by doing the following. Code gen.AddRes = true;In our stub, we need to add Code System.Resources.ResourceManager ResManager = new System.Resources.ResourceManager("PathWhereToSave", System.Reflection.Assembly.GetExecutingAssembly());Code string FromRes = (string)ResManager.GetObject("ResourceString");And for all the coders working on their 1337 FUD Crypters and Binders, if you want to work with bytes, you need to use this fro writing Code System.Resources.ResourceWriter ResWriter = new System.Resources.ResourceWriter("SomeName.resources");Code byte[] TheBytes = (byte[])ResManager.GetObject("MyBytes");Debug-Mode Well nothing much to explain about this. You can enable it with Code Compiler.DebugMode = true-saves sourcecode to clipboard, so you can have a look over it if something went wrong -will have the compiler treat warings as errors -will look for everything tha compiler could complain about, even if it wouldn't affect the output at all. credits: http://msdn.microsoft.com/ So I hope you like it. Always feel free to post questions, feedback and suggestions. * - TheExDamage - Jun 17, 2013 Nice work keep it up .... 👍 * - Psychotiic - Jun 18, 2013 this is nice work, i really only care about the icon change though, but very nice overall |