于是我又想到了另外一個方法,就是把獲取硬盤序列號的native dll作為資源文件封裝到managed code中,然后在每次要調要該dll時,先把該dll寫入磁盤,再動態綁定。由于managed code可以通過混淆器來保護,以致不能對其進行修改,這個我在《如何保護我們的 .net 程序集?》中已經給出了答案。動態綁定native dll又是另外一個技術難題,我已經找到了一些資料,與大家分享。 late binding on native dlls with c# late-binding dlls in c# using legacy plug-ins with .net - part 1 using legacy plug-ins with .net - part 2 c-function pointer for .net dynamic pinvoke method calls
不過最牛的就是下面這一招了!直接把native code用字節數組保存在managed code中,然后調用,真是牛b,不過我還沒有完全弄懂,希望大家來實踐實踐。 execute native code from .net