Results 1 to 3 of 3

Thread: Statically link to C from .NET?

  1. #1
    Junior Member
    Join Date
    Mar 2005

    Statically link to C from .NET?

    I have a some C code which does some security checks. From a C# .NET application I can access this through a DLL by using a DLLimport. However this is insecure because anyone could replace the DLL with one which always returns true to all my security checks.

    Is there anyway I could statically link to the C library form .NET.

    Or is there a good way to ensure the C DLL (not a .NET assembly) has not been tampered with?

  2. #2
    Junior Member
    Join Date
    Feb 2003
    My recommnedation, get a simple commandline MD5 utility and call it from your C# program to verify the MD5 hash of your DLL before you load it. I believe md5checksum is a command line app, but not positive.
    Intelligent people talk about ideas.
    Average people talk about things.
    Small people talk about other people.

  3. #3
    Ninja Code Monkey
    Join Date
    Nov 2001
    Washington State

    .net has built in crypto libraries for doing an assortment of things including hashing and public key crypto. There are some good books out there on it such as - http://www.amazon.com/exec/obidos/tg...books&n=507846

    as far as linking C libraries into the c# code you need to look into .net interop services and pinvoke. You'd probably need to write your own verification methods for what you want....

    If it was me I'd probably re-write the .dll using C#.
    "When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
    "There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
    "Mischief my ass, you are an unethical moron." - chsh
    Blog of X

Posting Permissions

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