typedef struct _SECURITY_ATTRIBUTES { // sa
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES;




How can I reserve BOOL variable ? as a bit BYTE or WORD?
What values has Yes? or No?

Could you give me the example for struc in FASM/MASM for this C++'s structure above?
Posted on 2003-10-23 06:41:25 by HarryTuttle
struc SECURITY_ATTRIBUTES {

.nLength dd ?
.lpSecurityDescriptor dd ?
.bInheritHandle dd ?
}
struct SECURITY_ATTRIBUTES


and for win32, BOOL is one of this:
TRUE = 1
FALSE = 0

(it is also diffused having FALSE as zero and TRUE as non-zero)
Posted on 2003-10-23 06:58:53 by pelaillo
masm

SECURITY_ATTRIBUTES STRUCT
nLength DWORD ?
lpSecurityDescriptor DWORD ?
bInheritHandle DWORD ?
SECURITY_ATTRIBUTES ENDS

hint: in the masm32 package browse through the various include files :)
most things are defined in windows.inc
Posted on 2003-10-23 07:14:07 by Hiroshimator
thx a lot

it means bool size is dword ?:)
Posted on 2003-10-23 08:06:03 by HarryTuttle
You know that a bit is enough to a bool value but...
In a 32 bit machine, is better to have it a DWORD. Otherwise you lost some clocks cycles to pack/unpack it to a register or memory location.
In modern processors, with pipelines and cache, each missalignment causes lost of performance that are difficult to measure or predict.

In such a situation, the *waste* is justified...
Posted on 2003-10-23 09:26:06 by pelaillo
There's no such thing as C's BOOL :)
First of all, C doesn't have booleans, only C++ does.
Secondly, BOOL in all caps is a windows type, not a C++ type. And usually (at least in VC) the windows BOOL and C++'s bool are different.

A BOOL is a windows type, the same as a DWORD. bool in lower case is C++'s type for a boolean value. Its exact size is not defined as with all of C++'s types, but usually a byte is used for it. Keep this in mind when mixing C++ and asm, or when programming win32 in C++. I once had a problem with a win32 API that returned a BOOL via a pointer to it, but since I used bool instead of BOOL, it only reserved a byte while it should reserve a DWORD. This leaded to stack corruption and a hard to find bug :)..

Thomas
Posted on 2003-10-24 17:10:50 by Thomas
Thomas is right and
there is no BOOL in Borlands C++ too , i think its only in M$ VC.
Posted on 2003-10-25 01:44:49 by Ranma_at

Thomas is right and
there is no BOOL in Borlands C++ too , i think its only in M$ VC.

It's not in MS's VC either, it's a define in the windows includes (#define BOOL DWORD or something)

Thomas
Posted on 2003-10-25 04:06:04 by Thomas
Originally posted by Thomas

but usually a byte is used for it. Keep this in mind when mixing C++ and asm, or when programming win32 in C++.


Not just when mixing with C++. If one's target OS includes Win9x family, he should be really careful about it. Some APIs in Win9x return byte-size BOOL (which, I suspect, might have been linked from Win16 libraries without recompiling), and test eax,eax is useless in those cases.
Posted on 2003-10-25 05:46:41 by Starless
When I'm programming in C I always use bool, MSVC++ after looking at the code uses one byte to hold it. BOOL I have never used.
Posted on 2003-10-26 18:27:31 by x86asm
ther is no need to cry over a brocken glass...


gracias;)
Posted on 2003-10-27 04:19:19 by HarryTuttle