/*********************************************************************** * read_xx_header [internal] */ static int read_xx_header( HFILE lzfd ) { IMAGE_DOS_HEADER mzh; char magic[3]; LZSeek( lzfd, 0, SEEK_SET ); if ( sizeof(mzh) != LZRead( lzfd, (LPSTR)&mzh, sizeof(mzh) ) ) return 0; if ( mzh.e_magic != IMAGE_DOS_SIGNATURE ) return 0; LZSeek( lzfd, mzh.e_lfanew, SEEK_SET ); if ( 2 != LZRead( lzfd, magic, 2 ) ) return 0; LZSeek( lzfd, mzh.e_lfanew, SEEK_SET ); if ( magic[0] == 'N' && magic[1] == 'E' ) return IMAGE_OS2_SIGNATURE; if ( magic[0] == 'P' && magic[1] == 'E' ) return IMAGE_NT_SIGNATURE; magic[2] = '\0'; WARN("Can't handle %s files.\n", magic ); return 0; }
static BOOL get_file_sizes_lz( LPCWSTR source, DWORD *source_size, DWORD *target_size ) { DWORD size; BOOL ret = TRUE; if (source_size) { if (!get_file_size( source, &size )) ret = FALSE; else *source_size = size; } if (target_size) { INT file; OFSTRUCT of; if ((file = LZOpenFileW( (LPWSTR)source, &of, OF_READ )) < 0) { ERR("cannot open source file for reading\n"); return FALSE; } *target_size = LZSeek( file, 0, 2 ); LZClose( file ); } return ret; }
/*********************************************************************** * find_ne_resource [internal] */ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid, DWORD *resLen, DWORD *resOff ) { IMAGE_OS2_HEADER nehd; NE_TYPEINFO *typeInfo; NE_NAMEINFO *nameInfo; DWORD nehdoffset; LPBYTE resTab; DWORD resTabSize; int count; /* Read in NE header */ nehdoffset = LZSeek( lzfd, 0, SEEK_CUR ); if ( sizeof(nehd) != LZRead( lzfd, (LPSTR)&nehd, sizeof(nehd) ) ) return FALSE; resTabSize = nehd.ne_restab - nehd.ne_rsrctab; if ( !resTabSize ) { TRACE("No resources in NE dll\n" ); return FALSE; } /* Read in resource table */ resTab = HeapAlloc( GetProcessHeap(), 0, resTabSize ); if ( !resTab ) return FALSE; LZSeek( lzfd, nehd.ne_rsrctab + nehdoffset, SEEK_SET ); if ( resTabSize != LZRead( lzfd, (char*)resTab, resTabSize ) )
/*********************************************************************** * LZSeek (LZEXPAND.4) */ LONG WINAPI LZSeek16( HFILE16 fd, LONG off, INT16 type ) { if (IS_LZ_HANDLE(fd)) return LZSeek( fd, off, type ); return _llseek( (HFILE)DosFileHandleToWin32Handle(fd), off, type ); }