Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   C Structures into Delphi (https://www.delphipraxis.net/165542-c-structures-into-delphi.html)

sdean 5. Jan 2012 01:08

Delphi-Version: 7

C Structures into Delphi
 
Hi, i'm trying to port some C code into Pascal , i did some part .

Code:
struct DLL{
       char* Dllname;
       dword imagebase;
       dword size;
       dword vAddr;
};

struct API{
       char* ApiName;
       DLL*  libName;
       dword args;
       dword addr;
      int (*Start_func)(Thread*,dword*);
};
so i ported it in this way :

Delphi-Quellcode:
type
     PDll = ^TDll;
     TDLL = record
     Dllname: Pchar;
     imagebase: dword;
     size: dword;
     vAddr: dword;
end;
    API = record
    Apiname: PChar;
    libName: PDLL;
    args: dword;
    addr: dword;
   //*** But the problem is here
   int (*Start_func)(Thread*,dword*);
   //*** how it can be done ?

How this can be done inside a Structure
Code:
int (*Start_func)(Thread*,dword*);

many thanks

Furtbichler 5. Jan 2012 07:03

AW: C Structures into Delphi
 
Try this
Delphi-Quellcode:
Type
  TMyFunction= Function (aThread : TThread; Var dwordParam : DWORD) : Int;

  TMyRecord = Record
  ... myFunc : TMyFunction;
  End

sdean 5. Jan 2012 20:12

AW: C Structures into Delphi
 
many thanks Furtbichler ,
what about this :

Code:
struct image_resource_directory_entry
{
  union
  {
    struct
    {
      unsigned long name_offset : 31;
      unsigned long name_is_string : 1;
    };
    unsigned long name;
    unsigned short id;
  };
  union
  {
    unsigned long offset_to_data;
    struct
    {
      unsigned long offset_to_directory : 31;
      unsigned long data_is_directory : 1;
    };
  };
};

Furtbichler 5. Jan 2012 21:03

AW: C Structures into Delphi
 
Delphi-Quellcode:
Type
  TMyUnion = Record
    case boolean of
       false : (Foobar : Word);
       true : (Foo,Bar : Char);
   end;
Foobar and Foo, Bar have the same physical memory space, i.e. if you modify e.g. Foobar, Foo and Bar will also be modified.

Adapt this idea to your challenge.


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:32 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz