Мелочи: Как устанавливать ACL'ы и создавать SECUIRTY_DESCRIPTOR'ы

?????? ??????? ?????????? ACL (Access Control List) ?? ????? ??? ?????-?? ?????? ???????, ????? ????? ? registry, COM ??????? ??? ?????????? ??? ?????-??????. ? ?????? ??? ????? ???? ?????-?????? ??????? ????? ????? CoInitializeSecurity ??? COM ???????? ??? SetFileSecurity ??? ??????.

??? ?????? ???? ???? - ??? ??? ????????? ?????????? ? ????????? ????????? SECURITY_DESCRIPTOR. ? ????? ?? ????????? ???????????, ??? ?? ?? ???????, ?? ?????? ?????? ????? ?????????????? ?? ??????? ??????? ??????? ?????? InitializeSecurityDescriptor, ConvertStringSidToSidW, SetSecurityDescriptorOwner, InitializeAcl, AddAccessAllowedAce and SetSecurityDescriptorDacl (???????? ?? ?????-?????? ????, ???? ???? ?????? ?????????).

??????, ???? ??????????? ????? ??????? ?????? ? ?????????????? Security Descriptor String Format, SDDL ? ???????????? ?????? ConvertStringSecurityDescriptorToSecurityDescriptor. ??? ???????? ???:

    PSECURITY_DESCRIPTOR psd = NULL;
    ULONG   cSDSize = 0;

    if ( ! ConvertStringSecurityDescriptorToSecurityDescriptor(
            L"O:BAD:(A;;GAFA;;;SY)(A;;GAFA;;;BA)",
            SDDL_REVISION_1, &psd, &cSDSize
            )
        )
    {
         // ??????? ????-????? ?? ?????? ???????????? ??????????????
    }

    ... ???????????? SECURITY_DESCRIPTOR ? psd

    // ?? ?????? ?????????? ???, ????? ??? ?? ?????
    if ( psd ) LocalFree(psd);

?????????? ?????? L"O:BAD:(A;;GAFA;;;SY)(A;;GAFA;;;BA)" ????????, ??? ?????????? ??????? (O:) ?????? ???? ????? ?????? ADMINISTRATORS (BA), ? ??? ??? ? SYSTEM (SY) ????? ??? ????? (GA) ? ???????? (FA) ????? (D:) ??? ????? ???????.

?????? ??? ?????? ?????????? ?????:
O:sid_?????????
G:sid_??????
D:?????_dacl(ace1)(ace2)...(acen)
S:?????_sacl(ace1)(ace2)...(acen)
(??????, ??? ?????? ? ???????, ????? ?????? ?? ?????)

SID ????????? ? ?????? ????? ???????????? ? ??????? ??????? (????? S-1-5-32-544) ??? ??????????? ?????????? (????? BA), ??????? ????? ????? ????? ? ?????. ACE'? ??????????? ? SDDL ???????. ??? ?????????? ?????? ? ?????????.