annotate loader/resource.c @ 34221:12bcb27faa26

Do not create a 0-sized palette side data from extradata. Fixes decoding of interplay video files.
author reimar
date Sun, 06 Nov 2011 00:26:16 +0000
parents 0f1b5b68af32
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * Resources
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Copyright 1993 Robert J. Amstadt
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * Copyright 1995 Alexandre Julliard
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 11000
diff changeset
6 *
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 15166
diff changeset
7 * Modified for use with MPlayer, detailed changelog at
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 15166
diff changeset
8 * http://svn.mplayerhq.hu/mplayer/trunk/
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 11000
diff changeset
9 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 */
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
11 #include "config.h"
21261
a2e02e6b6379 Rename config.h --> debug.h and include config.h explicitly.
diego
parents: 18783
diff changeset
12 #include "debug.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <assert.h>
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 1
diff changeset
15 #include <stdio.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <sys/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <sys/stat.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include <unistd.h>
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
22
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
23 #include "wine/winbase.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
24 #include "wine/windef.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
25 #include "wine/winuser.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
26 #include "wine/heap.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
27 #include "wine/module.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
28 #include "wine/debugtools.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
29 #include "wine/winerror.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
30 #include "loader.h"
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 1
diff changeset
31
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 #define CP_ACP 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 WORD WINE_LanguageId=0x409;//english
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 #define HRSRC_MAP_BLOCKSIZE 16
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24386
diff changeset
38 typedef struct HRSRC_ELEM
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 HANDLE hRsrc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 WORD type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 } HRSRC_ELEM;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24386
diff changeset
44 typedef struct HRSRC_MAP
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 int nAlloc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 int nUsed;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 HRSRC_ELEM *elem;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 } HRSRC_MAP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 LPCSTR name, WORD lang, int unicode)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 HRSRC hRsrc = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
55 LPWSTR typeStr, nameStr;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 if(!wm)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
59 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 /* 32-bit PE module */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
62
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 if ( HIWORD( type ) && (!unicode))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 typeStr = (LPWSTR)type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 if ( HIWORD( name ) && (!unicode))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 nameStr = (LPWSTR)name;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
71
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
73
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
74 if ( HIWORD( type ) && (!unicode))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 HeapFree( GetProcessHeap(), 0, typeStr );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
76 if ( HIWORD( name ) && (!unicode))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 HeapFree( GetProcessHeap(), 0, nameStr );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 return hRsrc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 * RES_FindResource
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 static HRSRC RES_FindResource( HMODULE hModule, LPCSTR type,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 LPCSTR name, WORD lang, int unicode )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 HRSRC hRsrc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 // __TRY
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 // {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 hRsrc = RES_FindResource2(hModule, type, name, lang, unicode);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 // }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 // __EXCEPT(page_fault)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 // {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 // WARN("page fault\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 // SetLastError(ERROR_INVALID_PARAMETER);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 // return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 // }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 // __ENDTRY
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 return hRsrc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 * RES_SizeofResource
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 DWORD size = 0;
24386
3a8d72016ed7 warning fixes:
diego
parents: 21261
diff changeset
110 // HRSRC hRsrc32;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 // HMODULE16 hMod16 = MapHModuleLS( hModule );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 // NE_MODULE *pModule = NE_GetPtr( hMod16 );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
114 // WINE_MODREF *wm = pModule && pModule->module32?
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 // MODULE32_LookupHMODULE( pModule->module32 ) : NULL;
25797
89f34e147606 Comment out unused variables, fixes the warnings:
diego
parents: 25794
diff changeset
116 // WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 if ( !hModule || !hRsrc ) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 /* 32-bit PE module */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 /* If we got a 16-bit hRsrc, convert it */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 // hRsrc32 = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 if(!HIWORD(hRsrc))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 printf("16-bit hRsrcs not supported\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
127 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 size = PE_SizeofResource( hModule, hRsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 return size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 * RES_AccessResource
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 static HFILE RES_AccessResource( HMODULE hModule, HRSRC hRsrc )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 HFILE hFile = HFILE_ERROR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138
25797
89f34e147606 Comment out unused variables, fixes the warnings:
diego
parents: 25794
diff changeset
139 // WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 if ( !hModule || !hRsrc ) return HFILE_ERROR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 /* 32-bit PE module */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 FIXME("32-bit modules not yet supported.\n" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 hFile = HFILE_ERROR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 return hFile;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 * RES_LoadResource
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 HGLOBAL hMem = 0;
24386
3a8d72016ed7 warning fixes:
diego
parents: 21261
diff changeset
156 // HRSRC hRsrc32;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 if ( !hModule || !hRsrc ) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 /* 32-bit PE module */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 /* If we got a 16-bit hRsrc, convert it */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 // hRsrc32 = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 if(!HIWORD(hRsrc))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 printf("16-bit hRsrcs not supported\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 hMem = PE_LoadResource( wm, hRsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 return hMem;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 * RES_LockResource
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 static LPVOID RES_LockResource( HGLOBAL handle )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 LPVOID bits = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 TRACE("(%08x, %s)\n", handle, "PE" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 bits = (LPVOID)handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 return bits;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 * RES_FreeResource
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 static WIN_BOOL RES_FreeResource( HGLOBAL handle )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 HGLOBAL retv = handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 return (WIN_BOOL)retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 * FindResourceA (KERNEL32.128)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 HANDLE WINAPI FindResourceA( HMODULE hModule, LPCSTR name, LPCSTR type )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
204 return RES_FindResource( hModule, type, name,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 WINE_LanguageId, 0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 HANDLE WINAPI FindResourceW( HMODULE hModule, LPCWSTR name, LPCWSTR type )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
209 return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 WINE_LanguageId, 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 * FindResourceExA (KERNEL32.129)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
216 HANDLE WINAPI FindResourceExA( HMODULE hModule,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 LPCSTR type, LPCSTR name, WORD lang )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
219 return RES_FindResource( hModule, type, name,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 lang, 0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
223 HANDLE WINAPI FindResourceExW( HMODULE hModule,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 LPCWSTR type, LPCWSTR name, WORD lang )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
226 return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 lang, 1 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 * LockResource (KERNEL32.384)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 LPVOID WINAPI LockResource( HGLOBAL handle )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 return RES_LockResource( handle );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 * FreeResource (KERNEL32.145)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 WIN_BOOL WINAPI FreeResource( HGLOBAL handle )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 return RES_FreeResource( handle );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 * AccessResource (KERNEL32.64)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 INT WINAPI AccessResource( HMODULE hModule, HRSRC hRsrc )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 return RES_AccessResource( hModule, hRsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 * SizeofResource (KERNEL32.522)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 DWORD WINAPI SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 return RES_SizeofResource( hModule, hRsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 LPWSTR buffer, INT buflen );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 * LoadStringA (USER32.375)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 LPSTR buffer, INT buflen )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 INT retval;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 INT wbuflen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 INT abuflen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 LPWSTR wbuf = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 LPSTR abuf = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 if ( buffer != NULL && buflen > 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 *buffer = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 wbuflen = LoadStringW(instance,resource_id,NULL,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 if ( !wbuflen )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 wbuflen ++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 retval = 0;
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
290 wbuf = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, wbuflen * sizeof(WCHAR) );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 wbuflen = LoadStringW(instance,resource_id,wbuf,wbuflen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 if ( wbuflen > 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,NULL,0,NULL,NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 if ( abuflen > 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 if ( buffer == NULL || buflen == 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 retval = abuflen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
301 abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 if ( abuflen > 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 abuflen = min(abuflen,buflen - 1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 memcpy( buffer, abuf, abuflen );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 buffer[abuflen] = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 retval = abuflen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 HeapFree( GetProcessHeap(), 0, abuf );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 HeapFree( GetProcessHeap(), 0, wbuf );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 return retval;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 * LoadStringW (USER32.376)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 LPWSTR buffer, INT buflen )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 HGLOBAL hmem;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 HRSRC hrsrc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 WCHAR *p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 int string_num;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 if (HIWORD(resource_id)==0xFFFF) /* netscape 3 passes this */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 resource_id = (UINT)(-((INT)resource_id));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 TRACE("instance = %04x, id = %04x, buffer = %08x, "
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
336 /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 * 20 - 31. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 hrsrc = FindResourceW( instance, (LPCWSTR)(((resource_id>>4)&0xffff)+1),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 RT_STRINGW );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 if (!hrsrc) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 hmem = LoadResource( instance, hrsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 if (!hmem) return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
343
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 1307
diff changeset
344 p = (WCHAR*) LockResource(hmem);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 string_num = resource_id & 0x000f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 for (i = 0; i < string_num; i++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347 p += *p + 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
348
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 TRACE("strlen = %d\n", (int)*p );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
350
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 if (buffer == NULL) return *p;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 i = min(buflen - 1, *p);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 if (i > 0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 memcpy(buffer, p + 1, i * sizeof (WCHAR));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 buffer[i] = (WCHAR) 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 if (buflen > 1) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 buffer[0] = (WCHAR) 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 #if 0
11000
6e35326c742f many small typo and grammar fixes
gabucino
parents: 7386
diff changeset
362 WARN("Don't know why caller give buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 TRACE("String loaded !\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 return i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 /* Messages...used by FormatMessage32* (KERNEL32.something)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
371 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 * They can be specified either directly or using a message ID and
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 * loading them from the resource.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
374 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 * The resourcedata has following format:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 * start:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 * 0: DWORD nrofentries
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 * nrofentries * subentry:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 * 0: DWORD firstentry
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 * 4: DWORD lastentry
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 * 8: DWORD offset from start to the stringentries
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 * (lastentry-firstentry) * stringentry:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 * 0: WORD len (0 marks end)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 * 2: WORD flags
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 * 4: CHAR[len-4]
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 * (stringentry i of a subentry refers to the ID 'firstentry+i')
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 * Yes, ANSI strings in win32 resources. Go figure.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 * LoadMessageA (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 LPSTR buffer, INT buflen )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 HGLOBAL hmem;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 HRSRC hrsrc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 PMESSAGE_RESOURCE_DATA mrd;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 PMESSAGE_RESOURCE_BLOCK mrb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 PMESSAGE_RESOURCE_ENTRY mre;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 int i,slen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 TRACE("instance = %08lx, id = %08lx, buffer = %p, length = %ld\n", (DWORD)instance, (DWORD)id, buffer, (DWORD)buflen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 /*FIXME: I am not sure about the '1' ... But I've only seen those entries*/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 hrsrc = FindResourceExW(instance,RT_MESSAGELISTW,(LPWSTR)1,lang);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 if (!hrsrc) return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 hmem = LoadResource( instance, hrsrc );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 if (!hmem) return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 25849
diff changeset
412
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 mrd = (PMESSAGE_RESOURCE_DATA)LockResource(hmem);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 mre = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 mrb = &(mrd->Blocks[0]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 for (i=mrd->NumberOfBlocks;i--;) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 id -= mrb->LowId;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 mrb++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 if (!mre)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 for (i=id;i--;) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 if (!mre->Length)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 slen=mre->Length;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 TRACE(" - strlen=%d\n",slen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 i = min(buflen - 1, slen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 if (buffer == NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435 return slen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 if (i>0) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 lstrcpynA(buffer,(char*)mre->Text,i);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 buffer[i]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 if (buflen>1) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 buffer[0]=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445 if (buffer)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 TRACE("'%s' copied !\n", buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447 return i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 * EnumResourceTypesA (KERNEL32.90)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 WIN_BOOL WINAPI EnumResourceTypesA( HMODULE hmodule,ENUMRESTYPEPROCA lpfun,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 LONG lParam)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 /* FIXME: move WINE_MODREF stuff here */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 return PE_EnumResourceTypesA(hmodule,lpfun,lParam);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 * EnumResourceNamesA (KERNEL32.88)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 WIN_BOOL WINAPI EnumResourceNamesA( HMODULE hmodule, LPCSTR type,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466 ENUMRESNAMEPROCA lpfun, LONG lParam )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468 /* FIXME: move WINE_MODREF stuff here */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 return PE_EnumResourceNamesA(hmodule,type,lpfun,lParam);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 * EnumResourceLanguagesA (KERNEL32.86)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 WIN_BOOL WINAPI EnumResourceLanguagesA( HMODULE hmodule, LPCSTR type,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 LPCSTR name, ENUMRESLANGPROCA lpfun,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
476 LONG lParam)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
477 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
478 /* FIXME: move WINE_MODREF stuff here */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
479 return PE_EnumResourceLanguagesA(hmodule,type,name,lpfun,lParam);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 /**********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 * LoadResource (KERNEL32.370)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
483 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
484 HGLOBAL WINAPI LoadResource( HINSTANCE hModule, HRSRC hRsrc )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
485 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
486 return RES_LoadResource( hModule, hRsrc);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 }