LoadStringA inserts terminating null in the buffer when the string
[wine] / dlls / version / ver16.c
1 /*
2  * Implementation of VER.DLL
3  *
4  * Copyright 1999 Ulrich Weigand
5  */
6
7 #include "winbase.h"
8 #include "wine/winbase16.h"
9 #include "winver.h"
10 #include "ldt.h"
11 #include "debugtools.h"
12
13 DEFAULT_DEBUG_CHANNEL(ver);
14
15
16 /*************************************************************************
17  * GetFileResourceSize16                     [VER.2]
18  */
19 DWORD WINAPI GetFileResourceSize16( LPCSTR lpszFileName, 
20                                     SEGPTR spszResType, SEGPTR spszResId,
21                                     LPDWORD lpdwFileOffset )
22 {
23     LPCSTR lpszResType = HIWORD( spszResType )? PTR_SEG_TO_LIN( spszResType )
24                                               : (LPCSTR)spszResType;
25     LPCSTR lpszResId = HIWORD( spszResId )? PTR_SEG_TO_LIN( spszResId )
26                                           : (LPCSTR)spszResId;
27
28     return GetFileResourceSize( lpszFileName, 
29                                   lpszResType, lpszResId, lpdwFileOffset );
30 }
31
32 /*************************************************************************
33  * GetFileResource16                         [VER.3]
34  */
35 DWORD WINAPI GetFileResource16( LPCSTR lpszFileName, 
36                                 SEGPTR spszResType, SEGPTR spszResId,
37                                 DWORD dwFileOffset, 
38                                 DWORD dwResLen, LPVOID lpvData )
39 {
40     LPCSTR lpszResType = HIWORD( spszResType )? PTR_SEG_TO_LIN( spszResType )
41                                               : (LPCSTR)spszResType;
42     LPCSTR lpszResId = HIWORD( spszResId )? PTR_SEG_TO_LIN( spszResId )
43                                           : (LPCSTR)spszResId;
44
45     return GetFileResource( lpszFileName, lpszResType, lpszResId,
46                               dwFileOffset, dwResLen, lpvData );
47 }
48
49 /*************************************************************************
50  * GetFileVersionInfoSize16                  [VER.6]
51  */
52 DWORD WINAPI GetFileVersionInfoSize16( LPCSTR lpszFileName, LPDWORD lpdwHandle )
53 {
54     TRACE("(%s, %p)\n", debugstr_a(lpszFileName), lpdwHandle );
55     return GetFileVersionInfoSizeA( lpszFileName, lpdwHandle );
56 }
57
58 /*************************************************************************
59  * GetFileVersionInfo16                      [VER.7]
60  */
61 DWORD WINAPI GetFileVersionInfo16( LPCSTR lpszFileName, DWORD handle,
62                                    DWORD cbBuf, LPVOID lpvData )
63 {
64     TRACE("(%s, %08lx, %ld, %p)\n", 
65                 debugstr_a(lpszFileName), handle, cbBuf, lpvData );
66
67     return GetFileVersionInfoA( lpszFileName, handle, cbBuf, lpvData );
68 }
69
70 /*************************************************************************
71  * VerFindFile16                             [VER.8]
72  */
73 DWORD WINAPI VerFindFile16( UINT16 flags, LPCSTR lpszFilename, 
74                             LPCSTR lpszWinDir, LPCSTR lpszAppDir,
75                             LPSTR lpszCurDir, UINT16 *lpuCurDirLen,
76                             LPSTR lpszDestDir, UINT16 *lpuDestDirLen )
77 {
78     UINT curDirLen, destDirLen;
79     DWORD retv = VerFindFileA( flags, lpszFilename, lpszWinDir, lpszAppDir,
80                                  lpszCurDir, &curDirLen, lpszDestDir, &destDirLen );
81
82     *lpuCurDirLen = (UINT16)curDirLen;
83     *lpuDestDirLen = (UINT16)destDirLen;
84     return retv;
85 }
86
87 /*************************************************************************
88  * VerInstallFile16                          [VER.9]
89  */
90 DWORD WINAPI VerInstallFile16( UINT16 flags, 
91                                LPCSTR lpszSrcFilename, LPCSTR lpszDestFilename, 
92                                LPCSTR lpszSrcDir, LPCSTR lpszDestDir, LPCSTR lpszCurDir,
93                                LPSTR lpszTmpFile, UINT16 *lpwTmpFileLen )
94 {
95     UINT filelen;
96     DWORD retv = VerInstallFileA( flags, lpszSrcFilename, lpszDestFilename, 
97                                     lpszSrcDir, lpszDestDir, lpszCurDir, 
98                                     lpszTmpFile, &filelen);
99
100     *lpwTmpFileLen = (UINT16)filelen;
101     return retv;
102 }
103
104 /*************************************************************************
105  * VerLanguageName16                        [VER.10]
106  */
107 DWORD WINAPI VerLanguageName16( UINT16 uLang, LPSTR lpszLang, UINT16 cbLang )
108 {
109     return VerLanguageNameA( uLang, lpszLang, cbLang );
110 }
111
112 /*************************************************************************
113  * VerQueryValue16                          [VER.11]
114  */
115 DWORD WINAPI VerQueryValue16( SEGPTR spvBlock, LPCSTR lpszSubBlock, 
116                               SEGPTR *lpspBuffer, UINT16 *lpcb )
117 {
118     LPVOID lpvBlock = PTR_SEG_TO_LIN( spvBlock );
119     LPVOID buffer = lpvBlock;
120     UINT buflen;
121     DWORD retv;
122
123     TRACE("(%p, %s, %p, %p)\n", 
124                 lpvBlock, debugstr_a(lpszSubBlock), lpspBuffer, lpcb );
125
126     retv = VerQueryValueA( lpvBlock, lpszSubBlock, &buffer, &buflen );
127     if ( !retv ) return FALSE;
128
129     if ( OFFSETOF( spvBlock ) + ((char *) buffer - (char *) lpvBlock) >= 0x10000 )
130     {
131         FIXME("offset %08X too large relative to %04X:%04X\n",
132                (char *) buffer - (char *) lpvBlock, SELECTOROF( spvBlock ), OFFSETOF( spvBlock ) );
133         return FALSE;
134     }
135
136     if (lpcb) *lpcb = buflen;
137     *lpspBuffer = (SEGPTR) ((char *) spvBlock + ((char *) buffer - (char *) lpvBlock));
138
139     return retv;
140 }
141