aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-12-16 18:10:10 +0000
committerChristopher Faylor <me@cgf.cx>2005-12-16 18:10:10 +0000
commitfd01d14ab1258e2601a94dc3734fa7505942391d (patch)
treef4aa021c4ff0740c51cf1d0678393b61c34dfe10
parentf5778dc7f4e17136b5dd0d1be1a440d52a0d24d6 (diff)
downloadnewlib-fd01d14ab1258e2601a94dc3734fa7505942391d.zip
newlib-fd01d14ab1258e2601a94dc3734fa7505942391d.tar.gz
newlib-fd01d14ab1258e2601a94dc3734fa7505942391d.tar.bz2
* hookapi.cc (putmem): Remove query of previous memory protection since we get
that for free the first time we call VirtualProtect.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/hookapi.cc17
2 files changed, 8 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 839467c..85fe362 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-16 Christopher Faylor <cgf@timesys.com>
+
+ * hookapi.cc (putmem): Remove query of previous memory protection since
+ we get that for free the first time we call VirtualProtect.
+
2005-12-15 Corinna Vinschen <corinna@vinschen.de>
* mmap.cc (fhandler_dev_zero::fixup_mmap_after_fork): Use
diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc
index 29a9889..26aff51 100644
--- a/winsup/cygwin/hookapi.cc
+++ b/winsup/cygwin/hookapi.cc
@@ -53,25 +53,14 @@ rvadelta (PIMAGE_NT_HEADERS pnt, DWORD import_rva)
void *
putmem (PIMAGE_THUNK_DATA pi, const void *hookfn)
{
-
- DWORD flOldProtect, flNewProtect, flDontCare;
- MEMORY_BASIC_INFORMATION mbi;
-
- /* Get the current protection attributes */
- VirtualQuery (pi, &mbi, sizeof (mbi));
-
- /* Remove ReadOnly and ExecuteRead attributes, add on ReadWrite flag */
- flNewProtect = mbi.Protect;
- flNewProtect &= ~(PAGE_READONLY | PAGE_EXECUTE_READ);
- flNewProtect |= PAGE_READWRITE;
-
- if (!VirtualProtect (pi, sizeof (PVOID), flNewProtect, &flOldProtect) )
+ DWORD ofl;
+ if (!VirtualProtect (pi, sizeof (PVOID), PAGE_READWRITE, &ofl) )
return NULL;
void *origfn = (void *) pi->u1.Function;
pi->u1.Function = (DWORD) hookfn;
- VirtualProtect (pi, sizeof (PVOID), flOldProtect, &flDontCare);
+ VirtualProtect (pi, sizeof (PVOID), ofl, &ofl);
return origfn;
}