diff options
-rw-r--r-- | loader/ext.c | 12 | ||||
-rw-r--r-- | loader/ldt_keeper.c | 6 | ||||
-rw-r--r-- | loader/ldt_keeper.h | 1 | ||||
-rw-r--r-- | osdep/mmap_anon.c | 7 | ||||
-rw-r--r-- | osdep/mmap_anon.h | 2 |
5 files changed, 7 insertions, 21 deletions
diff --git a/loader/ext.c b/loader/ext.c index e00491878c..b702cc1dd3 100644 --- a/loader/ext.c +++ b/loader/ext.c @@ -248,7 +248,7 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start, if (unix_handle == -1) { - ret = mmap_anon( start, size_low, prot, flags, &fd, offset_low ); + ret = mmap_anon( start, size_low, prot, flags, offset_low ); } else { @@ -365,12 +365,10 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr, mmap_access |=PROT_READ|PROT_WRITE; if(anon) - answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, &hFile, 0); + answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, 0); else answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0); - if(anon && hFile != -1) - close(hFile); if(answer!=(LPVOID)-1) { if(fm==0) @@ -395,8 +393,6 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr, fm->name=NULL; fm->mapping_size=len; - if(anon && hFile != -1) - close(hFile); return (HANDLE)answer; } return (HANDLE)0; @@ -495,11 +491,9 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type, DWORD protec } answer=mmap_anon(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE, &fd, 0); + MAP_PRIVATE, 0); // answer=FILE_dommap(-1, address, 0, size, 0, 0, // PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE); - if (fd != -1) - close(fd); if (answer != (void *)-1 && address && answer != address) { /* It is dangerous to try mmap() with MAP_FIXED since it does not diff --git a/loader/ldt_keeper.c b/loader/ldt_keeper.c index 504d449a33..fe270b6ba9 100644 --- a/loader/ldt_keeper.c +++ b/loader/ldt_keeper.c @@ -196,12 +196,10 @@ ldt_fs_t* Setup_LDT_Keeper(void) return NULL; fs_seg= - ldt_fs->fs_seg = mmap_anon(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, &ldt_fs->fd, - 0); + ldt_fs->fs_seg = mmap_anon(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, 0); if (ldt_fs->fs_seg == (void*)-1) { perror("ERROR: Couldn't allocate memory for fs segment"); - close(ldt_fs->fd); free(ldt_fs); return NULL; } @@ -282,7 +280,5 @@ void Restore_LDT_Keeper(ldt_fs_t* ldt_fs) free(ldt_fs->prev_struct); munmap((char*)ldt_fs->fs_seg, getpagesize()); ldt_fs->fs_seg = 0; - if (ldt_fs->fd != -1) - close(ldt_fs->fd); free(ldt_fs); } diff --git a/loader/ldt_keeper.h b/loader/ldt_keeper.h index d36ebb892c..e2626e39b5 100644 --- a/loader/ldt_keeper.h +++ b/loader/ldt_keeper.h @@ -9,7 +9,6 @@ extern "C" typedef struct { void* fs_seg; char* prev_struct; - int fd; } ldt_fs_t; void Setup_FS_Segment(void); diff --git a/osdep/mmap_anon.c b/osdep/mmap_anon.c index b6d0b7cf35..484615311a 100644 --- a/osdep/mmap_anon.c +++ b/osdep/mmap_anon.c @@ -31,7 +31,7 @@ * \param zerofd * \return a pointer to the mapped region upon successful completion, -1 otherwise. */ -void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t offset) +void *mmap_anon(void *addr, size_t len, int prot, int flags, off_t offset) { int fd; void *result; @@ -46,7 +46,6 @@ void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t #ifdef MAP_ANONYMOUS /* BSD-style anonymous mapping */ - fd = -1; result = mmap(addr, len, prot, flags | MAP_ANONYMOUS, -1, offset); #else /* SysV-style anonymous mapping */ @@ -57,11 +56,9 @@ void *mmap_anon(void *addr, size_t len, int prot, int flags, int *zerofd, off_t } result = mmap(addr, len, prot, flags, fd, offset); + close(fd); #endif /* MAP_ANONYMOUS */ - if (zerofd) - *zerofd = fd; - return result; } diff --git a/osdep/mmap_anon.h b/osdep/mmap_anon.h index edb909bdc0..e0f2d4e1ed 100644 --- a/osdep/mmap_anon.h +++ b/osdep/mmap_anon.h @@ -3,6 +3,6 @@ #include <sys/types.h> -void *mmap_anon(void *, size_t, int, int, int *, off_t); +void *mmap_anon(void *, size_t, int, int, off_t); #endif /* _OSDEP_MMAP_ANON_H_ */ |