Rzeczywiście. Zmieniłem kod - wygląda następująco. (Tam gdzie były poprawki dałem komentarz obok)
function ReadList(var PID: LongInt; res: TArrayOfCharListEntry; var adrServerList_CollectionStart: AddressPath): LongInt;
var
i : integer;
tmpElement : ListEntry;
adrCOLLECTION_START : LongInt;
adrCharList : LongInt;
adrType : LongINt;
adrCharListStart : LongInt;
resSize : LongInt;
bytesPerElement : LongInt;
lastI : LongInt;
tamStruct : LongInt;
tmpAdr : LongInt;
tmp,resStruct : Array of Byte;
begin
adrCOLLECTION_START := ReadCurrentAddress(pid, adrServerList_CollectionStart, -1, False);
adrCharList := QMemory_Read4Bytes(pid, Pointer(adrCOLLECTION_START + 8));
adrType := QMemory_Read4Bytes(pid, Pointer(adrCharList));
If adrType = -1 Then
begin
Result := -1;
Exit;
End;
if (adrType > 1000) Then
adrCharList := QMemory_Read4Bytes(pid, Pointer(adrType));
resSize := QMemory_Read4Bytes(pid, Pointer(adrCharList + $C));
adrCharListStart := adrCharList + $10;
If (resSize = 0) Then
begin
Result := -1;
Exit;
end;
bytesPerElement := resSize * 4;
SetLength(Tmp, BytesPerElement); // było SetLength(Tmp, BytesPerElement - 1);
QMemory_ReadNBytes(pid, Pointer(adrCharListStart), tmp);
tamStruct := 60;
SetLength(res, resSize); // było SetLength(res, resSize - 1);
lastI := resSize - 1;
For i := 0 To resSize - 1 do // było For i := 0 To resSize do
begin
tmpElement.Id := i;
tmpElement.entry_address := BitConverter_ToInt32(tmp, 4 * i);
SetLength(resStruct, tamStruct - 1);
QMemory_ReadNBytes(pid, Pointer(tmpElement.entry_address), resStruct);
tmpAdr := QMemory_Read4Bytes(pid, Pointer(tmpElement.entry_address + $10));
tmpElement.name_address := tmpAdr;
tmpElement.name := QMemory_ReadString(pid, Pointer(tmpAdr));
tmpAdr := QMemory_Read4Bytes(pid, Pointer(tmpElement.entry_address + $14));
tmpElement.server := QMemory_ReadString(pid, Pointer(tmpAdr));
res[i] := tmpElement;
end;
Result := resSize - 1;
end;
Gdy wywołuje poprzez showmessage -
tmpElement.server := QMemory_ReadString(pid, Pointer(tmpAdr));
oraz
tmpElement.name := QMemory_ReadString(pid, Pointer(tmpAdr));
Wszystkie dane pokolei ładnie się wyświetlają. Problem natomiast jest przy próbie wyświetlenia tych danych ...
For i := 0 To lastEntry do
lstChars.Items.Add(res[i].name + ' / ' + res[i].server);
// wyrzuca przy próbie dodania tych danych z tablicy res