[C#]Making a DLL Unaccessible By Unwanted Access

Results 1 to 8 of 8
  1. #1
    Grand Master xSilv3rbullet is offline
    Grand MasterRank
    Apr 2009 Join Date
    1,226Posts

    [C#]Making a DLL Unaccessible By Unwanted Access

    So I'm making a library right now, but I'm gonna have to include it with my program.

    However, I don't want people to be able to use the methods inside of the DLL.

    How do I do this?
    O_O


  2. #2
    Ginger by design. jMerliN is offline
    Grand MasterRank
    Feb 2007 Join Date
    2,500Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    Quote Originally Posted by xSilv3rbullet View Post
    So I'm making a library right now, but I'm gonna have to include it with my program.

    However, I don't want people to be able to use the methods inside of the DLL.

    How do I do this?
    O_O
    There are a N + 1 ways, the simplest is to use ordinals because it throws off what the exported functions really do.

    Other ways are much more complex but much more effective, etc. A common one is to make 1 export but only pass a bunch of callbacks through, etc.

    I digress, however, that since your stuff is C#, if someone wants to know something, they'll just decompile it. Hf.
    Last edited by jMerliN; 29-09-09 at 03:35 AM.

  3. #3

    I love Dan

    TheAJ is offline

    DeveloperRank
    May 2007 Join Date
    Toronto, CanadaLocation
    3,944Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    use the "protected internal" modifier. This allows access only to what's within the assembly:

    Code:
    public class Foo
    {
        protected internal void DoSomething()
        {
            ...
        }
    }

    Eg:
    namespace = Assembly1 = allowed
    namespace = Assembly1.Sub = allowed
    namespace = Assembly2 = denied

    Unless i did not yet what your meaning?
    Last edited by TheAJ; 29-09-09 at 04:25 AM.

  4. #4
    Grand Master xSilv3rbullet is offline
    Grand MasterRank
    Apr 2009 Join Date
    1,226Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    Quote Originally Posted by TheAJ View Post
    use the "protected internal" modifier. This allows access only to what's within the assembly:

    Code:
    public class Foo
    {
        protected internal void DoSomething()
        {
            ...
        }
    }

    Eg:
    namespace = Assembly1 = allowed
    namespace = Assembly1.Sub = allowed
    namespace = Assembly2 = denied

    Unless i did not yet what your meaning?
    What I'm trying to do is to prevent unwanted access to methods and such in my library.

    I've already done something like

    Code:
    public Foo(string password, int id, int header, string body)
    {
    //Code that I'm too lazy to add here. :P  But hashes the passwords and stuff and compares them to what they should be
    }


    ---------- Post added at 07:31 PM ---------- Previous post was at 07:30 PM ----------

    Quote Originally Posted by jMerliN View Post
    There are a N + 1 ways, the simplest is to use ordinals because it throws off what the exported functions really do.

    Other ways are much more complex but much more effective, etc. A common one is to make 1 export but only pass a bunch of callbacks through, etc.

    I digress, however, that since your stuff is C#, if someone wants to know something, they'll just decompile it. Hf.
    C# can't be decompiled...or can it?
    I read an article how the most decompilers do is take the EXE and spit out ASM.

  5. #5

    I love Dan

    TheAJ is offline

    DeveloperRank
    May 2007 Join Date
    Toronto, CanadaLocation
    3,944Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    Quote Originally Posted by xSilv3rbullet View Post
    What I'm trying to do is to prevent unwanted access to methods and such in my library.

    I've already done something like

    Code:
    public Foo(string password, int id, int header, string body)
    {
    //Code that I'm too lazy to add here. :P  But hashes the passwords and stuff and compares them to what they should be
    }
    ... yeah this disallows access from without the assembly (library, console, form, etc)

  6. #6
    Elite Member Team Zebra is offline
    Member +Rank
    Mar 2009 Join Date
    234Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    You were probably reading about C/C++ decompilers. C# isn't a native language, it's compiled into MSIL (Microsoft's answer to Java bytecode). It can be decompiled to near-perfect source code.

  7. #7
    iNewLegend , Leo123 zolamu is offline
    Grand MasterRank
    Apr 2006 Join Date
    Холон, IsrLocation
    737Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    pack with themida
    and make some password to get library working

  8. #8
    Thanks for the memories! Nillus is offline
    Grand MasterRank
    Feb 2007 Join Date
    The NetherlandsLocation
    2,627Posts

    Re: [C#]Making a DLL Unaccessible By Unwanted Access

    You can go with the 'internal' keyword, but I would also use Xenocode Postbuild or SmartAssembly on top of it against decompilers. Those applications obfuscate all related assemblies (so executables and libraries), but in such a way that they can still communicate. They are being informed about changed method names etc. The program also removes the CLI header so apps like Reflector cant even see the obfuscated code at all.
    Posted via Mobile Device



Advertisement