lynnux / xpsupport

make rust support XP and vista
31 stars 1 forks source link

运行报错“无法定位程序输入点 QueryFullProcessImageNameA 于动态链接库 KERNEL32.dll” #2

Closed FourLeafTec closed 4 years ago

FourLeafTec commented 4 years ago

成功构建后拷贝 exe和xpsupport-7f5ee64e971a2dbf.dll 到xp sp3后,运行报错

无法定位程序输入点 QueryFullProcessImageNameA 于动态链接库 KERNEL32.dll

构建主机: macOS Catalina

rustup 1.20.2 (13979c968 2019-10-16) cargo 1.37.0 (9edd08916 2019-08-02) mingw-w64: stable 6.0.0 (bottled)

lynnux commented 4 years ago

嗯,测试了下是有问题,估计rust的std又多用了win API QueryFullProcessImageNameA ,等我去研究下源码。。

lynnux commented 4 years ago

问题找到了,我发了份issue给官方,看他们怎么处理,他们不改我再想办法,目前用msvc构建可以绕过这个问题。具体细节可以看这里 https://github.com/rust-lang/backtrace-rs/issues/262

FourLeafTec commented 4 years ago

xp的issue估计官方是不会管了,前面关于xp backtrace的issue解决了的都好几年前的了 msvc构建能绕过也好,已经找公司又要了台电脑装机了...晚上装完环境我再试一下.

您那边的rust和vs环境是什么呀,我现在装的win10, vs2019, 和nightly的rust,如果晚上还不行我尝试复现您那边的环境,活太紧了

lynnux commented 4 years ago

我还在用vs2013呢,rustc 1.40.0-nightly。msvc版本如果要用backtrace的话要包含一份比较新的dbghelp.dll(导出表有SymInitializeW)放到bin所在目录,我下载的这里可以http://wt.ouyaoxiazai.com:89/xiazaidian/DbgHelpDLL.rar。

FourLeafTec commented 4 years ago

vs2019 默认工具链build缺好多东西...

PS D:\work\service-proxy-sx\code\data-sync> cargo rustc -- -C link-args="/subsystem:console,5.01" > log.log
warning: The package `xpsupport` provides no linkable target. The compiler might raise an error while compiling `xpsupport_sys`. Consider adding 'dylib' or 'rlib' to key `crate-type` in `xpsupport`'s Cargo.toml. This warning might turn into a hard error in the future.
   Compiling xpsupport v0.1.5
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\work\\service-proxy-sx\\code\\data-sync\\target\\debug\\deps\\xpsupport-0f4ea48279830bfb.xpsupport.u4epkqx9-cgu.0.rcgu.o" "/OUT:D:\\work\\service-proxy-sx\\code\\data-sync\\target\\debug\\deps\\xpsupport-0f4ea48279830bfb.dll" "/DEF:C:\\Users\\ylsk\\AppData\\Local\\Temp\\rustcUwdTu5\\lib.def" "D:\\work\\service-proxy-sx\\code\\data-sync\\target\\debug\\deps\\xpsupport-0f4ea48279830bfb.15jkqa6gtldfb5wp.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:D:\\work\\service-proxy-sx\\code\\data-sync\\target\\debug\\deps" "/LIBPATH:D:\\work\\service-proxy-sx\\code\\data-sync\\target\\debug\\build\\xpsupport-85238333a3a783a8\\out" "/LIBPATH:C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "minhook.lib" "kernel32.lib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-8864852919b3dde3.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_abort-ad12bcb34e183f0e.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libbacktrace-e90b3ab99b608a07.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-d9b7b1604d471c6c.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-a439eac7fda93b7a.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-058c975bf38e4686.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-711d56157cf28645.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-d802c196c150a787.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-7147008fc56d32b8.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-57b2ee5c835455f8.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-6391a360e3eeafba.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-6c8df881cdc2afb2.rlib" "C:\\Users\\ylsk\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-f998976453a15b70.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib" "/DLL" "/IMPLIB:D:\\work\\service-proxy-sx\\code\\data-sync\\target\\debug\\deps\\xpsupport-0f4ea48279830bfb.dll.lib"
  = note:    Creating library D:\work\service-proxy-sx\code\data-sync\target\debug\deps\xpsupport-0f4ea48279830bfb.dll.lib and object D:\work\service-proxy-sx\code\data-sync\target\debug\deps\xpsupport-0f4ea48279830bfb.dll.exp
          minhook.lib(main.o) : error LNK2019: unresolved external symbol strcmp referenced in function HookGetProcAddress
          libcore-6c8df881cdc2afb2.rlib(core-6c8df881cdc2afb2.core.9ec9rshx-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memcpy
          minhook.lib(hook.o) : error LNK2001: unresolved external symbol memcpy
          minhook.lib(trampoline.o) : error LNK2001: unresolved external symbol memcpy
          libstd-8864852919b3dde3.rlib(std-8864852919b3dde3.std.9y6kx5re-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memcpy
          liballoc-57b2ee5c835455f8.rlib(alloc-57b2ee5c835455f8.alloc.a0u0bu3x-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memcpy
          libstd-8864852919b3dde3.rlib(std-8864852919b3dde3.std.9y6kx5re-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol __CxxFrameHandler3
          librustc_demangle-d9b7b1604d471c6c.rlib(rustc_demangle-d9b7b1604d471c6c.rustc_demangle.davdwee1-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol __CxxFrameHandler3
          liballoc-57b2ee5c835455f8.rlib(alloc-57b2ee5c835455f8.alloc.a0u0bu3x-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol __CxxFrameHandler3
          libcore-6c8df881cdc2afb2.rlib(core-6c8df881cdc2afb2.core.9ec9rshx-cgu.0.rcgu.o) : error 
LNK2001: unresolved external symbol __CxxFrameHandler3
          libstd-8864852919b3dde3.rlib(std-8864852919b3dde3.std.9y6kx5re-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol memcmp referenced in function _ZN4core3str22SplitInternal$LT$P$GT$9next_back17h74d5d5cf84bf16e3E
          librustc_demangle-d9b7b1604d471c6c.rlib(rustc_demangle-d9b7b1604d471c6c.rustc_demangle.davdwee1-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memcmp
          libcore-6c8df881cdc2afb2.rlib(core-6c8df881cdc2afb2.core.9ec9rshx-cgu.0.rcgu.o) : error 
LNK2001: unresolved external symbol memcmp
          libstd-8864852919b3dde3.rlib(std-8864852919b3dde3.std.9y6kx5re-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol memset referenced in function _ZN5alloc11collections5btree3map21BTreeMap$LT$K$C$V$GT$6insert17hc5e37be72c9db591E
          libbacktrace-e90b3ab99b608a07.rlib(backtrace-e90b3ab99b608a07.backtrace.8erfzk2q-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memset
          librustc_demangle-d9b7b1604d471c6c.rlib(rustc_demangle-d9b7b1604d471c6c.rustc_demangle.davdwee1-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memset
          libcore-6c8df881cdc2afb2.rlib(core-6c8df881cdc2afb2.core.9ec9rshx-cgu.0.rcgu.o) : error 
LNK2001: unresolved external symbol memset
          libstd-8864852919b3dde3.rlib(std-8864852919b3dde3.std.9y6kx5re-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol memmove referenced in function _ZN5alloc11collections5btree3map21BTreeMap$LT$K$C$V$GT$6insert17hc5e37be72c9db591E
          liballoc-57b2ee5c835455f8.rlib(alloc-57b2ee5c835455f8.alloc.a0u0bu3x-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol memmove
          libstd-8864852919b3dde3.rlib(std-8864852919b3dde3.std.9y6kx5re-cgu.0.rcgu.o) : error LNK2019: unresolved external symbol strlen referenced in function _ZN3std3ffi5c_str7CString8from_raw17h79277fb0266da141E
          D:\work\service-proxy-sx\code\data-sync\target\debug\deps\xpsupport-0f4ea48279830bfb.dll : fatal error LNK1120: 7 unresolved externals
lynnux commented 4 years ago

你试试 cargo rustc -- -C link-args="/subsystem:console,5.01 vcruntime.lib ucrt.lib" 呢。 我实在不想装vs2019,官方有个open issue不知道是不是同样的问题 https://github.com/rust-lang/rust/issues/54137。这个要麻烦你自己测试下了,应该是缺少了vc的内置lib

FourLeafTec commented 4 years ago

无效,看上去不是这两个库的问题,我也尝试了直接拷贝到一个LIBPATH目录也是无效

另外,现在release版本能够成功构建,但是需要引用的VCRUNTIME140.dll 和 api-ms-win-xxxx.dll那些我应该从哪里复制啊,从磁盘上能搜到一堆,我试了十几组了,都不对,总是会缺函数

FourLeafTec commented 4 years ago

找到了

vcruntime140.dll从System32下拷贝就可以

api-ms-win-xxx.dll从%programfiles%\Windows Kits\10\Redist\ucrt\DLLs\x86 下找就可以

lynnux commented 4 years ago

@FourLeafTec 0.2版本已出,不再需要dll了。不过gnu那个问题必须官方更新才能解决了。

FourLeafTec commented 4 years ago

好的,我试一下,我先close了 如果有问题再打开

lynnux commented 4 years ago

官方已经merge我提的pr,下个nightly版本应该不会出现该问题了

FourLeafTec commented 4 years ago

这个厉害了,从下个nightly gnu工具链也就能正常工作了