Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * W32SYS |
| 3 | * helper DLL for Win32s |
| 4 | * |
| 5 | * Copyright (c) 1996 Anand Kumria |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 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 |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 22 | #include "config.h" |
| 23 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 24 | #include <stdarg.h> |
Alexandre Julliard | 402b79a | 2003-11-27 00:59:36 +0000 | [diff] [blame] | 25 | #include <stdio.h> |
Patrik Stridvall | d016f81 | 2002-08-17 00:43:16 +0000 | [diff] [blame] | 26 | #ifdef HAVE_UNISTD_H |
| 27 | # include <unistd.h> |
| 28 | #endif |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 29 | |
Jim Aston | 2e1cafa | 1999-03-14 16:35:05 +0000 | [diff] [blame] | 30 | #include "windef.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 31 | #include "winbase.h" |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 32 | #include "wine/windef16.h" |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 33 | #include "wine/winbase16.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 34 | #include "wine/debug.h" |
Marcus Meissner | 2f521d3 | 1999-09-10 13:51:11 +0000 | [diff] [blame] | 35 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 36 | WINE_DEFAULT_DEBUG_CHANNEL(dll); |
Alexandre Julliard | a007f33 | 2000-08-09 00:54:58 +0000 | [diff] [blame] | 37 | |
| 38 | typedef struct |
| 39 | { |
| 40 | BYTE bMajor; |
| 41 | BYTE bMinor; |
| 42 | WORD wBuildNumber; |
| 43 | BOOL16 fDebug; |
| 44 | } WIN32SINFO, *LPWIN32SINFO; |
Marcus Meissner | 2f521d3 | 1999-09-10 13:51:11 +0000 | [diff] [blame] | 45 | |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 46 | /*********************************************************************** |
| 47 | * GetWin32sInfo (W32SYS.12) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 48 | * RETURNS |
| 49 | * 0 on success, 1 on failure |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 50 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 51 | WORD WINAPI GetWin32sInfo16( |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 52 | LPWIN32SINFO lpInfo /* [out] Win32S special information */ |
| 53 | ) { |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 54 | lpInfo->bMajor = 1; |
| 55 | lpInfo->bMinor = 3; |
| 56 | lpInfo->wBuildNumber = 0; |
| 57 | lpInfo->fDebug = FALSE; |
| 58 | |
| 59 | return 0; |
| 60 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 61 | |
| 62 | /*********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 63 | * GetW32SysVersion (W32SYS.5) |
Alexandre Julliard | 4220b29 | 1999-07-11 17:20:01 +0000 | [diff] [blame] | 64 | */ |
Alexandre Julliard | e02a540 | 1999-07-24 10:28:37 +0000 | [diff] [blame] | 65 | WORD WINAPI GetW32SysVersion16(void) |
Alexandre Julliard | 4220b29 | 1999-07-11 17:20:01 +0000 | [diff] [blame] | 66 | { |
| 67 | return 0x100; |
| 68 | } |
| 69 | |
| 70 | /*********************************************************************** |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 71 | * GetPEResourceTable (W32SYS.7) |
| 72 | * retrieves the resourcetable from the passed filedescriptor |
| 73 | * RETURNS |
| 74 | * dunno what. |
| 75 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 76 | WORD WINAPI GetPEResourceTable16( |
Jon Griffiths | eb5bf7d | 2005-02-25 14:07:56 +0000 | [diff] [blame] | 77 | HFILE16 hf /* [in] Handle of executable file */ |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 78 | ) { |
| 79 | return 0; |
| 80 | } |
Marcus Meissner | 2f521d3 | 1999-09-10 13:51:11 +0000 | [diff] [blame] | 81 | |
Patrik Stridvall | 54fe838 | 2000-04-06 20:21:16 +0000 | [diff] [blame] | 82 | /*********************************************************************** |
Patrik Stridvall | 044855c | 2001-07-11 18:56:41 +0000 | [diff] [blame] | 83 | * LoadPeResource (W32SYS.11) |
Patrik Stridvall | 54fe838 | 2000-04-06 20:21:16 +0000 | [diff] [blame] | 84 | */ |
Marcus Meissner | 2f521d3 | 1999-09-10 13:51:11 +0000 | [diff] [blame] | 85 | DWORD WINAPI LoadPeResource16(WORD x,SEGPTR y) { |
| 86 | FIXME("(0x%04x,0x%08lx),stub!\n",x,y); |
| 87 | return 0; |
| 88 | } |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 89 | |
| 90 | |
| 91 | /********************************************************************** |
Patrik Stridvall | 01d5e5b | 2001-07-02 19:59:40 +0000 | [diff] [blame] | 92 | * IsPeFormat (W32SYS.2) |
Jon Griffiths | eb5bf7d | 2005-02-25 14:07:56 +0000 | [diff] [blame] | 93 | * Check if a file is a PE format executable. |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 94 | * RETURNS |
| 95 | * TRUE, if it is. |
| 96 | * FALSE if not. |
| 97 | */ |
Jon Griffiths | eb5bf7d | 2005-02-25 14:07:56 +0000 | [diff] [blame] | 98 | BOOL16 WINAPI IsPeFormat16( LPSTR fn, /* [in] filename of executable */ |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 99 | HFILE16 hf16 ) /* [in] open file, if filename is NULL */ |
| 100 | { |
| 101 | BOOL16 ret = FALSE; |
| 102 | IMAGE_DOS_HEADER mzh; |
| 103 | OFSTRUCT ofs; |
| 104 | DWORD xmagic; |
| 105 | HFILE hf; |
| 106 | |
| 107 | if (fn) hf = OpenFile(fn,&ofs,OF_READ); |
Alexandre Julliard | b34fb35 | 2002-10-18 23:48:57 +0000 | [diff] [blame] | 108 | else hf = (HFILE)DosFileHandleToWin32Handle( hf16 ); |
Alexandre Julliard | 2682bc2 | 2000-11-27 22:03:23 +0000 | [diff] [blame] | 109 | if (hf == HFILE_ERROR) return FALSE; |
| 110 | _llseek(hf,0,SEEK_SET); |
| 111 | if (sizeof(mzh)!=_lread(hf,&mzh,sizeof(mzh))) goto done; |
| 112 | if (mzh.e_magic!=IMAGE_DOS_SIGNATURE) goto done; |
| 113 | _llseek(hf,mzh.e_lfanew,SEEK_SET); |
| 114 | if (sizeof(DWORD)!=_lread(hf,&xmagic,sizeof(DWORD))) goto done; |
| 115 | ret = (xmagic == IMAGE_NT_SIGNATURE); |
| 116 | done: |
| 117 | if (fn) _lclose(hf); |
| 118 | return ret; |
| 119 | } |