Make sure things still work if 16-bit dlls cannot be loaded.
This commit is contained in:
parent
c728efc3c9
commit
9842b19931
|
@ -31,7 +31,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
|||
|
||||
|
||||
HINSTANCE COMDLG32_hInstance = 0;
|
||||
HINSTANCE16 COMDLG32_hInstance16 = 0;
|
||||
static HINSTANCE16 COMDLG32_hInstance16;
|
||||
|
||||
static DWORD COMDLG32_TlsIndex;
|
||||
|
||||
|
@ -78,15 +78,7 @@ BOOL WINAPI COMDLG32_DllEntryPoint(HINSTANCE hInstance, DWORD Reason, LPVOID Res
|
|||
COMDLG32_hInstance = hInstance;
|
||||
DisableThreadLibraryCalls(hInstance);
|
||||
|
||||
if(!COMDLG32_hInstance16)
|
||||
{
|
||||
if(!(COMDLG32_hInstance16 = LoadLibrary16("commdlg.dll")))
|
||||
{
|
||||
ERR("Could not load sibling commdlg.dll\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
COMDLG32_hInstance16 = LoadLibrary16("commdlg.dll");
|
||||
COMDLG32_TlsIndex = 0xffffffff;
|
||||
|
||||
SHELL32_hInstance = GetModuleHandleA("SHELL32.DLL");
|
||||
|
@ -128,8 +120,6 @@ BOOL WINAPI COMDLG32_DllEntryPoint(HINSTANCE hInstance, DWORD Reason, LPVOID Res
|
|||
|
||||
case DLL_PROCESS_DETACH:
|
||||
if (COMDLG32_TlsIndex != 0xffffffff) TlsFree(COMDLG32_TlsIndex);
|
||||
COMDLG32_TlsIndex = 0xffffffff;
|
||||
COMDLG32_hInstance = 0;
|
||||
if(COMDLG32_hInstance16) FreeLibrary16(COMDLG32_hInstance16);
|
||||
if(SHFOLDER_hInstance) FreeLibrary(SHFOLDER_hInstance);
|
||||
break;
|
||||
|
|
|
@ -68,8 +68,8 @@ static BOOL process_attach(void)
|
|||
/* Initialize DOS memory */
|
||||
if (!DOSMEM_Init(0)) return FALSE;
|
||||
|
||||
if ((hModule = LoadLibrary16( "krnl386.exe" )) < 32) return FALSE;
|
||||
|
||||
if ((hModule = LoadLibrary16( "krnl386.exe" )) >= 32)
|
||||
{
|
||||
/* Initialize special KERNEL entry points */
|
||||
|
||||
/* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
|
||||
|
@ -99,9 +99,10 @@ static BOOL process_attach(void)
|
|||
NE_SetEntryPoint( hModule, 193, DOSMEM_BiosDataSeg ); /* KERNEL.193: __0040H */
|
||||
NE_SetEntryPoint( hModule, 194, DOSMEM_BiosSysSeg ); /* KERNEL.194: __F000H */
|
||||
#undef SET_ENTRY_POINT
|
||||
}
|
||||
|
||||
/* Force loading of some dlls */
|
||||
if (LoadLibrary16( "system" ) < 32) return FALSE;
|
||||
LoadLibrary16( "system" );
|
||||
|
||||
/* Create 16-bit task */
|
||||
TASK_CreateMainTask();
|
||||
|
|
|
@ -214,8 +214,12 @@ static BOOL process_attach(void)
|
|||
HINSTANCE16 instance;
|
||||
|
||||
/* Create USER heap */
|
||||
if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE;
|
||||
USER_HeapSel = instance | 7;
|
||||
if ((instance = LoadLibrary16( "USER.EXE" )) >= 32) USER_HeapSel = instance | 7;
|
||||
else
|
||||
{
|
||||
USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 65536 );
|
||||
LocalInit16( USER_HeapSel, 32, 65534 );
|
||||
}
|
||||
|
||||
/* Load the graphics driver */
|
||||
tweak_init();
|
||||
|
|
|
@ -584,8 +584,7 @@ BOOL GDI_Init(void)
|
|||
hkey = 0;
|
||||
|
||||
/* create GDI heap */
|
||||
if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE;
|
||||
GDI_HeapSel = instance | 7;
|
||||
if ((instance = LoadLibrary16( "GDI.EXE" )) >= 32) GDI_HeapSel = instance | 7;
|
||||
|
||||
/* create stock objects */
|
||||
stock_objects[WHITE_BRUSH] = CreateBrushIndirect( &WhiteBrush );
|
||||
|
@ -680,7 +679,16 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_
|
|||
_EnterSysLevel( &GDI_level );
|
||||
switch(magic)
|
||||
{
|
||||
/* allocate DCs on the larger heap */
|
||||
default:
|
||||
if (GDI_HeapSel)
|
||||
{
|
||||
if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error;
|
||||
assert( hlocal & 2 );
|
||||
obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hlocal );
|
||||
*handle = (HGDIOBJ)(ULONG_PTR)hlocal;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
case DC_MAGIC:
|
||||
case DISABLED_DC_MAGIC:
|
||||
case META_DC_MAGIC:
|
||||
|
@ -691,12 +699,6 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_
|
|||
case BITMAP_MAGIC:
|
||||
if (!(obj = alloc_large_heap( size, handle ))) goto error;
|
||||
break;
|
||||
default:
|
||||
if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error;
|
||||
assert( hlocal & 2 );
|
||||
obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hlocal );
|
||||
*handle = (HGDIOBJ)(ULONG_PTR)hlocal;
|
||||
break;
|
||||
}
|
||||
|
||||
obj->hNext = 0;
|
||||
|
@ -724,17 +726,33 @@ void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object )
|
|||
{
|
||||
HGDIOBJ new_handle;
|
||||
|
||||
assert( handle & 2 ); /* no realloc for large handles */
|
||||
LOCAL_Unlock( GDI_HeapSel, handle );
|
||||
if (!(new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE )))
|
||||
if (handle & 2) /* GDI heap handle */
|
||||
{
|
||||
LOCAL_Unlock( GDI_HeapSel, handle );
|
||||
if ((new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE )))
|
||||
{
|
||||
assert( new_handle == handle ); /* moveable handle cannot change */
|
||||
return LOCAL_Lock( GDI_HeapSel, handle );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
|
||||
if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
|
||||
{
|
||||
void *new_ptr = HeapReAlloc( GetProcessHeap(), 0, large_handles[i], size );
|
||||
if (new_ptr)
|
||||
{
|
||||
large_handles[i] = new_ptr;
|
||||
return new_ptr;
|
||||
}
|
||||
}
|
||||
else ERR( "Invalid handle %x\n", handle );
|
||||
}
|
||||
TRACE_SEC( handle, "leave" );
|
||||
_LeaveSysLevel( &GDI_level );
|
||||
return NULL;
|
||||
}
|
||||
assert( new_handle == handle ); /* moveable handle cannot change */
|
||||
return LOCAL_Lock( GDI_HeapSel, handle );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -125,23 +125,20 @@ static HPEN SysColorPens[NUM_SYS_COLORS];
|
|||
*/
|
||||
static void SYSCOLOR_MakeObjectSystem( HGDIOBJ handle, BOOL set)
|
||||
{
|
||||
static WORD GDI_heap_sel = 0;
|
||||
WORD heap_sel;
|
||||
LPWORD ptr;
|
||||
|
||||
if (!GDI_heap_sel)
|
||||
if ((heap_sel = GetModuleHandle16( "gdi" )))
|
||||
{
|
||||
GDI_heap_sel = LoadLibrary16("gdi");
|
||||
FreeLibrary16(GDI_heap_sel);
|
||||
}
|
||||
|
||||
ptr = (LPWORD)LOCAL_Lock(GDI_heap_sel, handle);
|
||||
ptr = (LPWORD)LOCAL_Lock(heap_sel, handle);
|
||||
|
||||
/* touch the "system" bit of the wMagic field of a GDIOBJHDR */
|
||||
if (set)
|
||||
*(ptr+1) &= ~OBJECT_NOSYSTEM;
|
||||
else
|
||||
*(ptr+1) |= OBJECT_NOSYSTEM;
|
||||
LOCAL_Unlock( GDI_heap_sel, handle );
|
||||
LOCAL_Unlock( heap_sel, handle );
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
Loading…
Reference in New Issue