mirror of
https://github.com/reactos/wine.git
synced 2025-01-12 14:41:09 +00:00
d7d4fdf898
Sat Dec 23 18:15:59 1995 Alexandre Julliard <julliard@sunsite.unc.edu> * [configure.in] [Makefile.in] [tools/install-sh] New 'install' target installs Wine binary, library and man page. Library is now more logically named libwine.a. Split toolkit/ directory into library (for library code) and libtest (for test programs). * [controls/edit.c] Quick hack to partially support EM_PASSWORD style (avoids displaying your passwords on the screen when testing programs...) * [configure.in] [controls/menu.c] [include/resource.h] [misc/commdlg.c] [misc/ole2nls.c] [misc/shell.c] [windows/msgbox.c] Language is now a run-time option (wine -language xx). * [debugger/dbg.y] Dump some more debugging info on crash. * [misc/profile.c] Only consider ';' as a comment if it's the first non-blank character on the line. * [miscemu/dpmi.c] More debugging info for real-mode callback. * [objects/gdiobj.c] Rewrote EnumObjects() to do the Right Thing. * [resources/sysres*] New directory containing system resources. Fri Dec 22 11:24:39 GMT 1995 John Harvey <john@division.co.uk> * [win32/file.c] [win32/memory.c] Unixware doesn't have MAP_ANON ifdefed out for now. * [misc/dos_fs.c] DOS_GetDosFileName didn't truncate paths starting ./ properly. * [tools/build.c] Produces assembly code that works with the unixware assembler. Wed Dec 20 22:22:29 +0100 1995 Morten Welinder <terra@diku.dk> * [miscemu/instr.c] INSTR_GetOperandAddr: 16-bit addresses should be masked to 16 bits. * [misc/dos_fs.c] DOS_readdir should always return directories, even if they don't match the file name mask. Tue Dec 19 18:00:00 1995 Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de> * [misc/exec.c] Give arguments to winhelp. * [miscemu/int21.c] Implemented Interrupt 21 AX=6C00 EXTENDED OPEN/CREATE. Created function ExtendedOpenCreateFile. Give for some Windows95 interrupts the return value 'not implemented'. Sun Dec 17 16:51:56 EST 1995 Jim Peterson <jspeter@birch.ee.vt.edu> * [include/kernel32.h] [include/windows.h] Moved the typedefs for SYSTEMTIME and LPSYSTEMTIME from include/kernel32.h to include/windows.h and declared the new Win32 API functions Sleep(), GetLocalTime(), and GetSystemTime(). Redefined INFINITE as 0xFFFFFFFF if WINELIB32. * [rc/rc (new file)] Created the shell script 'rc', which should simplify resource compilation. * [win32/environment.c] Kludged around an undefined reference to wine_files. This change should be fixed some time. * [win32/time.c] [if1632/kernel32.spec] Added the functions GetSystemTime(), and Sleep(). * [miscemu/int21.c] Renamed static function GetSystemTime to INT21_GetSystemTime to avoid conflicts with the API function of the same name. * [include/wintypes.h] Added the SPFMT definition for printf statements. * [misc/shell.c] [include/shell.h] Changed ERROR_* defines to SHELL_ERROR_*, as they were conflicting with the ones in include/winerror.h. They should probably use the versions in winerror.h, but I'm not certain, and that can be done later. * [windows/mdi.c] Translated WM_MDIACTIVATE(?,(LOhwnd,HIhwnd)) messages to WM_MDIACTIVATE(HIhwnd,LOhwnd) for WINELIB32. The ? parameter (boolean) was discarded with this translation. Translated handler of WM_MDISETMENU(ref,(loHMENU,hiHMENU)) to handle WM_MDISETMENU(loHMENU, hiHMENU) messages in WINELIB32 (ref assumed false, call DrawMenuBar() if desired). * [*/*] General explicit casts and more rigid typing to remove warnings. * [include/winpos.h] [windows/winpos.c] Changed return type of WINPOS_ChangeActiveWindow to BOOL. * [include/commdlg.h] [misc/commdlg.c] Added prototypes for ChooseColor(), CommDlgExtendedError(), FindText() GetFileTitle(), GetOpenFileName(), GetSaveFileName(), PrintDlg, and ReplaceText(). Renamed the CommDlgExtendError() function to CommDlgExtendedError(). Made GetFileTitle return a short, as per the API definition. * [Makefile.in] Added line to clean and distclean that removes temporaries from the include directory. Sat Dec 16 19:39:14 MET 1995 Steffen Moeller <smoe0024@rz.uni-hildesheim.de> * [controls/edit.c] Almost rewrote EDIT_GetLineMsg. Sat Dec 16 13:51:48 MST 1995 Andrew Taylor <andrew@riscan.com> * [windows/mdi.c] Fixed MDITile() bug that occurs when 0 windows are present or all windows are minimized. Wed Dec 12 23:30:00 1995 Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de> * [misc/profile.c] Try harder to find files, especially in the working directory. Look in $HOME/.wine too and create it there if it isn't found.
363 lines
11 KiB
C
363 lines
11 KiB
C
#ifndef WINELIB
|
|
/*
|
|
*
|
|
* Copyright 1993 Robert J. Amstadt
|
|
* Copyright 1995 Alexandre Julliard
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include "windows.h"
|
|
#include "arch.h"
|
|
#include "dos_fs.h"
|
|
#include "global.h"
|
|
#include "ldt.h"
|
|
#include "module.h"
|
|
#include "neexe.h"
|
|
#include "resource.h"
|
|
#include "stddebug.h"
|
|
#include "debug.h"
|
|
|
|
typedef struct resource_typeinfo_s NE_TYPEINFO;
|
|
typedef struct resource_nameinfo_s NE_NAMEINFO;
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_FindNameTableId
|
|
*
|
|
* Find the type and resource id from their names.
|
|
* Return value is MAKELONG( typeId, resId ), or 0 if not found.
|
|
*/
|
|
static DWORD NE_FindNameTableId( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_TYPEINFO *pTypeInfo;
|
|
NE_NAMEINFO *pNameInfo;
|
|
HGLOBAL handle;
|
|
WORD *p;
|
|
DWORD ret = 0;
|
|
int count;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
|
|
for (; pTypeInfo->type_id != 0;
|
|
pTypeInfo = (NE_TYPEINFO *)((char*)(pTypeInfo+1) +
|
|
pTypeInfo->count * sizeof(NE_NAMEINFO)))
|
|
{
|
|
if (pTypeInfo->type_id != 0x800f) continue;
|
|
pNameInfo = (NE_NAMEINFO *)(pTypeInfo + 1);
|
|
for (count = pTypeInfo->count; count > 0; count--, pNameInfo++)
|
|
{
|
|
dprintf_resource( stddeb, "NameTable entry: type=%04x id=%04x\n",
|
|
pTypeInfo->type_id, pNameInfo->id );
|
|
handle = LoadResource( hModule,
|
|
(HANDLE)((int)pNameInfo - (int)pModule) );
|
|
for(p = (WORD*)LockResource(handle); p && *p; p = (WORD *)((char*)p+*p))
|
|
{
|
|
dprintf_resource( stddeb," type=%04x '%s' id=%04x '%s'\n",
|
|
p[1], (char *)(p+3), p[2],
|
|
(char *)(p+3)+strlen((char *)(p+3))+1 );
|
|
/* Check for correct type */
|
|
|
|
if (p[1] & 0x8000)
|
|
{
|
|
if (!HIWORD(typeId)) continue;
|
|
if (strcasecmp( (char *)PTR_SEG_TO_LIN(typeId),
|
|
(char *)(p + 3) )) continue;
|
|
}
|
|
else if (HIWORD(typeId) || ((typeId & ~0x8000)!= p[1]))
|
|
continue;
|
|
|
|
/* Now check for the id */
|
|
|
|
if (p[2] & 0x8000)
|
|
{
|
|
if (!HIWORD(resId)) continue;
|
|
if (strcasecmp( (char *)PTR_SEG_TO_LIN(resId),
|
|
(char*)(p+3)+strlen((char*)(p+3))+1 )) continue;
|
|
|
|
}
|
|
else if (HIWORD(resId) || ((resId & ~0x8000) != p[2]))
|
|
continue;
|
|
|
|
/* If we get here, we've found the entry */
|
|
|
|
dprintf_resource( stddeb, " Found!\n" );
|
|
ret = MAKELONG( p[1], p[2] );
|
|
break;
|
|
}
|
|
FreeResource( handle );
|
|
if (ret) return ret;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_FindResourceFromType
|
|
*
|
|
* Find a resource once the type info structure has been found.
|
|
*/
|
|
static HRSRC NE_FindResourceFromType( NE_MODULE *pModule,
|
|
NE_TYPEINFO *pTypeInfo, SEGPTR resId )
|
|
{
|
|
BYTE *p;
|
|
int count;
|
|
NE_NAMEINFO *pNameInfo = (NE_NAMEINFO *)(pTypeInfo + 1);
|
|
|
|
if (HIWORD(resId) != 0) /* Named resource */
|
|
{
|
|
char *str = (char *)PTR_SEG_TO_LIN( resId );
|
|
BYTE len = strlen( str );
|
|
for (count = pTypeInfo->count; count > 0; count--, pNameInfo++)
|
|
{
|
|
if (pNameInfo->id & 0x8000) continue;
|
|
p = (BYTE *)pModule + pModule->res_table + pNameInfo->id;
|
|
if ((*p == len) && !strncasecmp( p+1, str, len ))
|
|
return (HRSRC)((int)pNameInfo - (int)pModule);
|
|
}
|
|
}
|
|
else /* Numeric resource id */
|
|
{
|
|
WORD id = LOWORD(resId) | 0x8000;
|
|
for (count = pTypeInfo->count; count > 0; count--, pNameInfo++)
|
|
if (pNameInfo->id == id)
|
|
return (HRSRC)((int)pNameInfo - (int)pModule);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_FindResource
|
|
*/
|
|
HRSRC NE_FindResource( HMODULE hModule, SEGPTR typeId, SEGPTR resId )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_TYPEINFO *pTypeInfo;
|
|
HRSRC hRsrc;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
if (!pModule || !pModule->res_table) return 0;
|
|
pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
|
|
|
|
if (HIWORD(typeId) || HIWORD(resId))
|
|
{
|
|
/* Search the names in the nametable */
|
|
DWORD id = NE_FindNameTableId( hModule, typeId, resId );
|
|
if (id) /* found */
|
|
{
|
|
typeId = LOWORD(id);
|
|
resId = HIWORD(id);
|
|
}
|
|
}
|
|
|
|
if (HIWORD(typeId) != 0) /* Named type */
|
|
{
|
|
char *str = (char *)PTR_SEG_TO_LIN( typeId );
|
|
BYTE len = strlen( str );
|
|
while (pTypeInfo->type_id)
|
|
{
|
|
if (!(pTypeInfo->type_id & 0x8000))
|
|
{
|
|
BYTE *p = (BYTE*)pModule+pModule->res_table+pTypeInfo->type_id;
|
|
if ((*p == len) && !strncasecmp( p+1, str, len ))
|
|
{
|
|
dprintf_resource( stddeb, " Found type '%s'\n", str );
|
|
hRsrc = NE_FindResourceFromType(pModule, pTypeInfo, resId);
|
|
if (hRsrc)
|
|
{
|
|
dprintf_resource( stddeb, " Found id %08lx\n", resId );
|
|
return hRsrc;
|
|
}
|
|
dprintf_resource( stddeb, " Not found, going on\n" );
|
|
}
|
|
}
|
|
dprintf_resource( stddeb, " Skipping type %04x\n",
|
|
pTypeInfo->type_id );
|
|
pTypeInfo = (NE_TYPEINFO *)((char*)(pTypeInfo+1) +
|
|
pTypeInfo->count * sizeof(NE_NAMEINFO));
|
|
}
|
|
}
|
|
else /* Numeric type id */
|
|
{
|
|
WORD id = LOWORD(typeId) | 0x8000;
|
|
while (pTypeInfo->type_id)
|
|
{
|
|
if (pTypeInfo->type_id == id)
|
|
{
|
|
dprintf_resource( stddeb, " Found type %04x\n", id );
|
|
hRsrc = NE_FindResourceFromType( pModule, pTypeInfo, resId );
|
|
if (hRsrc)
|
|
{
|
|
dprintf_resource( stddeb, " Found id %08lx\n", resId );
|
|
return hRsrc;
|
|
}
|
|
dprintf_resource( stddeb, " Not found, going on\n" );
|
|
}
|
|
dprintf_resource( stddeb, " Skipping type %04x\n",
|
|
pTypeInfo->type_id );
|
|
pTypeInfo = (NE_TYPEINFO *)((char*)(pTypeInfo+1) +
|
|
pTypeInfo->count * sizeof(NE_NAMEINFO));
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_AllocResource
|
|
*/
|
|
HGLOBAL NE_AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_NAMEINFO *pNameInfo=NULL;
|
|
WORD sizeShift;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
if (!pModule || !pModule->res_table) return 0;
|
|
sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
|
|
#ifndef WINELIB
|
|
pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
|
|
#endif
|
|
if (size < (DWORD)pNameInfo->length << sizeShift)
|
|
size = (DWORD)pNameInfo->length << sizeShift;
|
|
return GLOBAL_Alloc( GMEM_FIXED, size, hModule, FALSE, FALSE, FALSE );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_AccessResource
|
|
*/
|
|
int NE_AccessResource( HMODULE hModule, HRSRC hRsrc )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_NAMEINFO *pNameInfo=NULL;
|
|
WORD sizeShift;
|
|
char *name;
|
|
int fd;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
if (!pModule || !pModule->res_table) return 0;
|
|
#ifndef WINELIB
|
|
pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
|
|
#endif
|
|
|
|
name = ((LOADEDFILEINFO*)((char*)pModule + pModule->fileinfo))->filename;
|
|
fd = open( DOS_GetUnixFileName(name), O_RDONLY );
|
|
sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
|
|
lseek( fd, (int)pNameInfo->offset << sizeShift, SEEK_SET );
|
|
return fd;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_SizeofResource
|
|
*/
|
|
DWORD NE_SizeofResource( HMODULE hModule, HRSRC hRsrc )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_NAMEINFO *pNameInfo=NULL;
|
|
WORD sizeShift;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
if (!pModule || !pModule->res_table) return 0;
|
|
sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
|
|
#ifndef WINELIB
|
|
pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
|
|
#endif
|
|
return (DWORD)pNameInfo->length << sizeShift;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_LoadResource
|
|
*/
|
|
HGLOBAL NE_LoadResource( HMODULE hModule, HRSRC hRsrc )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_NAMEINFO *pNameInfo=NULL;
|
|
WORD sizeShift;
|
|
int fd;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
if (!pModule || !pModule->res_table) return 0;
|
|
#ifndef WINELIB
|
|
pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
|
|
#endif
|
|
if (pNameInfo->handle)
|
|
{
|
|
pNameInfo->usage++;
|
|
dprintf_resource( stddeb, " Already loaded, new count=%d\n",
|
|
pNameInfo->usage );
|
|
return pNameInfo->handle;
|
|
}
|
|
sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
|
|
dprintf_resource( stddeb, " Loading, pos=%d, len=%d\n",
|
|
(int)pNameInfo->offset << sizeShift,
|
|
(int)pNameInfo->length << sizeShift );
|
|
if ((fd = MODULE_OpenFile( hModule )) == -1) return 0;
|
|
pNameInfo->handle = NE_AllocResource( hModule, hRsrc, 0 );
|
|
pNameInfo->usage = 1;
|
|
lseek( fd, (int)pNameInfo->offset << sizeShift, SEEK_SET );
|
|
read( fd, GlobalLock( pNameInfo->handle ),
|
|
(int)pNameInfo->length << sizeShift );
|
|
return pNameInfo->handle;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_LockResource
|
|
*/
|
|
SEGPTR NE_LockResource( HMODULE hModule, HGLOBAL handle )
|
|
{
|
|
/* May need to reload the resource if discarded */
|
|
|
|
return (SEGPTR)WIN16_GlobalLock( handle );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* NE_FreeResource
|
|
*/
|
|
BOOL NE_FreeResource( HMODULE hModule, HGLOBAL handle )
|
|
{
|
|
NE_MODULE *pModule;
|
|
NE_TYPEINFO *pTypeInfo;
|
|
NE_NAMEINFO *pNameInfo;
|
|
WORD count;
|
|
|
|
pModule = (NE_MODULE *)GlobalLock( hModule );
|
|
if (!pModule || !pModule->res_table) return FALSE;
|
|
pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
|
|
while (pTypeInfo->type_id)
|
|
{
|
|
pNameInfo = (NE_NAMEINFO *)(pTypeInfo + 1);
|
|
for (count = pTypeInfo->count; count > 0; count--)
|
|
{
|
|
if (pNameInfo->handle == handle)
|
|
{
|
|
if (pNameInfo->usage > 0) pNameInfo->usage--;
|
|
if (pNameInfo->usage == 0)
|
|
{
|
|
GlobalFree( pNameInfo->handle );
|
|
pNameInfo->handle = 0;
|
|
}
|
|
return TRUE;
|
|
}
|
|
pNameInfo++;
|
|
}
|
|
pTypeInfo = (NE_TYPEINFO *)pNameInfo;
|
|
}
|
|
fprintf( stderr, "FreeResource: "NPFMT" "NPFMT" not found!\n", hModule, handle );
|
|
return FALSE;
|
|
}
|
|
#endif /* WINELIB */
|