@@ -933,87 +933,93 @@ PhoenixExtract(unsigned char *BIOSImage, int BIOSLength, int BIOSOffset,
933
933
InitRemainder (BIOSImage , BIOSLength );
934
934
}
935
935
936
- for (ID = (struct PhoenixID * )(BIOSImage + BCPSegmentOffset + 10 );
937
- ((void * )ID < (void * )(BIOSImage + BIOSLength )) && ID -> Name [0 ];
938
- ID =
939
- (struct PhoenixID * )(((unsigned char * )ID ) +
940
- le16toh (ID -> Length ))) {
936
+ struct bcpCompress * bcpComp = NULL ;
937
+ if (!memcmp (BIOSImage + BCPSegmentOffset , "BCPSEGMENT" , 10 )) {
938
+ for (ID = (struct PhoenixID * )(BIOSImage + BCPSegmentOffset + 10 );
939
+ ((void * )ID < (void * )(BIOSImage + BIOSLength )) && ID -> Name [0 ];
940
+ ID =
941
+ (struct PhoenixID * )(((unsigned char * )ID ) +
942
+ le16toh (ID -> Length ))) {
941
943
#if 0
942
- printf
943
- ("PhoenixID: Name %c%c%c%c%c%c, Flags 0x%04X, Length %d, Position %05X\n" ,
944
- ID -> Name [0 ], ID -> Name [1 ], ID -> Name [2 ], ID -> Name [3 ],
945
- ID -> Name [4 ], ID -> Name [5 ], le16toh (ID -> Flags ),
946
- le16toh (ID -> Length ), (unsigned int ) (((unsigned char * ) ID ) - BIOSImage ));
944
+ printf
945
+ ("PhoenixID: Name %c%c%c%c%c%c, Flags 0x%04X, Length %d, Position %05X\n" ,
946
+ ID -> Name [0 ], ID -> Name [1 ], ID -> Name [2 ], ID -> Name [3 ],
947
+ ID -> Name [4 ], ID -> Name [5 ], le16toh (ID -> Flags ),
948
+ le16toh (ID -> Length ), (unsigned int ) (((unsigned char * ) ID ) - BIOSImage ));
947
949
#endif
948
- if (!le16toh (ID -> Length ))
949
- break ;
950
-
951
- if (!strncmp (ID -> Name , "BCPSYS" , 6 )) {
952
- SYS = ID ;
953
- if (FFV )
950
+ if (!le16toh (ID -> Length ))
954
951
break ;
955
- } else if (!strncmp (ID -> Name , "BCPFFV" , 6 )) {
956
- FFV = ID ;
957
- if (SYS )
958
- break ;
959
- }
960
- }
961
952
962
- if (!SYS ) {
963
- SYS = (struct PhoenixID * ) memmem (BIOSImage , BIOSLength - 6 , "BCPSYS" , 6 );
953
+ if (!strncmp (ID -> Name , "BCPSYS" , 6 )) {
954
+ SYS = ID ;
955
+ if (FFV )
956
+ break ;
957
+ } else if (!strncmp (ID -> Name , "BCPFFV" , 6 )) {
958
+ FFV = ID ;
959
+ if (SYS )
960
+ break ;
961
+ }
962
+ }
964
963
965
964
if (!SYS ) {
966
- fprintf (stderr , "Error: Failed to locate BCPSYS offset.\n" );
967
- return FALSE;
968
- }
969
- }
965
+ SYS = (struct PhoenixID * ) memmem (BIOSImage , BIOSLength - 6 , "BCPSYS" , 6 );
970
966
971
- /* Get some info */
972
- char Date [9 ], Time [9 ], Version [9 ];
967
+ if (!SYS ) {
968
+ fprintf (stderr , "Error: Failed to locate BCPSYS offset.\n" );
969
+ return FALSE;
970
+ }
971
+ }
973
972
974
- strncpy (Date , ((char * )SYS ) + 0x0F , 8 );
975
- Date [8 ] = 0 ;
976
- strncpy (Time , ((char * )SYS ) + 0x18 , 8 );
977
- Time [8 ] = 0 ;
978
- strncpy (Version , ((char * )SYS ) + 0x37 , 8 );
979
- Version [8 ] = 0 ;
973
+ /* Get some info */
974
+ char Date [9 ], Time [9 ], Version [9 ];
980
975
981
- printf ("Version \"%s\", created on %s at %s.\n" , Version , Date , Time );
976
+ strncpy (Date , ((char * )SYS ) + 0x0F , 8 );
977
+ Date [8 ] = 0 ;
978
+ strncpy (Time , ((char * )SYS ) + 0x18 , 8 );
979
+ Time [8 ] = 0 ;
980
+ strncpy (Version , ((char * )SYS ) + 0x37 , 8 );
981
+ Version [8 ] = 0 ;
982
982
983
- if (!FFV )
984
- FFV = (struct PhoenixID * ) memmem (BIOSImage , BIOSLength - 6 , "BCPFFV" , 6 );
983
+ printf ("Version \"%s\", created on %s at %s.\n" , Version , Date , Time );
985
984
986
- /* BCPCMP parsing */
985
+ if (!FFV )
986
+ FFV = (struct PhoenixID * ) memmem (BIOSImage , BIOSLength - 6 , "BCPFFV" , 6 );
987
987
988
- unsigned char * bcpcmp = memmem (BIOSImage , BIOSLength - 6 , "BCPCMP" , 6 );
989
- struct bcpCompress * bcpComp = NULL ;
990
- if (bcpcmp ) {
991
- uint32_t bcpoff = bcpcmp - BIOSImage ;
992
- bcpComp = (struct bcpCompress * )(BIOSImage + bcpoff );
993
- phx .compression = bcpComp -> alg ;
994
- if ((bcpComp -> head .major_revision == 0 ) && (bcpComp -> head .minor_revision == 0 ))
995
- phx .commonCharacterLZSS = bcpComp -> alt .commonCharacterLZSS ;
996
- else
997
- phx .commonCharacterLZSS = bcpComp -> main .commonCharacterLZSS ;
998
- } else {
999
- /* BCPCMP can be missing (Hitachi Flora 3100 - 4.04 for Corollary C-bus) */
1000
- phx .compression = 0 ;
1001
- phx .commonCharacterLZSS = ' ' ;
1002
- }
988
+ /* BCPCMP parsing */
1003
989
1004
- if (SYS -> Length >= 0x7b ) {
1005
- Offset = le32toh (* ((uint32_t * ) (((char * )SYS ) + 0x77 )));
1006
- Offset &= (BIOSLength - 1 );
1007
- if (!Offset ) {
1008
- fprintf (stderr , "BCPSYS module offset is NULL.\n" );
1009
- if (FFV )
1010
- PhoenixFFV (BIOSImage , BIOSLength , FFV );
990
+ unsigned char * bcpcmp = memmem (BIOSImage , BIOSLength - 6 , "BCPCMP" , 6 );
991
+ if (bcpcmp ) {
992
+ uint32_t bcpoff = bcpcmp - BIOSImage ;
993
+ bcpComp = (struct bcpCompress * )(BIOSImage + bcpoff );
994
+ phx .compression = bcpComp -> alg ;
995
+ if ((bcpComp -> head .major_revision == 0 ) && (bcpComp -> head .minor_revision == 0 ))
996
+ phx .commonCharacterLZSS = bcpComp -> alt .commonCharacterLZSS ;
997
+ else
998
+ phx .commonCharacterLZSS = bcpComp -> main .commonCharacterLZSS ;
999
+ } else {
1000
+ /* BCPCMP can be missing (Hitachi Flora 3100 - 4.04 for Corollary C-bus) */
1001
+ phx .compression = 0 ;
1002
+ phx .commonCharacterLZSS = ' ' ;
1011
1003
}
1012
1004
1013
- while (Offset ) {
1014
- Offset = PhoenixModule (BIOSImage , BIOSLength , Offset );
1015
- Offset &= BIOSLength - 1 ;
1005
+ if (SYS -> Length >= 0x7b ) {
1006
+ Offset = le32toh (* ((uint32_t * ) (((char * )SYS ) + 0x77 )));
1007
+ Offset &= (BIOSLength - 1 );
1008
+ if (!Offset ) {
1009
+ fprintf (stderr , "BCPSYS module offset is NULL.\n" );
1010
+ if (FFV )
1011
+ PhoenixFFV (BIOSImage , BIOSLength , FFV );
1012
+ }
1013
+
1014
+ while (Offset ) {
1015
+ Offset = PhoenixModule (BIOSImage , BIOSLength , Offset );
1016
+ Offset &= BIOSLength - 1 ;
1017
+ }
1016
1018
}
1019
+ } else {
1020
+ printf ("Phoenix-compressed Compaq BIOS.\n" );
1021
+ phx .compression = 2 ;
1022
+ phx .commonCharacterLZSS = ' ' ;
1017
1023
}
1018
1024
1019
1025
/* All scans below based on phoedeco */
0 commit comments