 
 
 ! typedef enum _TOKEN_INFORMATION_CLASS {
-: TokenUser 1 ; inline
-: TokenGroups 2 ; inline
-: TokenPrivileges 3 ; inline
-: TokenOwner 4 ; inline
-: TokenPrimaryGroup 5 ; inline
-: TokenDefaultDacl 6 ; inline
-: TokenSource 7 ; inline
-: TokenType 8 ; inline
-: TokenImpersonationLevel 9 ; inline
-: TokenStatistics 10 ; inline
-: TokenRestrictedSids 11 ; inline
-: TokenSessionId 12 ; inline
-: TokenGroupsAndPrivileges 13 ; inline
-: TokenSessionReference 14 ; inline
-: TokenSandBoxInert 15 ; inline
+CONSTANT: TokenUser 1
+CONSTANT: TokenGroups 2
+CONSTANT: TokenPrivileges 3
+CONSTANT: TokenOwner 4
+CONSTANT: TokenPrimaryGroup 5
+CONSTANT: TokenDefaultDacl 6
+CONSTANT: TokenSource 7
+CONSTANT: TokenType 8
+CONSTANT: TokenImpersonationLevel 9
+CONSTANT: TokenStatistics 10
+CONSTANT: TokenRestrictedSids 11
+CONSTANT: TokenSessionId 12
+CONSTANT: TokenGroupsAndPrivileges 13
+CONSTANT: TokenSessionReference 14
+CONSTANT: TokenSandBoxInert 15
 ! } TOKEN_INFORMATION_CLASS;
 
-: DELETE                     HEX: 00010000 ; inline
-: READ_CONTROL               HEX: 00020000 ; inline
-: WRITE_DAC                  HEX: 00040000 ; inline
-: WRITE_OWNER                HEX: 00080000 ; inline
-: SYNCHRONIZE                HEX: 00100000 ; inline
-: STANDARD_RIGHTS_REQUIRED   HEX: 000f0000 ; inline
-
-: STANDARD_RIGHTS_READ       READ_CONTROL ; inline
-: STANDARD_RIGHTS_WRITE      READ_CONTROL ; inline
-: STANDARD_RIGHTS_EXECUTE    READ_CONTROL ; inline
-
-: TOKEN_TOKEN_ADJUST_DEFAULT   HEX: 0080 ; inline
-: TOKEN_ADJUST_GROUPS          HEX: 0040 ; inline
-: TOKEN_ADJUST_PRIVILEGES      HEX: 0020 ; inline
-: TOKEN_ADJUST_SESSIONID       HEX: 0100 ; inline
-: TOKEN_ASSIGN_PRIMARY         HEX: 0001 ; inline
-: TOKEN_DUPLICATE              HEX: 0002 ; inline
-: TOKEN_EXECUTE                STANDARD_RIGHTS_EXECUTE ; inline
-: TOKEN_IMPERSONATE            HEX: 0004 ; inline
-: TOKEN_QUERY                  HEX: 0008 ; inline
-: TOKEN_QUERY_SOURCE           HEX: 0010 ; inline
-: TOKEN_ADJUST_DEFAULT         HEX: 0080 ; inline
-: TOKEN_READ ( -- n ) STANDARD_RIGHTS_READ TOKEN_QUERY bitor ;
+CONSTANT: DELETE                     HEX: 00010000
+CONSTANT: READ_CONTROL               HEX: 00020000
+CONSTANT: WRITE_DAC                  HEX: 00040000
+CONSTANT: WRITE_OWNER                HEX: 00080000
+CONSTANT: SYNCHRONIZE                HEX: 00100000
+CONSTANT: STANDARD_RIGHTS_REQUIRED   HEX: 000f0000
+
+ALIAS: STANDARD_RIGHTS_READ       READ_CONTROL
+ALIAS: STANDARD_RIGHTS_WRITE      READ_CONTROL
+ALIAS: STANDARD_RIGHTS_EXECUTE    READ_CONTROL
+
+CONSTANT: TOKEN_TOKEN_ADJUST_DEFAULT   HEX: 0080
+CONSTANT: TOKEN_ADJUST_GROUPS          HEX: 0040
+CONSTANT: TOKEN_ADJUST_PRIVILEGES      HEX: 0020
+CONSTANT: TOKEN_ADJUST_SESSIONID       HEX: 0100
+CONSTANT: TOKEN_ASSIGN_PRIMARY         HEX: 0001
+CONSTANT: TOKEN_DUPLICATE              HEX: 0002
+ALIAS: TOKEN_EXECUTE                STANDARD_RIGHTS_EXECUTE
+CONSTANT: TOKEN_IMPERSONATE            HEX: 0004
+CONSTANT: TOKEN_QUERY                  HEX: 0008
+CONSTANT: TOKEN_QUERY_SOURCE           HEX: 0010
+CONSTANT: TOKEN_ADJUST_DEFAULT         HEX: 0080
+: TOKEN_READ ( -- n ) { STANDARD_RIGHTS_READ TOKEN_QUERY } flags ;
 
 : TOKEN_WRITE ( -- n )
     {


TYPEDEF: ACL* PACL

: ACCESS_ALLOWED_ACE_TYPE 0 ; inline
: ACCESS_DENIED_ACE_TYPE 1 ; inline
: SYSTEM_AUDIT_ACE_TYPE 2 ; inline
: SYSTEM_ALARM_ACE_TYPE 3 ; inline

: OBJECT_INHERIT_ACE HEX: 1 ; inline
: CONTAINER_INHERIT_ACE HEX: 2 ; inline
: NO_PROPAGATE_INHERIT_ACE HEX: 4 ; inline
: INHERIT_ONLY_ACE HEX: 8 ; inline
: VALID_INHERIT_FLAGS HEX: f ; inline

C-STRUCT: ACE_HEADER
    { "BYTE" "AceType" }

USING: alias alien.syntax kernel math windows.types math.bitwise
constants ;
IN: windows.advapi32
LIBRARY: advapi32

CONSTANT: PROV_RSA_FULL       1
CONSTANT: PROV_RSA_SIG        2
CONSTANT: PROV_DSS            3
CONSTANT: PROV_FORTEZZA       4
CONSTANT: PROV_MS_EXCHANGE    5
CONSTANT: PROV_SSL            6
CONSTANT: PROV_RSA_SCHANNEL  12
CONSTANT: PROV_DSS_DH        13
CONSTANT: PROV_EC_ECDSA_SIG  14
CONSTANT: PROV_EC_ECNRA_SIG  15
CONSTANT: PROV_EC_ECDSA_FULL 16
CONSTANT: PROV_EC_ECNRA_FULL 17
CONSTANT: PROV_DH_SCHANNEL   18
CONSTANT: PROV_SPYRUS_LYNKS  20
CONSTANT: PROV_RNG           21
CONSTANT: PROV_INTEL_SEC     22
CONSTANT: PROV_REPLACE_OWF   23
CONSTANT: PROV_RSA_AES       24

CONSTANT: MS_DEF_DH_SCHANNEL_PROV "Microsoft DH Schannel Cryptographic Provider"

CONSTANT: MS_DEF_DSS_DH_PROV
    "Microsoft Base DSS and Diffie-Hellman Cryptographic Provider"

CONSTANT: MS_DEF_DSS_PROV
    "Microsoft Base DSS Cryptographic Provider"

CONSTANT: MS_DEF_PROV
    "Microsoft Base Cryptographic Provider v1.0"

CONSTANT: MS_DEF_RSA_SCHANNEL_PROV
    "Microsoft RSA Schannel Cryptographic Provider"

! Unsupported (!)
CONSTANT: MS_DEF_RSA_SIG_PROV
    "Microsoft RSA Signature Cryptographic Provider"

CONSTANT: MS_ENH_DSS_DH_PROV
    "Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider"

CONSTANT: MS_ENH_RSA_AES_PROV
    "Microsoft Enhanced RSA and AES Cryptographic Provider"

CONSTANT: MS_ENHANCED_PROV
    "Microsoft Enhanced Cryptographic Provider v1.0"

CONSTANT: MS_SCARD_PROV
    "Microsoft Base Smart Card Crypto Provider"

CONSTANT: MS_STRONG_PROV
    "Microsoft Strong Cryptographic Provider"

CONSTANT: CRYPT_VERIFYCONTEXT  HEX: F0000000
CONSTANT: CRYPT_NEWKEYSET      HEX: 8
CONSTANT: CRYPT_DELETEKEYSET   HEX: 10
CONSTANT: CRYPT_MACHINE_KEYSET HEX: 20
CONSTANT: CRYPT_SILENT         HEX: 40

C-STRUCT: ACL
    { "BYTE" "AclRevision" }
