简体   繁体   English

如何将带有 ld_preload 的库预加载到 wine(windows 游戏(32 位))?

[英]How to preload library with ld_preload to wine(windows game(32bit))?

I want to learn how to preload and hook functions in wine running windows apps.我想学习如何在运行 windows 应用程序的 wine 中预加载和挂钩函数。 I'm trying to preload a library with ld_preload to wine(windows game(32-bit)) on Arch Linux (64-bit but I think I installed 32-bit support).我正在尝试将带有ld_preload的库预加载到 Arch Linux(64 位,但我认为我安装了 32 位支持)上的 wine(windows 游戏(32 位))。 I get the error wrong ELF class: ELFCLASS32 and the same for ELFCLASS64 .我得到错误的wrong ELF class: ELFCLASS32ELFCLASS64相同。

Full error text:完整的错误文本:

"ERROR: ld.so: object './eve.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored." “错误:ld.so: object './eve.so' 来自 LD_PRELOAD 无法预加载(错误的 ELF class: ELFCLASS32):忽略。”

the same for 64bit and another one 64位和另一个相同

ERROR: ld.so: object './eve.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.错误:ld.so: object './eve.so' 来自 LD_PRELOAD 无法预加载(无法打开共享 object 文件):忽略。

How am I getting "wrong class" when I have both 32 and 64-bit installed?当我同时安装 32 位和 64 位时,我如何得到“错误的课程”? What architecture do I need to make it work right?我需要什么架构才能使其正常工作?

Wow.exe:哇.exe:

Wow.exe: PE32 executable (GUI) Intel 80386, for MS Windows Wow.exe:PE32 可执行文件 (GUI) Intel 80386,用于 MS Windows

I tried to build with and without the -m32 flag ( I changed all uint32 to uint64 ):我尝试使用和不使用-m32标志进行构建(我将所有uint32更改为uint64 ):

gcc -std=c99 -Wall -Werror -m32 -O0 -fpic -shared -ldl -lGL -o eve.so eve.c

I saw this answer:我看到了这个答案:

ltrace /lib/ld-linux.so.2 --preload /path/to/lib/strcmp.so./exec ltrace /lib/ld-linux.so.2 --preload /path/to/lib/strcmp.so./exec

But don't know how to run it with wine running the app.但是不知道如何使用运行应用程序的 wine 来运行它。

I want to learn how to preload and hook functions in wine running windows apps.我想学习如何在运行 windows 应用程序的 wine 中预加载和挂钩函数。 I saw this guide: https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/276206-linux-simple-injection-ld_preload.html我看到了这个指南: https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/276206-linux-simple-injection-ld_preload.ZFC35FDC70D5FC69D269883A822C7A53

The wrong ELF class: ELFCLASS32 means you are trying to inject a 32-bit program into a 64-bit process. wrong ELF class: ELFCLASS32表示您正在尝试将 32 位程序注入 64 位进程。 This would lead me to believe your game is 64-bit, and you should compile your libraries as 64-bit as well.这会让我相信你的游戏是 64 位的,你也应该将你的库编译为 64 位。 But since you mention you saw the error for 64-bits as well, it would be best to check your wine installation directly.但是既然你提到你也看到了 64 位的错误,最好直接检查你的 wine 安装。 Run dpkg -l | grep wine运行dpkg -l | grep wine dpkg -l | grep wine . dpkg -l | grep wine You'll see something like this:你会看到这样的东西:

dpkg -l | grep wine
ii  libwine:i386                          4.0-2                               i386         Windows API implementation - library
ii  wine                                  4.0-2                               all          Windows API implementation - standard suite
ii  wine32:i386                           4.0-2                               i386         Windows API implementation - 32-bit binary loader
ii  winetricks                            0.0+20181203-3                      all          simple tool to work around common problems in Wine

On the far right, you can see this example is 32-bit.在最右边,您可以看到这个示例是 32 位的。

The second error message you reported, cannot open shared object file , means the dynamic linker can't find your library.您报告的第二条错误消息, cannot open shared object file ,表示动态 linker 找不到您的库。 Double check all your file paths.仔细检查所有文件路径。 Instead of using the relative import ./eve.so , use a full absolute path ( /path/to/lib/eve.so ) so there's no ambiguity to the system.不要使用相对导入./eve.so ,而是使用完整的绝对路径 ( /path/to/lib/eve.so ),这样系统就不会产生歧义。 You usually want to specify an absolute path to LD_PRELOAD.您通常希望指定 LD_PRELOAD 的绝对路径。 The reason is that it being an environment variable, it's inherited by child processes - which may have a different working directory than the parent process.原因是它是一个环境变量,它是由子进程继承的——它可能具有与父进程不同的工作目录。 So any relative path would fail to locate the library to preload.因此,任何相对路径都无法找到要预加载的库。

As for how to set the environment variable in Wine, wine passes on the entire shell environment variable space to the Windows environment variable space, so you just set the variable in Linux beforehand and it will be available to the game inside wine:至于如何在Wine中设置环境变量, wine将整个shell环境变量空间传递给Windows环境变量空间,所以你只需在ZEDC9F0A5A5D57797BF68E3736474383Z环境变量空间中设置变量,就可以在wine里面使用:

export LD_PRELOAD=/path/to/lib/eve.so
wine ...

As another note, LD_PRELOAD will affect the wine loader only.另外需要注意的是, LD_PRELOAD只会影响wine加载器。 If you would like to affect wineserver as well:如果你也想影响wineserver

wineserver -k
export LD_PRELOAD=...
wine ...

Finally, see this post for more details if this still isn't working for you.最后,如果这仍然不适合您,请参阅这篇文章了解更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM