Jump to content
Sign in to follow this  
Iczer

DLL Structure with bite-based elements instead of bytes

Recommended Posts

Iczer

To get info from :

wDate struct {
                unsigned ft_day   : 5;
                unsigned ft_month : 4;
                unsigned ft_year  : 7;
            } _DosDate;

 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
|<--(year - 1980)--->|<---month->|<-----day---->|


;----------------------------------------------------------------
wTime struct {
                unsigned ft_tsec : 5;
                unsigned ft_min  : 6;
                unsigned ft_hour : 5;
            } _DosTime;

 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
|<------hours---->|<----minutes-->|<--sec/ 2)-->|

Edited by Iczer

Share this post


Link to post
Share on other sites
trancexx

Create "word" struct and then use BitShift and BitAnd to read parts of the word value.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Iczer

I know :

$year = BitShift(BitAND($aRet[0],65024),9)+1980
$month = BitShift(BitAND($aRet[0],480),5)
$day = BitAND($aRet[0],31)

$Hours = BitShift(BitAND($aRet[0],63488),11)
$Minutes = BitShift(BitAND($aRet[0],2016),5)
$Seconds = BitAND($aRet[0],31)*2

it seem there are no bit-based structures... but would't  it be more clean way to have them? Since they are exist  :sweating:  :sorcerer:

Share this post


Link to post
Share on other sites
trancexx

They don't actually exist. The smallest addressable memory unit is byte (8 bits).


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Danyfirex

Hi, I think could do something like this: Edit: I did not look you want bit.  use bitwise instead.

Local $tword=DllStructCreate("word")

DllStructSetData($tword,1,258)

Local $tbytes=DllStructCreate("byte[" & DllStructGetSize($tword) & "]",DllStructGetPtr($tword))

msgbox(0,"the low byte",DllStructGetData($tbytes,1,1))

msgbox(0,"the high byte",DllStructGetData($tbytes,1,2))

But I sure trancexx way is the best.

saludos

Edited by Danyfirex

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×