//—————————————————————————
#include
#pragma argsused
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fwdreason, LPVOID lpvReserved)
{
return 1;
}
//—————————————————————————
//本示例代码用BCB5编写,很简略移植到VC++等编译环境
//导出函数mcuisp_AntiCopy,mcuisp.exe将调用mcuisp_AntiCopy函数来完成反复制功用
extern “C” __declspec(dllexport) int __stdcall mcuisp_AntiCopy(
unsigned char *buf,//FLASH内容存储缓冲
DWORD buflen,//FLASH代码长度(字节)
DWORD startaddress,//FLASH的地址偏移,STM32F一般为0x08000000
unsigned char const *inbuf, //前12字节为96bit的芯片序列号
DWORD inputbuflen//序列号信息的长度
);
//–
int __stdcall mcuisp_AntiCopy(
unsigned char *buf,//FLASH内容存储缓冲
DWORD buflen,//FLASH代码长度(字节)
DWORD startaddress,//FLASH的地址偏移,STM32F一般为0x08000000
unsigned char const *inbuf, //前12字节为96bit的芯片序列号
DWORD inputbuflen//序列号信息的长度
)
{
//mcuisp_AntiCopy依据FLASH内容和芯片序列号,通过运算后,修正FLASH内容
//本例中,简略的把序列号复制到0x08010000的方位
//能够在STM32的代码中比对0x08010000和0x1ffff7e8的内容,相符才正常运转
//实践使用中,能够采纳比较复杂的算法
memcpy(buf+0x10000,inbuf,12);
return 0;
};
上述DLL与mcuisp合作,即可完成STM32F AntiCopy功用。
因为算法由用户自己掌握,自由发挥,可最大极限维护用户的代码
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/peixun/258377.html