@@ -12,36 +12,37 @@ public class SmartE : IPathCheck, IExecutableCheck<PortableExecutable>
1212 public string ? CheckExecutable ( string file , PortableExecutable exe , bool includeDebug )
1313 {
1414 string ? name = exe . InternalName ;
15-
16- // Only works on stub generated from running the program yourself
15+
16+ // Only works on stub generated from running the program yourself
1717 if ( name . OptionalEquals ( "SmarteSECURE" ) )
1818 return "SmartE" ;
19-
20- var sections = exe . SectionTable ?? [ ] ;
2119
22- if ( sections . Length > 0 )
23- {
24- // Get the last section data, if it exists
25- var lastSectionData = exe . GetSectionData ( sections . Length - 1 ) ;
26- if ( lastSectionData != null )
27- {
28- // All sections seen so far are the last sections, so this is "technically"
29- // the only known needed check so far. Others kept as backups if this fails
30- // on some future entry
31- var matchers = GenerateMatchers ( ) ;
32- var match = MatchUtil . GetFirstMatch ( file , lastSectionData , matchers , includeDebug ) ;
33- if ( ! string . IsNullOrEmpty ( match ) )
34- return match ;
35- }
36- }
37-
38- // Specific known named sections:
39- // .bss (Rise of Nations)
40- // .tls (Zoo Tycoon 2)
41- // .idata (http://redump.org/disc/58561/ and http://redump.org/disc/71983/)
42- // .edata (http://redump.org/disc/36619/)
43-
44- return null ;
20+ // TODO: Investigate if this can be found by aligning to section containing entry point
21+
22+ var sections = exe . SectionTable ?? [ ] ;
23+ if ( sections . Length > 0 )
24+ {
25+ // Get the last section data, if it exists
26+ var lastSectionData = exe . GetSectionData ( sections . Length - 1 ) ;
27+ if ( lastSectionData != null )
28+ {
29+ // All sections seen so far are the last sections, so this is "technically"
30+ // the only known needed check so far. Others kept as backups if this fails
31+ // on some future entry
32+ var matchers = GenerateMatchers ( ) ;
33+ var match = MatchUtil . GetFirstMatch ( file , lastSectionData , matchers , includeDebug ) ;
34+ if ( ! string . IsNullOrEmpty ( match ) )
35+ return match ;
36+ }
37+ }
38+
39+ // Specific known named sections:
40+ // .bss (Rise of Nations)
41+ // .tls (Zoo Tycoon 2)
42+ // .idata (http://redump.org/disc/58561/ and http://redump.org/disc/71983/)
43+ // .edata (http://redump.org/disc/36619/)
44+
45+ return null ;
4546 }
4647
4748 /// <inheritdoc/>
@@ -70,7 +71,7 @@ public List<string> CheckDirectoryPath(string path, List<string>? files)
7071
7172 return MatchUtil . GetFirstMatch ( path , matchers , any : true ) ;
7273 }
73-
74+
7475 /// <summary>
7576 /// Generate the set of matchers used for each section
7677 /// </summary>
@@ -81,18 +82,18 @@ private static List<ContentMatchSet> GenerateMatchers()
8182 // Matches most games, but a few like http://redump.org/disc/16541/
8283 // are only matched on the 00001/2.TMP files. PiD and other programs
8384 // don't detect this game either, though (Aside from the stub)
84- new ( new byte ? [ ]
85+ new ( new byte ? [ ]
8586 {
86- 0xEB , 0x15 , 0x03 , 0x00 , 0x00 , 0x00 , null , 0x00 ,
87- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
88- 0x00 , 0x00 , 0x68 , 0x00 , 0x00 , 0x00 , 0x00 , 0x55 ,
89- 0xE8 , 0x00 , 0x00 , 0x00 , 0x00 , 0x5D , 0x81 , 0xED ,
90- 0x1D , 0x00 , 0x00 , 0x00 , 0x8B , 0xC5 , 0x55 , 0x60 ,
91- 0x9C , 0x2B , 0x85 , 0x8F , 0x07 , 0x00 , 0x00 , 0x89 ,
92- 0x85 , 0x83 , 0x07 , 0x00 , 0x00 , 0xFF , 0x74 , 0x24 ,
93- 0x2C , 0xE8 , 0xBB , 0x01 , 0x00 , 0x00 , 0x0F , 0x82 ,
94- 0x2F , 0x06 , 0x00 , 0x00 , 0xE8 , 0x8E , 0x04 , 0x00 ,
95- 0x00 , 0x49 , 0x0F , 0x88 , 0x23 , 0x06
87+ 0xEB , 0x15 , 0x03 , 0x00 , 0x00 , 0x00 , null , 0x00 ,
88+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
89+ 0x00 , 0x00 , 0x68 , 0x00 , 0x00 , 0x00 , 0x00 , 0x55 ,
90+ 0xE8 , 0x00 , 0x00 , 0x00 , 0x00 , 0x5D , 0x81 , 0xED ,
91+ 0x1D , 0x00 , 0x00 , 0x00 , 0x8B , 0xC5 , 0x55 , 0x60 ,
92+ 0x9C , 0x2B , 0x85 , 0x8F , 0x07 , 0x00 , 0x00 , 0x89 ,
93+ 0x85 , 0x83 , 0x07 , 0x00 , 0x00 , 0xFF , 0x74 , 0x24 ,
94+ 0x2C , 0xE8 , 0xBB , 0x01 , 0x00 , 0x00 , 0x0F , 0x82 ,
95+ 0x2F , 0x06 , 0x00 , 0x00 , 0xE8 , 0x8E , 0x04 , 0x00 ,
96+ 0x00 , 0x49 , 0x0F , 0x88 , 0x23 , 0x06
9697 } , "SmartE" ) ,
9798 ] ;
9899 }
0 commit comments