首页 > 解决方案 > Run exe file from resource in c# with security(prevent extracting)

问题描述

Hi Engineers, i made a login panel with c# form. I coded everything but now I am in a section that I'm still searching about 1 week and I did not get any result.

I want to add a exe file (rather not .NET) to my resources. and run it when login button press

»»»»IMPORTANT: but I don't want it to copy my exe resources to HDD (simple security :D) so I think I should run it from memory

I dont know this code is true or no but i use this

                    FileStream fs = new FileStream(filepath, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);
                byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length));
                fs.Close();
                br.Close();

                Assembly a = Assembly.Load(bin);

                MethodInfo method = a.EntryPoint;
                if (method != null) {
                    object o = a.CreateInstance(method.Name);
                    // invoke the application starting point
                    method.Invoke(o, null);

                }

but I get this error

Could not load file or assembly '8237056 bytes loaded

can anybody help me?

标签: c#memoryresources.net-assemblyobfuscation

解决方案


推荐阅读