how to load a dll into AutoCAD from http or ftp

how to load a dll into AutoCAD from http or ftp

ashrafa33
Enthusiast Enthusiast
968 Views
3 Replies
Message 1 of 4

how to load a dll into AutoCAD from http or ftp

ashrafa33
Enthusiast
Enthusiast

is there way to load a dll into AutoCAD from http or ftp

0 Likes
969 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

DLL from http/ftp?

 

Basically, this is 2-step work: 

1. down load the DLL file to the computer where AutoCAD runs. You can use Sysytem.Net.WebClient class to down load the DLL file (or any file, for that matter, as long as the file is available in the http/ftp server for downloading);

2. use Assembly.Load/LoadFromFile(), or better yet, use AutoCAD .NET API's ExtensionLoader.Load() to load the DLL into AutoCAD.

 

HOWERVER, there are a security issue you need to deal with, unless the DLL is digitally signed:

 

The OS (Windows) automatically flag ANY executable file (exe, dll, ... ) downloaded from http(s) (not sure on ftp, though) as unsafe and and set an "unsave" lock on the file. You need to unlock it before loading it into AutoCAD. I am not sure how to do it from Windows API code (or even it is doable);

 

Doing things like this (download executable and load to application behind the scene) raise a huge security issue. If your AutoCAD need to get DLL from remote source, I'd strongly recommend do the download separately from loading it into AutoCAD, so that user is aware explicitly that the DLL is downloaded once from a known source, and he/she explicitly unlocks the downloaded file and save it into a known location (AutoCAD's trusted location). Only after this, the dll can be loaded into AutoCAD, manually/automatically.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4

ashrafa33
Enthusiast
Enthusiast

thank you for reply
I Am working in a program and i want to multi users after finished
but i'm afraid from decompiler it
so if you have any way to secure it ??
I Have ftp,http sever so i think to put my dll on the server and make the user to load it from server
than you

0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor

I do think AutoCAD can only load .NET DLL from intranet network folder, or local drive folder, but not from other remote source as stream (http/ftp). So, even you digitally signed the DLL, you still need to down load the file to a network folder/local drive before you can loaded with ExtensionLoader.Load(); meaning, a local copy will exist locally. You might include an small EXE app with your DLL application to be downloaded to the computer, and has the EXE started when AutoCAD is closing; then after AutoCAD is closed, the exe deletes your DLL. However, the exe effectively acts like a spyware, and could be detected/flagged by some anti-virus/spyware app, and you eventually destroy your app's reputation.

 

You could use some kind of obfuscating to your .NET code, then there are many de-obfuscating tools.

 

IMO, it is not worth the effort of preventing de-compiling with downloading DLL from http/ftp.

 

If you do not mind the online requirement to run your DLL (since you want to use http/ftp), you can have you DLL ALWAYS started to request some online data at start, or in the middle of execution (whether the data is needed by the app logic or not), and then build a web service to provide the data. This way, the user must have access to online data in order to run your dll, and the web service would hide some of you code logic away. Again, you still have to decide if it is worth the effort. In most cases, I'd not be bothered by someone decompiling my DLLs and focusing continuously improving my code/functionalities.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes