CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    1

    C# DLL loaded from memory during run-time

    I'm developing an application that requires high levels of security and needs to hide certain libraries so that they cannot be detected from file scanning and such.

    It isn't a virus or anything malicious but it does need to contain code that is undetectable so to speak.

    I thought up a way to do this but am unsure how to complete the final step. For instance, I compiled a DLL, converted the DLL file to a base 64 Encoded String, Encrypted the String and Saved it inside of a new project as a String variable.

    Now, when I compile my main application hypothetically it should Decrypt the String to base 64 encoding, decode base 64 into byte array and load the byte array as a library inside of the executable. All of this should be done in memory without file IO during run-time.

    The final step of loading the library during run time from raw memory is the step where I am confused. I'm sure this has to be possible. I know that DLLImport command allows external libraries to be loaded but what about libraries built in memory. Could I cast the byte array to an interface and access the code that way?

    By the way, an obfuscation program is not what I'm interested in. I already have one and it doesn't work very well. The others are way too expensive.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: C# DLL loaded from memory during run-time

    Rather than DllImport, can you make the dll a managed assembly and call LoadAssembly?

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: C# DLL loaded from memory during run-time

    If the dll is a common .net assembly, convert the base64 string into byte array and call Assembly.Load(byte[]) with it. It should work.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured