Commit dec5b509 authored by Dave Pickles's avatar Dave Pickles Committed by Alexandre Julliard

Implement SHGFI_EXETYPE function of SHGetFileInfo.

parent 6f9c840c
...@@ -118,6 +118,65 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes, ...@@ -118,6 +118,65 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
psfi->szDisplayName[0] = '\0'; psfi->szDisplayName[0] = '\0';
psfi->szTypeName[0] = '\0'; psfi->szTypeName[0] = '\0';
psfi->iIcon = 0; psfi->iIcon = 0;
if (flags & SHGFI_EXETYPE) {
BOOL status = FALSE;
HANDLE hfile;
DWORD BinaryType;
IMAGE_DOS_HEADER mz_header;
IMAGE_NT_HEADERS nt;
DWORD len;
char magic[4];
if (flags != SHGFI_EXETYPE) return 0;
status = GetBinaryTypeA (path, &BinaryType);
if (!status) return 0;
if ((BinaryType == SCS_DOS_BINARY)
|| (BinaryType == SCS_PIF_BINARY)) return 0x4d5a;
hfile = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, -1 );
if ( hfile == INVALID_HANDLE_VALUE ) return 0;
/* The next section is adapted from MODULE_GetBinaryType, as we need
* to examine the image header to get OS and version information. We
* know from calling GetBinaryTypeA that the image is valid and either
* an NE or PE, so much error handling can be omitted.
* Seek to the start of the file and read the header information.
*/
SetFilePointer( hfile, 0, NULL, SEEK_SET );
ReadFile( hfile, &mz_header, sizeof(mz_header), &len, NULL );
SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
ReadFile( hfile, magic, sizeof(magic), &len, NULL );
if ( *(DWORD*)magic == IMAGE_NT_SIGNATURE )
{
SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
ReadFile( hfile, &nt, sizeof(nt), &len, NULL );
CloseHandle( hfile );
if (nt.OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {
return IMAGE_NT_SIGNATURE
| (nt.OptionalHeader.MajorSubsystemVersion << 24)
| (nt.OptionalHeader.MinorSubsystemVersion << 16);
}
return IMAGE_NT_SIGNATURE;
}
else if ( *(WORD*)magic == IMAGE_OS2_SIGNATURE )
{
IMAGE_OS2_HEADER ne;
SetFilePointer( hfile, mz_header.e_lfanew, NULL, SEEK_SET );
ReadFile( hfile, &ne, sizeof(ne), &len, NULL );
CloseHandle( hfile );
if (ne.ne_exetyp == 2) return IMAGE_OS2_SIGNATURE
| (ne.ne_expver << 16);
return 0;
}
CloseHandle( hfile );
return 0;
}
/* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified
the pidl functions fail on not existing file names */ the pidl functions fail on not existing file names */
...@@ -249,10 +308,6 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes, ...@@ -249,10 +308,6 @@ DWORD WINAPI SHGetFileInfoA(LPCSTR path,DWORD dwFileAttributes,
if (SUCCEEDED(hr) && (flags & SHGFI_ICON)) if (SUCCEEDED(hr) && (flags & SHGFI_ICON))
psfi->hIcon = pImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL); psfi->hIcon = pImageList_GetIcon((flags & SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL);
if (flags & SHGFI_EXETYPE)
FIXME("type of executable, stub\n");
if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3)) if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3))
FIXME("unknown attribute!\n"); FIXME("unknown attribute!\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment