[fpc-devel]strange work with dll (dynamic dll)

Michail A.Baikov baikov at mosfilm.ru
Tue Oct 17 20:04:07 CEST 2000


Screen after runed testdll.exe:

268435456
Begin readconfig
Runtime error 103 at 0x10001085
  0x10001085
  0x00401158
  0x004012D9

Runtime error 216 at 0x02CDFC06
  0x02CDFC06
Runtime error 216 at 0x0040234E
  0x0040234E
  0x00401CB8
  0x004016EE
  0x0040152F
  0x004023A4
  0x02CDFC06

Runtime error 103 at 0x10001085
  0x10001085
  0x81702954
  0xBFFB1B20
  0xBFFB1B20



----- Original Message ----- 
From: "Michail A.Baikov" <baikov at mosfilm.ru>
To: <fpc-devel at deadlock.et.tudelft.nl>
Sent: Tuesday, October 17, 2000 10:02 PM
Subject: [fpc-devel]strange work with dll (dynamic dll)


> main program:
> 
> Program TestDLLBug;
> 
> Uses    Strings,
>         Windows;
> 
> type
> 
>         xreadconfig = function (var s:string;var s1:string):boolean;
> 
> 
> var
>         pc              :       Pchar;
>         ReadConfig      :       XReadConfig;
>         Handle          :       THandle;
>         S, S1           :       String;
> 
> begin
>   pc:=StrAlloc (length('C:\CORE2.DLL')+1);
>   pc:=StrPCopy(pc,'C:\CORE2.DLL');
> 
>   Handle:=LoadLibrary(pc);
> 
>   Writeln(Handle);
> 
>   if Handle >= 32 then
>   begin
>    @readconfig:=GetProcAddress(Handle,'READCONFIG');
>    if @readconfig=nil then
>    begin
>     Writeln('CORE2.DLL missed or corrupt! Program halt.');
>     halt(252)
>    end;
>   end;
> 
>  writeln('Begin readconfig');
>  readconfig(S,S1);
>  writeln('End readconfig');
>  FreeLibrary(Handle);
> end.
> 
> CORE2.DLL:
> 
> library core2;
> 
> uses windows;
> 
> 
> function readconfig (var S:String;var S1:String):boolean;export;stdcall;
> begin
> assign(output,'');
> writeln('Hello!');
> close(output);
> end;
> 
> exports
>         readconfig;
> 
> begin
> end.
> 
> 
> And this not work.
> 
> 1. Why not work assign(output,'');writeln('blabla');close(output); ? In
> BP70/DPMI all working
> 2. Why in -S2 option fpc don't allow assign values to an address
> (@readconfig := blablabla (see up)).
> 
> 
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel





More information about the fpc-devel mailing list