start program directly from memory?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I would like load teh data(it's my program decrypted) in memory and run it
directly from my memory.

If you have an idea?

best regards,

wavemill
 
Hello!

thank's for your answers.

assembly.load, load but not run my program.

I would like run my program directly from my memory.

best regards,

wavemill

Mattias Sjögren said:
If you have an idea?

Assembly.Load(byte[]) may be useful.


Mattias
 
Lets suppose that assebly that you've loaded has type (class) MyType. This
type has method StartProgram();

After the assembly was loaded this type can be obtained with
Assembly asm = Assebmly.Load(byte[]);
Type t = asm.GetType("MyType");
BindingFlags flags = (BindingFlags.Public | BindingFlags.Instance );
MethodInfo mInfo = t.GetMethod("StartProgram", flags);
mInfo.Invoke(...);


--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com


wavemill said:
Hello!

thank's for your answers.

assembly.load, load but not run my program.

I would like run my program directly from my memory.

best regards,

wavemill

Mattias Sjogren said:
If you have an idea?

Assembly.Load(byte[]) may be useful.


Mattias
 
after the assembly is loaded. Assembly.EntryPoint will give you the
entry point of your executable (the static Main), you can call Invoke
off of that to start the program.
 
This is my code:
FileStream fs = new FileStream(@"C:\Documents and Settings\Berdoues\Mes
documents\VisualStudioProjects\Application_Test_WindowsForm\LoadAssembly\CaptureControl.exe",FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] byteload = br.ReadBytes(Convert.ToInt32(fs.Length));
fs.Close();
br.Close();

Assembly asm = Assembly.Load(byteload);
object o = asm.CreateInstance("CaptureControl");
MethodInfo mi = asm.EntryPoint;
if(mi != null)
{
mi.Invoke(o,null);
}

It doesn'work.
"capturecontrol" is the name of my assemble and the namespce of my class
I don't understand the parameter of mi.Invoke(?,?);
Thank you for your help and patience!

wavemill
 
Back
Top