News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

h2incX

Started by Biterider, June 30, 2018, 06:30:07 PM

Previous topic - Next topic

Biterider

Hi Vortex
This is really weird!
UASM v2.46, Jun 23 2018, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

SimpleWnd.asm: 87 lines, 2 passes, 218 ms, 0 warnings, 0 errors


I had to adjust a few paths on your code and it compiled without drama  :P

I'll look into the error list to see where ML has a problem. I have just recognized some of them. The most obvious is the ML6.15 doesn't know what a SQWORD is...

Biterider

Biterider

Hi Vortex
I know what is going on. I'm using the modified UASM version of Habran (see here http://masm32.com/board/index.php?topic=7212.0).
Attached the corrected WinUser.inc file.
Biterider

Biterider

Btw, looking a bit closer into WinNT.h  I found
typedef struct _SE_TOKEN_USER {
    union {
        TOKEN_USER TokenUser;
        SID_AND_ATTRIBUTES User;
    } DUMMYUNIONNAME;
    union {
        SID Sid;
        BYTE  Buffer[SECURITY_MAX_SID_SIZE];
    } DUMMYUNIONNAME2;
} SE_TOKEN_USER , PSE_TOKEN_USER;


Should not it be like this?

... } SE_TOKEN_USER , *PSE_TOKEN_USER;

Biterider

habran

You are correct Biterider 8)

You have been doing an excellent job :t
I am looking forward to your final work :biggrin:

Cod-Father

LiaoMi

Quote from: Biterider on September 10, 2018, 06:26:20 AM
Btw, looking a bit closer into WinNT.h  I found
typedef struct _SE_TOKEN_USER {
    union {
        TOKEN_USER TokenUser;
        SID_AND_ATTRIBUTES User;
    } DUMMYUNIONNAME;
    union {
        SID Sid;
        BYTE  Buffer[SECURITY_MAX_SID_SIZE];
    } DUMMYUNIONNAME2;
} SE_TOKEN_USER , PSE_TOKEN_USER;


Should not it be like this?

... } SE_TOKEN_USER , *PSE_TOKEN_USER;

Biterider

Hi Biterider,

;
; Token information class structures
;

TOKEN_USER STRUCT DEFALIGNMASM
User SID_AND_ATTRIBUTES <>
TOKEN_USER ENDS


IFNDEF MIDL_PASS

SE_TOKEN_USER STRUCT DEFALIGNMASM
union DUMMYUNIONNAME
aTokenUser TOKEN_USER <>
User SID_AND_ATTRIBUTES <>
ENDS
union DUMMYUNIONNAME2
Sid SID <>
Buffer BYTE SECURITY_MAX_SID_SIZE dup (?)
ENDS
SE_TOKEN_USER ENDS


PSE_TOKEN_USER EQU <SE_TOKEN_USER>

TOKEN_USER_MAX_SIZE equ < sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE>
ENDIF


So its made in sdk from ToutEnMasm  ::)

Vortex

Hi Biterider,

According to the MS documentation :

https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntifs/ns-ntifs-_se_token_user

typedef struct _SE_TOKEN_USER {
  union {
    TOKEN_USER         TokenUser;
    SID_AND_ATTRIBUTES User;
  } DUMMYUNIONNAME;
  union {
    SID   Sid;
    UCHAR Buffer[SECURITY_MAX_SID_SIZE];
  } DUMMYUNIONNAME2;
} SE_TOKEN_USER, PSE_TOKEN_USER;


My MinGW setup (ntifs.h ) does not provide this structure. Same result with the header file http://www.acc.umu.se/~bosse/ntifs.h. No any reference to this structure.


Vortex

Hi Biterider,

Using the unmodified Uasm release and the header file supplied with the zip file winuser.zip, I managed to assemble the Window example, thanks.

habran

I found here this:
Quote
typedef struct _SE_TOKEN_USER {
  union {
    TOKEN_USER         TokenUser;
    SID_AND_ATTRIBUTES User;
  };
  union {
    SID   Sid;
    UCHAR Buffer[SECURITY_MAX_SID_SIZE];
  };
} SE_TOKEN_USER, *PSE_TOKEN_USER;

It must be $MS error because pointers should have asterisks

I would ask them about that.
Cod-Father

fearless

Yes looks like an error. I scanned the sdk's and ddk for any reference of usage and it appears PSE_TOKEN_USER isn't used anywhere in any function or other structure - so thats why ms probably didnt notice the typo as PSE_TOKEN_USER is not used anywhere cept at the end of SE_TOKEN_USER structure define, and should be a pointer to that struct.

Biterider

Hi Vortex
At least I know I'm not alone  :biggrin:


Biterider

Biterider

Hi
I found some time to come back to this project and work on some of the found issues.
So far I ported the whole code to BNC (Bitness Neutral Code). h2incX is now a 64 bit app.
I also corrected the multilevel array issue. The produced code looks like

float Matrix [3][4] => Matrix float (4)*(3) dup(?)

Record members are now build in the same order as C++ bitfields.

Function pointer declarations now emit a variable declaration/structure member. Example from OAIdl.h

        EXCEPINFO struct
          wCode WORD ?
          wReserved WORD ?
          bstrSource BSTR ?
          bstrDescription BSTR ?
          bstrHelpFile BSTR ?
          dwHelpContext DWORD ?
          pvReserved PVOID ?
          TYPE_pfnDeferredFillIn typedef proto WIN_STD_CALL_CONV :ptr tagEXCEPINFO
          pfnDeferredFillIn typedef ptr TYPE_pfnDeferredFillIn
          pfnDeferredFillIn pfnDeferredFillIn ?
          scode SCODE ?
        EXCEPINFO ends
        tagEXCEPINFO typedef EXCEPINFO
        LPEXCEPINFO typedef ptr EXCEPINFO



Complex structure declarations are handled correctly. e.g.

      CRYPT_INTEGER_BLOB struct
        cbData DWORD ?
        pbData POINTER ?
      CRYPT_INTEGER_BLOB ends



Biterider

fearless

I think I posted about this repo before: win32metadata - https://github.com/microsoft/win32metadata (since its related to the generation of api information like h2incX)


But there is an additional repo that generates api info in json format as well: https://github.com/marlersoft/win32json/tree/main/api


Could be useful to generate the api info from the json format perhaps if that is any easier - although you are still relying on the win32meta generation to output correctly the information and it probably also has some edge cases where it cant handle the conversion of the headers.

Thought it useful and interesting to mention it

Biterider

Hi fearless
Thank you, super interesting links.  :thumbsup:
Winmd should be up to date as it is maintained by MS. It's an excellent base from which to build something like MASM Windows.inc, or to get information for an intellisense add-in.

The malersoft repo is easier to read (JSON) because you don't have to deal with the metadata format. The downside is that it is being maintained by a third party and you never know how long it will exist.

IMHO some information is still lost using this approach, e.g. how the .h files are structured and the dependencies. By setting some inclusion flags, you can choose which part of the API you want to use, excluding most of the unused information.

The metadata approach (database) is interesting and for sure a good way to get the asm include files (projections as MS call them  :cool: ).

Biterider

Biterider

Hello fearless
You piqued my interest in the "MASM projection" using the set of JSON files.  :biggrin:
It shouldn't take that much effort to generate some inc files with it. Unfortunately, I'll only see if it works at the end, when everything has been put together.

I think it might be worth it.

Biterider

fearless

Nice, sounds good. Yes a Masm projection would be useful. The point about the third party json generation is good. Although he has a repo for how it is generated, so the third party tool could also be used I imagine if needed, but yes coming straight from MS gives a bit more of a guarantee of stability and longevity - hopefully ;-)