1 | /*
|
---|
2 | * Shell Library Functions
|
---|
3 | *
|
---|
4 | * 1998 Marcus Meissner
|
---|
5 | */
|
---|
6 | #include <assert.h>
|
---|
7 | #include <stdlib.h>
|
---|
8 | #include <string.h>
|
---|
9 | //#include <unistd.h>
|
---|
10 | #include <ctype.h>
|
---|
11 |
|
---|
12 | #include <odin.h>
|
---|
13 |
|
---|
14 | #define ICOM_CINTERFACE 1
|
---|
15 | #define CINTERFACE 1
|
---|
16 |
|
---|
17 | //#include "wine/winuser16.h"
|
---|
18 | //#include "wine/winbase16.h"
|
---|
19 | //#include "wine/shell16.h"
|
---|
20 | #include "winerror.h"
|
---|
21 | //#include "file.h"
|
---|
22 | #include "heap.h"
|
---|
23 | #include "ldt.h"
|
---|
24 | #include "module.h"
|
---|
25 | #include "neexe.h"
|
---|
26 | #include "dlgs.h"
|
---|
27 | #include "cursoricon.h"
|
---|
28 | #include "shellapi.h"
|
---|
29 | #include "shlobj.h"
|
---|
30 | #include "debugtools.h"
|
---|
31 | #include "winreg.h"
|
---|
32 | //#include "syslevel.h"
|
---|
33 | #include "imagelist.h"
|
---|
34 |
|
---|
35 | #include <heapstring.h>
|
---|
36 | #include <misc.h>
|
---|
37 |
|
---|
38 | DECLARE_DEBUG_CHANNEL(exec)
|
---|
39 | DECLARE_DEBUG_CHANNEL(shell)
|
---|
40 |
|
---|
41 | /* .ICO file ICONDIR definitions */
|
---|
42 |
|
---|
43 | #include "pshpack1.h"
|
---|
44 |
|
---|
45 | typedef struct
|
---|
46 | {
|
---|
47 | BYTE bWidth; /* Width, in pixels, of the image */
|
---|
48 | BYTE bHeight; /* Height, in pixels, of the image */
|
---|
49 | BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */
|
---|
50 | BYTE bReserved; /* Reserved ( must be 0) */
|
---|
51 | WORD wPlanes; /* Color Planes */
|
---|
52 | WORD wBitCount; /* Bits per pixel */
|
---|
53 | DWORD dwBytesInRes; /* How many bytes in this resource? */
|
---|
54 | DWORD dwImageOffset; /* Where in the file is this image? */
|
---|
55 | } icoICONDIRENTRY, *LPicoICONDIRENTRY;
|
---|
56 |
|
---|
57 | typedef struct
|
---|
58 | {
|
---|
59 | WORD idReserved; /* Reserved (must be 0) */
|
---|
60 | WORD idType; /* Resource Type (1 for icons) */
|
---|
61 | WORD idCount; /* How many images? */
|
---|
62 | icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */
|
---|
63 | } icoICONDIR, *LPicoICONDIR;
|
---|
64 |
|
---|
65 | #include "poppack.h"
|
---|
66 |
|
---|
67 | static const char* lpstrMsgWndCreated = "OTHERWINDOWCREATED";
|
---|
68 | static const char* lpstrMsgWndDestroyed = "OTHERWINDOWDESTROYED";
|
---|
69 | static const char* lpstrMsgShellActivate = "ACTIVATESHELLWINDOW";
|
---|
70 |
|
---|
71 | static HWND16 SHELL_hWnd = 0;
|
---|
72 | static HHOOK SHELL_hHook = 0;
|
---|
73 | static UINT16 uMsgWndCreated = 0;
|
---|
74 | static UINT16 uMsgWndDestroyed = 0;
|
---|
75 | static UINT16 uMsgShellActivate = 0;
|
---|
76 | HINSTANCE16 SHELL_hInstance = 0;
|
---|
77 | HINSTANCE SHELL_hInstance32;
|
---|
78 | static int SHELL_Attach = 0;
|
---|
79 |
|
---|
80 | /***********************************************************************
|
---|
81 | * SHELL_DllEntryPoint [SHELL.entry]
|
---|
82 | *
|
---|
83 | * Initialization code for shell.dll. Automatically loads the
|
---|
84 | * 32-bit shell32.dll to allow thunking up to 32-bit code.
|
---|
85 | *
|
---|
86 | * RETURNS:
|
---|
87 | */
|
---|
88 | BOOL WINAPI SHELL_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst,
|
---|
89 | WORD ds, WORD HeapSize, DWORD res1, WORD res2)
|
---|
90 | {
|
---|
91 | TRACE_(shell)("(%08lx, %04x, %04x, %04x, %08lx, %04x)\n",
|
---|
92 | Reason, hInst, ds, HeapSize, res1, res2);
|
---|
93 |
|
---|
94 | switch(Reason)
|
---|
95 | {
|
---|
96 | case DLL_PROCESS_ATTACH:
|
---|
97 | SHELL_Attach++;
|
---|
98 | if (SHELL_hInstance)
|
---|
99 | {
|
---|
100 | ERR_(shell)("shell.dll instantiated twice!\n");
|
---|
101 | /*
|
---|
102 | * We should return FALSE here, but that will break
|
---|
103 | * most apps that use CreateProcess because we do
|
---|
104 | * not yet support seperate address-spaces.
|
---|
105 | */
|
---|
106 | return TRUE;
|
---|
107 | }
|
---|
108 |
|
---|
109 | SHELL_hInstance = hInst;
|
---|
110 | if(!SHELL_hInstance32)
|
---|
111 | {
|
---|
112 | if(!(SHELL_hInstance32 = LoadLibraryA("shell32.dll")))
|
---|
113 | {
|
---|
114 | ERR_(shell)("Could not load sibling shell32.dll\n");
|
---|
115 | return FALSE;
|
---|
116 | }
|
---|
117 | }
|
---|
118 | break;
|
---|
119 |
|
---|
120 | case DLL_PROCESS_DETACH:
|
---|
121 | if(!--SHELL_Attach)
|
---|
122 | {
|
---|
123 | SHELL_hInstance = 0;
|
---|
124 | if(SHELL_hInstance32)
|
---|
125 | FreeLibrary(SHELL_hInstance32);
|
---|
126 | }
|
---|
127 | break;
|
---|
128 | }
|
---|
129 | return TRUE;
|
---|
130 | }
|
---|
131 |
|
---|
132 | /*************************************************************************
|
---|
133 | * DragAcceptFiles32 [SHELL32.54]
|
---|
134 | */
|
---|
135 | void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
|
---|
136 | {
|
---|
137 | LONG exstyle;
|
---|
138 |
|
---|
139 |
|
---|
140 | if( !IsWindow(hWnd) )
|
---|
141 | return;
|
---|
142 | exstyle = GetWindowLongA(hWnd,GWL_EXSTYLE);
|
---|
143 | if (b)exstyle |= WS_EX_ACCEPTFILES;
|
---|
144 | else exstyle &= ~WS_EX_ACCEPTFILES;
|
---|
145 | SetWindowLongA(hWnd,GWL_EXSTYLE,exstyle);
|
---|
146 | }
|
---|
147 |
|
---|
148 | /*************************************************************************
|
---|
149 | * SHELL_DragQueryFile [internal]
|
---|
150 | *
|
---|
151 | */
|
---|
152 | static UINT SHELL_DragQueryFile(LPSTR lpDrop, LPWSTR lpwDrop, UINT lFile,
|
---|
153 | LPSTR lpszFile, LPWSTR lpszwFile, UINT lLength)
|
---|
154 | {
|
---|
155 | UINT i;
|
---|
156 |
|
---|
157 | i = 0;
|
---|
158 | if (lpDrop) {
|
---|
159 | while (i++ < lFile) {
|
---|
160 | while (*lpDrop++); /* skip filename */
|
---|
161 | if (!*lpDrop)
|
---|
162 | return (lFile == 0xFFFFFFFF) ? i : 0;
|
---|
163 | }
|
---|
164 | }
|
---|
165 | if (lpwDrop) {
|
---|
166 | while (i++ < lFile) {
|
---|
167 | while (*lpwDrop++); /* skip filename */
|
---|
168 | if (!*lpwDrop)
|
---|
169 | return (lFile == 0xFFFFFFFF) ? i : 0;
|
---|
170 | }
|
---|
171 | }
|
---|
172 |
|
---|
173 | if (lpDrop) i = lstrlenA(lpDrop);
|
---|
174 | if (lpwDrop) i = lstrlenW(lpwDrop);
|
---|
175 | i++;
|
---|
176 | if (!lpszFile && !lpszwFile) {
|
---|
177 | return i; /* needed buffer size */
|
---|
178 | }
|
---|
179 | i = (lLength > i) ? i : lLength;
|
---|
180 | if (lpszFile) {
|
---|
181 | if (lpDrop) lstrcpynA (lpszFile, lpDrop, i);
|
---|
182 | else lstrcpynWtoA(lpszFile, lpwDrop, i);
|
---|
183 | } else {
|
---|
184 | if (lpDrop) lstrcpynAtoW(lpszwFile, lpDrop, i);
|
---|
185 | else lstrcpynW (lpszwFile, lpwDrop, i);
|
---|
186 | }
|
---|
187 | return i;
|
---|
188 | }
|
---|
189 |
|
---|
190 | /*************************************************************************
|
---|
191 | * DragQueryFile32A [SHELL32.81] [shell32.82]
|
---|
192 | */
|
---|
193 | UINT WINAPI DragQueryFileA(HDROP hDrop, UINT lFile, LPSTR lpszFile,
|
---|
194 | UINT lLength)
|
---|
195 | { /* hDrop is a global memory block allocated with GMEM_SHARE
|
---|
196 | * with DROPFILESTRUCT as a header and filenames following
|
---|
197 | * it, zero length filename is in the end */
|
---|
198 |
|
---|
199 | LPDROPFILESTRUCT lpDropFileStruct;
|
---|
200 | LPSTR lpCurrent;
|
---|
201 | UINT i;
|
---|
202 |
|
---|
203 | TRACE_(shell)("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength);
|
---|
204 |
|
---|
205 | lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
|
---|
206 | if(!lpDropFileStruct)
|
---|
207 | return 0;
|
---|
208 |
|
---|
209 | lpCurrent = (LPSTR) lpDropFileStruct + lpDropFileStruct->lSize;
|
---|
210 | i = SHELL_DragQueryFile(lpCurrent, NULL, lFile, lpszFile, NULL, lLength);
|
---|
211 | GlobalUnlock(hDrop);
|
---|
212 | return i;
|
---|
213 | }
|
---|
214 |
|
---|
215 | /*************************************************************************
|
---|
216 | * DragQueryFile32W [shell32.133]
|
---|
217 | */
|
---|
218 | UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile,
|
---|
219 | UINT lLength)
|
---|
220 | {
|
---|
221 | LPDROPFILESTRUCT lpDropFileStruct;
|
---|
222 | LPWSTR lpwCurrent;
|
---|
223 | UINT i;
|
---|
224 |
|
---|
225 | TRACE_(shell)("(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength);
|
---|
226 |
|
---|
227 | lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
|
---|
228 | if(!lpDropFileStruct)
|
---|
229 | return 0;
|
---|
230 |
|
---|
231 | lpwCurrent = (LPWSTR) lpDropFileStruct + lpDropFileStruct->lSize;
|
---|
232 | i = SHELL_DragQueryFile(NULL, lpwCurrent, lFile, NULL, lpszwFile,lLength);
|
---|
233 | GlobalUnlock(hDrop);
|
---|
234 | return i;
|
---|
235 | }
|
---|
236 |
|
---|
237 |
|
---|
238 | /*************************************************************************
|
---|
239 | * DragFinish32 [SHELL32.80]
|
---|
240 | */
|
---|
241 | void WINAPI DragFinish(HDROP h)
|
---|
242 | { TRACE_(shell)("\n");
|
---|
243 | GlobalFree((HGLOBAL)h);
|
---|
244 | }
|
---|
245 |
|
---|
246 | /*************************************************************************
|
---|
247 | * DragFinish16 [SHELL.12]
|
---|
248 | */
|
---|
249 | void WINAPI DragFinish16(HDROP16 h)
|
---|
250 | { TRACE_(shell)("\n");
|
---|
251 | GlobalFree16((HGLOBAL16)h);
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 | /*************************************************************************
|
---|
256 | * DragQueryPoint32 [SHELL32.135]
|
---|
257 | */
|
---|
258 | BOOL WINAPI DragQueryPoint(HDROP hDrop, POINT *p)
|
---|
259 | {
|
---|
260 | LPDROPFILESTRUCT lpDropFileStruct;
|
---|
261 | BOOL bRet;
|
---|
262 | TRACE_(shell)("\n");
|
---|
263 | lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
|
---|
264 |
|
---|
265 | memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT));
|
---|
266 | bRet = lpDropFileStruct->fInNonClientArea;
|
---|
267 |
|
---|
268 | GlobalUnlock(hDrop);
|
---|
269 | return bRet;
|
---|
270 | }
|
---|
271 |
|
---|
272 | /*************************************************************************
|
---|
273 | * DragQueryPoint16 [SHELL.13]
|
---|
274 | */
|
---|
275 | BOOL16 WINAPI DragQueryPoint16(HDROP16 hDrop, POINT16 *p)
|
---|
276 | {
|
---|
277 | LPDROPFILESTRUCT16 lpDropFileStruct;
|
---|
278 | BOOL16 bRet;
|
---|
279 | TRACE_(shell)("\n");
|
---|
280 | lpDropFileStruct = (LPDROPFILESTRUCT16) GlobalLock16(hDrop);
|
---|
281 |
|
---|
282 | memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT16));
|
---|
283 | bRet = lpDropFileStruct->fInNonClientArea;
|
---|
284 |
|
---|
285 | GlobalUnlock16(hDrop);
|
---|
286 | return bRet;
|
---|
287 | }
|
---|
288 |
|
---|
289 | /*************************************************************************
|
---|
290 | * SHELL_FindExecutable [Internal]
|
---|
291 | *
|
---|
292 | * Utility for code sharing between FindExecutable and ShellExecute
|
---|
293 | */
|
---|
294 | HINSTANCE SHELL_FindExecutable( LPCSTR lpFile,
|
---|
295 | LPCSTR lpOperation,
|
---|
296 | LPSTR lpResult)
|
---|
297 | { char *extension = NULL; /* pointer to file extension */
|
---|
298 | char tmpext[5]; /* local copy to mung as we please */
|
---|
299 | char filetype[256]; /* registry name for this filetype */
|
---|
300 | LONG filetypelen=256; /* length of above */
|
---|
301 | char command[256]; /* command from registry */
|
---|
302 | LONG commandlen=256; /* This is the most DOS can handle :) */
|
---|
303 | char buffer[256]; /* Used to GetProfileString */
|
---|
304 | HINSTANCE retval=31; /* default - 'No association was found' */
|
---|
305 | char *tok; /* token pointer */
|
---|
306 | int i; /* random counter */
|
---|
307 | char xlpFile[256]; /* result of SearchPath */
|
---|
308 |
|
---|
309 | TRACE_(shell)("%s\n", (lpFile != NULL?lpFile:"-") );
|
---|
310 |
|
---|
311 | lpResult[0]='\0'; /* Start off with an empty return string */
|
---|
312 |
|
---|
313 | /* trap NULL parameters on entry */
|
---|
314 | if (( lpFile == NULL ) || ( lpResult == NULL ) || ( lpOperation == NULL ))
|
---|
315 | { WARN_(exec)("(lpFile=%s,lpResult=%s,lpOperation=%s): NULL parameter\n",
|
---|
316 | lpFile, lpOperation, lpResult);
|
---|
317 | return 2; /* File not found. Close enough, I guess. */
|
---|
318 | }
|
---|
319 |
|
---|
320 | if (SearchPathA( NULL, lpFile,".exe",sizeof(xlpFile),xlpFile,NULL))
|
---|
321 | { TRACE_(shell)("SearchPath32A returned non-zero\n");
|
---|
322 | lpFile = xlpFile;
|
---|
323 | }
|
---|
324 |
|
---|
325 | /* First thing we need is the file's extension */
|
---|
326 | extension = strrchr( xlpFile, '.' ); /* Assume last "." is the one; */
|
---|
327 | /* File->Run in progman uses */
|
---|
328 | /* .\FILE.EXE :( */
|
---|
329 | TRACE_(shell)("xlpFile=%s,extension=%s\n", xlpFile, extension);
|
---|
330 |
|
---|
331 | if ((extension == NULL) || (extension == &xlpFile[strlen(xlpFile)]))
|
---|
332 | { WARN_(shell)("Returning 31 - No association\n");
|
---|
333 | return 31; /* no association */
|
---|
334 | }
|
---|
335 |
|
---|
336 | /* Make local copy & lowercase it for reg & 'programs=' lookup */
|
---|
337 | lstrcpynA( tmpext, extension, 5 );
|
---|
338 | CharLowerA( tmpext );
|
---|
339 | TRACE_(shell)("%s file\n", tmpext);
|
---|
340 |
|
---|
341 | /* Three places to check: */
|
---|
342 | /* 1. win.ini, [windows], programs (NB no leading '.') */
|
---|
343 | /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
|
---|
344 | /* 3. win.ini, [extensions], extension (NB no leading '.' */
|
---|
345 | /* All I know of the order is that registry is checked before */
|
---|
346 | /* extensions; however, it'd make sense to check the programs */
|
---|
347 | /* section first, so that's what happens here. */
|
---|
348 |
|
---|
349 | /* See if it's a program - if GetProfileString fails, we skip this
|
---|
350 | * section. Actually, if GetProfileString fails, we've probably
|
---|
351 | * got a lot more to worry about than running a program... */
|
---|
352 | if ( GetProfileStringA("windows", "programs", "exe pif bat com",
|
---|
353 | buffer, sizeof(buffer)) > 0 )
|
---|
354 | { for (i=0;i<strlen(buffer); i++) buffer[i]=tolower(buffer[i]);
|
---|
355 |
|
---|
356 | tok = strtok(buffer, " \t"); /* ? */
|
---|
357 | while( tok!= NULL)
|
---|
358 | {
|
---|
359 | if (strcmp(tok, &tmpext[1])==0) /* have to skip the leading "." */
|
---|
360 | {
|
---|
361 | strcpy(lpResult, xlpFile);
|
---|
362 | /* Need to perhaps check that the file has a path
|
---|
363 | * attached */
|
---|
364 | TRACE_(shell)("found %s\n", lpResult);
|
---|
365 | return 33;
|
---|
366 |
|
---|
367 | /* Greater than 32 to indicate success FIXME According to the
|
---|
368 | * docs, I should be returning a handle for the
|
---|
369 | * executable. Does this mean I'm supposed to open the
|
---|
370 | * executable file or something? More RTFM, I guess... */
|
---|
371 | }
|
---|
372 | tok=strtok(NULL, " \t");
|
---|
373 | }
|
---|
374 | }
|
---|
375 |
|
---|
376 | /* Check registry */
|
---|
377 | if (RegQueryValueA( HKEY_CLASSES_ROOT, tmpext, filetype,
|
---|
378 | &filetypelen ) == ERROR_SUCCESS )
|
---|
379 | {
|
---|
380 | filetype[filetypelen]='\0';
|
---|
381 | TRACE_(shell)("File type: %s\n", filetype);
|
---|
382 |
|
---|
383 | /* Looking for ...buffer\shell\lpOperation\command */
|
---|
384 | strcat( filetype, "\\shell\\" );
|
---|
385 | strcat( filetype, lpOperation );
|
---|
386 | strcat( filetype, "\\command" );
|
---|
387 |
|
---|
388 | if (RegQueryValueA( HKEY_CLASSES_ROOT, filetype, command,
|
---|
389 | &commandlen ) == ERROR_SUCCESS )
|
---|
390 | {
|
---|
391 | /* Is there a replace() function anywhere? */
|
---|
392 | command[commandlen]='\0';
|
---|
393 | strcpy( lpResult, command );
|
---|
394 | tok=strstr( lpResult, "%1" );
|
---|
395 | if (tok != NULL)
|
---|
396 | {
|
---|
397 | tok[0]='\0'; /* truncate string at the percent */
|
---|
398 | strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
|
---|
399 | tok=strstr( command, "%1" );
|
---|
400 | if ((tok!=NULL) && (strlen(tok)>2))
|
---|
401 | {
|
---|
402 | strcat( lpResult, &tok[2] );
|
---|
403 | }
|
---|
404 | }
|
---|
405 | retval=33; /* FIXME see above */
|
---|
406 | }
|
---|
407 | }
|
---|
408 | else /* Check win.ini */
|
---|
409 | {
|
---|
410 | /* Toss the leading dot */
|
---|
411 | extension++;
|
---|
412 | if ( GetProfileStringA( "extensions", extension, "", command,
|
---|
413 | sizeof(command)) > 0)
|
---|
414 | {
|
---|
415 | if (strlen(command)!=0)
|
---|
416 | {
|
---|
417 | strcpy( lpResult, command );
|
---|
418 | tok=strstr( lpResult, "^" ); /* should be ^.extension? */
|
---|
419 | if (tok != NULL)
|
---|
420 | {
|
---|
421 | tok[0]='\0';
|
---|
422 | strcat( lpResult, xlpFile ); /* what if no dir in xlpFile? */
|
---|
423 | tok=strstr( command, "^" ); /* see above */
|
---|
424 | if ((tok != NULL) && (strlen(tok)>5))
|
---|
425 | {
|
---|
426 | strcat( lpResult, &tok[5]);
|
---|
427 | }
|
---|
428 | }
|
---|
429 | retval=33; /* FIXME - see above */
|
---|
430 | }
|
---|
431 | }
|
---|
432 | }
|
---|
433 |
|
---|
434 | TRACE_(shell)("returning %s\n", lpResult);
|
---|
435 | return retval;
|
---|
436 | }
|
---|
437 |
|
---|
438 |
|
---|
439 | /*************************************************************************
|
---|
440 | * SHELL_GetResourceTable
|
---|
441 | */
|
---|
442 | static DWORD SHELL_GetResourceTable(HFILE hFile,LPBYTE *retptr)
|
---|
443 | { IMAGE_DOS_HEADER mz_header;
|
---|
444 | char magic[4];
|
---|
445 | int size;
|
---|
446 |
|
---|
447 | TRACE_(shell)("\n");
|
---|
448 |
|
---|
449 | *retptr = NULL;
|
---|
450 | _llseek( hFile, 0, SEEK_SET );
|
---|
451 | if ((_lread(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) || (mz_header.e_magic != IMAGE_DOS_SIGNATURE))
|
---|
452 | { /* .ICO file ? */
|
---|
453 | if (mz_header.e_cblp == 1)
|
---|
454 | { /* ICONHEADER.idType, must be 1 */
|
---|
455 | *retptr = (LPBYTE)-1;
|
---|
456 | return 1;
|
---|
457 | }
|
---|
458 | else
|
---|
459 | return 0; /* failed */
|
---|
460 | }
|
---|
461 | _llseek( hFile, mz_header.e_lfanew, SEEK_SET );
|
---|
462 |
|
---|
463 | if (_lread( hFile, magic, sizeof(magic) ) != sizeof(magic))
|
---|
464 | return 0;
|
---|
465 |
|
---|
466 | _llseek( hFile, mz_header.e_lfanew, SEEK_SET);
|
---|
467 |
|
---|
468 | if (*(DWORD*)magic == IMAGE_NT_SIGNATURE)
|
---|
469 | return IMAGE_NT_SIGNATURE;
|
---|
470 |
|
---|
471 | if (*(WORD*)magic == IMAGE_OS2_SIGNATURE)
|
---|
472 | { IMAGE_OS2_HEADER ne_header;
|
---|
473 | LPBYTE pTypeInfo = (LPBYTE)-1;
|
---|
474 |
|
---|
475 | if (_lread(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
|
---|
476 | return 0;
|
---|
477 |
|
---|
478 | if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
|
---|
479 | return 0;
|
---|
480 |
|
---|
481 | size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
|
---|
482 |
|
---|
483 | //@@@PH no NE support
|
---|
484 | #if 0
|
---|
485 | if( size > sizeof(NE_TYPEINFO) )
|
---|
486 | { pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
|
---|
487 | if( pTypeInfo )
|
---|
488 | { _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
|
---|
489 | if( _lread( hFile, (char*)pTypeInfo, size) != size )
|
---|
490 | { HeapFree( GetProcessHeap(), 0, pTypeInfo);
|
---|
491 | pTypeInfo = NULL;
|
---|
492 | }
|
---|
493 | }
|
---|
494 | }
|
---|
495 | #endif
|
---|
496 |
|
---|
497 | *retptr = pTypeInfo;
|
---|
498 | return IMAGE_OS2_SIGNATURE;
|
---|
499 | }
|
---|
500 | return 0; /* failed */
|
---|
501 | }
|
---|
502 |
|
---|
503 |
|
---|
504 | /*************************************************************************
|
---|
505 | * ExtractAssociatedIcon [SHELL.36]
|
---|
506 | *
|
---|
507 | * Return icon for given file (either from file itself or from associated
|
---|
508 | * executable) and patch parameters if needed.
|
---|
509 | */
|
---|
510 | HICON WINAPI ExtractAssociatedIconA(HINSTANCE hInst, LPSTR lpIconPath, LPWORD lpiIcon)
|
---|
511 | { TRACE_(shell)("\n");
|
---|
512 | HICON hIcon;
|
---|
513 |
|
---|
514 | hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
|
---|
515 |
|
---|
516 | if( hIcon < 2 )
|
---|
517 | { if( hIcon == 1 ) /* no icons found in given file */
|
---|
518 | { char tempPath[0x104];
|
---|
519 | UINT16 uRet = FindExecutableA(lpIconPath,NULL,tempPath);
|
---|
520 |
|
---|
521 | if( uRet > 32 && tempPath[0] )
|
---|
522 | { strcpy(lpIconPath,tempPath);
|
---|
523 | hIcon = ExtractIconA(hInst, lpIconPath, *lpiIcon);
|
---|
524 | if( hIcon > 2 )
|
---|
525 | return hIcon;
|
---|
526 | }
|
---|
527 | else hIcon = 0;
|
---|
528 | }
|
---|
529 |
|
---|
530 | if( hIcon == 1 )
|
---|
531 | *lpiIcon = 2; /* MSDOS icon - we found .exe but no icons in it */
|
---|
532 | else
|
---|
533 | *lpiIcon = 6; /* generic icon - found nothing */
|
---|
534 |
|
---|
535 | GetModuleFileNameA(hInst, lpIconPath, 0x80);
|
---|
536 | hIcon = LoadIconA( hInst, (LPCSTR)*lpiIcon);
|
---|
537 | }
|
---|
538 | return hIcon;
|
---|
539 | }
|
---|