首页 > 解决方案 > 在 Windows CE 上使用为 X86 编译的 DLL 是绝对不可能的吗?

问题描述

我正在研究在 Windows CE7 上编写安全加密狗的可能性。生产加密狗的公司没有明确声明支持 Windows CE,但根据他们的销售人员的说法,应该支持 Windows CE6。加密狗使用一个导入库 (.lib),它引用了一个具有我想要使用的功能的 .dll。查看 .dll 的标头信息,dumpbin /headers我可以看到 .dll 是为 x86 (14c) 编译的,并且子系统是Windows GUI. 作为参考,我在 Windows CE 设备上使用的 .dll 是为 Thumb(1c2,ARM afaik)编译的,并且具有子系统Windows CE GUI

这是 dumpbin 命令的简短输出。

Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file <name removed>.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               5 number of sections
        502875ED time date stamp Mon Aug 13 12:35:09 2012
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            210E characteristics
                   Executable
                   Line numbers stripped
                   Symbols stripped
                   32 bit word machine
                   DLL

OPTIONAL HEADER VALUES
             10B magic # (PE32)
            6.00 linker version
            A000 size of code
            C000 size of initialized data
               0 size of uninitialized data
            4EA2 entry point (10004EA2)
            1000 base of code
            B000 base of data
        10000000 image base (10000000 to 10016FFF)
            1000 section alignment
            1000 file alignment
            4.00 operating system version
            0.00 image version
            4.00 subsystem version
               0 Win32 version
           17000 size of image
            1000 size of headers
           1A38F checksum
               2 subsystem (Windows GUI)
               0 DLL characteristics
          100000 size of stack reserve
            1000 size of stack commit
          100000 size of heap reserve
            1000 size of heap commit
               0 loader flags
              10 number of directories
            BED0 [      D9] RVA [size] of Export Directory
            B770 [      50] RVA [size] of Import Directory
           14000 [     7C8] RVA [size] of Resource Directory
               0 [       0] RVA [size] of Exception Directory
           12000 [    17D0] RVA [size] of Certificates Directory
           15000 [     990] RVA [size] of Base Relocation Directory
               0 [       0] RVA [size] of Debug Directory
               0 [       0] RVA [size] of Architecture Directory
               0 [       0] RVA [size] of Global Pointer Directory
               0 [       0] RVA [size] of Thread Storage Directory
               0 [       0] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
            B000 [     144] RVA [size] of Import Address Table Directory
               0 [       0] RVA [size] of Delay Import Directory
               0 [       0] RVA [size] of COM Descriptor Directory
               0 [       0] RVA [size] of Reserved Directory

这是我第一次像这样分析 dll 和 lib,因此我对它们不太熟悉。

  1. 如果一个 dll 是为 x86 编译的,那么它只能在 x86 机器上使用,而不能在其他架构上使用。这确实是有道理的,但是考虑到 dll 使用的是 PE 格式(PORTABLE 可执行文件),不同架构之间不应该至少有一些兼容性吗?也许我误解了它的“便携”部分。
  2. 如果上述观点成立,除了要求供应商为 Windows CE 重新编译 dll 之外,是否有任何机会让 dll 在 Windows CE 上运行?

标签: dllx86armwindows-celib

解决方案


我联系了供应商,看起来销售人员向我转发了错误的 DLL 集。他们实际上有一组为 Windows CE6 编译的 DLL。我测试了它,它似乎正在工作。对于我的问题的直接答案,我基于@Peter Cordes 的评论。您不能在 Windows CE 上使用 x86-DLL,因为 Windows CE 不理解 x86 机器代码。反过来也一样。理论上,您可以实现某种模拟层来进行转换,但最简单的选择仍然是要求供应商为 Windows CE 重新编译。


推荐阅读