Specify Custom Obfuscators for Protected Models
When creating a protected model, you can specify your own postprocessing function for
            files that the protected model creation process generates. Before packaging the
            protected model files, this function is called by the Simulink.ModelReference.protect function. You can use this functionality
            to run your own custom obfuscator on the generated files by following these steps:
- Create your postprocessing function. Use this function to call your custom obfuscator. The function must be on the MATLAB® path and accept a - Simulink.ModelReference.ProtectedModel.HookInfoobject as an input variable.
- In your function, get the files and exported symbol information that your custom obfuscator requires to process the protected model files. To get the files and information, access the properties of your function input variable. The variable is a - Simulink.ModelReference.ProtectedModel.HookInfoobject with the following properties:- SourceFiles
- NonSourceFiles
- ExportedSymbols
 
- Pass the protected model file information to your custom obfuscator. The following is an example of a postprocessing function for custom obfuscation: - function myHook(protectedModelInfo) % Get source file list information. srcFileList = protectedModelInfo.SourceFiles; disp('### Obfuscating...'); for i=1:length(srcFileList) disp(['### Obfuscator: Processing ' srcFileList{i} '...']); % call to custom obfuscator customObfuscator(srcFileList{i}); end end
- Specify your postprocessing function when creating the protected model: - Simulink.ModelReference.protect('myModel, ... 'Mode', ... 'CodeGeneration', ... 'CustomPostProcessingHook', ... @(protectedModelInfo)myHook(protectedModelInfo))
The protected model creator can also enable obfuscation of simulation target code and
            generated code through the ‘ObfuscateCode’ option of the
                Simulink.ModelReference.protect function. Your custom
            obfuscator runs only on the generated code and not on the simulation target code or the
            generated HDL code. If both obfuscators are in use, the custom obfuscator is the last to
            run on the generated code before the files are packaged.