msi: Properly register and unregister components.
[wine] / dlls / version / ver16.c
1 /*
2  * Implementation of VER.DLL
3  *
4  * Copyright 1999 Ulrich Weigand
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "wine/winbase16.h"
25 #include "winver.h"
26 #include "wine/debug.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(ver);
29
30
31 /*************************************************************************
32  * GetFileVersionInfoSize                  [VER.6]
33  */
34 DWORD WINAPI GetFileVersionInfoSize16( LPCSTR lpszFileName, LPDWORD lpdwHandle )
35 {
36     TRACE("(%s, %p)\n", debugstr_a(lpszFileName), lpdwHandle );
37     return GetFileVersionInfoSizeA( lpszFileName, lpdwHandle );
38 }
39
40 /*************************************************************************
41  * GetFileVersionInfo                      [VER.7]
42  */
43 DWORD WINAPI GetFileVersionInfo16( LPCSTR lpszFileName, DWORD handle,
44                                    DWORD cbBuf, LPVOID lpvData )
45 {
46     TRACE("(%s, %08x, %d, %p)\n",
47                 debugstr_a(lpszFileName), handle, cbBuf, lpvData );
48
49     return GetFileVersionInfoA( lpszFileName, handle, cbBuf, lpvData );
50 }
51
52 /*************************************************************************
53  * VerFindFile                             [VER.8]
54  */
55 DWORD WINAPI VerFindFile16( UINT16 flags, LPSTR lpszFilename,
56                             LPSTR lpszWinDir, LPSTR lpszAppDir,
57                             LPSTR lpszCurDir, UINT16 *lpuCurDirLen,
58                             LPSTR lpszDestDir, UINT16 *lpuDestDirLen )
59 {
60     UINT curDirLen, destDirLen;
61     DWORD retv = VerFindFileA( flags, lpszFilename, lpszWinDir, lpszAppDir,
62                                  lpszCurDir, &curDirLen, lpszDestDir, &destDirLen );
63
64     *lpuCurDirLen = (UINT16)curDirLen;
65     *lpuDestDirLen = (UINT16)destDirLen;
66     return retv;
67 }
68
69 /*************************************************************************
70  * VerInstallFile                          [VER.9]
71  */
72 DWORD WINAPI VerInstallFile16( UINT16 flags,
73                                LPSTR lpszSrcFilename, LPSTR lpszDestFilename,
74                                LPSTR lpszSrcDir, LPSTR lpszDestDir, LPSTR lpszCurDir,
75                                LPSTR lpszTmpFile, UINT16 *lpwTmpFileLen )
76 {
77     UINT filelen;
78     DWORD retv = VerInstallFileA( flags, lpszSrcFilename, lpszDestFilename,
79                                     lpszSrcDir, lpszDestDir, lpszCurDir,
80                                     lpszTmpFile, &filelen);
81
82     *lpwTmpFileLen = (UINT16)filelen;
83     return retv;
84 }
85
86 /*************************************************************************
87  * VerLanguageName                        [VER.10]
88  */
89 DWORD WINAPI VerLanguageName16( UINT16 uLang, LPSTR lpszLang, UINT16 cbLang )
90 {
91     return VerLanguageNameA( uLang, lpszLang, cbLang );
92 }
93
94 /*************************************************************************
95  * VerQueryValue                          [VER.11]
96  */
97 DWORD WINAPI VerQueryValue16( SEGPTR spvBlock, LPSTR lpszSubBlock,
98                               SEGPTR *lpspBuffer, UINT16 *lpcb )
99 {
100     LPVOID lpvBlock = MapSL( spvBlock );
101     LPVOID buffer = lpvBlock;
102     UINT buflen;
103     DWORD retv;
104
105     TRACE("(%p, %s, %p, %p)\n",
106                 lpvBlock, debugstr_a(lpszSubBlock), lpspBuffer, lpcb );
107
108     retv = VerQueryValueA( lpvBlock, lpszSubBlock, &buffer, &buflen );
109     if ( !retv ) return FALSE;
110
111     if ( OFFSETOF( spvBlock ) + ((char *) buffer - (char *) lpvBlock) >= 0x10000 )
112     {
113         FIXME("offset %08X too large relative to %04X:%04X\n",
114                (char *) buffer - (char *) lpvBlock, SELECTOROF( spvBlock ), OFFSETOF( spvBlock ) );
115         return FALSE;
116     }
117
118     if (lpcb) *lpcb = buflen;
119     *lpspBuffer = (SEGPTR) ((char *) spvBlock + ((char *) buffer - (char *) lpvBlock));
120
121     return retv;
122 }