Author Topic: Getting an error when using the dll in .net on x64  (Read 9455 times)

Tooms

  • Newbie
  • *
  • Posts: 3
Getting an error when using the dll in .net on x64
« on: October 13, 2015, 07:05:12 PM »
Hi

First thanks alot for making the tool.

I am trying to make an application there is scanning fileservers for encrypted files after an cryptolocker attack and is there for using the TrIDLib to do the matching.

my dev VM is an windows xp with VS.2008 and i have download your sample codes for using the lib and on the XP it is working fine and it looks like this.

Code: [Select]
Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\VS projekt\Trid-test1\VB.NET\bin\Debug>Demo.exe
TrIDLib demo

TrID_LoadDefsPack code: 5956
DEFSNUM: 5956
File: C:\VS projekt\Trid-test1\VB.NET\bin\Debug\triddefs.trd
1
ResNum: 3
total_point: 36009

RES_NUM: 1
RES_FILETYPE: TrID defs package
RES_FILEEXT: TRD
RES_POINTS: 22009
Procent: 61,121%)
-------------------
RES_NUM: 2
RES_FILETYPE: AOS File Format
RES_FILEEXT: AOS
RES_POINTS: 10000
Procent: 27,771%)
-------------------
RES_NUM: 3
RES_FILETYPE: Generic RIFF container
RES_FILEEXT:
RES_POINTS: 4000
Procent: 11,108%)
-------------------
Procent_calc_recalctotal: 100
Press any key to continue . . .
C:\VS projekt\Trid-test1\VB.NET\bin\Debug>

but when i am moving the app to my Windows 7 x64 then i am getting this error, that the dll cannot load the triddefs.trd file.

Code: [Select]
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

c:\temp\ToomsFSscan2>Demo.exe
TrIDLib demo

Unhandled Exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at Demo.TrIDLib.TrID_LoadDefsPack(String& sPath)
   at Demo.Demo.Main()

c:\temp\ToomsFSscan2>


So why is it not able to load the same triddefs.trd file on another version of windows ?


Thanks

Tooms

Mark0

  • Administrator
  • Hero Member
  • *****
  • Posts: 2743
    • Mark0's Home Page
Re: Getting an error when using the dll in .net on x64
« Reply #1 on: October 13, 2015, 08:07:54 PM »
The problem is that TrIDLib is a Win32 DLL, and so it cannot be called from a 64bit application.
To run around that, you can probably rebuild you app explicitly targeting x86 as the platform, instead of Any CPU.

Have a look here, for example: http://stackoverflow.com/questions/1108137/how-to-run-a-32-bit-net-application-in-a-64-bit-environment
« Last Edit: October 13, 2015, 08:10:30 PM by Mark0 »

Tooms

  • Newbie
  • *
  • Posts: 3
Re: Getting an error when using the dll in .net on x64
« Reply #2 on: October 13, 2015, 08:50:10 PM »


ahh yes ofcource that will help by locking it to 32bit.


just some other questions, will there be an 64bit dll or an combined dll for 32/64bit?

Can the scanning be started from an offset, like not start at the first byte but start at byte 10?


Thanks
Thomas


Mark0

  • Administrator
  • Hero Member
  • *****
  • Posts: 2743
    • Mark0's Home Page
Re: Getting an error when using the dll in .net on x64
« Reply #3 on: October 17, 2015, 04:12:29 PM »
Sorry for the late reply.
A 64bit DLL is something I'm planning to do, but I don't have any timeline at the moment.
Scanning from an offset is also something that I think to implement in some future versions.

Tooms

  • Newbie
  • *
  • Posts: 3
Re: Getting an error when using the dll in .net on x64
« Reply #4 on: October 17, 2015, 07:53:56 PM »

Hi

That is just okay, i fully understand that time is limit and i will just play around with making my own engine so i better can hook into functions that i need like file streams, memorystreams, alternatedatastreams, start at offsets, 64bit and many other ideas.
Time will tell how it go.

Thanks for your good work on the trid

Tooms