flat assembler
Message board for the users of flat assembler.

Index > Windows > Convert C Struct bit fields to FASM

Author
Thread Post new topic Reply to topic
mns



Joined: 20 Dec 2007
Posts: 150
Location: Piliyandala,Sri lanka
mns 03 Jul 2020, 13:48
I am trying to convert d3d11.h file to FASM include file and found this.

typedef struct D3D11_VIDEO_PROCESSOR_COLOR_SPACE
{
UINT Usage : 1;
UINT RGB_Range : 1;
UINT YCbCr_Matrix : 1;
UINT YCbCr_xvYCC : 1;
UINT Nominal_Range : 2;
UINT Reserved : 26;
} D3D11_VIDEO_PROCESSOR_COLOR_SPACE;

Is there way to convert bit field parts to FASM or I just have to convert the struct without bit fields as this,
struct D3D11_VIDEO_PROCESSOR_COLOR_SPACE
Usage dd ?
RGB_Range dd ?
YCbCr_Matrix dd ?
YCbCr_xvYCC dd ?
Nominal_Range dd ?
Reserved dd ?
ends


(although I found a previous post on similar topic using unions but couldn't understand a bit)
Hope someone can help? Shocked
Post 03 Jul 2020, 13:48
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 03 Jul 2020, 14:03
The whole structure is one dword. And within that are the bits.
Code:
D3D11_VIDEO_PROCESSOR_COLOR_SPACE  dd ?

;for multipliers
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.Usage  = 1 shl 0
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.RGB_Range  = 1 shl 1
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.YCbCr_Matrix  = 1 shl 2
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.YCbCr_xvYCC  = 1 shl 3
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.Nominal_Range  = 1 shl 4

;for masks
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.Usage  = 1 shl 0
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.RGB_Range  = 1 shl 1
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.YCbCr_Matrix  = 1 shl 2
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.YCbCr_xvYCC  = 1 shl 3
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.Nominal_Range  = 3 shl 4

;for shifts
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.Usage  = 0
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.RGB_Range  = 1
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.YCbCr_Matrix  = 2
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.YCbCr_xvYCC  = 3
D3D11_VIDEO_PROCESSOR_COLOR_SPACE.Nominal_Range  = 4    
Post 03 Jul 2020, 14:03
View user's profile Send private message Visit poster's website Reply with quote
mns



Joined: 20 Dec 2007
Posts: 150
Location: Piliyandala,Sri lanka
mns 03 Jul 2020, 17:28
Thank you revolution, for the kind quick response.
So the "=" will define the size of the struct: members?(If the question is silly and not grasping the basic knowladge of FASM, kindly bear with me) Confused
Post 03 Jul 2020, 17:28
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 03 Jul 2020, 23:22
"=" is just defining a value, there is no special meaning, it is just a number.

You can use the number to examine the bits you need. For example if you are using masks:
Code:
mov eax, [D3D11_VIDEO_PROCESSOR_COLOR_SPACE]
test eax, D3D11_VIDEO_PROCESSOR_COLOR_SPACE.RGB_Range    
Post 03 Jul 2020, 23:22
View user's profile Send private message Visit poster's website Reply with quote
mns



Joined: 20 Dec 2007
Posts: 150
Location: Piliyandala,Sri lanka
mns 04 Jul 2020, 08:08
Thank you very much revolution
Post 04 Jul 2020, 08:08
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.