Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

Problem with DLL in Delphi

  Alt 21. Aug 2014, 15:10
Delphi-Version: XE5
I want to use this DLL:

Code:
http://ntinfo.biz/files/diedll.zip
in Delphi.

C header is:

Code:
#ifndef DIEDLL_H
#define DIEDLL_H

#include <windows.h>

// flags
#define DIE_SHOWERRORS             0x00000001
#define DIE_SHOWOPTIONS            0x00000002
#define DIE_SHOWVERSION            0x00000004
#define DIE_SHOWENTROPY            0x00000008
#define DIE_SINGLELINEOUTPUT       0x00000010
#define DIE_SHOWFILEFORMATONCE     0x00000020

#ifdef __cplusplus
extern "C" {
#endif

int __declspec(dllexport) __stdcall DIE_scanA(char *pszFileName,char *pszOutBuffer,int nOutBufferSize,unsigned int nFlags);
int __declspec(dllexport) __stdcall DIE_scanW(wchar_t *pwszFileName,char *pszOutBuffer,int nOutBufferSize,unsigned int nFlags);
int __declspec(dllexport) __stdcall DIE_scanExA(char *pszFileName,char *pszOutBuffer,int nOutBufferSize,unsigned int nFlags,char *pszDataBase);
int __declspec(dllexport) __stdcall DIE_scanExW(wchar_t *pwszFileName,char *pszOutBuffer,int nOutBufferSize,unsigned int nFlags,wchar_t *pwszDataBase);
PCHAR __declspec(dllexport) __stdcall DIE_versionA(void);
PWCHAR __declspec(dllexport) __stdcall DIE_versionW(void);


#ifdef UNICODE
#define DIE_scan DIE_scanW
#define DIE_scanEx DIE_scanExW
#define DIE_version DIE_versionW
#else
#define DIE_scan DIE_scanA
#define DIE_scanEx DIE_scanExA
#define DIE_version DIE_versionA
#endif

#ifdef __cplusplus
}
#endif

#endif // DIEDLL_H
I ported it to Delphi:

Delphi-Quellcode:
unit diedll;

interface

const
  DIE_SHOWERRORS = $00000001;
  DIE_SHOWOPTIONS = $00000002;
  DIE_SHOWVERSION = $00000004;
  DIE_SHOWENTROPY = $00000008;
  DIE_SINGLELINEOUTPUT = $00000010;
  DIE_SHOWFILEFORMATONCE = $00000020;

function DIE_scanA(pszFileName, pszOutBuffer: PAnsiChar; nOutBufferSize: Cardinal; nFlags: Cardinal): Integer; stdcall;
  external 'diedll.dllname 'DIE_scanA';
function DIE_scanW(pszFileName, pszOutBuffer: PWideChar; nOutBufferSize: Cardinal; nFlags: Cardinal): Integer; stdcall;
  external 'diedll.dllname 'DIE_scanW';
function DIE_scanExA(pszFileName, pszOutBuffer: PAnsiChar; nOutBufferSize: Cardinal; nFlags: Cardinal; pszDataBase: PAnsiChar): Integer; stdcall;
  external 'diedll.dllname 'DIE_scanExA';
function DIE_scanExW(pszFileName, pszOutBuffer: PWideChar; nOutBufferSize: Cardinal; nFlags: Cardinal; pwszDataBase: PWideChar): Integer; stdcall;
  external 'diedll.dllname 'DIE_scanExW';
function DIE_versionA: PAnsiChar; stdcall;
  external 'diedll.dllname 'DIE_versionA';
function DIE_versionW: PWideChar; stdcall;
  external 'diedll.dllname 'DIE_versionW';

implementation

end.
No I tried use it:

Delphi-Quellcode:
var
  Buffer: array [0..1023] of Char;
begin
  Caption := DIE_versionW;
  DIE_scanW('C:\Windows\notepad.exe', Buffer, 1024, DIE_SHOWOPTIONS or DIE_SHOWVERSION);
  ShowMessage(string(Buffer));
end;
Message: Function entry point not found in diedll.dll.
I checked what is exported from DLL and make changes in unit:

Delphi-Quellcode:
function DIE_scanA(pszFileName, pszOutBuffer: PAnsiChar; nOutBufferSize: Cardinal; nFlags: Cardinal): Integer; stdcall;
  external 'diedll.dllname '_DIE_scanA@16';
function DIE_scanW(pszFileName, pszOutBuffer: PWideChar; nOutBufferSize: Cardinal; nFlags: Cardinal): Integer; stdcall;
  external 'diedll.dllname '_DIE_scanW@16';
function DIE_scanExA(pszFileName, pszOutBuffer: PAnsiChar; nOutBufferSize: Cardinal; nFlags: Cardinal; pszDataBase: PAnsiChar): Integer; stdcall;
  external 'diedll.dllname '_DIE_scanExA@20';
function DIE_scanExW(pszFileName, pszOutBuffer: PWideChar; nOutBufferSize: Cardinal; nFlags: Cardinal; pwszDataBase: PWideChar): Integer; stdcall;
  external 'diedll.dllname '_DIE_scanExW@20';
function DIE_versionA: PAnsiChar; stdcall;
  external 'diedll.dllname '_DIE_versionA@0';
function DIE_versionW: PWideChar; stdcall;
  external 'diedll.dllname '_DIE_versionW@0';
So, function to check version looks to be ok, but in scans is something wrong:

Code:
---------------------------
Debugger Exception Notification
---------------------------
Project DIE.exe raised exception class $C0000090 with message 'floating point invalid operation at 0x6c09023f'.
---------------------------
Break  Continue  Help  
---------------------------
Help make it working, please
  Mit Zitat antworten Zitat