解決 WinXP下 libcurl.dll 無法定位程式輸入點GetTickCount64問題
阿新 • • 發佈:2019-01-11
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
{CURL_SRC}\src\tool_util.cstruct 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 style="color:#ff0000;">//#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 style="color:#ff0000;">/*#else ULONGLONG milliseconds = GetTickCount64(); now.tv_sec = (long) (milliseconds / 1000); now.tv_usec = (long) (milliseconds % 1000) * 1000; #endif*/</span> return now; }
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 style="color:#ff0000;">/*#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) ULONGLONG milliseconds = GetTickCount64(); #else*/</span> DWORD milliseconds = GetTickCount(); <span style="color:#ff0000;">//#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 style="color:#ff0000;">/D_USING_V110_SDK71_</span>
CURL_CFLAGS = /I../lib /I../include /nologo /W3 /EHsc /DWIN32 /FD /c <span style="color:#ff0000;">/D_USING_V110_SDK71_</span>
CURL_LFLAGS = /nologo /out:$(DIRDIST)\bin\$(PROGRAM_NAME) <span style="color:#ff0000;">/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 目錄生成目標檔案.