Calling dll in protected model.

3 vues (au cours des 30 derniers jours)
Quentin Coret
Quentin Coret le 30 Mar 2023
Commenté : Jack le 30 Mar 2023
Hello,
I've been trying to call a .dll from a protected model, but it doesn't seem to be calling my function from the .dll.
I've succesfully been able to call my dll function in my Simulink block, but when I create a protected model out of this Simulink block, it seems like it doesn't call the function from the dll anymore.
I know it's not called for two reasons:
  1. The simulation return is wrong
  2. I've added a license check with a dongle to the dll and it runs even without the dongle
Is it a limitation of protected models? Is there any other way to protect this model? I don't want the user to be able to see/modify/remove this.
Thanks!
  1 commentaire
Quentin Coret
Quentin Coret le 30 Mar 2023
I think it might be because I am using a not in-line S-function as I am using the S-function to call the dll...

Connectez-vous pour commenter.

Réponse acceptée

Jack
Jack le 30 Mar 2023
Hi,
It is possible that the issue you are facing is related to the use of a non-inline S-function. Protected models have certain limitations on the types of S-functions that can be used, and non-inline S-functions may not be supported.
One solution you could try is to convert your S-function into an inline S-function, which should be compatible with protected models. To do this, you can use the S-function Builder, which is a tool provided by Simulink to create S-functions.
Here are the steps to create an inline S-function using the S-function Builder:
  1. Open the S-function Builder by typing sfcn in the MATLAB command window.
  2. Click "New" to create a new S-function.
  3. In the "General" tab, specify the name and location of the S-function.
  4. In the "Ports" tab, specify the input and output ports of the S-function.
  5. In the "Parameters" tab, specify any parameters that the S-function requires.
  6. In the "Callbacks" tab, implement the S-function's functions (such as mdlInitializeSizes, mdlInitializeSampleTimes, mdlStart, mdlOutputs, etc.) using MATLAB code.
  7. Save and close the S-function Builder.
Once you have created the inline S-function, you can use it in your Simulink model and protect the model using Simulink's built-in protection mechanisms.
Alternatively, you could consider encrypting your DLL using a tool such as Themida or VMProtect, which would make it more difficult for users to access and modify your DLL. However, this approach may not be foolproof, and it would not prevent users from using your DLL outside of your protected model.
  2 commentaires
Quentin Coret
Quentin Coret le 30 Mar 2023
Thanks for the detailed answer.
I've just tried it, but you need to put C code in the S-function builder, and it ends up pretty much generating the same S-function that I've build by hand.
Turns out, I figured I didn't have to do this in Simulink, and I've found an easier way to do what I want with Matlab script that I can protect with pcode.
Jack
Jack le 30 Mar 2023
I'm glad to hear that you found a solution that works for you! Using MATLAB script and protecting it with pcode can be a good option for implementing custom functionality in Simulink while keeping your code confidential. If you have any further questions or concerns, feel free to ask.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by