在 32 位程序中使用 64 位驱动程序。 视窗

发布于 2024-07-14 22:19:52 字数 480 浏览 8 评论 0原文

这只是一个半路编程问题。 首先,我有一个 PCI-Express 卡和 32/64 位驱动程序。 目标操作系统必须是 Windows 64 位系统。 我读到,在 Vista64 下,所有驱动程序都必须经过认证 64 位驱动程序。 这是 64 位操作系统下的一般限制吗?这是否也适用于“XP 64”或任何 Linux 系统?

因此,为了简单起见,假设我在 Vista64 下为我的 PCIe 卡使用 64 位驱动程序,并且有一堆 64 位 DLL 来使用卡功能。 另一方面,有一个大型的传统 32 位 exe 程序需要使用 PCIe 设备。 将程序转换为 64 位将是一项巨大的工作。

那么如何才能将 32 位程序和 64 位驱动程序结合在一起呢? 我读到混合 32/64 位二进制文​​件和 DLL 根本不可能,但这对我来说很难相信。 我确信您可以在 32 位应用程序中打印出 Vista64 下的文档,并且 Windows 会以某种方式将其包装到 64 位打印机驱动程序。

This is only a half-way programming question. First of all I have a PCI-Express card and 32/64 bit drivers. The target operating system has to be a Windows 64 bit system. I read that under Vista64 all drivers have to be certified 64 bit drivers. Is this a general restriction under 64 bit operating systems and does this also apply to "XP 64" or any Linux system?

So for simplicity let's say I use a 64 bit driver for my PCIe card under Vista64 and have a bunch of 64 bit DLLs to use the cards functionality. On the other side there's a large, legacy 32 bit exe program which needs to use the PCIe device. Converting the program to 64 bit would be a really huge effort.

So what can be done to bring that 32 bit program and the 64 bit driver together? I read that mixing 32/64 bit binaries and DLLs is not possible at all but this is hard to believe for me. I'm sure you can print out a document under Vista64 from within a 32 bit app and Windows will somehow wrap this around to a 64 bit printer driver.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅浅淡淡 2024-07-21 22:19:52

仅 Vista 下才需要 64 位认证; 非 Windows 平台没有认证机构,而且我不相信 XP 或 Windows Server 会检查认证(不过不确定,这可能取决于您使用的服务包)。

如果您通过 Windows API 使用驱动程序,那么应该不会有任何问题; Windows 将在内核中进行 32→64 位转换。 如果您尝试在自己的进程中加载​​驱动程序,那可能是不可能的。 正如 Dirk 所说,您必须在自己的进程内运行它并通过 COM 服务器进行通信。 如果您必须在更高权限的执行级别运行驱动程序并希望从用户模式调用它,我不确定您必须跳过哪些障碍。

希望您的 64 位 DLL 提供 32 位 API,或者 Windows 提供标准驱动程序接口(如果它是常见的 I/O 设备,如显示器或网卡)。

64-bit certification is only required under Vista; there is no certifying authority for non-Windows platforms, and I don't believe that XP or Windows Server checks for certification (not sure though, and it may depend on which service pack you're on).

If you're using the driver via the Windows API, then there shouldn't be any problem; Windows will do the 32<->64-bit translations in the kernel. If you're trying to load the driver inside your own process, that probably won't be possible. As Dirk says you'll have to run it inside its own process and communicate through a COM server. I'm not sure what hoops you'll have to jump through if you have to run your driver in a higher-privilege execution level and want to make calls to it from user mode.

Hopefully your 64-bit DLLs offer a 32-bit API, or Windows offers a standard driver interface (if it's a common I/O device like a display or network card).

深居我梦 2024-07-21 22:19:52

你的32位应用程序直接调用驱动程序吗? (我猜是驱动程序的模拟器!)

32 位和 64 位 dll 之间通信的唯一方法是编写一个管理通信的 COM 服务器(阅读:包装应用程序调用或 64 位驱动程序)响应)之间。

有一件事让我痛苦不已:当我第一次编写这个 COM 服务器时(是的,在我知道这个技巧之前,我也不得不忍受许多不眠之夜)我只构建了 32 位版本的(自动生成的) ) 代理/存根 DLL。 在我知道解决方案之前,又经历了一轮不眠之夜:为 32 位和 64 位构建代理/存根 dll。 32 位端处理 32 位端(在您的情况下是应用程序),64 位端处理 64 位端(驱动程序)。 COM 管理不同版本的代理/存根如何相互通信。 哦,一定要在您的系统上注册服务器。 容易,对吧?

Does your 32-bit application directly call the driver? (I'm guessing a simulator for the driver!)

The only way to communicate between 32-bit and 64-bit dlls is to write a COM server that manages the communication (read: wrap EITHER the applications calls OR the 64-bit driver responses) in between.

One thing that came back to bite me: When I first wrote this COM server (yes, I too had to bear many sleepless nights before I came to know of this trick) I only built the 32-bit version of the (auto-generated) proxy/stub dll. Another bout of sleepless nights ensued before I came to know of the solution: Build the proxy/stub dll for both 32-bit and 64-bit. The 32-bit side deals with the 32-bit side (in your case the application) and the 64-bit with the 64-bit side (the driver). COM manages how the differnt versions of the proxy/stub talk to each other. And oh, do get the server registered on your system. Easy, right?

浅唱々樱花落 2024-07-21 22:19:52

我认为驱动程序的全部意义在于抽象出硬件的实际工作原理并为软件提供一个通用接口。 在这种情况下,PCIe 驱动程序需要是 64 位的,以便它可以充当 Windows 和硬件的中间人,但我认为 32 位应用程序可以毫无问题地访问设备。

您读到的不兼容性意味着 32 位和 64 位程序集不能成为同一应用程序的一部分 - 应用程序必须以其中之一为目标,尽管 32 位应用程序通常会 使用 WoW64 在 Windows x64 上运行良好,它仅充当翻译器。

您目前是否遇到问题,或者您只是假设性地询问?

I think the whole point of a driver is to abstract away the actually workings of the hardware and present a common interface to the software. In this case, the PCIe driver needs to be 64-bit so that it can act as a go-between for Windows and the hardware, but I would think that a 32-bit application could then access the device without any troubles at all.

What's meant by that incompatibility you read about is that 32 and 64-bit assemblies can't be part of the same application - an application has to target either one or the other, though 32-bit application will generally run fine on Windows x64 using WoW64, which just acts as a translator.

Are you currently experiencing problems, or are you just asking hypothetically?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文