解决 WinXP下 libcurl.dll 无法定位程序输入点GetTickCount64问题

时间:2022-03-30 21:52:22

标签:

1. 问题描述

用 IDA 打开libcurl.dll 可以在导入表看到对 GetTickCount64的引用,在 xp 的kernel32.dll中没有 GetTickCount64,

所以会出现 无法定位 GetTickCount64的问题

2. 解决方法

下载源码,自己编译libcurl.dll 

 

编译环境:

Win7 64位系统 + vs2015

 

2.1  下载源码

https://curl.haxx.se/download/curl-7.50.3.tar.gz

2.2   打开 Visual Studio 2015 x64 x86 兼容工具命令提示符

注释掉以下文件中和 GetTickCount64有关的代码

{CURL_SRC}\lib\timeval.c

struct timeval curlx_tvnow(void) { /* ** GetTickCount() is available on _all_ Windows versions from W95 up ** to nowadays. Returns milliseconds elapsed since last system boot, ** increases monotonically and wraps once 49.7 days have elapsed. */ struct timeval now; <span >//#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || (_WIN32_WINNT < _WIN32_WINNT_VISTA)</span> DWORD milliseconds = GetTickCount(); now.tv_sec = milliseconds / 1000; now.tv_usec = (milliseconds % 1000) * 1000; <span >/*#else ULONGLONG milliseconds = GetTickCount64(); now.tv_sec = (long) (milliseconds / 1000); now.tv_usec = (long) (milliseconds % 1000) * 1000; #endif*/</span> return now; }

{CURL_SRC}\src\tool_util.c

struct timeval tool_tvnow(void) { /* ** GetTickCount() is available on _all_ Windows versions from W95 up ** to nowadays. Returns milliseconds elapsed since last system boot, ** increases monotonically and wraps once 49.7 days have elapsed. ** ** GetTickCount64() is available on Windows version from Windows Vista ** and Windows Server 2008 up to nowadays. The resolution of the ** function is limited to the resolution of the system timer, which ** is typically in the range of 10 milliseconds to 16 milliseconds. */ struct timeval now; <span >/*#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) ULONGLONG milliseconds = GetTickCount64(); #else*/</span> DWORD milliseconds = GetTickCount(); <span >//#endif</span> now.tv_sec = (long)(milliseconds / 1000); now.tv_usec = (milliseconds % 1000) * 1000; return now; }


为了让vs2015编译的程序能在xp下运行,,需要修改{CURL_SRC}\winbuild\MakefileBuild.vc

CFLAGS = /I. /I ../lib /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL <span >/D_USING_V110_SDK71_</span> CURL_CFLAGS = /I../lib /I../include /nologo /W3 /EHsc /DWIN32 /FD /c <span >/D_USING_V110_SDK71_</span> CURL_LFLAGS = /nologo /out:$(DIRDIST)\bin\$(PROGRAM_NAME) <span >/subsystem:console,"5.01"</span> /machine:$(MACHINE)


在 Visual Studio 2015 x64 x86 兼容工具命令提示符下输入命令;

nmake /f Makefile.vc mode=dll MACHINE=x86 ENABLE_WINSSL=no ENABLE_IDN=no ENABLE_SSPI=no

编译成功后在 {CURL_SRC}\builds 目录生成目标文件.

解决 WinXP下 libcurl.dll 无法定位程序输入点GetTickCount64问题