w32sys.c 3.17 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3 4 5
/*
 * W32SYS
 * helper DLL for Win32s
 *
 * Copyright (c) 1996 Anand Kumria
6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Alexandre Julliard's avatar
Alexandre Julliard committed
20 21
 */

22 23
#include "config.h"

24
#include <stdarg.h>
Alexandre Julliard's avatar
Alexandre Julliard committed
25
#include <stdio.h>
26 27 28
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
29

30
#include "windef.h"
31
#include "winbase.h"
32
#include "wine/windef16.h"
33
#include "wine/winbase16.h"
34
#include "wine/debug.h"
35

36
WINE_DEFAULT_DEBUG_CHANNEL(dll);
37 38 39 40 41 42 43 44

typedef struct
{
    BYTE   bMajor;
    BYTE   bMinor;
    WORD   wBuildNumber;
    BOOL16 fDebug;
} WIN32SINFO, *LPWIN32SINFO;
45

Alexandre Julliard's avatar
Alexandre Julliard committed
46 47
/***********************************************************************
 *           GetWin32sInfo   (W32SYS.12)
Alexandre Julliard's avatar
Alexandre Julliard committed
48 49
 * RETURNS
 *  0 on success, 1 on failure
Alexandre Julliard's avatar
Alexandre Julliard committed
50
 */
51
WORD WINAPI GetWin32sInfo16(
Alexandre Julliard's avatar
Alexandre Julliard committed
52 53
	LPWIN32SINFO lpInfo	/* [out] Win32S special information */
) {
Alexandre Julliard's avatar
Alexandre Julliard committed
54 55 56 57 58 59 60
    lpInfo->bMajor = 1;
    lpInfo->bMinor = 3;
    lpInfo->wBuildNumber = 0;
    lpInfo->fDebug = FALSE;

    return 0;
}
Alexandre Julliard's avatar
Alexandre Julliard committed
61

62
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
63
 *            GetW32SysVersion  (W32SYS.5)
64
 */
65
WORD WINAPI GetW32SysVersion16(void)
66 67 68 69
{
    return 0x100;
}

Alexandre Julliard's avatar
Alexandre Julliard committed
70 71 72 73 74 75
/***********************************************************************
 *           GetPEResourceTable   (W32SYS.7)
 * retrieves the resourcetable from the passed filedescriptor
 * RETURNS
 *	dunno what.
 */
76
WORD WINAPI GetPEResourceTable16(
77
	HFILE16 hf		/* [in] Handle of executable file */
Alexandre Julliard's avatar
Alexandre Julliard committed
78 79 80
) {
	return 0;
}
81

82
/***********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
83
 *           LoadPeResource (W32SYS.11)
84
 */
85
DWORD WINAPI LoadPeResource16(WORD x,SEGPTR y) {
86
	FIXME("(0x%04x,0x%08x),stub!\n",x,y);
87 88
	return 0;
}
89 90 91


/**********************************************************************
Patrik Stridvall's avatar
Patrik Stridvall committed
92
 *		IsPeFormat		(W32SYS.2)
93
 * Check if a file is a PE format executable.
94 95 96 97
 * RETURNS
 *  TRUE, if it is.
 *  FALSE if not.
 */
98
BOOL16 WINAPI IsPeFormat16( LPSTR fn,      /* [in] filename of executable */
99 100 101 102 103 104 105 106 107
                            HFILE16 hf16 ) /* [in] open file, if filename is NULL */
{
    BOOL16 ret = FALSE;
    IMAGE_DOS_HEADER mzh;
    OFSTRUCT ofs;
    DWORD xmagic;
    HFILE hf;

    if (fn) hf = OpenFile(fn,&ofs,OF_READ);
108
    else hf = (HFILE)DosFileHandleToWin32Handle( hf16 );
109 110 111 112 113 114 115 116 117 118 119
    if (hf == HFILE_ERROR) return FALSE;
    _llseek(hf,0,SEEK_SET);
    if (sizeof(mzh)!=_lread(hf,&mzh,sizeof(mzh))) goto done;
    if (mzh.e_magic!=IMAGE_DOS_SIGNATURE) goto done;
    _llseek(hf,mzh.e_lfanew,SEEK_SET);
    if (sizeof(DWORD)!=_lread(hf,&xmagic,sizeof(DWORD))) goto done;
    ret = (xmagic == IMAGE_NT_SIGNATURE);
 done:
    if (fn) _lclose(hf);
    return ret;
}