Autor Beitrag
SchelmVomElm
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 154

W2K Pro
D5 Pro
BeitragVerfasst: Mi 29.10.08 10:18 
Hallo,

ich habe ein merkwürdiges Problem:
Ich lade eine Funktion dynamisch aus einer DLL (GetValue).
In TMainForm wird die Funktion korekt aufgerufen mit Index von 0 bis 13668.
Beim debuggen der DLL kommt aber als Übergabeparameter "Index" immer
andere viel zu hohe Zahlen an die dann auch pro Aufruf um 1 inkrementiert werden.
z.B. 13348608, 13348609, 13348610...
Das Problem trat plötzlich auf und ohne dass
ich etwas an den beteiligten Funktionen geändert hätte.

Aufruf im Hauptprogramm:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function TMainForm.GetValue(index: integer): string;
var
  DllFx: TInfoIndexFunction;
const
  FxName = 'GetValue';
begin
  if PlugHandle <> 0 then
  begin
    @DllFx := GetProcAddress(PlugHandle, PChar(FxName));
    if @DllFx <> nil then
      Result := string(DllFx(index))
    else MsgNoFx(FxName);
  end else MsgNoLib(FxName);
end;


DLL Funktion
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function GetValue(index: integer): PChar;
begin
  if ((index < StrBuf.Count) and (index >= 0)) then
    Result := PChar(StrBuf[index]) else
  Result := PChar('ERROR');
end;

_________________
for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("|"+(*u/4)%2);
SchelmVomElm Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 154

W2K Pro
D5 Pro
BeitragVerfasst: Mi 29.10.08 10:37 
Stop - hat sich erledigt fehler schon gefunden:

ausblenden Delphi-Quelltext
1:
TInfoIndexFunction = function(index: byte): PChar;					


Mich wundert allerdings dass sich der Fehler erst jetzt bemerkbar macht das Byte
hätte schon immer überlaufen müssen. :gruebel:

_________________
for(;P("\n"),R--;P("|"))for(e=C;e--;P("_"+(*u++/8)%2))P("|"+(*u/4)%2);