annotate loader/resource.c @ 5764:1e07af707b15

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