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
22 #include "wine/port.h"
37 #include "wine/winbase16.h"
38 #include "wine/library.h"
44 #include "builtin16.h"
45 #include "stackframe.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 /***********************************************************************
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
,
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
);