Removed dependency on ntdll_misc.h.
[wine/wine64.git] / loader / ne / module.c
blob2b7556e04963d4ff3ebec9072f9e72e788b61fbb
1 /*
2 * NE modules
4 * Copyright 1995 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <assert.h>
25 #include <fcntl.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #ifdef HAVE_UNISTD_H
31 # include <unistd.h>
32 #endif
33 #include <ctype.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wine/winbase16.h"
38 #include "wine/library.h"
39 #include "winerror.h"
40 #include "module.h"
41 #include "toolhelp.h"
42 #include "file.h"
43 #include "task.h"
44 #include "builtin16.h"
45 #include "stackframe.h"
46 #include "excpt.h"
47 #include "wine/exception.h"
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(module);
51 WINE_DECLARE_DEBUG_CHANNEL(loaddll);
53 #define hFirstModule (pThhook->hExeHead)
56 /***********************************************************************
57 * NE_GetPtr
59 NE_MODULE *NE_GetPtr( HMODULE16 hModule )
61 return (NE_MODULE *)GlobalLock16( GetExePtr(hModule) );
65 /**********************************************************************
66 * GetModuleFileName (KERNEL.49)
68 * Comment: see GetModuleFileNameA
70 * Even if invoked by second instance of a program,
71 * it still returns path of first one.
73 INT16 WINAPI GetModuleFileName16( HINSTANCE16 hModule, LPSTR lpFileName,
74 INT16 nSize )
76 NE_MODULE *pModule;
78 /* Win95 does not query hModule if set to 0 !
79 * Is this wrong or maybe Win3.1 only ? */
80 if (!hModule) hModule = GetCurrentTask();
82 if (!(pModule = NE_GetPtr( hModule ))) return 0;
83 lstrcpynA( lpFileName, NE_MODULE_NAME(pModule), nSize );
84 if (pModule->expected_version >= 0x400)
85 GetLongPathNameA(NE_MODULE_NAME(pModule), lpFileName, nSize);
86 TRACE("%04x -> '%s'\n", hModule, lpFileName );
87 return strlen(lpFileName);