国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

c++實現(xiàn)加載so動態(tài)庫中的資源

2020-05-23 13:54:48
字體:
供稿:網(wǎng)友

實例如下:

#include <stdio.h> #include <dlfcn.h> #include <stdlib.h> #include <iostream> //編譯命令 g++ -m32 EncodeOrDecode.cpp -ldl -o edcode//名字通過nm -D xxxxxx.so獲取using namespace std;int main(int argc,char **argv){void *handle = dlopen("./libpub_com_service.so",RTLD_LAZY);if(!handle){printf("open libpub error ,dlerror=%s/n",dlerror());return -1;}string src = "05d7151349b7fe9b54306d90f9c938b3";string desKey = "pub.%?d5";//58printf("start ..src=[%s].....size=[%d]./n",src.c_str(),src.size());//encode typedef string (*encode_t)(const string encodeSrc,const string encodeKey);encode_t encode = (encode_t)dlsym(handle,"_ZN10NS_PUB_API9DesEncodeESsSs");if(!encode){printf("not found encode function ,dlerror= %s /n",dlerror());dlclose(handle);return -1;}string encodeStr = encode(src,desKey);printf("get the encode function success ..encodeStr=[%s].....size=[%d]/n",encodeStr.c_str(),encodeStr.size());//decode typedef bool (*decode_t)(const string decodeSrc,const string decodeKey,string &outResult);decode_t decode = (decode_t)dlsym(handle,"_ZN10NS_PUB_API9DesDecodeESsSsRSs");if(!decode){printf("not found decode function ,dlerror= %s /n",dlerror());dlclose(handle);return -1;}string decodeOut;bool ret = decode(encodeStr,desKey,decodeOut);printf("get the decode function success ...ret=[%d]...decodeOut=[%s].....size=[%d]/n",ret,decodeOut.c_str(),decodeOut.size());//enddlclose(handle);return 0;}

以上就是小編為大家?guī)淼腸++實現(xiàn)加載so動態(tài)庫中的資源全部內(nèi)容了,希望大家多多支持VEVB武林網(wǎng)~


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 安仁县| 仪征市| 江源县| 嫩江县| 沛县| 南召县| 陇西县| 香河县| 祁东县| 仙桃市| 井陉县| 台湾省| 岗巴县| 泾源县| 富蕴县| 东莞市| 新建县| 永济市| 嘉禾县| 通辽市| 仁怀市| 苍南县| 哈巴河县| 临洮县| 静海县| 海盐县| 南皮县| 葫芦岛市| 巴青县| 普宁市| 富锦市| 积石山| 青海省| 应城市| 建宁县| 达州市| 鹤庆县| 曲水县| 博白县| 荔浦县| 湘潭市|