Condividi tramite


Immagini eseguibili

I file eseguibili vengono caricati nello spazio degli indirizzi di un processo usando un file di immagine mappato alla memoria. Non è necessario aprire il file stesso né creare un handle perché il mapping viene eseguito tramite una sezione. I file system devono controllare per applicare queste semantiche speciali, presupponendo che supportino i file mappati alla memoria. Ad esempio, il codice del file system FASTFAT per verificare la presenza di questo caso è reperibile nella funzione FatOpenExistingFCB nel file di origine Create.c dagli esempi fastfat contenuti in WDK:

    //
    //  If the user wants write access to the file, make sure there
    //  is not a process mapping this file as an image. Any attempt to
    //  delete the file will be stopped in fileinfo.c
    //
    //  If the user wants to delete on close, check at this
    //  point though.
    //

    if (FlagOn(*DesiredAccess, FILE_WRITE_DATA) || DeleteOnClose) {

        Fcb->OpenCount += 1;
        DecrementFcbOpenCount = TRUE;

        if (!MmFlushImageSection( &Fcb->NonPaged->SectionObjectPointers,
                                  MmFlushForWrite )) {

            Iosb.Status = DeleteOnClose ? STATUS_CANNOT_DELETE :STATUS_SHARING_VIOLATION;
            try_return( Iosb );
        }
    }

Pertanto, il file system garantisce che un file mappato alla memoria, inclusa un'immagine eseguibile, non possa essere eliminato anche se il file non è aperto.