wine/win32/init.c
Alexandre Julliard b1bac32007 Release 961215
Sun Dec 15 16:18:15 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [graphics/x11drv/bitblt.c]
	Fixed BITBLT_StretchImage for partially covered or inverted
	bitmaps.

	* [objects/dib.c]
	Fixed the upside-down bitmap problem.

Sat Dec 14 02:49:57 1996  Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk>

	* [if1632/user32.spec]
	IsMenu and RemoveMenu added (use existing Win16 functions).

	* [include/windows.h]
	Corrections to BITMAPINFOHEADER structure.

	* [loader/module.c] [if1632/kernel32.spec]
	New function GetModuleFileName32A (heavily based on original
	Win16 version).

	* [loader/pe_image.c]
	Hack to allow files with short PE header to be loaded (e.g.
	COMDLG32.DLL from Win32s).

	* [misc/winsock_async.c]
	#if out EIDRM case (not present in FreeBSD).

	* [tools/build.c]
	Remove trailing comments from .s files generated by build
	as these break assembly when not run through pre-processor.

	* [windows/graphics.c] [if1632/gdi32.spec]
	New function Polyline32 - based on original Polyline. Needs
	metafile support adding still.

Fri Dec 13 13:04:06 1996  Bruce Milner <Bruce.Milner@genetics.utah.edu>

	* [win32/findfile.c] [if1632/kernel.spec]
	FindFirstFile32A(): Use dos current directory for drive prefixes.
	FindNextFile32A(): Fill in file attribute information.
	Implement FindFirstFile16, FindNextFile16, FindClose16.

	* [files/drive.c]
	GetCurrentDirectory32A - Fix problem with null 3rd character in
	string.

Tue Dec 10 14:49:07 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [windows/painting.c][windows/message.c]
	Don't use linked lists to call SendMessage(), for it might destroy
 	the current listentry.

	* [misc/registry.c]
	Fixed temporary file saving (rename doesn't work across
	partitions).

	* [files/*.c]
	GetFullPathName*,GetDriveType32A fixed, CreateDirectoryEx*,
	GetVolumeInformation32W fixed.

	* [win32/process.c][if1632/kernel.spec][if1632/kernel32.spec]
	LoadLibrary* updated to new naming std., *32W added.

	* [win32/console.c] [include/wincon.h]
	Additions for NT commandline executables.

	* [if1632/advapi32.spec][if1632/kernel32.spec][win32/init.c]	
	GetUserName32W added, GetComputerName32W added,
	GetStartupInfo32W added, GetSystemInfo updated to NT standard.

	* [windows/msgbox.c][misc/shell.c][windows/graphics.c]
	MessageBox32W, ShellAbout32W, CommandLineToArgvW, Polygon32 added.

	* [misc/crtdll.c][include/crtdll.h][if1632/crtdll.spec][misc/ntdll.c]
	  [if1632/ntdll.spec]
	Lot of new unicode functions added (needed for NT).

	* [loader/pe_image.c]
	NtCurrentTeb added.

Tue Dec 10 22:39:33 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [windows/keyboard.c]
	Rewrote function TranslateAccelerator().

Mon Dec  9 14:52:13 1996  Slaven Rezic  <eserte@cs.tu-berlin.de>

	* [windows/defwnd.c] 
	DEFWND_SetText(): Set icon name.

Sun Dec  8 23:30:00 1996  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [loader/signal.c] [misc/winsock.c] [misc/winsock_async.c]
	  [if1632/winsock.spec]
	IPC resource cleanup, bugfixes.

	* [windows/dialog.c] [windows/defdlg.c]
	More DefDlgProc() fixes.

Sun Dec  8 14:01:42 1996  Vadim Strizhevsky  <striv@ms.com>

	* [misc/clipboard.c] [objects/font.c] [win32/init.c]
 	  [win32/newfns.c] [windows/graphics.c]
	Added a few WIN32 functions which needed to run some win32
	accessories. Clock should now work almost as well as 16 bit version.
	Add: RegisterClipboardFormat32W GetTextExtentExPoint32*
	     GetModuleHandleW, DisableThreadLibraryCalls (empty stub),
	     Polygon32
	Fix: Polygon16 possible memory leak on error return.
1996-12-15 19:45:59 +00:00

229 lines
6 KiB
C

/*
* Win32 kernel functions
*
* Copyright 1995 Martin von Loewis and Cameron Heide
*/
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "windows.h"
#include "winerror.h"
#include "handle32.h"
#include "except.h"
#include "task.h"
#include "stddebug.h"
#include "string32.h"
#define DEBUG_WIN32
#include "debug.h"
#include "string32.h"
#include "xmalloc.h"
/* The global error value
*/
int WIN32_LastError;
/*********************************************************************
* CloseHandle (KERNEL32.23)
*/
BOOL CloseHandle(KERNEL_OBJECT *handle)
{
if (handle<0x1000) /* FIXME: hack */
return CloseFileHandle(handle);
if (handle==0xFFFFFFFF)
return FALSE;
switch(handle->magic)
{
case KERNEL_OBJECT_UNUSED:
SetLastError(ERROR_INVALID_HANDLE);
return 0;
/* FIXME
case KERNEL_OBJECT_FILE:
rc = CloseFileHandle((FILE_OBJECT *)handle);
break;
*/
default:
dprintf_win32(stddeb, "CloseHandle: type %ld not implemented yet.\n",
handle->magic);
break;
}
ReleaseKernelObject(handle);
return 0;
}
/***********************************************************************
* GetModuleHandle (KERNEL32.237)
*/
HMODULE32 WIN32_GetModuleHandleA(char *module)
{
HMODULE32 hModule;
dprintf_win32(stddeb, "GetModuleHandleA: %s\n", module ? module : "NULL");
/* Freecell uses the result of GetModuleHandleA(0) as the hInstance in
all calls to e.g. CreateWindowEx. */
if (module == NULL) {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
hModule = pTask->hInstance;
} else
hModule = GetModuleHandle(module);
dprintf_win32(stddeb, "GetModuleHandleA: returning %d\n", hModule );
return hModule;
}
HMODULE32 WIN32_GetModuleHandleW(LPCWSTR module)
{
HMODULE32 hModule;
LPSTR modulea;
if(module==NULL) return WIN32_GetModuleHandleA(NULL);
modulea=STRING32_DupUniToAnsi(module);
hModule = WIN32_GetModuleHandleA(modulea);
free(modulea);
return hModule;
}
/***********************************************************************
* GetStartupInfoA (KERNEL32.273)
*/
VOID GetStartupInfo32A(LPSTARTUPINFO32A lpStartupInfo)
{
lpStartupInfo->cb = sizeof(STARTUPINFO32A);
lpStartupInfo->lpReserved = "<Reserved>";
lpStartupInfo->lpDesktop = "Desktop";
lpStartupInfo->lpTitle = "Title";
lpStartupInfo->cbReserved2 = 0;
lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
lpStartupInfo->hStdInput = (HANDLE32)0;
lpStartupInfo->hStdOutput = (HANDLE32)1;
lpStartupInfo->hStdError = (HANDLE32)2;
}
/***********************************************************************
* GetStartupInfoW (KERNEL32.274)
*/
VOID GetStartupInfo32W(LPSTARTUPINFO32W lpStartupInfo)
{
lpStartupInfo->cb = sizeof(STARTUPINFO32W);
lpStartupInfo->lpReserved = STRING32_DupAnsiToUni("<Reserved>");
lpStartupInfo->lpDesktop = STRING32_DupAnsiToUni("Desktop");
lpStartupInfo->lpTitle = STRING32_DupAnsiToUni("Title");
lpStartupInfo->cbReserved2 = 0;
lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
lpStartupInfo->hStdInput = (HANDLE32)0;
lpStartupInfo->hStdOutput = (HANDLE32)1;
lpStartupInfo->hStdError = (HANDLE32)2;
}
/***********************************************************************
* GetStartupInfoA (KERNEL32.284)
* FIXME: perhaps supply better values.
* add other architectures for WINELIB.
*/
VOID
GetSystemInfo(LPSYSTEM_INFO si) {
WORD cpu;
si->u.x.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
si->dwPageSize = 4096; /* 4K */
si->lpMinimumApplicationAddress = 0x40000000;
si->lpMaximumApplicationAddress = 0x80000000;
si->dwActiveProcessorMask = 1;
si->dwNumberOfProcessors = 1;
#ifdef WINELIB
/* FIXME: perhaps check compilation defines ... */
si->dwProcessorType = PROCESSOR_INTEL_386;
cpu = 3;
#else
cpu = runtime_cpu();
switch (cpu) {
case 4: si->dwProcessorType = PROCESSOR_INTEL_486;
break;
case 5: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM;
break;
case 3:
default: si->dwProcessorType = PROCESSOR_INTEL_386;
break;
}
#endif
si->dwAllocationGranularity = 8; /* hmm? */
si->wProcessorLevel = cpu;
si->wProcessorRevision = 0; /* FIXME, see SDK */
}
/* Initialize whatever internal data structures we need.
*
* Returns 1 on success, 0 on failure.
*/
int KERN32_Init(void)
{
#ifndef WINELIB
/* Initialize exception handling */
EXC_Init();
#endif
return 1;
}
/***********************************************************************
* GetComputerNameA (KERNEL32.165)
*/
BOOL32
GetComputerName32A(LPSTR name,LPDWORD size) {
if (-1==gethostname(name,*size))
return FALSE;
*size = lstrlen32A(name);
return TRUE;
}
/***********************************************************************
* GetComputerNameW (KERNEL32.166)
*/
BOOL32
GetComputerName32W(LPWSTR name,LPDWORD size) {
LPSTR nameA = (LPSTR)xmalloc(*size);
if (!GetComputerName32A(nameA,size)) {
free(nameA);
return FALSE;
}
lstrcpynAtoW(name,nameA,*size);
free(nameA);
/* FIXME : size correct? */
return TRUE;
}
/***********************************************************************
* GetUserNameA [ADVAPI32.67]
*/
BOOL32 GetUserName32A(LPSTR lpszName, LPDWORD lpSize)
{
size_t len;
char *name;
name=getlogin();
len = name ? strlen(name) : 0;
if (!len || !lpSize || len > *lpSize) {
if (lpszName) *lpszName = 0;
return 0;
}
*lpSize=len;
strcpy(lpszName, name);
return 1;
}
/***********************************************************************
* GetUserNameW [ADVAPI32.68]
*/
BOOL32 GetUserName32W(LPWSTR lpszName, LPDWORD lpSize)
{
LPSTR name = (LPSTR)xmalloc(*lpSize);
DWORD size = *lpSize;
BOOL32 res = GetUserName32A(name,lpSize);
lstrcpynAtoW(lpszName,name,size);
return res;
}