Hi,
Here is another problem in BigJig a jigsaw puzzle game (free download at www.lenagames.com).
The program calls BitBlt with destination an in memory DIB. Inside BitBlt, the destination bits are set to PAGE_NOACCESS:
| 0009:Call kernel32.VirtualProtect(727f0000,00123324,00000001,77a5f7bc) ret=770032ba | 0009:Call ntdll.NtProtectVirtualMemory(ffffffff,77a5f69c,77a5f6a0,00000001,77a5f7bc) ret=77b6929e | trace:virtual:NtProtectVirtualMemory 0xffffffff 0x727f0000 00123324 00000001 | trace:virtual:VIRTUAL_SetProt 0x727f0000-0x72913fff c---- | View: 0x727f0000 - 0x72913fff (valloc) | 0x727f0000 - 0x72913fff c---- | 0009:Ret ntdll.NtProtectVirtualMemory() retval=00000000 ret=77b6929e
This memory segment (727f0000,00123324) does not appear in the log anymore until it is written to disk:
| 0009:Call kernel32.WriteFile(00000084,727f0000,00123324,77a5f360,00000000) ret=00408ac1 .. The call fails ( not in the log because I fixed it) with error STATUS_INVALID_USER_BUFFER and the program hangs.
I managed to fixed it in two ways:
1. put a X11DRV_CoerceDIBSection( physDevDst, DIB_Status_InSync, FALSE ); at the end of X11DRV_BitBlt. This probably defeats the whole purpose of these protections so:
2. Add a "IsBadReadPtr( buffer, bytesToWrite)" in the top of WriteFile to force an exception and everything works.
Would that be an acceptable fix?
Rein.
Rein Klazes wijn@wanadoo.nl writes:
I managed to fixed it in two ways:
- put a X11DRV_CoerceDIBSection( physDevDst, DIB_Status_InSync, FALSE );
at the end of X11DRV_BitBlt. This probably defeats the whole purpose of these protections so:
- Add a "IsBadReadPtr( buffer, bytesToWrite)" in the top of WriteFile
to force an exception and everything works.
Would that be an acceptable fix?
We don't want that at the top of WriteFile, but it could be OK to add special handling of the INVALID_USER_BUFFER error, with a big FIXME comment...
On 06 May 2005 16:01:06 +0200, you wrote:
Rein Klazes wijn@wanadoo.nl writes:
I managed to fixed it in two ways:
- put a X11DRV_CoerceDIBSection( physDevDst, DIB_Status_InSync, FALSE );
at the end of X11DRV_BitBlt. This probably defeats the whole purpose of these protections so:
- Add a "IsBadReadPtr( buffer, bytesToWrite)" in the top of WriteFile
to force an exception and everything works.
Would that be an acceptable fix?
We don't want that at the top of WriteFile, but it could be OK to add special handling of the INVALID_USER_BUFFER error, with a big FIXME comment...
Special handling: try again after an IsBadReadPtr call.
Changelog:
dlls/kernel : file.c
Work around a problem where WriteFile is asked to write memory protected by DIBSection code.
Rein.