Module: wine Branch: master Commit: 16e8633ee597c68336bc1b1561260fa7d0eced2b URL: http://source.winehq.org/git/wine.git/?a=commit;h=16e8633ee597c68336bc1b1561...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Apr 14 20:39:52 2008 +0200
winedos: Handle memory reservation errors more gracefully.
---
dlls/winedos/dosmem.c | 5 ++--- programs/winevdm/winevdm.c | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/winedos/dosmem.c b/dlls/winedos/dosmem.c index 9829f1a..876a3e7 100644 --- a/dlls/winedos/dosmem.c +++ b/dlls/winedos/dosmem.c @@ -506,14 +506,13 @@ BOOL DOSMEM_MapDosLayout(void) unsigned short sel; LDT_ENTRY entry;
- if (DOSMEM_dosmem) + if (DOSMEM_dosmem || !VirtualProtect( NULL, DOSMEM_SIZE, PAGE_EXECUTE_READWRITE, NULL )) { - ERR( "Needs access to the first megabyte for DOS mode\n" ); + ERR( "Need full access to the first megabyte for DOS mode\n" ); ExitProcess(1); } MESSAGE( "Warning: unprotecting memory to allow real-mode calls.\n" " NULL pointer accesses will no longer be caught.\n" ); - VirtualProtect( NULL, DOSMEM_SIZE, PAGE_EXECUTE_READWRITE, NULL ); /* copy the BIOS and ISR area down */ memcpy( DOSMEM_dosmem, DOSMEM_sysmem, 0x400 + 0x100 ); DOSMEM_sysmem = DOSMEM_dosmem; diff --git a/programs/winevdm/winevdm.c b/programs/winevdm/winevdm.c index 140efab..263f561 100644 --- a/programs/winevdm/winevdm.c +++ b/programs/winevdm/winevdm.c @@ -383,6 +383,7 @@ int main( int argc, char *argv[] ) char *cmdline, *appname, **first_arg; char *p; HMODULE winedos; + MEMORY_BASIC_INFORMATION mem_info;
if (!argv[1]) usage();
@@ -405,7 +406,12 @@ int main( int argc, char *argv[] ) if (!(winedos = LoadLibraryA( "winedos.dll" )) || !(wine_load_dos_exe = (void *)GetProcAddress( winedos, "wine_load_dos_exe" ))) { - WINE_MESSAGE( "winevdm: unable to exec '%s': 16-bit support missing\n", argv[1] ); + WINE_MESSAGE( "winevdm: unable to exec '%s': DOS support unavailable\n", appname ); + ExitProcess(1); + } + if (!VirtualQuery( NULL, &mem_info, sizeof(mem_info) ) || mem_info.State == MEM_FREE) + { + WINE_MESSAGE( "winevdm: unable to exec '%s': DOS memory range unavailable\n", appname ); ExitProcess(1); }