Autor Beitrag
Hendi48
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Sa 11.04.09 10:25 
Hallo, ich bins mal wieder mit einem Übersetzungsproblem. :P

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
  unsigned int len;
  len = 0x480;
  
  while(len) {
      [...]
      len -= 0x60;
  }


Was hat while(len) zu bedeuten? Solange es über 0 ist? Eine unsigned Zahl kann doch gar nicht kleiner als 0 sein oder?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 11.04.09 10:39 
Nicht kleiner als 0, aber genau 0. Und das ist dann false. (Alles <> 0 ist true.)

Wenn also die Ursprungszahl nicht wie in diesem Fall durch 60 teilbar wäre, wärs schlecht. ;-)
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Sa 11.04.09 11:22 
Ah, ok.
Ich weiß nicht mehr weiter.. :(
Ich möchte gerne eine Datei von einer Wii DVD extrahieren. Ich blicke bei diesen C-Pointer-Lesemethoden nicht durch

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
static void partition_read(u64 offset, u8 *data, u32 len)
{
  u8 block[0x8000];
  u32 offset_in_block;
  u32 len_in_block;

  while(len) {
    offset_in_block = offset % 0x7c00;
    len_in_block = 0x7c00 - offset_in_block;
    if (len_in_block > len)
      len_in_block = len;

    partition_read_block(offset / 0x7c00, block);   // Hier findet das eigentliche Lesen dann statt
    memcpy(data, block + offset_in_block, len_in_block);

    data += len_in_block;
    offset += len_in_block;
    len -= len_in_block;
  }
}

// Aufruf:
   u8 b[0x480];

   partition_read(0, b, sizeof b);


Wenn b ein array ist, was passiert dann bei data += len_in_block; ??

Meine bisherige Übersetzung sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure PartitionRead(Offset: Int64; var Data; Len: Integer);
var
  block: array[0..$7FFF] of Byte;       // Length = $8000
  offset_in_block, len_in_block: Integer;
begin
  while Len > 0 do
  begin
    offset_in_block := offset mod $7c00;
    len_in_block := $7c00 - offset_in_block;
    if (len_in_block > Len) then
      len_in_block := Len;
    PartitionReadBlock(offset / $7c00, block);

  end;
end;


Zuletzt bearbeitet von Hendi48 am Sa 11.04.09 11:49, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 11.04.09 11:42 
user profile iconHendi48 hat folgendes geschrieben Zum zitierten Posting springen:
was passiert dann bei data += len_in_block; ??
Der Pointer data wird um len_in_block weitergeschoben.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Sa 11.04.09 11:46 
Und was heißt das im Klartext?
Wenn z.B. data += 6 gemacht wird, ist dann sozusagen das alte data[6] das neue data[0] ?! Ich hab's mit Pointern nicht so :?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 11.04.09 11:49 
Stell dir den (Ansi)String 'abcdefg' vor, der im Arbeitsspeicher liegt. Jetzt hast du einen PChar darauf. Das heißt einen Pointer auf eine nullterminierte Liste von Chars. Der Pointer zeigt zunächst auf das a. Wenn du den jetzt um 2 Byte erhöhst, dann zeigt der Pointer auf das c.

In dem Pointer steht ja nur die Speicheradresse. Und wenn du den Pointer also im Wert veränderst, dann zeigt der entsprechend auf diese Speicherstelle.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Sa 11.04.09 12:02 
Achso, und das wirkt sich dann auch auf das memcpy aus, da sonst data immer wieder überschrieben werden würde?

Wie mach ich das denn dann am besten in Delphi? Aufzurufen wär es mir so am liebsten:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  b: array[0..$47F] of Byte;
begin
  PartitionRead(0, b, $480);
end;

Geht das mit dem 2. Parameter als "var Data" überhaupt irgendwie, oder soll ich es besser anders machen?

Edit: Ich löse es jetzt anders. (Mit einer Library)
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Do 23.04.09 19:25 
So, jetzt habe ich doch noch ein C-Problem:

ausblenden C#-Quelltext
1:
2:
3:
  u64 offset = 8;
  
  offset *= 512ULL;


Was bedeutet 512ULL?

Gruß,
Hendi
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 23.04.09 20:46 
ULL = Suffix für Zahlennumeral-Typ. Steht für unsinged long long, was ein vorzeichenloser Int64 ist, den es aber so in Delphi nicht gibt. Schau inwiefern Du das mit vorzeichenbehaftet umschiffen kannst.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 23.04.09 20:49 
UInt64 als vorzeichenlosen Int64 Wert gibts ja in Delphi. Inwiefern das das selbe ist, weiß ich nicht.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 23.04.09 20:53 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
UInt64 als vorzeichenlosen Int64 Wert gibts ja in Delphi. Inwiefern das das selbe ist, weiß ich nicht.

Nicht in D7 ;-) Den haben die später mal nachgefrickelt ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 23.04.09 21:01 
Im Profil steht in diesem Fall aber Delphi 2009, da gibts das. ;-)

Ich weiß eben nur rein gar nichts über die Interna des hier angesprochenen Typs von C, also auch nicht, ob das schon direkt das richtige ist.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Do 23.04.09 21:05 
unsigned long long = UInt64 (unter D2009. Die sind von den Interna genauso ...

Wollt das nur ergänzen bzgl. D7, dass man dort (und glaub auch noch D2005\2006) Int64 nehmen und um das Unsigned etwas herum arbeiten musste ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.