Как определить, почему Ruby-FFI и VB.net не могут загрузить файл DLL? - PullRequest
0 голосов
/ 03 февраля 2019

У меня есть файл с четырьмя функциями, которые мне нужно использовать.Документация по функциям DLL здесь .Я попытался загрузить DLL с Lib в VB.net и ffi_lib с Ruby-FFI.Оба дают мне ошибки при загрузке DLL, но я ничего не смог использовать, чтобы выяснить, почему он не может загрузить DLL.Как определить, почему FFI (мой предпочтительный метод доступа, но я также приму VB.net) не может загрузить DLL?Я пробовал как на Windows, так и на Mac.

Файл DLL доступен здесь или путем установки файла под номером 5 на странице поддержки здесь http://www.mscashdrawer.com/techcashdrawerUSB.php. Это сделает C: \ Program Files \ MS Cash Drawer каталог, который будет содержать файл DLL.

Ruby-FFI на Mac говорит

/Users/brandoncc/dev/open_cash_drawer/MSPOS_USB.dll: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00

Обновление: я думаю, что это может быть из-за того, что dll 32-битная,Ниже приведены заголовки из dumpbin

Dump of file .\dev\open_cash_drawer\MSPOS_USB.dll

PE signature found

File Type: DLL

FILE HEADER VALUES
             14C machine (x86)
               4 number of sections
        53978AFD time date stamp Tue Jun 10 14:47:25 2014
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            2102 characteristics
                   Executable
                   32 bit word machine
                   DLL

OPTIONAL HEADER VALUES
             10B magic # (PE32)
            9.00 linker version
            1800 size of code
            1200 size of initialized data
               0 size of uninitialized data
            1AE4 entry point (10001AE4)
            1000 base of code
            3000 base of data
        10000000 image base (10000000 to 10005FFF)
            1000 section alignment
             200 file alignment
            6.01 operating system version
            6.01 image version
            5.01 subsystem version
               0 Win32 version
            6000 size of image
             400 size of headers
            7714 checksum
               3 subsystem (Windows CUI)
             140 DLL characteristics
                   Dynamic base
                   NX compatible
           40000 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
            2710 [      9D] RVA [size] of Export Directory
            232C [      64] RVA [size] of Import Directory
            4000 [     3D0] RVA [size] of Resource Directory
               0 [       0] RVA [size] of Exception Directory
               0 [       0] RVA [size] of Certificates Directory
            5000 [     1C8] RVA [size] of Base Relocation Directory
            10B0 [      1C] 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
            1138 [      40] RVA [size] of Load Configuration Directory
               0 [       0] RVA [size] of Bound Import Directory
            1000 [      9C] 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


SECTION HEADER #1
   .text name
    17AD virtual size
    1000 virtual address (10001000 to 100027AC)
    1800 size of raw data
     400 file pointer to raw data (00000400 to 00001BFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
60000020 flags
         Code
         Execute Read

  Debug Directories

        Time Type        Size      RVA  Pointer
    -------- ------- -------- -------- --------
    53978AFD cv            73 00001180      580    Format: RSDS, {6AFEFF09-4F33-4F1A-AE27-CA8FB3D57A60}, 1, d:\current\mscashdrawer\mscashdrawercontroller\mspos_dll\objfre_wxp_x86\i386\MSPOS_USB.pdb

SECTION HEADER #2
   .data name
     70C virtual size
    3000 virtual address (10003000 to 1000370B)
     400 size of raw data
    1C00 file pointer to raw data (00001C00 to 00001FFF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

SECTION HEADER #3
   .rsrc name
     3D0 virtual size
    4000 virtual address (10004000 to 100043CF)
     400 size of raw data
    2000 file pointer to raw data (00002000 to 000023FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

SECTION HEADER #4
  .reloc name
     47C virtual size
    5000 virtual address (10005000 to 1000547B)
     600 size of raw data
    2400 file pointer to raw data (00002400 to 000029FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
42000040 flags
         Initialized Data
         Discardable
         Read Only

  Summary

        1000 .data
        1000 .reloc
        1000 .rsrc
        2000 .text

1 Ответ

0 голосов
/ 02 марта 2019

Оказывается, я пытался использовать 32-битную DLL в 64-битной системе.Я надеюсь, что это помогает кому-то еще!

...