Store a "removable" flag instead of the full drive type in the server
file object; this way we don't need to use GetDriveTypeW in the loader
code.
Make sure we always have a valid builtin_load_info pointer.

diff --git a/server/file.c b/server/file.c
index 1ff29a9..5ed8d4c 100644
--- a/server/file.c
+++ b/server/file.c
@@ -59,7 +59,7 @@
     unsigned int        access;     /* file access (GENERIC_READ/WRITE) */
     unsigned int        flags;      /* flags (FILE_FLAG_*) */
     unsigned int        sharing;    /* file sharing mode */
-    int                 drive_type; /* type of drive the file is on */
+    int                 removable;     /* is file on removable media? */
     struct async_queue  read_q;
     struct async_queue  write_q;
 };
@@ -134,7 +134,7 @@
 /* create a file from a file descriptor */
 /* if the function fails the fd is closed */
 static struct file *create_file_for_fd( int fd, unsigned int access, unsigned int sharing,
-                                        unsigned int attrs, int drive_type )
+                                        unsigned int attrs, int removable )
 {
     struct file *file;
 
@@ -145,7 +145,7 @@
         file->access     = access;
         file->flags      = attrs;
         file->sharing    = sharing;
-        file->drive_type = drive_type;
+        file->removable  = removable;
         if (file->flags & FILE_FLAG_OVERLAPPED)
         {
             init_async_queue (&file->read_q);
@@ -163,7 +163,7 @@
 
 static struct file *create_file( const char *nameptr, size_t len, unsigned int access,
                                  unsigned int sharing, int create, unsigned int attrs,
-                                 int drive_type )
+                                 int removable )
 {
     struct file *file;
     int hash, flags;
@@ -205,7 +205,7 @@
     file->access     = access;
     file->flags      = attrs;
     file->sharing    = sharing;
-    file->drive_type = drive_type;
+    file->removable  = removable;
     file->name       = name;
     file->next       = file_hash[hash];
     file_hash[hash]  = file;
@@ -242,10 +242,10 @@
     return !strcmp( file1->name, file2->name );
 }
 
-/* get the type of drive the file is on */
-int get_file_drive_type( struct file *file )
+/* check if the file is on removable media */
+int is_file_removable( struct file *file )
 {
-    return file->drive_type;
+    return file->removable;
 }
 
 /* create a temp file for anonymous mappings */
@@ -262,7 +262,7 @@
         return NULL;
     }
     unlink( tmpfn );
-    return create_file_for_fd( fd, access, 0, 0, DRIVE_FIXED );
+    return create_file_for_fd( fd, access, 0, 0, FALSE );
 }
 
 static void file_dump( struct object *obj, int verbose )
@@ -598,7 +598,7 @@
 
     reply->handle = 0;
     if ((file = create_file( get_req_data(), get_req_data_size(), req->access,
-                             req->sharing, req->create, req->attrs, req->drive_type )))
+                             req->sharing, req->create, req->attrs, req->removable )))
     {
         reply->handle = alloc_handle( current->process, file, req->access, req->inherit );
         release_object( file );
@@ -618,7 +618,7 @@
         return;
     }
     if ((file = create_file_for_fd( fd, req->access, FILE_SHARE_READ | FILE_SHARE_WRITE,
-                                    0, DRIVE_UNKNOWN )))
+                                    0, FALSE )))
     {
         reply->handle = alloc_handle( current->process, file, req->access, req->inherit );
         release_object( file );
diff --git a/server/file.h b/server/file.h
index 8bc09e9..890cdb3 100644
--- a/server/file.h
+++ b/server/file.h
@@ -91,7 +91,7 @@
                                   unsigned int access );
 extern int get_file_unix_fd( struct file *file );
 extern int is_same_file( struct file *file1, struct file *file2 );
-extern int get_file_drive_type( struct file *file );
+extern int is_file_removable( struct file *file );
 extern int grow_file( struct file *file, int size_high, int size_low );
 extern struct file *create_temp_file( int access );
 extern void file_set_error(void);
diff --git a/server/mapping.c b/server/mapping.c
index ccd0e8c..092f48a 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -391,7 +391,7 @@
         reply->base        = mapping->base;
         reply->shared_file = 0;
         reply->shared_size = mapping->shared_size;
-        reply->drive_type  = get_file_drive_type( mapping->file );
+        reply->removable   = is_file_removable( mapping->file );
         if (mapping->shared_file)
             reply->shared_file = alloc_handle( current->process, mapping->shared_file,
                                                GENERIC_READ|GENERIC_WRITE, 0 );
diff --git a/server/process.c b/server/process.c
index 0e5da95..7be8afd 100644
--- a/server/process.c
+++ b/server/process.c
@@ -1107,8 +1107,15 @@
     struct process_dll *dll;
     struct file *file = NULL;
 
-    if (req->handle &&
-        !(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
+    if (req->handle)
+    {
+        if (!(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
+        if (is_file_removable( file ))  /* don't keep the file open on removable media */
+        {
+            release_object( file );
+            file = NULL;
+        }
+    }
 
     if ((dll = process_load_dll( current->process, file, req->base,
                                  get_req_data(), get_req_data_size() )))
diff --git a/server/protocol.def b/server/protocol.def
index e05d62b..e11111c 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -578,7 +578,7 @@
     unsigned int sharing;       /* sharing flags */
     int          create;        /* file create action */
     unsigned int attrs;         /* file attributes for creation */
-    int          drive_type;    /* type of drive the file is on */
+    int          removable;     /* is file on removable media? */
     VARARG(filename,string);    /* file name */
 @REPLY
     obj_handle_t handle;        /* handle to the file */
@@ -1104,7 +1104,7 @@
     void*        base;          /* default base addr (for VPROT_IMAGE mapping) */
     obj_handle_t shared_file;   /* shared mapping file handle */
     int          shared_size;   /* shared mapping size */
-    int          drive_type;    /* type of drive the file is on */
+    int          removable;     /* is file on removable media? */
 @END
 
 
diff --git a/server/trace.c b/server/trace.c
index 635c012..99ae649 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -841,7 +841,7 @@
     fprintf( stderr, " sharing=%08x,", req->sharing );
     fprintf( stderr, " create=%d,", req->create );
     fprintf( stderr, " attrs=%08x,", req->attrs );
-    fprintf( stderr, " drive_type=%d,", req->drive_type );
+    fprintf( stderr, " removable=%d,", req->removable );
     fprintf( stderr, " filename=" );
     dump_varargs_string( cur_size );
 }
@@ -1348,7 +1348,7 @@
     fprintf( stderr, " base=%p,", req->base );
     fprintf( stderr, " shared_file=%p,", req->shared_file );
     fprintf( stderr, " shared_size=%d,", req->shared_size );
-    fprintf( stderr, " drive_type=%d", req->drive_type );
+    fprintf( stderr, " removable=%d", req->removable );
 }
 
 static void dump_create_device_request( const struct create_device_request *req )