<s> import struct <EOL> from plumbum . lib import six <EOL> LFANEW_OFFSET = <NUM_LIT:30> * <NUM_LIT:2> <EOL> FILE_HEADER_SIZE = <NUM_LIT:5> * <NUM_LIT:4> <EOL> SUBSYSTEM_OFFSET = <NUM_LIT> * <NUM_LIT:4> <EOL> IMAGE_SUBSYSTEM_WINDOWS_GUI = <NUM_LIT:2> <EOL> IMAGE_SUBSYSTEM_WINDOWS_CUI = <NUM_LIT:3> <EOL> def get_pe_subsystem ( filename ) : <EOL> with open ( filename , "<STR_LIT:rb>" ) as f : <EOL> if f . read ( <NUM_LIT:2> ) != six . b ( "<STR_LIT>" ) : <EOL> return None <EOL> f . seek ( LFANEW_OFFSET ) <EOL> lfanew = struct . unpack ( "<STR_LIT:L>" , f . read ( <NUM_LIT:4> ) ) [ <NUM_LIT:0> ] <EOL> f . seek ( lfanew ) <EOL> if f . read ( <NUM_LIT:4> ) != six . b ( "<STR_LIT>" ) : <EOL> return None <EOL> f . seek ( FILE_HEADER_SIZE + SUBSYSTEM_OFFSET , <NUM_LIT:1> ) <EOL> subsystem = struct . unpack ( "<STR_LIT:H>" , f . read ( <NUM_LIT:2> ) ) [ <NUM_LIT:0> ] <EOL> return subsystem </s>
