Entwickler-Ecke

Sonstiges (Delphi) - Fragen zum Übersezten einiger typen


Boldar - Do 18.09.08 18:45
Titel: Fragen zum Übersezten einiger typen
Hallo Leute,
was sind die entsprechungen folgender (C-) Typen in delphi?

Quelltext
1:
2:
3:
4:
5:
6:
PLARGE_INTEGER
ULONG
PVOID
PIO_STATUS_BLOCK
POBJECT_ATTRIBUTES
NTSTATUS

Die letzten Beiden sind vermutlich pointer, ebenso PLarge_integer, aber worauf?

Was ist in delphi ein Large integer? int64? und ist Ulong dann cardinal?
Und Was ist Pvoid??


jaenicke - Do 18.09.08 19:24


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
  PLARGE_INTEGER = ^LARGE_INTEGER;
  ULONG = Cardinal;

  PVOID = Pointer;

  TObjectAttributes = packed record 
    Length: ULONG; 
    RootDirectory: THandle; 
    ObjectName: PUNICODE_STRING; 
    Attributes: ULONG; 
    SecurityDescriptor: PVOID;        // Points to type SECURITY_DESCRIPTOR 
    SecurityQualityOfService: PVOID;  // Points to type SECURITY_QUALITY_OF_SERVICE 
  end
  OBJECT_ATTRIBUTES = TObjectAttributes; 
  POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES; 

  NTSTATUS = Longint;

  PIO_STATUS_BLOCK = ^IO_STATUS_BLOCK; 
  IO_STATUS_BLOCK = packed record 
    Status: NTSTATUS; 
    Information: DWORD; 
  end;
ULONG ist bei mir auch so definiert in Delphi (2006).
http://www.delphipraxis.net/topic10030.html
http://www.delphipraxis.net/topic3014.html


Knulli - Do 18.09.08 19:29

PLARGE_INTEGER: PInt64 oder ^Int64
ULONG Cardinal
PVOID Pointer
PIO_STATUS_BLOCK kenn ich nich...Pointer auf IO_STATUS_BLOCK?? = ^IO_STATUS_BLOCK
POBJECT_ATTRIBUTES kenn ich auch nich
NTSTATUS kenn ich auch nich


Boldar - Do 18.09.08 20:54

Und was ist dann

Delphi-Quelltext
1:
Punicode_string                    


ist das dann so etwas in C?

Quelltext
1:
2:
3:
4:
5:
typedef struct _LSA_UNICODE_STRING {
  USHORT Length;
  USHORT MaximumLength;
  PWSTR Buffer;
} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING;


In Delphi müsste das dann so aussehen:
Aber welchen Typ hat Buffer?? Etwa Widestring??


Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type Tunicodestring = packed record
  length: byte;
  Maximumlength: byte;
  Buffer : ?????;
  end;
type Punicode_string = ^unicode_string;


mkinzler - Do 18.09.08 21:05

PWideChar


Boldar - Do 18.09.08 21:18

Also ist das so korekt? Oder fehlt da noch was? Und ist das mit var und const korrekt?


Delphi-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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
type phandle = pointer;
type access_mask = integer;
type
  PLARGE_INTEGER = ^LARGE_INTEGER;
  ULONG = Cardinal;

  PVOID = Pointer;

  TObjectAttributes = packed record
    Length: ULONG;
    RootDirectory: THandle;
    ObjectName: Pwidechar;
    Attributes: ULONG;
    SecurityDescriptor: PVOID;
    SecurityQualityOfService: PVOID;
  end;
  OBJECT_ATTRIBUTES = TObjectAttributes;
  POBJECT_ATTRIBUTES = ^OBJECT_ATTRIBUTES;

  NTSTATUS = Longint;

  PIO_STATUS_BLOCK = ^IO_STATUS_BLOCK;
  IO_STATUS_BLOCK = packed record
    Status: NTSTATUS;
    Information: DWORD;
  end;


function NtCreateFile(
var FileHandle : PHANDLE;
const DesiredAccess: ACCESS_MASK;
const ObjectAttributes : POBJECT_ATTRIBUTES;
var IoStatusBlock : PIO_STATUS_BLOCK;
const AllocationSize : PLARGE_INTEGER ;
const FileAttributes : ULONG ;
const ShareAccess : ULONG;
const CreateDisposition : ULONG;
const CreateOptions : ULONG;
const EaBuffer : PVOID;
const EaLength : ULONG
): NTSTATUS;stdcall;external 'ntdll.dll';


jaenicke - Do 18.09.08 21:29

Schau mal hier weiter unten bei Accepted Solution, da ist die komplette Übersetzung zu der DLL schon fertig^^:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_20285753.html


Boldar - Do 18.09.08 21:33

Da isses abba nur in C, nich in Delphi(zumindest bei mir nicht!).


jaenicke - Do 18.09.08 23:16

Dann bist du da nicht eingeloggt.