00174 :
00175
00176 This routine applies protection to
the system partition that
00177 prevents all users except administrators from accessing
the
00178 partition.
00179
00180
00181 This routine
is only used during system initialization.
00182 As such, all memory allocations are expected to succeed.
00183 Success
is tested
only with assertions.
00184
00185
00186 Arguments:
00187
00188 LoaderBlock - Supplies a pointer to
the loader parameter block that was
00189 created by
the OS Loader.
00190
00191 Return Value:
00192
00193 The function value
is the final status from attempting to set
the system
00194 partition protection.
00195
00196
00197 --*/
00198
00199 {
00200
NTSTATUS status;
00201 PACL dacl;
00202 SECURITY_DESCRIPTOR securityDescriptor;
00203 OBJECT_ATTRIBUTES objectAttributes;
00204 ULONG length;
00205
CHAR ArcNameFmt[12];
00206
00207 ArcNameFmt[0] =
'\\';
00208 ArcNameFmt[1] =
'A';
00209 ArcNameFmt[2] =
'r';
00210 ArcNameFmt[3] =
'c';
00211 ArcNameFmt[4] =
'N';
00212 ArcNameFmt[5] =
'a';
00213 ArcNameFmt[6] =
'm';
00214 ArcNameFmt[7] =
'e';
00215 ArcNameFmt[8] =
'\\';
00216 ArcNameFmt[9] =
'%';
00217 ArcNameFmt[10] =
's';
00218 ArcNameFmt[11] =
'\0';
00219
00220
ASSERT( ARGUMENT_PRESENT( LoaderBlock ) );
00221
ASSERT( ARGUMENT_PRESENT( LoaderBlock->ArcHalDeviceName ) );
00222
00223
00224
00225
00226
00227 length = (ULONG)
sizeof( ACL ) +
00228 ( 2 * ((ULONG)
sizeof( ACCESS_ALLOWED_ACE ))) +
00229
SeLengthSid( SeLocalSystemSid ) +
00230
SeLengthSid( SeAliasAdminsSid ) +
00231 8;
00232
00233 dacl = (PACL)
ExAllocatePool( PagedPool, length );
00234
if (!dacl) {
00235
return STATUS_INSUFFICIENT_RESOURCES;
00236 }
00237
00238 status =
RtlCreateAcl( dacl, length, ACL_REVISION2 );
00239
if (
NT_SUCCESS( status )) {
00240
00241 status =
RtlAddAccessAllowedAce( dacl,
00242 ACL_REVISION2,
00243 GENERIC_ALL,
00244 SeLocalSystemSid );
00245
if (
NT_SUCCESS( status )) {
00246
00247 status =
RtlAddAccessAllowedAce( dacl,
00248 ACL_REVISION2,
00249 GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | READ_CONTROL,
00250 SeAliasAdminsSid );
00251
if (
NT_SUCCESS( status )) {
00252
00253
00254
00255
00256
00257
00258 status =
RtlCreateSecurityDescriptor( &securityDescriptor,
00259 SECURITY_DESCRIPTOR_REVISION );
00260
if (
NT_SUCCESS( status )) {
00261
00262 status =
RtlSetDaclSecurityDescriptor( &securityDescriptor,
00263 TRUE,
00264 dacl,
00265 FALSE );
00266 }
00267 }
00268 }
00269 }
00270
00271
if (!
NT_SUCCESS( status )) {
00272
ExFreePool( dacl );
00273
return status;
00274 }
00275
00276
00277
00278
00279
00280 {
00281
NTSTATUS tmpStatus;
00282 UCHAR deviceNameBuffer[256];
00283 STRING deviceNameString;
00284 UNICODE_STRING deviceNameUnicodeString;
00285 HANDLE deviceHandle;
00286 IO_STATUS_BLOCK ioStatusBlock;
00287
00288
00289
00290
00291
00292
00293
sprintf( deviceNameBuffer,
00294 ArcNameFmt,
00295 LoaderBlock->ArcHalDeviceName );
00296
00297
RtlInitAnsiString( &deviceNameString, deviceNameBuffer );
00298
00299 status =
RtlAnsiStringToUnicodeString( &deviceNameUnicodeString,
00300 &deviceNameString,
00301 TRUE );
00302
00303
if (
NT_SUCCESS( status )) {
00304
00305 InitializeObjectAttributes( &objectAttributes,
00306 &deviceNameUnicodeString,
00307 OBJ_CASE_INSENSITIVE,
00308 NULL,
00309 NULL );
00310
00311 status =
ZwOpenFile( &deviceHandle,
00312 WRITE_DAC,
00313 &objectAttributes,
00314 &ioStatusBlock,
00315 TRUE,
00316 0 );
00317
00318
RtlFreeUnicodeString( &deviceNameUnicodeString );
00319
00320
if (
NT_SUCCESS( status )) {
00321
00322
00323
00324
00325
00326
00327
00328 status = ZwSetSecurityObject( deviceHandle,
00329 DACL_SECURITY_INFORMATION,
00330 &securityDescriptor );
00331
00332 tmpStatus =
NtClose( deviceHandle );
00333 }
00334 }
00335 }
00336
00337
00338
00339
00340
00341
ExFreePool( dacl );
00342
00343
return status;
00344 }
}