473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

In-Memory Assemblies

Hi,
I'm trying to make something work and I'm pretty sure it can be done, but I
can't get it working.

I have a encrypted file that contains everything my software needs: exe,
dlls, et al. I want to make a "loader" that will decrypt the file and get
all parts in memory and run the exe in-memory without dropping it to the
disk. Is it possible or not? and how can I do it? I absolutely dont need to
reference the dlls from my loader, it only needs to call the exe and then
the exe could find it's own dlls.

As an other option... is there some place where I could place the file on
the disk without the user being able to access them? I mean, like a virtual
disk reserved exclusively to my own "Loader" application?

thanks

ThunderMusic
Nov 6 '07 #1
12 1708
Hey ThunderMusic,

Take a look at this article: http://www.codeproject.com/useritems...toAssembly.asp

"This example shows how to load an application and run from memory
system. After the application load, you can use it without the source
EXE file (usually blocked from the system). Useful when you don't have
to have the source EXE file on HDD (e.g. on a USB key)."
Colby Africa
http://colbyafrica.blogspot.com
Nov 6 '07 #2
Hi,
ok, now... since C# seems to require an on-disk assembly, would it be
possible to create like a virtual disk in-memory (like a virtual drive)
where C# could read what it needs to but where the user could not have
access to?

Thanks

ThunderMusic
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,
I'm trying to make something work and I'm pretty sure it can be done, but
I can't get it working.

I have a encrypted file that contains everything my software needs: exe,
dlls, et al. I want to make a "loader" that will decrypt the file and get
all parts in memory and run the exe in-memory without dropping it to the
disk. Is it possible or not? and how can I do it? I absolutely dont need
to reference the dlls from my loader, it only needs to call the exe and
then the exe could find it's own dlls.

As an other option... is there some place where I could place the file on
the disk without the user being able to access them? I mean, like a
virtual disk reserved exclusively to my own "Loader" application?

thanks

ThunderMusic

Nov 6 '07 #3
A RAM disk would be wonderful, but that is implemented as a device
driver... You could take a look at memory mapped files:

http://www.winterdom.com/dev/dotnet/index.html
Nov 6 '07 #4
Yes, it is possible, but it is not pretty. You are going to have to
create a custom host for the assembly, which would probe the encyrpted exe
and tell the CLR which assemblies are loaded, etc, etc.

Look into custom CLR hosts for more information.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,
I'm trying to make something work and I'm pretty sure it can be done, but
I can't get it working.

I have a encrypted file that contains everything my software needs: exe,
dlls, et al. I want to make a "loader" that will decrypt the file and get
all parts in memory and run the exe in-memory without dropping it to the
disk. Is it possible or not? and how can I do it? I absolutely dont need
to reference the dlls from my loader, it only needs to call the exe and
then the exe could find it's own dlls.

As an other option... is there some place where I could place the file on
the disk without the user being able to access them? I mean, like a
virtual disk reserved exclusively to my own "Loader" application?

thanks

ThunderMusic

Nov 6 '07 #5
This is great if you load an exe with no dll attached. but I have a some
dll... I tried to use the LoadModule method but the name I specify is not
what is expected from the method. How can I load the dlls the exe needs to
run? the dlls are in memory too.

Thanks

ThunderMusic

"Colby Africa" <co**********@gmail.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Hey ThunderMusic,

Take a look at this article:
http://www.codeproject.com/useritems...toAssembly.asp

"This example shows how to load an application and run from memory
system. After the application load, you can use it without the source
EXE file (usually blocked from the system). Useful when you don't have
to have the source EXE file on HDD (e.g. on a USB key)."
Colby Africa
http://colbyafrica.blogspot.com


Nov 6 '07 #6
LoadModule should do the trick, but you need to provide the exact name
as it appears in the exe's manifest...
Nov 6 '07 #7
Thanks

And where can I get this name?

"Colby Africa" <co**********@gmail.comwrote in message
news:11**********************@d55g2000hsg.googlegr oups.com...
LoadModule should do the trick, but you need to provide the exact name
as it appears in the exe's manifest...


Nov 6 '07 #8
The name will include the namespace + the type name (so, something
like ThunderMusic.Projects.DLL.MyDll).

Does that make sense?
Nov 6 '07 #9
Hello!
You wrote on Tue, 6 Nov 2007 09:25:22 -0500:

TAs an other option... is there some place where I could place the file
Ton the disk without the user being able to access them? I mean, like a
Tvirtual disk reserved exclusively to my own "Loader" application?

You can implement what you need using Solid File System Driver Edition (
http://www.eldos.com/solfs/driver.php ) however this would require
installation of the custom driver to the system. Installation is done once
(usually during installation of your own application) and rquires
administrator privileges. But you need them to install software anyway.

With best regards,
Eugene Mayevski
http://www.SecureBlackbox.com - the comprehensive component suite for
network security

Nov 6 '07 #10
I made it... not by loading a module tought... I handle the
AssemblyResolve event of the AppDomain and load the appropriate assembly
when needed.

Thanks to all..

ThunderMusic

"Colby Africa" <co**********@gmail.comwrote in message
news:11*********************@v3g2000hsg.googlegrou ps.com...
The name will include the namespace + the type name (so, something
like ThunderMusic.Projects.DLL.MyDll).

Does that make sense?


Nov 6 '07 #11
Hi ThunderMusic,

Can you please supply a sample code so I can learn how to do what you did?

Thanks a mill

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:OX**************@TK2MSFTNGP03.phx.gbl...
>I made it... not by loading a module tought... I handle the
AssemblyResolve event of the AppDomain and load the appropriate assembly
when needed.

Thanks to all..

ThunderMusic

"Colby Africa" <co**********@gmail.comwrote in message
news:11*********************@v3g2000hsg.googlegrou ps.com...
>The name will include the namespace + the type name (so, something
like ThunderMusic.Projects.DLL.MyDll).

Does that make sense?



Nov 6 '07 #12
Here it is:

// try to run the program
if (m_Files.ContainsKey(APPLICATION_ASSEMBLY))
{
// get the file and load it
Assembly a = Assembly.Load(m_Files[APPLICATION_ASSEMBLY]);
// find the entry point of the file (Main)
MethodInfo mi = a.EntryPoint;
if (mi != null)
{
// create an istance of the Startup form Main method
object o = a.CreateInstance(mi.Name);
// handle the Resolve assembly event so we can handle known
assemblies
AppDomain.CurrentDomain.AssemblyResolve += new
ResolveEventHandler(CurrentDomain_AssemblyResolve) ;
// invoke the application starting point
mi.Invoke(o, null);
}
}
private static Assembly CurrentDomain_AssemblyResolve(object sender,
ResolveEventArgs args)
{
string AssemblyName = args.Name.Substring(0, args.Name.IndexOf(','));
if (m_Files.ContainsKey(AssemblyName))
{
// Load the requested assembly from our files
Assembly a = Assembly.Load(m_Files[AssemblyName]);
return a;
}
else return null; // unknown assembly (often in the GAC)
}

I hope it helps

"IfThenElse" <sq**********@hotmail.comwrote in message
news:u0**************@TK2MSFTNGP05.phx.gbl...
Hi ThunderMusic,

Can you please supply a sample code so I can learn how to do what you did?

Thanks a mill

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:OX**************@TK2MSFTNGP03.phx.gbl...
>>I made it... not by loading a module tought... I handle the
AssemblyResolve event of the AppDomain and load the appropriate assembly
when needed.

Thanks to all..

ThunderMusic

"Colby Africa" <co**********@gmail.comwrote in message
news:11*********************@v3g2000hsg.googlegro ups.com...
>>The name will include the namespace + the type name (so, something
like ThunderMusic.Projects.DLL.MyDll).

Does that make sense?




Nov 9 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Curious Expatriate | last post by:
Hi- I'm completely stumped. I'm trying to write some code that will parse a file and rewrite it with all URLs replaced by something else. For example: if the file looks like this: <b>click...
1
by: JS Bangs | last post by:
I started using PHP's object-oriented stuff a little while ago, which has mostly been a joy. However, I've noticed that they don't seem to echo as I would like. Eg: $this->field = 255;...
5
by: lawrence | last post by:
I've waited 6 weeks for an answer to my other question and still no luck, so let me rephrase the question. I know I can do this: <form method="post" action="$self"> <input type="text"...
0
by: Ben Eisenberg | last post by:
I'm trying to run a php script setuid. I've tried POSIX_setuid but you have to be root to run this. The files are located on a public access unix system and have me as the owner and nobody as the...
2
by: Felix | last post by:
Hi, I've a problem: I want to have the result of my Mysql Query in a Table in my php file. Now I've this: <?
1
by: James | last post by:
What is the best way to update a record in a MYSQL DB using a FORM and PHP ? Where ID = $ID ! Any examples or URLS ? Thanks
1
by: Patrick Schlaepfer | last post by:
Why this code is not working on Solaris 2.8 host. Always getting: PHP Fatal error: swfaction() : getURL('http://www.php.net' ^ Line 1: Reason: 'syntax error' in /.../htdocs/ming2.php on...
1
by: phpkid | last post by:
Howdy I've been given conflicting answers about search engines picking up urls like: http://mysite.com/index.php?var1=1&var2=2&var3=3 Do search engines pick up these urls? I've been considering...
1
by: lawrence | last post by:
What is the PHP equivalent of messaging, as in Java?
3
by: Quinten Carlson | last post by:
Is there a way to conditionally define a function in php? I'm trying to run a php page 10 times using the include statement, but I get an error because my function is already defined. The docs...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.