Board index » delphi » BP7 problem with thunking and LoadLibraryEx32W

BP7 problem with thunking and LoadLibraryEx32W

Help please!!!

I have a problem with thunking and LoadLibraryEx32W in BP7.
I'm running Win2K and compile for DOS protected mode. The
problem is that every time i call LoadLibraryEx32W the
program terminates with a "invalid entrypoint called".
I have tried to use LoadLibrary , which does not fail, to
load LoadLibraryEx32W but when I call GetProcAddress its
the same deal.

Ok; heres some code to illustrate the problem:

///////////////////////////////////////////////////////////
// Lib.pas
///////////////////////////////////////////////////////////
unit lib;

interface

uses wintypes, winprocs;

type
  THandle32 = Longint;
  DWORD     = Longint;

function LoadLibraryEx32W(LibFileName:PChar; hFile,dwFlags:DWORD):THandle32;

implementation

function LoadLibraryEx32W; external 'KERNEL' index 513;

end.

///////////////////////////////////////////////////////////
// Main.pas
///////////////////////////////////////////////////////////
program test;

{$F+}

uses lib;

VAR
  hLib     : Longint;
  SomeFunc : TFarProc;

BEGIN
  hLib := LoadLibraryEx32W('Some32bitdll.dll', 0, 0);
  { !!!!!!!!!!!!!!!!!
    BOOM: the program crashes
  } !!!!!!!!!!!!!!!!!

  IF hLib = 0 Then
    Exit;

  SomeFunc := GetProcAddress32W(hLib, 'SomeFunc');
  If OpenComm = nil Then
  BEGIN
    FreeLibrary32W(hLib);
    Exit;
  END;

  If CallProc32W(0, DWORD(SomeFunc), 1, 1) <> 2 Then
  Begin
    FreeLibrary32W(hLib);
    Exit;
  End;

  FreeLibrary32W(hLib);

Quote
}

END.

What am i doing wrong? or is it just not possible on Win2K?

Thanks for your time
\S{*word*249} Hansen

 

Re:BP7 problem with thunking and LoadLibraryEx32W


Quote
S{*word*249} Hansen <shackleto...@yahoo.dk> wrote in message

news:4bc34d28.0210100256.596ea287@posting.google.com...

Quote
> Help please!!!

> I have a problem with thunking and LoadLibraryEx32W in BP7.
> I'm running Win2K and compile for DOS protected mode. The
> problem is that every time i call LoadLibraryEx32W the
> program terminates with a "invalid entrypoint called".
> I have tried to use LoadLibrary , which does not fail, to
> load LoadLibraryEx32W but when I call GetProcAddress its
> the same deal.

You must remember that BP7 programs compiled for (16-bit) DPMI use RTM.EXE as
a Windows 3.x kernel emulator. the 'KERNEL' dll is inside RTM.EXE, but
LoadLibraryEx32W is a Win32's kernel function, NOT a native Win 3.x function.
It does not therefore exist in the standard RTM.EXE.

--
Jay

Jason Burgon - Author of "Graphic Vision"  GUI for DOS/DPMI
=== Free LFN capable Dos/WinDos replacement and ===
=== New Graphic Vision  version 2.21 available from:  ===
http://www.jayman.demon.co.uk

Re:BP7 problem with thunking and LoadLibraryEx32W


Hi Jason,

Thanks for your reply. If you have the time could you surgest
a possible solution to the problem. What i'm trying is the
write a win32 dll that can communicate with the serial-port
using the win32 api functions CreateFile, WriteFile etc.
As is I use pascal's 'port' function but dues to the VDM
the communication increases by a factor 10 on NTOS.
So i was hoping that LoadLibraryEx32W could solve my
problem and give me access to the functions in the dll.

Thanks again,
\S{*word*249} Hansen

Quote
"Jason Burgon" <ja...@jayman.demon.co.uk> wrote in message <news:ao52tg$504$1$8302bc10@news.demon.co.uk>...
> S{*word*249} Hansen <shackleto...@yahoo.dk> wrote in message
> news:4bc34d28.0210100256.596ea287@posting.google.com...
> > Help please!!!

> > I have a problem with thunking and LoadLibraryEx32W in BP7.
> > I'm running Win2K and compile for DOS protected mode. The
> > problem is that every time i call LoadLibraryEx32W the
> > program terminates with a "invalid entrypoint called".
> > I have tried to use LoadLibrary , which does not fail, to
> > load LoadLibraryEx32W but when I call GetProcAddress its
> > the same deal.

> You must remember that BP7 programs compiled for (16-bit) DPMI use RTM.EXE as
> a Windows 3.x kernel emulator. the 'KERNEL' dll is inside RTM.EXE, but
> LoadLibraryEx32W is a Win32's kernel function, NOT a native Win 3.x function.
> It does not therefore exist in the standard RTM.EXE.

Re:BP7 problem with thunking and LoadLibraryEx32W


S{*word*249} Hansen schrieb:

Quote
> Hi Jason,

> Thanks for your reply. If you have the time could you surgest
> a possible solution to the problem. What i'm trying is the
> write a win32 dll that can communicate with the serial-port
> using the win32 api functions CreateFile, WriteFile etc.
> As is I use pascal's 'port' function but dues to the VDM
> the communication increases by a factor 10 on NTOS.
> So i was hoping that LoadLibraryEx32W could solve my
> problem and give me access to the functions in the dll.

Hello!

I'm sorry to say, but maybe the Freepascal compiler might do what you
want. BP7 cannot afaik call 32 bit DLLs or 32-bit functions from DPMI.

Greetings

Markus

Re:BP7 problem with thunking and LoadLibraryEx32W


Quote
In article <3DA6C49E.8010...@freenet.de>, Markus Humm wrote:
>> Thanks for your reply. If you have the time could you surgest
>> a possible solution to the problem. What i'm trying is the
>> write a win32 dll that can communicate with the serial-port
>> using the win32 api functions CreateFile, WriteFile etc.
>> As is I use pascal's 'port' function but dues to the VDM
>> the communication increases by a factor 10 on NTOS.
>> So i was hoping that LoadLibraryEx32W could solve my
>> problem and give me access to the functions in the dll.

> I'm sorry to say, but maybe the Freepascal compiler might do what you
> want. BP7 cannot afaik call 32 bit DLLs or 32-bit functions from DPMI.

Neither can FPC (from DPMI), but the win32 version of course can.

Re:BP7 problem with thunking and LoadLibraryEx32W


Quote
> Thanks for your reply. If you have the time could you surgest
> a possible solution to the problem. What i'm trying is the
> write a win32 dll that can communicate with the serial-port
> using the win32 api functions CreateFile, WriteFile etc.
> As is I use pascal's 'port' function but dues to the VDM
> the communication increases by a factor 10 on NTOS.
> So i was hoping that LoadLibraryEx32W could solve my
> problem and give me access to the functions in the dll.

Take a look at the DWP project:

http://www.dwp42.org

This uses the Delphi IDE and compiler and the WDosX to produce 32-bit DPMI
programs. I'm pretty sure that WDosX supports LoadLibraryEx32W. This still
might not give you what you want mind, because it depends on what system calls
the dll's need to work.

--
Jay

Jason Burgon - Author of "Graphic Vision"  GUI for DOS/DPMI
=== Free LFN capable Dos/WinDos replacement and ===
=== New Graphic Vision  version 2.21 available from:  ===
http://www.jayman.demon.co.uk

Other Threads