アイデアを説明するための簡単なテスト プログラム:
「MyBuildSecurityDescriptor」は、基本的なセキュリティ記述子を作成するためにここからコピーされた関数です。
PSECURITY_DESCRIPTOR pSecDesc = MyBuildSecurityDescriptor();
// Convert to a PISECURITY_DESCRIPTOR to view the contents.
PISECURITY_DESCRIPTOR piSecDesc = (PISECURITY_DESCRIPTOR)pSecDesc;
LPTSTR szSecDesc;
ConvertSecurityDescriptorToStringSecurityDescriptor(pSecDesc, SECURITY_DESCRIPTOR_REVISION,
DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION,
&szSecDesc,
NULL);
// At this point szSecDesc has the correct security descriptor in it.
// "D:(A;;KR;;;WD)(A;;KA;;;BA)" for those interested.
// Now to convert back from string version.
PSECURITY_DESCRIPTOR pSecurityDescriptor;
ConvertStringSecurityDescriptorToSecurityDescriptor(szSecDesc, SDDL_REVISION_1, &pSecurityDescriptor, NULL);
// Convert to a PISECURITY_DESCRIPTOR to view the contents.
PISECURITY_DESCRIPTOR piNewSecDesc = (PISECURITY_DESCRIPTOR)pSecurityDescriptor;
上記のプログラムの
piSecDescとpiNewSecDescの Visual Studioでのデバッグ ビューを次に示します。
私の質問は、変換後の SECURITY_DESCRIPTOR に正しいデータがないのはなぜですか?
これが(ConverStringSecurityDescriptorToSecurityDescriptorについて)述べていることを考えると、「この関数は、ConvertSecurityDescriptorToStringSecurityDescriptor関数が文字列形式に変換したセキュリティ記述子を取得します。」この単純なプログラムが機能すると思います。
いくつかのコンテキスト 私の仕事では、SECURITY_DESCRIPTOR を取得し、これをパイプ経由で別のプログラムに渡す必要があります。最も簡単な方法は、文字列に変換して渡し、反対側で変換することでした。