News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

h2incX vs translatorus headinc - WinCrypt.h

Started by LiaoMi, May 23, 2021, 07:27:08 PM

Previous topic - Next topic

LiaoMi

Hi Biterider, TouEnMasm, Nidud, Rsala  :biggrin:

why are the structures so different? And the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB in both converters??

@Biterider h2incX doesn't handle multilevel arrays?

h2incX
  EncryptionState BYTE 16 dup (?)
  DecryptionState BYTE 16 dup (?)

vs
headinc
EncryptionState BYTE 15 dup (16 dup (?)) ; 14 rounds + 1
DecryptionState BYTE 15 dup (16 dup (?))

vs
asmc
EncryptionState db 16*15 dup(?)
DecryptionState db 16*15 dup(?)

vs
EasyCode
    EncryptionState DB 240 DUP(?)
    DecryptionState DB 240 DUP(?)


@Biterider is the size of this structure correct?
CRYPT_INTEGER_BLOB struct
  cbData DWORD ?
  __field_bcount typedef proto stdcall :cbData
  pbData POINTER ?
CRYPT_INTEGER_BLOB ends


@TouEnMasm __field_bcount(cbData)pbData XMASM ? - Parentheses in the text can create a compilation error or I'm wrong?


@Nidud What converter are you using? Your results are completely different!  :rolleyes:

@Rsala Same question, what converter are you using?  :biggrin:


@to All

Orig -    __field_bcount(cbData)  BYTE    *pbData;
AsmC -  pbData LPBYTE ?
h2incX - __field_bcount typedef proto stdcall :cbData
  pbData POINTER ?
Headinc - __field_bcount(cbData)pbData XMASM ?
EasyCode - pbData XPTR ?

Original header: struct _CRYPT_AES_128_KEY_STATE, struct _CRYPT_AES_256_KEY_STATE, struct _CRYPTOAPI_BLOB
typedef struct _CRYPT_AES_128_KEY_STATE {
    unsigned char Key[16];
    unsigned char IV[16];
    unsigned char EncryptionState[11][16];      // 10 rounds + 1
    unsigned char DecryptionState[11][16];
    unsigned char Feedback[16];
} CRYPT_AES_128_KEY_STATE, *PCRYPT_AES_128_KEY_STATE;

typedef struct _CRYPT_AES_256_KEY_STATE {
    unsigned char Key[32];
    unsigned char IV[16];
    unsigned char EncryptionState[15][16];      // 14 rounds + 1
    unsigned char DecryptionState[15][16];
    unsigned char Feedback[16];
} CRYPT_AES_256_KEY_STATE, *PCRYPT_AES_256_KEY_STATE;

//+-------------------------------------------------------------------------
//  CRYPTOAPI BLOB definitions
//--------------------------------------------------------------------------
// certenrolls_begin -- *_BLOB

typedef struct _CRYPTOAPI_BLOB {
                            DWORD   cbData;
    __field_bcount(cbData)  BYTE    *pbData;
} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB,
CRYPT_UINT_BLOB, *PCRYPT_UINT_BLOB,
CRYPT_OBJID_BLOB, *PCRYPT_OBJID_BLOB,
CERT_NAME_BLOB, *PCERT_NAME_BLOB,
CERT_RDN_VALUE_BLOB, *PCERT_RDN_VALUE_BLOB,
CERT_BLOB, *PCERT_BLOB,
CRL_BLOB, *PCRL_BLOB,
DATA_BLOB, *PDATA_BLOB,
CRYPT_DATA_BLOB, *PCRYPT_DATA_BLOB,
CRYPT_HASH_BLOB, *PCRYPT_HASH_BLOB,
CRYPT_DIGEST_BLOB, *PCRYPT_DIGEST_BLOB,
CRYPT_DER_BLOB, *PCRYPT_DER_BLOB,
CRYPT_ATTR_BLOB, *PCRYPT_ATTR_BLOB;


h2incX the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB
CRYPT_AES_128_KEY_STATE struct
  Key BYTE 16 dup (?)
  IV BYTE 16 dup (?)
  EncryptionState BYTE 16 dup (?)
  DecryptionState BYTE 16 dup (?)
  Feedback BYTE 16 dup (?)
CRYPT_AES_128_KEY_STATE ends

PCRYPT_AES_128_KEY_STATE typedef ptr CRYPT_AES_128_KEY_STATE

CRYPT_AES_256_KEY_STATE struct
  Key BYTE 32 dup (?)
  IV BYTE 16 dup (?)
  EncryptionState BYTE 16 dup (?)
  DecryptionState BYTE 16 dup (?)
  Feedback BYTE 16 dup (?)
CRYPT_AES_256_KEY_STATE ends

PCRYPT_AES_256_KEY_STATE typedef ptr CRYPT_AES_256_KEY_STATE

CRYPT_INTEGER_BLOB struct
  cbData DWORD ?
  __field_bcount typedef proto stdcall :cbData
  pbData POINTER ?
CRYPT_INTEGER_BLOB ends

PCRYPT_INTEGER_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_UINT_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_UINT_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_OBJID_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_OBJID_BLOB typedef ptr CRYPT_INTEGER_BLOB
CERT_NAME_BLOB typedef CRYPT_INTEGER_BLOB
PCERT_NAME_BLOB typedef ptr CRYPT_INTEGER_BLOB
CERT_RDN_VALUE_BLOB typedef CRYPT_INTEGER_BLOB
PCERT_RDN_VALUE_BLOB typedef ptr CRYPT_INTEGER_BLOB
CERT_BLOB typedef CRYPT_INTEGER_BLOB
PCERT_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRL_BLOB typedef CRYPT_INTEGER_BLOB
PCRL_BLOB typedef ptr CRYPT_INTEGER_BLOB
DATA_BLOB typedef CRYPT_INTEGER_BLOB
PDATA_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DATA_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_DATA_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_HASH_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_HASH_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DIGEST_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_DIGEST_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DER_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_DER_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_ATTR_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_ATTR_BLOB typedef ptr CRYPT_INTEGER_BLOB


;Errors: 0


translatorus headinc the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB

CRYPT_AES_128_KEY_STATE STRUCT DEFALIGNMASM
Key BYTE 16 dup (?)
IV BYTE 16 dup (?)
EncryptionState BYTE 11 dup (16 dup (?)) ; 10 rounds + 1
DecryptionState BYTE 11 dup (16 dup (?))
Feedback BYTE 16 dup (?)
CRYPT_AES_128_KEY_STATE ENDS



CRYPT_AES_256_KEY_STATE STRUCT DEFALIGNMASM
Key BYTE 32 dup (?)
IV BYTE 16 dup (?)
EncryptionState BYTE 15 dup (16 dup (?)) ; 14 rounds + 1
DecryptionState BYTE 15 dup (16 dup (?))
Feedback BYTE 16 dup (?)
CRYPT_AES_256_KEY_STATE ENDS


CRYPT_INTEGER_BLOB STRUCT DEFALIGNMASM
cbData DWORD ?
__field_bcount(cbData)pbData XMASM ?
CRYPT_INTEGER_BLOB ENDS


CRYPT_UINT_BLOB EQU <CRYPT_INTEGER_BLOB>

CRYPT_OBJID_BLOB EQU <CRYPT_INTEGER_BLOB>

CERT_NAME_BLOB EQU <CRYPT_INTEGER_BLOB>

CERT_RDN_VALUE_BLOB EQU <CRYPT_INTEGER_BLOB>

CERT_BLOB EQU <CRYPT_INTEGER_BLOB>

CRL_BLOB EQU <CRYPT_INTEGER_BLOB>

DATA_BLOB EQU <CRYPT_INTEGER_BLOB>

CRYPT_DATA_BLOB EQU <CRYPT_INTEGER_BLOB>

CRYPT_HASH_BLOB EQU <CRYPT_INTEGER_BLOB>

CRYPT_DIGEST_BLOB EQU <CRYPT_INTEGER_BLOB>

CRYPT_DER_BLOB EQU <CRYPT_INTEGER_BLOB>

CRYPT_ATTR_BLOB EQU <CRYPT_INTEGER_BLOB>



EasyCode the correct conversion looks like
CRYPT_AES_128_KEY_STATE STRUCT ALIGNMODE
    Key             DB 16 DUP(?)
    IV              DB 16 DUP(?)
    EncryptionState DB 176 DUP(?)
    DecryptionState DB 176 DUP(?)
    Feedback        DB 16 DUP(?)
CRYPT_AES_128_KEY_STATE ENDS

CRYPT_AES_256_KEY_STATE STRUCT ALIGNMODE
    Key             DB 32 DUP(?)
    IV              DB 16 DUP(?)
    EncryptionState DB 240 DUP(?)
    DecryptionState DB 240 DUP(?)
    Feedback        DB 16 DUP(?)
CRYPT_AES_256_KEY_STATE ENDS

CRYPTOAPI_BLOB STRUCT ALIGNMODE
    cbData DD   ?
    pbData XPTR ?
CRYPTOAPI_BLOB ENDS

CRYPT_BIT_BLOB STRUCT ALIGNMODE
    cbData      DD   ?
    pbData      XPTR ?
    cUnusedBits DD   ?
CRYPT_BIT_BLOB ENDS

CRYPT_INTEGER_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_UINT_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_OBJID_BLOB EQU <CRYPTOAPI_BLOB>
CERT_NAME_BLOB EQU <CRYPTOAPI_BLOB>
CERT_RDN_VALUE_BLOB EQU <CRYPTOAPI_BLOB>
CERT_BLOB EQU <CRYPTOAPI_BLOB>
CRL_BLOB EQU <CRYPTOAPI_BLOB>
DATA_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_DATA_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_HASH_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_DIGEST_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_DER_BLOB EQU <CRYPTOAPI_BLOB>
CRYPT_ATTR_BLOB EQU <CRYPTOAPI_BLOB>


asmc the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB, there are no other errors, pbData LPBYTE ? - What size LPBYTE has?
CRYPT_AES_128_KEY_STATE STRUC
Key db 16 dup(?)
IV db 16 dup(?)
EncryptionState db 16*11 dup(?)
DecryptionState db 16*11 dup(?)
Feedback db 16 dup(?)
CRYPT_AES_128_KEY_STATE ENDS
PCRYPT_AES_128_KEY_STATE typedef ptr CRYPT_AES_128_KEY_STATE

CRYPT_AES_256_KEY_STATE STRUC
Key db 32 dup(?)
IV db 16 dup(?)
EncryptionState db 16*15 dup(?)
DecryptionState db 16*15 dup(?)
Feedback db 16 dup(?)
CRYPT_AES_256_KEY_STATE ENDS
PCRYPT_AES_256_KEY_STATE typedef ptr CRYPT_AES_256_KEY_STATE
endif

CRYPT_INTEGER_BLOB STRUC
cbData dd ?
pbData LPBYTE ?
CRYPT_INTEGER_BLOB ENDS

PCRYPT_INTEGER_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_UINT_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_UINT_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_OBJID_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_OBJID_BLOB typedef ptr CRYPT_INTEGER_BLOB
CERT_NAME_BLOB typedef CRYPT_INTEGER_BLOB
PCERT_NAME_BLOB typedef ptr CRYPT_INTEGER_BLOB
CERT_RDN_VALUE_BLOB typedef CRYPT_INTEGER_BLOB
PCERT_RDN_VALUE_BLOB typedef ptr CRYPT_INTEGER_BLOB
CERT_BLOB typedef CRYPT_INTEGER_BLOB
PCERT_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRL_BLOB typedef CRYPT_INTEGER_BLOB
PCRL_BLOB typedef ptr CRYPT_INTEGER_BLOB
DATA_BLOB typedef CRYPT_INTEGER_BLOB
PDATA_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DATA_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_DATA_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_HASH_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_HASH_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DIGEST_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_DIGEST_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_DER_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_DER_BLOB typedef ptr CRYPT_INTEGER_BLOB
CRYPT_ATTR_BLOB typedef CRYPT_INTEGER_BLOB
PCRYPT_ATTR_BLOB typedef ptr CRYPT_INTEGER_BLOB
endif


The main gap is that this type of structure is converted with an incorrect name, which leads to the fact that the structures cannot be found!

Biterider

#1
Hi LiaoMi
Quotewhy are the structures so different? And the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB in both converters??
MS decided to do so. Check WinCrypt.inc (_CRYPTOAPI_BLOB typedef CRYPT_INTEGER_BLOB)

Quote@Biterider h2incX doesn't handle multilevel arrays?
Unfortunately no. HSE pointed that out some days ago. I put it in the todo list for the next release.

CRYPT_INTEGER_BLOB struct
  cbData DWORD ?
  __field_bcount typedef proto stdcall :cbData
  pbData POINTER ?
CRYPT_INTEGER_BLOB ends


seems to be wrong
What would be the correct translation?

Biterider

LiaoMi

Quote from: Biterider on May 23, 2021, 08:59:35 PM
Hi LiaoMi
Quotewhy are the structures so different? And the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB in both converters??
MS decided to do so. Check WinCript.h (_CRYPTOAPI_BLOB typedef CRYPT_INTEGER_BLOB)

Quote@Biterider h2incX doesn't handle multilevel arrays?
Unfortunately no. HSE pointed that out some days ago. I put it in the todo list for the next release.

CRYPT_INTEGER_BLOB struct
  cbData DWORD ?
  __field_bcount typedef proto stdcall :cbData
  pbData POINTER ?
CRYPT_INTEGER_BLOB ends


seems to be wrong
What would be the correct translation?

Biterider

I could not find a similar "_CRYPTOAPI_BLOB typedef CRYPT_INTEGER_BLOB" definition from visual studio 2013 to 2019  :undecided:

QuoteWhat would be the correct translation?
If I understand the record correctly, then this is a byte pointer (PTR, XMASM, XPTR), and the bit capacity in each mode will be different, i.e. different size.

#define __field_bcount(size)                _SAL1_Source_(__field_bcount, (size),  __notnull __byte_writableTo(size))
#define _SAL1_Source_(Name, args, annotes) _SA_annotes3(SAL_name, #Name, "", "1") _GrouP_(annotes _SAL_nop_impl_)
#define _SA_annotes3(n,pp1,pp2,pp3)    [SAL_annotes(Name=#n, p1=_SA_SPECSTRIZE(pp1), p2=_SA_SPECSTRIZE(pp2), p3=_SA_SPECSTRIZE(pp3))]

declspec SAL like __field_bcount, used to describe the extent of a fixed-size buffer in a struct or on the stack.

This structure is used for an arbitrary array of bytes. It provides flexibility for objects that can contain various data types.
typedef struct _CRYPTOAPI_BLOB {  DWORD cbData;  BYTE* pbData;}

Members
cbData
Count of bytes in the buffer pointed to by pbData.
pbData
Pointer to a block of data bytes.

######################################

LPBYTE   
A pointer to a BYTE.

This type is declared in WinDef.h as follows:

typedef BYTE far *LPBYTE;

######################################

EasyCode, AsmC versions have identified the correct type. translatorus headinc did not simplify the macro and did not remove the parentheses __field_bcount(cbData). h2incX also correctly defined the type, but didn't simplify the macro __field_bcount typedef proto stdcall :cbData.

The correct translation should be like:
CRYPT_INTEGER_BLOB struct
  cbData DWORD ?
  pbData POINTER ?
CRYPT_INTEGER_BLOB ends

nidud

#3
deleted

TouEnMasm

All translates who give the correct size are good.
After it's a question of syntax.
Headinc had followed the syntax given byThe Programmer's Guid for MASM 6.1  in 12 .doc with five appendice.
The c more often get the last name of a structure to use ii,but not always..As an automatised translate couldn't be random,it is always the last who is used by headinc.
You are exact assuming than annotations can create errors if the sdk_egales.txt isn't up to date.I am correcting this slowly,No urgence.An update of sdk_egales.txt is enough to solve the problem.

The MASM guid chapter 5 show:
Quote
You can also declare an array with the DUP operator. This operator works with any of the data allocation directives described in "Allocating Memory for Integer Variables" in Chapter 4. In the syntax
count DUP (initialvalue [[, initialvalue]]...)
the count value sets the number of times to repeat all values within the parentheses. The initialvalue can be an integer, character constant, or another DUP operator, and must always appear within parentheses. For example, the statement
barray  BYTE    5 DUP (1)

allocates the integer 1 five times for a total of 5 bytes.
The following examples show various ways to allocate data elements with the DUP operator:
array   DWORD   10 DUP (1)                    ; 10 doublewords
                                              ;   initialized to 1
buffer  BYTE    256 DUP (?)                   ; 256-byte buffer

masks   BYTE    20 DUP (040h, 020h, 04h, 02h) ; 80-byte buffer
                                              ;   with bit masks
three_d DWORD   5 DUP (5 DUP (5 DUP (0)))     ; 125 doublewords
                                              ;   initialized to 0



Fa is a musical note to play with CL

Biterider

Hi LiaoMi
Check the file ...\Windows Kits\10\Include\10.0.19041.0\um\wincrypt.h lines 1049-1052.
It defines the structure and the alias

typedef struct _CRYPTOAPI_BLOB {
                            DWORD   cbData;
    _Field_size_bytes_(cbData)  BYTE    *pbData;
} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB,


Biterider


rsala

Hi LiaoMi,

I am not using a converter, I just take the structures from MSDN and manually convert them to assembly syntax.
EC coder

hutch--

I think that is the most reliable way to get the structure definitions.

rsala

EC coder

LiaoMi

Quote from: Biterider on May 24, 2021, 12:48:36 AM
Hi LiaoMi
Check the file ...\Windows Kits\10\Include\10.0.19041.0\um\wincrypt.h lines 1049-1052.
It defines the structure and the alias

typedef struct _CRYPTOAPI_BLOB {
                            DWORD   cbData;
    _Field_size_bytes_(cbData)  BYTE    *pbData;
} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB,


Biterider

Hi Biterider,

I'm confused by the fact that access to these structures will be through the stub structure _CRYPTOAPI_BLOB, not through aliases, but through this structure.

https://en.cppreference.com/w/cpp/language/typedef
// common C idiom to avoid having to write "struct S"
typedef struct {
int a;
int b;
} S, *pS;

// the following two objects have the same type
pS ps1;
S* ps2;


It would be more logical to do something like (this was done in EasyCode):
#######################################################
CRYPTOAPI_BLOB struct
  cbData DWORD ?
  pbData POINTER ?
CRYPTOAPI_BLOB ends

//CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB, <- Orig
//CRYPT_UINT_BLOB, *PCRYPT_UINT_BLOB, <- Orig

CRYPT_INTEGER_BLOB  typedef ptr CRYPTOAPI_BLOB <- This line has been removed by the translator.
PCRYPT_INTEGER_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_UINT_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_UINT_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_OBJID_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_OBJID_BLOB typedef ptr CRYPTOAPI_BLOB
CERT_NAME_BLOB typedef CRYPTOAPI_BLOB
PCERT_NAME_BLOB typedef ptr CRYPTOAPI_BLOB
CERT_RDN_VALUE_BLOB typedef CRYPTOAPI_BLOB
PCERT_RDN_VALUE_BLOB typedef ptr CRYPTOAPI_BLOB
CERT_BLOB typedef CRYPTOAPI_BLOB
PCERT_BLOB typedef ptr CRYPTOAPI_BLOB
CRL_BLOB typedef CRYPTOAPI_BLOB
PCRL_BLOB typedef ptr CRYPTOAPI_BLOB
DATA_BLOB typedef CRYPTOAPI_BLOB
PDATA_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_DATA_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_DATA_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_HASH_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_HASH_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_DIGEST_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_DIGEST_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_DER_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_DER_BLOB typedef ptr CRYPTOAPI_BLOB
CRYPT_ATTR_BLOB typedef CRYPTOAPI_BLOB
PCRYPT_ATTR_BLOB typedef ptr CRYPTOAPI_BLOB
#######################################################

Since, based on the construction CRYPT_INTEGER_BLOB, it is the same alias as other records. Otherwise, it turns out that the alias was turned into the original structure. This can be done, provided that the original structure is preserved as a duplicate.

LiaoMi

Quote from: rsala on May 24, 2021, 12:51:13 AM
Hi LiaoMi,

I am not using a converter, I just take the structures from MSDN and manually convert them to assembly syntax.

Hi Rsala,

thanks for the info, it was hard work  :thumbsup:

LiaoMi

Quote from: TouEnMasm on May 23, 2021, 11:41:03 PM
All translates who give the correct size are good.
After it's a question of syntax.
Headinc had followed the syntax given byThe Programmer's Guid for MASM 6.1  in 12 .doc with five appendice.
The c more often get the last name of a structure to use ii,but not always..As an automatised translate couldn't be random,it is always the last who is used by headinc.
You are exact assuming than annotations can create errors if the sdk_egales.txt isn't up to date.I am correcting this slowly,No urgence.An update of sdk_egales.txt is enough to solve the problem.

The MASM guid chapter 5 show:
Quote
You can also declare an array with the DUP operator. This operator works with any of the data allocation directives described in "Allocating Memory for Integer Variables" in Chapter 4. In the syntax
count DUP (initialvalue [[, initialvalue]]...)
the count value sets the number of times to repeat all values within the parentheses. The initialvalue can be an integer, character constant, or another DUP operator, and must always appear within parentheses. For example, the statement
barray  BYTE    5 DUP (1)

allocates the integer 1 five times for a total of 5 bytes.
The following examples show various ways to allocate data elements with the DUP operator:
array   DWORD   10 DUP (1)                    ; 10 doublewords
                                              ;   initialized to 1
buffer  BYTE    256 DUP (?)                   ; 256-byte buffer

masks   BYTE    20 DUP (040h, 020h, 04h, 02h) ; 80-byte buffer
                                              ;   with bit masks
three_d DWORD   5 DUP (5 DUP (5 DUP (0)))     ; 125 doublewords
                                              ;   initialized to 0


Thanks, variable sizes seem to be correct for everyone. There is a difference in the type assignment syntax here, I could not find a reason why CRYPTOAPI_BLOB should be renamed to CRYPT_INTEGER_BLOB. I am sure there are other similar errors in the names  :tongue:

C++
https://en.cppreference.com/w/cpp/language/typedef
// common C idiom to avoid having to write "struct S"
typedef struct {
int a;
int b;
} S, *pS;

// the following two objects have the same type
pS ps1;
S* ps2;


Microsoft Macro Assembler
Microsoft Corporation - Microsoft Macro Assembler 6.11 Reference Manual_Macro Assembler Reference (1992, Microsoft Corporation)
name TYPEDEF type
Defines a new type called name, which is equivalent to type.

Microsoft Corporation - Microsoft Macro Assembler 6.11 Reference Manual_Programmers Guide (1992, Microsoft Corporation)
The TYPEDEF directive can define types for pointer variables. A type so defined
is considered the same as the intrinsic types provided by the assembler and can be
used in the same contexts. When used to define pointers, the syntax for TYPEDEF
is:
typename TYPEDEF [[distance]] PTR qualifiedtype
The typename is the name assigned to the new type. The distance can be NEAR,
FAR, or any distance modifier. The qualifiedtype can be any previously intrinsic or
defined MASM type, or a type previously defined with TYPEDEF. (For a full
definition of qualifiedtype, see "Data Types" in Chapter 1.)
Here are some examples of user-defined types:
PBYTE TYPEDEF PTR BYTE ; Pointer to bytes
NPBYTE TYPEDEF NEAR PTR BYTE ; Near pointer to bytes
FPBYTE TYPEDEF FAR PTR BYTE ; Far pointer to bytes
PWORD TYPEDEF PTR WORD ; Pointer to words
NPWORD TYPEDEF NEAR PTR WORD ; Near pointer to words
FPWORD TYPEDEF FAR PTR WORD ; Far pointer to words
PPBYTE TYPEDEF PTR PBYTE ; Pointer to pointer to bytes
; (in C, an array of strings)
PVOID TYPEDEF PTR ; Pointer to any type of data
PERSON STRUCT ; Structure type
name BYTE 20 DUP (?)
num WORD ?
PERSON ENDS
PPERSON TYPEDEF PTR PERSON ; Pointer to structure type

MSDN The structure definition includes aliases appropriate to the various functions that use it.

P.S. In general, this mod is not important, this little bithack does not change anything. But the structure discussed here can no longer be used directly.  :eusa_boohoo:

LiaoMi

Quote from: nidud on May 23, 2021, 10:48:45 PM
Quote from: LiaoMi on May 23, 2021, 07:27:08 PM
@Nidud What converter are you using? Your results are completely different!  :rolleyes:

I use my own version as Asmc handles enum, define, [if] defined, COM interface and class differently in addition to keywords like name, page, title, low, high, size, length, this, mask, width and type.

Quote
AsmC -  pbData LPBYTE ?

asmc the _CRYPTOAPI_BLOB structure is renamed to CRYPT_INTEGER_BLOB, there are no other errors, pbData LPBYTE ? - What size LPBYTE has?

A pointer is a pointer so the size is always the same, same as size_t.

As for structure names:

typedef struct tagBLOB {
} BLOB;
typedef struct _tagpropertykey {
} PROPERTYKEY;
typedef struct _CRYPT_INTERFACE_REG {
} CRYPT_INTERFACE_REG, *PCRYPT_INTERFACE_REG;

BLOB, PROPERTYKEY, and CRYPT_INTERFACE_REG will be used.

Hi nidud,

thanks for the review! Apparently the only reason why this structure disappears is the type definition at the beginning of the structure.

Explanation
The typedef specifier, when used in a declaration, specifies that the declaration is a typedef declaration rather than a variable or function declaration. Typically, the typedef specifier appears at the start of the declaration, though it is permitted to appear after the type specifiers, or between two type specifiers.

But the compiler  :biggrin: perfectly understands that such a structure exists, which means it is defined in the code. https://godbolt.org/
// common C idiom to avoid having to write "struct S"
typedef struct BLOB {int a; int b;} S, *pS;
struct Hello {int a; int b;};

void Array() {
   
// the following two objects have the same type
pS ps1 = 0;
S* ps2 = 0;

Hello hl;

hl.a = 5;
ps1->a = 5;

BLOB blo;

blo.a = 5;

}


ps1$ = 0
ps2$ = 8
hl$ = 16
blo$ = 24
void Array(void) PROC                                  ; Array
$LN3:
        sub     rsp, 40                             ; 00000028H
        mov     QWORD PTR ps1$[rsp], 0
        mov     QWORD PTR ps2$[rsp], 0
        mov     DWORD PTR hl$[rsp], 5
        mov     rax, QWORD PTR ps1$[rsp]
        mov     DWORD PTR [rax], 5
        mov     DWORD PTR blo$[rsp], 5
        add     rsp, 40                             ; 00000028H
        ret     0
void Array(void) ENDP                                  ; Array

TouEnMasm

Quote
Thanks, variable sizes seem to be correct for everyone. There is a difference in the type assignment syntax here, I could not find a reason why CRYPTOAPI_BLOB should be renamed to CRYPT_INTEGER_BLOB. I am sure there are other similar errors in the names
Here the reason:
define from micrososoft
Quote
typedef struct _CRYPTOAPI_BLOB {  DWORD cbData;  BYTE* pbData;} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB, CRYPT_UINT_BLOB, *PCRYPT_UINT_BLOB, CRYPT_OBJID
as you can  see,microsoft itself when he designe pointers use CRYPT_INTEGER_BLOB as a reference,not _CRYPTOAPI_BLOB.
:rolleyes:




Fa is a musical note to play with CL

rsala

EC coder