Dev*_*-iL 3 matlab reverse-engineering shared-libraries built-in function-definition
在MATLAB中,大致有3种方法来定义函数:非注释.m文件,.p文件和编译后的代码(例如DLL,MEX)。
在某些情况下,例如在对我们控制范围之外的某个功能进行重大更改时,知道在何处定义函数可能会有所帮助,并且我们希望尝试恢复为旧版本,以期使我们的代码再次正常工作; 或尝试反向工程某些未公开的算法时。
The which function is usually very good at identifying function definitions and their locations (which works for .m, .p and MEX), but isn't very useful when it comes to shared library functions, where (at best) it points to a comment-only documentation file:
>> which _mcheck
built-in (undocumented)
>> which svd
built-in (D:\Program Files\MATLAB\R2019a\toolbox\matlab\matfun\svd)
Run Code Online (Sandbox Code Playgroud)
If so, assuming a function found within a shared library is called during the execution of my code, how can I locate the specific file (DLL) that contains it?
It turns out that dbstop can be used for this. For example:
>> which svd
built-in (D:\Program Files\MATLAB\R2019a\toolbox\matlab\matfun\svd)
>> dbstop svd
Warning: Entering debug mode is only supported within running MATLAB code files.
Warning: MATLAB debugger can only stop in MATLAB code files, and "libmwmathlinalg>svd" is not a MATLAB code file.
Instead, the debugger will stop at the point right before "libmwmathlinalg>svd" is called.
Run Code Online (Sandbox Code Playgroud)
From there's it's just a matter of finding a file called libmwmathlinalg (with the relevant extension) - which isn't a difficult task if your drive is indexed.
| 归档时间: |
|
| 查看次数: |
59 次 |
| 最近记录: |