annotate loader/resource.c @ 24047:de28f9e8cb00

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