2014-10-25 2:53 GMT+02:00 dw <da...@limegreensocks.com>:
>
>> Ups, that was unintended to send an empty mail :)
>
> I did wonder.  I assumed it was just a ping.
>
>> So, here is a patch.
>
> Your patch does not look right.  You have added the new checks using "||"?

Hmm, might be a typo.

>> It would be great if somebody could verify that the reported
>> issue is solved by it.
>
> Yes, this is the hard part.  Vadim seems to be able to produce this with
> no problem, but I'm having no luck getting it to happen at all.
>
> BTW, what is __MINGW64_VERSION_MAJOR for?  Is there a time when it might
> not be defined in pseudo-reloc?  If it is defined, we end up checking
> the page attributes twice.

This macro is for testing for mingw-w64's feature-set.  So it should
be ok to test for it to verify that we use our startup.  You might
want to combine it with an __MINGW32___ check, so that we are sure we
are using our headers/crt in context of native Windows, and not in
context of cygwin.
(you can check also for !defined (__CYGWIN__) if you prefer).

> FWIW, my patch (which I haven't been able to test either) looks like
> this (removes the duplicate check):

Yes, it is more per formant for sure.  Please commit it, as Vladimir
tested it already.

Kai

> ----------------------- mingw-w64-crt/crt/pseudo-reloc.c
> -----------------------
> index 4e7f31b..7709208 100644
> @@ -206,7 +206,8 @@ mark_section_writable (LPVOID addr)
>         return;
>       }
>
> -  if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
> +  if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE
> +      && b.Protect != PAGE_EXECUTE_WRITECOPY && b.Protect !=
> PAGE_WRITECOPY)
>       {
>         if (!VirtualProtect (b.BaseAddress, b.RegionSize,
>                  PAGE_EXECUTE_READWRITE,
> @@ -259,16 +260,17 @@ restore_modified_sections (void)
>   static void
>   __write_memory (void *addr, const void *src, size_t len)
>   {
> -  MEMORY_BASIC_INFORMATION b;
> -  DWORD oldprot;
> -  int call_unprotect = 0;
> -
>     if (!len)
>       return;
>
>   #ifdef __MINGW64_VERSION_MAJOR
So make out out if instead '#if defined (__MINGW64_VERSION_MAJOR) &&
defined (__MINGW32__)'

> +  /* Mark the section writable once, and unset it in
> +   * restore_modified_sections */
>     mark_section_writable ((LPVOID) addr);
> -#endif
> +#else
> +  MEMORY_BASIC_INFORMATION b;
> +  DWORD oldprot = 0;
> +  int call_unprotect = 0;
>
>     if (!VirtualQuery (addr, &b, sizeof(b)))
>       {
> @@ -277,18 +279,25 @@ __write_memory (void *addr, const void *src,
> size_t len)
>       }
>
>     /* Temporarily allow write access to read-only protected memory. */
> -  if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
> +  if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE
> +      && b.Protect != PAGE_WRITECOPY && b.Protect !=
> PAGE_EXECUTE_WRITECOPY)
>       {
>         call_unprotect = 1;
>         VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,
>                 &oldprot);
>       }
> +#endif
>
>     /* write the data. */
>     memcpy (addr, src, len);
> +
> +#ifndef __MINGW64_VERSION_MAJOR

s.a.

>     /* Restore original protection. */
> -  if (call_unprotect && b.Protect != PAGE_EXECUTE_READWRITE &&
> b.Protect != PAGE_READWRITE)
> +  if (call_unprotect
> +      && b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE
> +      && b.Protect != PAGE_WRITECOPY && b.Protect !=
> PAGE_EXECUTE_WRITECOPY)
>       VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot);
> +#endif
>   }
>
>   #define RP_VERSION_V1 0
>
> ------------------------------------------------------------------------------
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to