您现在的位置是:首页 > 综合 > 精选知识 > 正文
lol无法定位程序输入点于动态链接库(2024年07月20日英雄联盟无法定位程序输入点setupdiget)
发布时间:2024-07-20 20:00:22滕天丹来源:
今天火狐为大家解答以上的问题。lol无法定位程序输入点于动态链接库,2024年07月20日英雄联盟无法定位程序输入点setupdiget相信很多小伙伴还不知道,现在让我们一起来看看吧!
1、第一步,我先从简单的调用出发,定义了一个简单的函数,该函数仅仅实现一个整数加法求和: LIBEXPORT_API int mySum(int a,int b){ return a+b;} C# 导入定义: public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=***.Auto,CallingConvention=CallingConvention.StdCall)] public static extern int mySum (int a,int b); } 在C#中调用测试: int iSum = RefComm.mySum(,); 运行查看结果iSum为5,调用正确。
2、第一步试验完成,说明在C#中能够调用自定义的动态链接库函数。
3、 第二步,我定义了字符串操作的函数(简单起见,还是采用前面的函数名),返回结果为字符串: LIBEXPORT_API char *mySum(char *a,char *b){sprintf(b,"%s",a); return a;} C# 导入定义: public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=***.Auto, CallingConvention=CallingConvention.StdCall)] public static extern string mySum (string a, string b); } 在C#中调用测试: string strDest=""; string strTmp= RefComm.mySum("45", strDest); 运行查看结果 strTmp 为"45",但是strDest为空。
4、我修改动态链接库实现,返回结果为串b: LIBEXPORT_API char *mySum(char *a,char *b){sprintf(b,"%s",a) return b;} 修改 C# 导入定义,将串b修改为ref方式: public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=***.Auto,CallingConvention=CallingConvention.StdCall)] public static extern string mySum (string a, ref string b); } 在C#中再调用测试: string strDest=""; string strTmp= RefComm.mySum("45", ref strDest); 运行查看结果 strTmp 和 strDest 均不对,含不可见字符。
5、再修改 C# 导入定义,将CharSet从Auto修改为Ansi: public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)] public static extern string mySum (string a, string b); } 在C#中再调用测试: string strDest=""; string strTmp= RefComm. mySum("45", ref strDest); 运行查看结果 strTmp 为"45",但是串 strDest 没有赋值。
6、第二步实现函数返回串,但是在函数出口参数中没能进行输出。
7、再次修改 C# 导入定义,将串b修改为引用(ref): public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)] public static extern string mySum (string a, ref string b); } 运行时调用失败,不能继续执行。
8、 第三步,修改动态链接库实现,将b修改为双重指针: LIBEXPORT_API char *mySum(char *a,char **b){sprintf((*b),"%s",a); return *b;} C#导入定义: public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)] public static extern string mySum (string a, ref string b); } 在C#中调用测试: string strDest=""; string strTmp= RefComm. mySum("45", ref strDest); 运行查看结果 strTmp 和 strDest 均为"45",调用正确。
9、第三步实现了函数出口参数正确输出结果。
10、 第四步,修改动态链接库实现,实现整数参数的输出: LIBEXPORT_API int mySum(int a,int b,int *c){ *c=a+b; return *c;} C#导入的定义: public class RefComm { [DllImport("LibEncrypt.dll", EntryPoint=" mySum ", CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)] public static extern int mySum (int a, int b,ref int c); } 在C#中调用测试: int c=0; int iSum= RefComm. mySum(,, ref c); 运行查看结果iSum 和c均为5,调用正确。
11、 经过以上几个步骤的试验,基本掌握了如何定义动态库函数以及如何在 C# 定义导入,有此基础,很快我实现了变长加密函数在 C# 中的调用,至此目标实现。
12、 三、结论 在 C# 中调用 C++ 编写的动态链接库函数,如果需要出口参数输出,则需要使用指针,对于字符串,则需要使用双重指针,对于 C# 的导入定义,则需要使用引用(ref)定义。
13、 对于函数返回值,C# 导入定义和 C++ 动态库函数声明定义需要保持一致,否则会出现函数调用失败。
14、定义导入时,一定注意 CharSet 和 CallingConvention 参数,否则导致调用失败或结果异常。
15、运行时,动态链接库放在 C# 程序的目录下即可,我这里是一个 C# 的动态链接库,两个动态链接库就在同一个目录下运行。
本文就为大家分享到这里,希望小伙伴们会喜欢。
标签:
猜你喜欢
- lol无法定位程序输入点于动态链接库(2024年07月20日英雄联盟无法定位程序输入点setupdiget)
- 长城红酒和张裕红酒的区别(2024年07月20日长城和张裕红酒哪个好)
- 小规模2021年4月(2024年07月20日小规模纳税人账务处理)
- 2021430太阳(2024年07月20日太阳质量)
- 系统保留分区未分配驱动器号无法更改(2024年07月20日系统保留分区未分配驱动器号)
- 阿酷字体转换器(2024年07月20日阿酷字体)
- 白苞筋骨草图片(2024年07月20日白玉筋骨贴)
- 2024年07月20日狗的动画片
- 2024铝合金与6061区别(2024年07月20日6061是什么材料)
- 金樽金樽清酒斗十千玉盘珍羞直万钱(2024年07月20日金樽清酒斗十千玉盘珍羞直万钱)
- 奔驰e200l新车报价2014款(2024年07月20日奔驰e200价格)
- 2024年7月20日是黄道吉日吗(2024年07月20日零度战姬女主被黄毛草)
- cad怎么绘制圆弧的切线(2024年07月20日cad怎么画圆弧的切线)
- 2024年7月20日黄历(2024年07月20日失孤迅雷下载)
- 海鲜酱的食用方法(2024年07月20日海鲜酱)
- 2024年7月22日(2024年07月20日疳)
- 2024年07月日历壁纸(2024年07月20日语文手抄报五年级)
- 眼睛激光手术后多久能怀孕(2024年07月20日眼睛激光手术多久恢复)
- 汪峰像梦一样自由现场版(2024年07月20日汪峰战队4强像梦一样自由mp3下载)
- 中华人民共和国行政诉讼法2024年修订全文(2024年07月20日诉讼是什么意思)
最新文章
- lol无法定位程序输入点于动态链接库(2024年07月20日英雄联盟无法定位程序输入点setupdiget)
- 胃不好喝什么茶最养胃(2024年07月20日胃不好喝什么茶养胃)
- 小学生四年级班规大全(2024年07月20日小学四年级班规内容)
- 小学四年级班级班规班训(2024年07月20日小学四年级班规内容)
- 长城红酒和张裕红酒的区别(2024年07月20日长城和张裕红酒哪个好)
- 小规模2021年4月(2024年07月20日小规模纳税人账务处理)
- 短篇小说投稿app(2024年07月20日短篇小说投稿赚钱)
- 壁水貐限定技能(2024年07月20日壁水羽最新作品)
- 2021430太阳(2024年07月20日太阳质量)
- 系统保留分区未分配驱动器号无法更改(2024年07月20日系统保留分区未分配驱动器号)
- 哈尔滨啤酒是哪一年开始生产的(2024年07月20日哈尔滨啤酒是哪个国家的)
- 永远的兄弟视频(2024年07月20日永远的兄弟)
- 2024年07月18日(2024年07月20日失烈门)
- 阿酷字体转换器(2024年07月20日阿酷字体)
- 炸裂,扣非净利暴增超139倍,股价频创新高,芯片龙头热度高居第一!多只苹果概念股被盯上
- 白苞筋骨草图片(2024年07月20日白玉筋骨贴)
- 辉腾1.4t报价(2024年07月20日phaeton辉腾报价)
- 武侠七公主迅雷1080p下载(2024年07月20日武侠七公主迅雷下载)
- led灯泡 功率(2024年07月20日led灯泡功率)
- 2024年07月20日狗的动画片
- 上半年景区类上市公司业绩冷暖不均:长白山、三特索道业绩预增,曲江文旅预亏超1.5亿元,桂林旅游跌超27倍
- 2024铝合金与6061区别(2024年07月20日6061是什么材料)
- 2021年天龙八部脚本(2024年07月20日天龙八部脚本莫愁)
- 孚日家纺上市了吗(2024年07月20日孚日家纺电子采购平台)