Skip to content

Commit

Permalink
Add signature offset to most conflicting parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulTaykalo committed Apr 10, 2019
1 parent 343d964 commit 1f5a299
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions XADRARParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ +(BOOL)recognizeFileWithHandle:(CSHandle *)handle firstBytes:(NSData *)data
if(header)
{
[props setObject:[NSNumber numberWithLongLong:header-bytes] forKey:@"RAREmbedOffset"];
[props setObject:[NSNumber numberWithLongLong:header-bytes] forKey:@"FoundSignatureOffset"];
return YES;
}

Expand Down
2 changes: 1 addition & 1 deletion XADZipSFXParsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}

+(int)requiredHeaderSize;
+(BOOL)recognizeFileWithHandle:(CSHandle *)handle firstBytes:(NSData *)data name:(NSString *)name;
+(BOOL)recognizeFileWithHandle:(CSHandle *)handle firstBytes:(NSData *)data name:(NSString *)name propertiesToAdd:(NSMutableDictionary *)props;
-(NSString *)formatName;

@end
Expand Down
10 changes: 7 additions & 3 deletions XADZipSFXParsers.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ @implementation XADZipSFXParser

+(int)requiredHeaderSize { return 0x10000; }

+(BOOL)recognizeFileWithHandle:(CSHandle *)handle firstBytes:(NSData *)data name:(NSString *)name;
+(BOOL)recognizeFileWithHandle:(CSHandle *)handle firstBytes:(NSData *)data name:(NSString *)name propertiesToAdd:(NSMutableDictionary *)props;
{
const uint8_t *bytes=[data bytes];
int length=[data length];
Expand All @@ -35,8 +35,12 @@ +(BOOL)recognizeFileWithHandle:(CSHandle *)handle firstBytes:(NSData *)data name

for(int i=2;i<length-9;i++)
{
if(bytes[i]=='P'&&bytes[i+1]=='K'&&bytes[i+2]==3&&bytes[i+3]==4)
if(bytes[i+4]>=10&&bytes[i+4]<40&&!bytes[i+9]) return YES;
if(bytes[i]=='P'&&bytes[i+1]=='K'&&bytes[i+2]==3&&bytes[i+3]==4) {
if(bytes[i+4]>=10&&bytes[i+4]<40&&!bytes[i+9]) {
[props setObject:[NSNumber numberWithLongLong:i] forKey:@"FoundSignatureOffset"];
return YES;
}
}
}

return NO;
Expand Down

0 comments on commit 1f5a299

Please sign in to comment.