Author Topic: h2incX  (Read 9803 times)

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #15 on: September 10, 2018, 05:59:26 AM »
Hi Vortex
This is really weird!
Code: [Select]
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

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #16 on: September 10, 2018, 06:21:37 AM »
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

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #17 on: September 10, 2018, 06:26:20 AM »
Btw, looking a bit closer into WinNT.h  I found
Code: [Select]
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?

Code: [Select]
... } SE_TOKEN_USER , *PSE_TOKEN_USER;
Biterider

habran

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: h2incX
« Reply #18 on: September 10, 2018, 08:43:27 PM »
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

  • Member
  • *****
  • Posts: 1009
Re: h2incX
« Reply #19 on: September 10, 2018, 09:28:03 PM »
Btw, looking a bit closer into WinNT.h  I found
Code: [Select]
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?

Code: [Select]
... } SE_TOKEN_USER , *PSE_TOKEN_USER;
Biterider

Hi Biterider,

Code: [Select]
;
; 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

  • Member
  • *****
  • Posts: 2657
Re: h2incX
« Reply #20 on: September 11, 2018, 03:15:39 AM »
Hi Biterider,

According to the MS documentation :

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

Code: [Select]
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

  • Member
  • *****
  • Posts: 2657
Re: h2incX
« Reply #21 on: September 11, 2018, 03:19:45 AM »
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

  • Member
  • *****
  • Posts: 1228
    • uasm
Re: h2incX
« Reply #22 on: September 11, 2018, 04:47:30 AM »
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

  • Member
  • ****
  • Posts: 544
    • Github
Re: h2incX
« Reply #23 on: September 11, 2018, 05:08:58 AM »
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.
fearless

Lian Li PC-O11DW Case, ASUS Crosshair VIII Hero, AMD Ryzen 9 5950X, 32GB DDR4, MSI RX 5700XT, NZXT Kraken Z73, Seasonic 1000W PSU

My Github  Twitter  My Gitbook

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #24 on: September 11, 2018, 05:34:45 AM »
Hi Vortex
At least I know I'm not alone  :biggrin:


Biterider

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #25 on: November 14, 2021, 05:45:37 PM »
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

Code: [Select]
        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.

Code: [Select]
      CRYPT_INTEGER_BLOB struct
        cbData DWORD ?
        pbData POINTER ?
      CRYPT_INTEGER_BLOB ends


Biterider

fearless

  • Member
  • ****
  • Posts: 544
    • Github
Re: h2incX
« Reply #26 on: November 14, 2021, 10:18:01 PM »
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
fearless

Lian Li PC-O11DW Case, ASUS Crosshair VIII Hero, AMD Ryzen 9 5950X, 32GB DDR4, MSI RX 5700XT, NZXT Kraken Z73, Seasonic 1000W PSU

My Github  Twitter  My Gitbook

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #27 on: November 15, 2021, 03:48:41 AM »
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

  • Moderator
  • Member
  • *****
  • Posts: 869
  • ObjAsm Developer
    • ObjAsm
Re: h2incX
« Reply #28 on: November 15, 2021, 05:33:16 AM »
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

  • Member
  • ****
  • Posts: 544
    • Github
Re: h2incX
« Reply #29 on: November 15, 2021, 06:47:52 AM »
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 ;-)
fearless

Lian Li PC-O11DW Case, ASUS Crosshair VIII Hero, AMD Ryzen 9 5950X, 32GB DDR4, MSI RX 5700XT, NZXT Kraken Z73, Seasonic 1000W PSU

My Github  Twitter  My Gitbook