Jump to content

kosovali

Members
  • Content Count

    7
  • Joined

  • Last visited

Posts posted by kosovali


  1. 26 minutes ago, Lars Fosdal said:

    Does the stream consist only of ptr_rec2 elements? Is it simply a double linked list?

    Is the element sequence in the stream of importance?

    Are the pointers relative positions in the stream or are they original memory positions in the old win32 app and discarded/replaced when loading in the receiving app?

    Do you need to keep it in the same linked list format in the new 64-bit app?

     

    Both ptr_rec1 and pointer are 8 bytes in 64-bit - so to read the stream in 64-bit, you would have to replace the pointer types with a 32-bit variable

    
    type
        Fake32bitPtr = UInt32;
        ptr_rec1=Fake32bitPtr;
        rec1=record
         i1:integer;
         p1:Fake32bitPtr;
        end;
       
        ActualPtr_rec2 = ^ptr_rec2;
        ptr_rec2=record
          rec:ptr_rec1;
          i:integer;
          p2:Fake32bitPtr;
        end;

    If the stream is not incredibly large, you could create a shadow structure that basically is an array of ActualPtr_rec2 and point to the ptr_rec2 elements without caring about the pointers?

     

     

    Records contains; Record Pointer, Double Link List Pointer. etc.

    Element sequence is important.

    Pointer values not important for streaming. Only used runtime. 

    We want to same format in the 64 bit app.

    Fake32bitPtr can not be used with GetMem. Error: "Incompatible Types".

    I can change -minimal- record fields for 64 bit compatibility. 

     

    Code changed for Win32/Win64 com.

    type
        Fake64bitPtr = UInt64;
        ptr_rec1=Fake64bitPtr;
        rec1=record
         i1:integer;
         p1:Fake64bitPtr;
        end;
       
        ActualPtr_rec2 = ^ptr_rec2;
        ptr_rec2=record
          rec:ptr_rec1;
          i:integer;
          p2:Fake64bitPtr;
        end;
        
        

    But GetMem raised error.


  2. 14 minutes ago, DelphiUdIT said:

    There is not only a problem of the length of the "pointers" but also of the arrangement of the data within the record.
    The compiler "fills" the record structure with zero bytes to align the data to the defined alignment (which can be the standard one or one defined in that section of code).
    Therefore, the transmission of that data (whatever it is) is still at risk even if it were performed within programs made with Delphi. A change of alignment (even the standard one) for example between different platforms or different compiler releases could lead to different results.

    Used packed record.


  3. Hi,

     

    I have 1000+ records.  This records contains pointer types. When records streamed on Win32 /Win64 has a different sizes. I want to use this records with win32/win64. 

    In Win32 Pointer size is 4, can be this size 8 bytes?

    Or any other solutions? 

     

    type
        ptr_rec1=^rec1;
        rec1=record
         i1:integer;
         p1:Pointer;
        end;
       
        ptr_rec2=record
          rec:ptr_rec1;
          i:integer;
          p2:Pointer;
        end;
        
        SizeOf(ptr_rec2); //Different sizes for Win32/Win64

     


  4. H.Alignment  changes does not affected. 

     

    LabelCapture.thumb.PNG.dcb70e7b05c633c1df232770f9cd7b0e.PNG

     

    Sample output with DrawTextEx WinApi call :

     

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Text:String;
      lpRect:TRect;
      uFormat:Cardinal;
      Options: Longint;
    begin
       Text:= '123 SAMPLE 456';
       lpRect:=Rect(10,10,300,150);
       uFormat:= {DT_LEFT or }DT_EXPANDTABS or DT_NOPREFIX or DT_RTLREADING;   
    
       DrawTextEx(Canvas.Handle, @Text[1], Length(Text), lpRect, uFormat, nil);
    end;

     

     

     

×