def testWriteMessage(self): """Tests the _WriteMessage function.""" message_resource_file = resource_file.MessageResourceFile( 'C:\\Windows\\System32\\wrc_test.dll') test_file_path = self._GetTestFilePath(['wrc_test.dll']) with open(test_file_path, 'rb') as file_object: message_resource_file.OpenFileObject(file_object) message_table_resource = message_resource_file.GetMessageTableResource( ) database_writer = database.MessageFileSqlite3DatabaseWriter( message_resource_file) with shared_test_lib.TempDirectory() as temporary_directory: test_file_path = os.path.join(temporary_directory, 'message_file.db') database_writer.Open(test_file_path) # TODO: implement test. # database_writer._WriteMessage( # message_resource_file, message_table_resource, 0x00000409, 0, # 'message_table_0x00000409', False) _ = message_table_resource database_writer.Close() message_resource_file.Close()
def testWriteStringTableLanguage(self): """Tests the _WriteStringTableLanguage function.""" message_resource_file = resource_file.MessageResourceFile( 'C:\\Windows\\System32\\wrc_test.dll') test_file_path = self._GetTestFilePath(['wrc_test.dll']) with open(test_file_path, 'rb') as file_object: message_resource_file.OpenFileObject(file_object) database_writer = database.MessageFileSqlite3DatabaseWriter( message_resource_file) with shared_test_lib.TempDirectory() as temporary_directory: test_file_path = os.path.join(temporary_directory, 'message_file.db') database_writer.Open(test_file_path) database_writer._WriteMessageFile(message_resource_file) message_file_key = database_writer._GetMessageFileKey( message_resource_file) database_writer._WriteStringTableLanguage( message_file_key, 0x00000409) database_writer._WriteStringTableLanguage( message_file_key, 0x00000409) database_writer.Close() message_resource_file.Close()
def WriteMessageFile(self, event_log_provider, message_resource_file, message_filename, message_file_type): """Writes the Windows Message Resource file. Args: event_log_provider: the Event Log provider (instance of EventLogProvider). message_resource_file: the message file (instance of MessageResourceFile). message_filename: string containing the message filename. message_file_type: string containing the message file type. """ database_filename = message_resource_file.windows_path _, _, database_filename = database_filename.rpartition(u'\\') database_filename = u'{0:s}.db'.format(database_filename.lower()) database_filename = re.sub(r'\.mui', '', database_filename) database_writer = database.MessageFileSqlite3DatabaseWriter( message_resource_file) database_writer.Open( os.path.join(self._databases_path, database_filename)) database_writer.WriteResources() database_writer.Close() self._database_writer.WriteMessageFile(message_filename, database_filename) # TODO: write the relationship between the event log provider and # the message file and the Windows version? self._database_writer.WriteMessageFilesPerEventLogProvider( event_log_provider, message_filename, message_file_type)