Results 1 to 4 of 4

Thread: How to disallow other people to use my dll?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Thanks for the advice.. I was starting to think about doing something like that but just thought there might be a more "official" way of doing it.. I'm still curious though how other vendors are able to design their dll's as to not even allow you to reference them from your project...

    thanks..

    Dan

  2. #2
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    the dlls you add through the "References" window must be ActiveX dlls. If they aren't then you'll get an error. This does not, however, mean that you can't access the function in that dll. If you have a list of functions and parameters, you can access the function in a dll through the Declare statement.

    Though vb can access this type of dll, it can't compile them. If you want to make a dll that is "Secure" from other programmers, use vc++ and don't release the function list.

  3. #3
    Guest
    The best way is to have your DLL implement a private interface that your application also implements.

    So, create a DLL project called ISecure, or something like that, and add on sub called 'AllowAccess'. Don't put any code in the sub (just a comment to stop VB thinking that it is a blank sub and deleting it).

    Compile this DLL.

    In your DLL, reference the DLL you just compiled, and at the top of each public class, add the line:
    Code:
    Implements ISecure
    In your DLL, have a module level var called mlngAllowAccess or something like that, and add this code
    Code:
    Private Sub ISecure_AllowAccess()
        mlngAllowAccess = True
    End Sub
    Then, use the mlngAllowAccess to decide if the DLL is going to perform the operation (raise an error or something similar)

    Finally, in the app calling the DLL, you will need to add a reference to the ISecure DLL, and before using your DLL, cast it to an ISecure variable and call the AllowAccess sub
    Code:
    Dim lobjTest as MyDll.ClassName ' the DLL we have secured
    Dim lobjISecure as ISecure ' the secure DLL
    
    Set lobjTest = new MyDll.ClassName ' init you DLL
    ' init the secure interface, and 
    'set cast it to an ISecure object
    Set lobjISecure = lobjTest 
    
    'Turn the security on
    lobjISecure.AllowAccess
    
    'Now you can do whatever you want to the actuall DLL
    lobjTest.PerformFunction
    Then, when you compile the application and distribute it, don't distribute the ISecure DLL. It isn't need because your app has a reference to uit in its Vtable, and that all it needs as there is no code in the DLL itself.

    This method can be worked around if someone was to look at the export functions of the DLL, create a DLL that was identical to the ISecure DLL, and then load your DLL late-bound, but it's far more complex than just adding a reference. An improvement to this approach is to map every function in the DLL to a matching function in the ISecure interface, and just call the interface functions instead of directly calling the DLL functions.

    The biggest advantage is that the ISecure_AllowAccess is PRIVATE in the DLL, not public, so it will never appearin the dropdown. Map all your functions in this way, and nothing will appear in the dropdown is someone was to add a reference.

    - gaffa

  4. #4
    Member
    Join Date
    Jan 2001
    Location
    Washington, USA
    Posts
    61

    Add all of the classes to your program

    What about taking the entire classes that are part of the dll, and putting it into your VB program? That way, there will be no seperate dll. It has the unfortunate effect of making a larger VB exe, and upgrades on the dll would be impossible, though.

    Samwise Galenorn
    [email protected]

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