![]() PSectionHeader := pImageSectionHeader( Cardinal( pNtHeaders ) + SizeOf( TImageNtHeaders ) ) įor i := 0 to - 1 do PNtHeaders := PImageNtHeaders( dwOffset + Cardinal( pDosHeader._lfanew ) ) PDosHeader := PImageDosHeader( pBaseAddress ) ![]() PBaseAddress := MapViewOfFile( hFileMap, FILE_MAP_READ, 0, 0, 0 ) HFileMap := CreateFileMapping( hFile, nil, PAGE_READONLY or SEC_IMAGE, 0, 0, nil ) HFile := CreateFile( PChar( Filename ), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ) Returns IsUPXCompressed - Modified for Delphi 2010 function IsUPXCompressed( const Filename: TFileName ): Boolean SetString(SectName, SizeOf(pSectionHeader.Name)) PSectionHeader := pImageSectionHeader(Cardinal(pNtHeaders) + SizeOf(TImageNtHeaders)) įor i := 0 to -1 do PNtHeaders := PImageNtHeaders(dwOffset + Cardinal(pDosHeader._lfanew)) PDosHeader := PImageDosHeader(pBaseAddress) PBaseAddress := MapViewOfFile(hFileMap, FILE_MAP_READ, 0, 0, 0) HFileMap := CreateFileMapping(hFile, nil, PAGE_READONLY or SEC_IMAGE, 0, 0, nil) If (hFile = INVALID_HANDLE_VALUE) then Exit HFile := CreateFile(PChar(Filename), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) so if read these sections and compare the name with the string UPX you can determine if the exe was compressed using the UPX packer.įunction IsUPXCompressed(const Filename:TFileName): Boolean UPX reports an IOException Permission denied error when trying to write the file.Ĭan anyone spot something wrong in the code that would cause this problem?Īnother Method, when a exe is packed with the UPX tool, the section of the PE header contains sections called UPX0, UPX1, etc. You you call it then try to run UPX it will not save the file. If I do not call the method then UPX can write the files with no problem. There is something not sharing rights correctly in the function. If the function IsUPXCompressed is called then you try to run upx, upx can not save the file it modifies. ![]() The function to determine if an exe file has been compressed is excellent except I found a problem with the code. Is there a method to determine if an exe file has been compressed with UPX? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |