AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

C Structures into Delphi

Ein Thema von sdean · begonnen am 5. Jan 2012 · letzter Beitrag vom 5. Jan 2012
Antwort Antwort
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#1

C Structures into Delphi

  Alt 5. Jan 2012, 01:08
Delphi-Version: 7
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
  Mit Zitat antworten Zitat
Furtbichler
(Gast)

n/a Beiträge
 
#2

AW: C Structures into Delphi

  Alt 5. Jan 2012, 07:03
Try this
Delphi-Quellcode:
Type
  TMyFunction= Function (aThread : TThread; Var dwordParam : DWORD) : Int;

  TMyRecord = Record
  ... myFunc : TMyFunction;
  End
  Mit Zitat antworten Zitat
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#3

AW: C Structures into Delphi

  Alt 5. Jan 2012, 20:12
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;
    };
  };
};
  Mit Zitat antworten Zitat
Furtbichler
(Gast)

n/a Beiträge
 
#4

AW: C Structures into Delphi

  Alt 5. Jan 2012, 21:03
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.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:03 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