annotate loader/resource.c @ 10612:8e678e833591

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