2 * Implementation of VER.DLL
4 * Copyright 1999 Ulrich Weigand
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/winbase16.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ver
);
32 extern DWORD
find_resource( HFILE lzfd
, LPCSTR type
, LPCSTR id
, DWORD
*reslen
, DWORD
*offset
);
34 /*************************************************************************
35 * GetFileResourceSize [VER.2]
37 DWORD WINAPI
GetFileResourceSize16( LPCSTR lpszFileName
, LPCSTR lpszResType
,
38 LPCSTR lpszResId
, LPDWORD lpdwFileOffset
)
44 TRACE("(%s,type=%p,id=%p,off=%p)\n",
45 debugstr_a(lpszFileName
), lpszResType
, lpszResId
, lpszResId
);
47 lzfd
= LZOpenFileA( (LPSTR
)lpszFileName
, &ofs
, OF_READ
);
50 if (!find_resource( lzfd
, lpszResType
, lpszResId
, &reslen
, lpdwFileOffset
)) reslen
= 0;
57 /*************************************************************************
58 * GetFileResource [VER.3]
60 DWORD WINAPI
GetFileResource16( LPCSTR lpszFileName
, LPCSTR lpszResType
,
61 LPCSTR lpszResId
, DWORD dwFileOffset
,
62 DWORD dwResLen
, LPVOID lpvData
)
66 DWORD reslen
= dwResLen
;
68 TRACE("(%s,type=%p,id=%p,off=%d,len=%d,data=%p)\n",
69 debugstr_a(lpszFileName
), lpszResType
, lpszResId
,
70 dwFileOffset
, dwResLen
, lpvData
);
72 lzfd
= LZOpenFileA( (LPSTR
)lpszFileName
, &ofs
, OF_READ
);
73 if ( lzfd
< 0 ) return 0;
77 if (!find_resource( lzfd
, lpszResType
, lpszResId
, &reslen
, &dwFileOffset
))
84 LZSeek( lzfd
, dwFileOffset
, 0 /* SEEK_SET */ );
85 reslen
= LZRead( lzfd
, lpvData
, min( reslen
, dwResLen
) );
91 /*************************************************************************
92 * GetFileVersionInfoSize [VER.6]
94 DWORD WINAPI
GetFileVersionInfoSize16( LPCSTR lpszFileName
, LPDWORD lpdwHandle
)
96 TRACE("(%s, %p)\n", debugstr_a(lpszFileName
), lpdwHandle
);
97 return GetFileVersionInfoSizeA( lpszFileName
, lpdwHandle
);
100 /*************************************************************************
101 * GetFileVersionInfo [VER.7]
103 DWORD WINAPI
GetFileVersionInfo16( LPCSTR lpszFileName
, DWORD handle
,
104 DWORD cbBuf
, LPVOID lpvData
)
106 TRACE("(%s, %08x, %d, %p)\n",
107 debugstr_a(lpszFileName
), handle
, cbBuf
, lpvData
);
109 return GetFileVersionInfoA( lpszFileName
, handle
, cbBuf
, lpvData
);
112 /*************************************************************************
113 * VerFindFile [VER.8]
115 DWORD WINAPI
VerFindFile16( UINT16 flags
, LPSTR lpszFilename
,
116 LPSTR lpszWinDir
, LPSTR lpszAppDir
,
117 LPSTR lpszCurDir
, UINT16
*lpuCurDirLen
,
118 LPSTR lpszDestDir
, UINT16
*lpuDestDirLen
)
120 UINT curDirLen
, destDirLen
;
121 DWORD retv
= VerFindFileA( flags
, lpszFilename
, lpszWinDir
, lpszAppDir
,
122 lpszCurDir
, &curDirLen
, lpszDestDir
, &destDirLen
);
124 *lpuCurDirLen
= (UINT16
)curDirLen
;
125 *lpuDestDirLen
= (UINT16
)destDirLen
;
129 /*************************************************************************
130 * VerInstallFile [VER.9]
132 DWORD WINAPI
VerInstallFile16( UINT16 flags
,
133 LPSTR lpszSrcFilename
, LPSTR lpszDestFilename
,
134 LPSTR lpszSrcDir
, LPSTR lpszDestDir
, LPSTR lpszCurDir
,
135 LPSTR lpszTmpFile
, UINT16
*lpwTmpFileLen
)
138 DWORD retv
= VerInstallFileA( flags
, lpszSrcFilename
, lpszDestFilename
,
139 lpszSrcDir
, lpszDestDir
, lpszCurDir
,
140 lpszTmpFile
, &filelen
);
142 *lpwTmpFileLen
= (UINT16
)filelen
;
146 /*************************************************************************
147 * VerLanguageName [VER.10]
149 DWORD WINAPI
VerLanguageName16( UINT16 uLang
, LPSTR lpszLang
, UINT16 cbLang
)
151 return VerLanguageNameA( uLang
, lpszLang
, cbLang
);
154 /*************************************************************************
155 * VerQueryValue [VER.11]
157 DWORD WINAPI
VerQueryValue16( SEGPTR spvBlock
, LPSTR lpszSubBlock
,
158 SEGPTR
*lpspBuffer
, UINT16
*lpcb
)
160 LPVOID lpvBlock
= MapSL( spvBlock
);
161 LPVOID buffer
= lpvBlock
;
165 TRACE("(%p, %s, %p, %p)\n",
166 lpvBlock
, debugstr_a(lpszSubBlock
), lpspBuffer
, lpcb
);
168 retv
= VerQueryValueA( lpvBlock
, lpszSubBlock
, &buffer
, &buflen
);
169 if ( !retv
) return FALSE
;
171 if ( OFFSETOF( spvBlock
) + ((char *) buffer
- (char *) lpvBlock
) >= 0x10000 )
173 FIXME("offset %08X too large relative to %04X:%04X\n",
174 (char *) buffer
- (char *) lpvBlock
, SELECTOROF( spvBlock
), OFFSETOF( spvBlock
) );
178 if (lpcb
) *lpcb
= buflen
;
179 *lpspBuffer
= (SEGPTR
) ((char *) spvBlock
+ ((char *) buffer
- (char *) lpvBlock
));