Added LGPL standard comment, and copyright notices where necessary.
[wine] / dlls / win32s / w32sys.c
1 /*
2  * W32SYS
3  * helper DLL for Win32s
4  *
5  * Copyright (c) 1996 Anand Kumria
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <unistd.h>
23
24 #include "windef.h"
25 #include "wine/windef16.h"
26 #include "wine/winbase16.h"
27 #include "wine/debug.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(dll);
30
31 typedef struct
32 {
33     BYTE   bMajor;
34     BYTE   bMinor;
35     WORD   wBuildNumber;
36     BOOL16 fDebug;
37 } WIN32SINFO, *LPWIN32SINFO;
38
39 /***********************************************************************
40  *           GetWin32sInfo   (W32SYS.12)
41  * RETURNS
42  *  0 on success, 1 on failure
43  */
44 WORD WINAPI GetWin32sInfo16(
45         LPWIN32SINFO lpInfo     /* [out] Win32S special information */
46 ) {
47     lpInfo->bMajor = 1;
48     lpInfo->bMinor = 3;
49     lpInfo->wBuildNumber = 0;
50     lpInfo->fDebug = FALSE;
51
52     return 0;
53 }
54
55 /***********************************************************************
56  *            GetW32SysVersion  (W32SYS.5)
57  */
58 WORD WINAPI GetW32SysVersion16(void)
59 {
60     return 0x100;
61 }
62
63 /***********************************************************************
64  *           GetPEResourceTable   (W32SYS.7)
65  * retrieves the resourcetable from the passed filedescriptor
66  * RETURNS
67  *      dunno what.
68  */
69 WORD WINAPI GetPEResourceTable16(
70         HFILE16 hf              /* [in] filedescriptor to opened executeable */
71 ) {
72         return 0;
73 }
74
75 /***********************************************************************
76  *           LoadPeResource (W32SYS.11)
77  */
78 DWORD WINAPI LoadPeResource16(WORD x,SEGPTR y) {
79         FIXME("(0x%04x,0x%08lx),stub!\n",x,y);
80         return 0;
81 }
82
83
84 /**********************************************************************
85  *              IsPeFormat              (W32SYS.2)
86  * Checks the passed filename if it is a PE format executeable
87  * RETURNS
88  *  TRUE, if it is.
89  *  FALSE if not.
90  */
91 BOOL16 WINAPI IsPeFormat16( LPSTR fn,      /* [in] filename to executeable */
92                             HFILE16 hf16 ) /* [in] open file, if filename is NULL */
93 {
94     BOOL16 ret = FALSE;
95     IMAGE_DOS_HEADER mzh;
96     OFSTRUCT ofs;
97     DWORD xmagic;
98     HFILE hf;
99
100     if (fn) hf = OpenFile(fn,&ofs,OF_READ);
101     else hf = DosFileHandleToWin32Handle( hf16 );
102     if (hf == HFILE_ERROR) return FALSE;
103     _llseek(hf,0,SEEK_SET);
104     if (sizeof(mzh)!=_lread(hf,&mzh,sizeof(mzh))) goto done;
105     if (mzh.e_magic!=IMAGE_DOS_SIGNATURE) goto done;
106     _llseek(hf,mzh.e_lfanew,SEEK_SET);
107     if (sizeof(DWORD)!=_lread(hf,&xmagic,sizeof(DWORD))) goto done;
108     ret = (xmagic == IMAGE_NT_SIGNATURE);
109  done:
110     if (fn) _lclose(hf);
111     return ret;
112 }