It is currently Mon Sep 23, 2019 9:05 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Structures LARGE_INTEGER, ULARGE_INTEGER
PostPosted: Tue Aug 13, 2019 1:35 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 892
The structure LARGE_INTEGER (ULARGE_INTEGER) is defined in Pb as follows:
Code:
Structure LARGE_INTEGER
  lowpart.l
  highpart.l
EndStructure

Correctly, the structure should look like this or something similar:
Code:
Structure LARGE_INTEGER_LONGPART
  lowpart.l
  highpart.l
EndStructure

Structure LARGE_INTEGER
  StructureUnion
    LongPart.LARGE_INTEGER_LONGPART
    QuadPart.q
  EndStructureUnion
EndStructure

A further problem with the simple version of PB is that when the structure is used as a datatype in another structure, it is aligned with a size of 4 instead of 8. With my 'extended version' this seems ok.
Code:
Structure MYSTRUC Align #PB_Structure_AlignC
  b.b
  li.LARGE_INTEGER
EndStructure

Debug SizeOf (MYSTRUC) ; should be 16

_________________
sorry for my bad english


Last edited by Josh on Fri Aug 16, 2019 8:45 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Structure LARGE_INTEGER
PostPosted: Thu Aug 15, 2019 6:25 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Apr 25, 2003 5:10 pm
Posts: 487
Location: Doubs - France
I think that alignment is not Fred rule but C rule for #PB_Structure_AlignC.
It's for C padding.

If you want to align with 8, use that instead of creating a new structure
LARGE_INTEGER will remain as defined in PB.

Code:
Structure MYSTRUC Align 8
  b.b
  li.LARGE_INTEGER
EndStructure


I've taken a look to sizeof() for both and it's the same result.

_________________
A+
Denis


Top
 Profile  
Reply with quote  
 Post subject: Re: Structure LARGE_INTEGER
PostPosted: Thu Aug 15, 2019 7:28 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 892
Denis wrote:
I think that alignment is not Fred rule but C rule for #PB_Structure_AlignC.
It's for C padding.
That's right. But for #PB_Structure_AlignC to work correctly, it is necessary that the underlying structures are correct. The C-structure looks like this:
Code:
typedef union _LARGE_INTEGER {
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } DUMMYSTRUCTNAME;
  struct {
    DWORD LowPart;
    LONG  HighPart;
  } u;
  LONGLONG QuadPart;
} LARGE_INTEGER;
Since Pb does not support anonymous structures, an additional help structure is required in Pb.


Denis wrote:
If you want to align with 8, use that instead of creating a new structure
LARGE_INTEGER will remain as defined in PB.

Code:
Structure MYSTRUC Align 8
  b.b
  li.LARGE_INTEGER
EndStructure


I've taken a look to sizeof() for both and it's the same result.
This is a workaround and does not change the fact that it is a bug. If I have to start checking everything, then I can forget #PB_Structure_AlignC right away and pad everything manually.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Structure LARGE_INTEGER
PostPosted: Fri Aug 16, 2019 6:32 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Apr 25, 2003 5:10 pm
Posts: 487
Location: Doubs - France
Josh,

i didn't take a look to MS definition.

you're right.

And the same with _ULARGE_INTEGER i use with Istorage/Istream interface
(i wasn't able to acces correctly to very big stream)

Code:
typedef union _ULARGE_INTEGER {
  struct {
    DWORD LowPart;
    DWORD HighPart;
  };
  struct {
    DWORD LowPart;
    DWORD HighPart;
  } u;
  ULONGLONG QuadPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;


Code:
Structure ULARGE_INTEGER
  LowPart.l
  HighPart.l
EndStructure

_________________
A+
Denis


Top
 Profile  
Reply with quote  
 Post subject: Re: Structure LARGE_INTEGER
PostPosted: Fri Aug 16, 2019 8:49 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 892
Denis wrote:
And the same with _ULARGE_INTEGER

ULARGE_INTEGER added in title and my first post.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye