一个dll文件 用implib生成了lib文件使用的问题

zwest 2006-07-14 11:05:58
该dll文件是一个改了名的dll文件 原名是abc.dll 现在的名字是abc0101.dll
implib abc0101.dll abc0101.lib 后
程序调用时如果dll 文件名是abc0101.dll是就不能调用,必须改为abc.dll才能调用

而用LoadLibrary(abc0101.dll )动态调用是改了名字dll就可以
怎么能用第一种静态调用时也能用改名后的dll(即abc0101.dll)呢
...全文
559 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯本 2006-07-14
  • 打赏
  • 举报
回复
可以,用ultra-edit/winhex或其它十六进制编辑工具,但有2点
1.要将lib文件中所有的abc.dll改成新的名字
2.dll名字的长度不可变,也就是说,你可改abc.dll为bde.dll,但不能改为abc0101.dll
zwest 2006-07-14
  • 打赏
  • 举报
回复
abc0101.lib 中是有"abc.dll"字符串
但是没有试过 lib文件是可以手工编辑的吗
cczlp 2006-07-14
  • 打赏
  • 举报
回复
abc0101.lib 中有"abc.dll"字符串, 如果替换一下也许可以.
BlueDeepOcean 2006-07-14
  • 打赏
  • 举报
回复
那就动态调用喽……
jaffy 2006-07-14
  • 打赏
  • 举报
回复
好象不可以吧,除非有原代码重新取个名字,编译一次应该就可以了
zwest 2006-07-14
  • 打赏
  • 举报
回复
主要是这个dll不是自己写的 是一个其他公司的接口dll 他们也是为了区分不同版本的才改名的
daydayup234 2006-07-14
  • 打赏
  • 举报
回复
不随便改名
不随便改路径
会省很多麻烦
zwest 2006-07-14
  • 打赏
  • 举报
回复
因为程序已经写好了 少改点
有办法能在静态调用时用新的文件名(abc0101.dll)吗
BlueDeepOcean 2006-07-14
  • 打赏
  • 举报
回复
能够动态读取为什么还要变成.lib后进行静态读取呢?
BlueDeepOcean 2006-07-14
  • 打赏
  • 举报
回复
The IMPLIB utility creates import library. IMPLIB takes as input DLLs, module definition files, or both, and produces an import library as output.

If you've created a Windows application, you've already used at least one import library, IMPORT32.LIB, the import library for the standard Windows DLLs. IMPORT32.LIB is linked automatically when you build a Win32 application in the C++Builder IDE and when using BCC32 at the command line.

An import library lists some or all of the exported functions for one or more DLLs. IMPLIB creates an import library directly from DLLs or from module definition files for DLLs (or a combination of the two).

Creating an Import Library for a DLL

Options must be lowercase and preceded by either a hyphen or a slash.

Type:

IMPLIB Options LibName [ DefFiles... | DLLs... ] [@ResponseFile]

where Options is an optional list of one or more IMPLIB options, LibName is the name for the new import library, DefFiles is a list of one or more existing module definition files for one or more DLLs, and DLLs is a list of one or more existing DLLs. You must specify at least one DLL or module definition file.

You can also use a response file to list the .DEF and .DLL files that you want to process. A response file is an ACSII text file that contains a list of files. The files must be separated by either spaces or new lines in the file. To specify a response file on the command line, precede the response filename with an "at" sign (@). For example,

implib foo.lib @respon.txt

Note: A DLL can also have an extension of .EXE or .DRV, not just .DLL.

Option Description

-a Add '_' alias for cdecl functions for compatibility with Microsoft libraries
-c Warnings on case sensitive symbols
-f Force imports by name
-w No warnings.
zwest 2006-07-14
  • 打赏
  • 举报
回复
cb中 implib 中有无参数可以修改名称呢
BlueDeepOcean 2006-07-14
  • 打赏
  • 举报
回复
晕……这可能就是传说中的早期破译技巧……
柯本 2006-07-14
  • 打赏
  • 举报
回复
应该不可以,你可以看以下我的dll转成的lib的头部分,dll名为dll1.dll,它的长度是固定的,你可以改为dll2.dll,但不能改为dll002.dll,后面没有位置了.


F0 0D 00 00 02 00 00 01 00 00 00 00 00 00 00 00 ?..............
80 12 00 10 5F 5F 5F 5F 43 50 50 64 65 62 75 67 €...____CPPdebug
48 6F 6F 6B 67 88 2F 00 00 A0 01 00 10 5F 5F 5F Hookg?..?..___
5F 43 50 50 64 65 62 75 67 48 6F 6F 6B 08 64 6C _CPPdebugHook.dl
6C 31 2E 64 6C 6C 0F 5F 5F 5F 43 50 50 64 65 62 l1.dll.___CPPdeb
75 67 48 6F 6F 6B DC 8A 02 00 00 74 00 00 00 00 ugHook軍...t....
80 07 00 05 5F 74 65 73 74 55 88 19 00 00 A0 01 €..._testU?..?
00 05 5F 74 65 73 74 08 64 6C 6C 31 2E 64 6C 6C .._test.dll1.dll
04 74 65 73 74 B8 8A 02 00 00 74 00 00 00 00 00 .test笂...t.....
F1 6D 01 00 00 00 00 00 00 00 00 00 00 00 00 00 駇..............
zwest 2006-07-14
  • 打赏
  • 举报
回复
多谢 keiy() 了
问题是现在改的长度就是不一样了 能否同步改长度呢
MSVC vs. MinGW 之 (lib,dll,def,obj,exe) vs (a,dll,def,o,exe) 玩转攻略手记 一份粗糙的研究记录,有待补完和整理。 MinGW: c -> o gcc -c a.c c -> exe gcc a.c libs.o -o a.exe (从主程序a.c,附加libs,生成a.exe) o -> exe gcc a.o b.o ... -o main.exe c -> dll,def,a gcc a.c -shared -o a.dll -Wl,--output-def,a.def,--out-implib,liba.a a -> dll a2dll liba.a dll -> a: dlltool --dllname a.dll --def a.def --output-lib liba.a (需要def文件) a -> def: dumpbin /exports lib.a > lib.def (在windows上调用,def需要修改) dll -> def : pexports a.dll -o > a.def (这里的-o是指给函数标序号) lib -> def : reimp -d a.lib lib -> a: (for __cdecl functions in most case) reimp a.lib; (for __stdcall functions) MSVC: c -> lib cl /LD a.c (注意已经定义了export列表) c -> dll cl /LD a.c c -> obj cl /c a.c c -> exe cl a.c /out:a.exe dll ->lib lib /machine:ix86 /def:a.def /out:a.lib (需要def文件) obj ->lib lib a.obj b.obj... /out:mylib.lib dll ->def DUMPBIN a.dll /EXPORTS /OUT:a.def (生成的def需要做修正) lib ->def reimp -d a.lib (这个要在MSYS+MinGW下用) 关于这些工具的适用范围可以很容易的理解和记忆。 dll和exe都是PE文件,所以可以使用pexports. lib和a是静态库文件,都是归档类型,不是PE格式。所以不能使用pexports. dll可以使用dlltool. lib可以使用lib, 和reimp(lib->a工具) 所有的bin文件,包括dll,exe,lib,a都可以使用dumpbin. 参考: http://hi.baidu.com/kaien_space/blog/item/5e77fafa2ba9ff16a8d3110a.html Mingw官网文档: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs http://oldwiki.mingw.org/index.php/CreateImportLibraries http://www.mingw.org/wiki/FAQ http://hi.baidu.com/opaquefog/blog/item/9b21b6deb324e25dccbf1ab7.html http://qzone.qq.com/blog/8330936-1238659272 http://hi.baidu.com/jzinfo/blog/item/b0aa1d308de99f9da8018e00.html 本篇测试用代码: 1. main.cpp #include #include #include "mylib.h" using namespace std; int main() { char str[]="Hello world!"; printhello(str); return 0; } 2. mylib.cpp #include #include #include "mylib.h" using namespace std; void EXPORT printhello(char *str) { cout << str << endl; } 3. mylib.h #define EXPORT __declspec(
1)VsDll为vs2010工程,编译生成动态库。 2)BCBCall为bcb工程,调用动态库 3)Viewdll.exe为查看DLL导出文件的工具。 注意事项一: VSDll里面有一个 KpHttps.def LIBRARY "KpHttps" EXPORTS InitKpHttp Project > Properties... > Linker > Input > Module Definition File 里面加入你刚才的KpHttps.def文件,重新编译就行了。出来的InitKpHttp函数前面没有下划线,后面没有@8或者@ABCDEF之类的。 注意事项二: 用C++Builder的implib工具生成DLL对应的lib文件。如:implib xx.lib xxx.dll生成lib文件之后,C++Builder便可以使用这个lib文件了。 注意事项三: 文件头的声明应该完全一样,否则(呵呵),会出现链接错误。 #ifdef DLL_API #define DLL_API extern "C" _declspec(dllexport) #else #define DLL_API extern "C" _declspec(dllimport) #endif #ifdef __cplusplus extern "C" { #endif DECLDIR int __stdcall InitKpHttp(void); DECLDIR int UnInitKpHttp(void); DECLDIR int KpHttpRequest(char *strurl,char *strhost,char *strresult,int &resultle;); DECLDIR int KpHttpsRequest(char *strurl,char *strhost,char *strresult,int &resultle;); DECLDIR int KpHttpPost(char *strurl,char *strhost,char *strPost,int postlen,char *strresult,int &resultle;); DECLDIR int KpHttpsPost(char *strurl,char *strhost,char *strPost,int postlen,char *strresult,int &resultle;); DECLDIR int KpUpLoadFile(char *strurl,char *strhost,char *filebuf,int filelen,char *strresult,int &resultle;); DECLDIR int KpDownLoadFile(char *strurl,char *strhost,char *filebuf,int &filelen;,char *strresult,int &resultle;); #ifdef __cplusplus } #endif

604

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder VCL组件使用和开发
社区管理员
  • VCL组件使用和开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧