ROSE  0.9.11.115
BinaryString.h
1 #ifndef ROSE_BinaryAnalysis_String_H
2 #define ROSE_BinaryAnalysis_String_H
3 
4 #include <MemoryMap.h>
5 #include <RoseException.h>
6 #include <Sawyer/CommandLine.h>
7 #include <Sawyer/Optional.h>
8 
9 namespace Rose {
10 namespace BinaryAnalysis {
11 
164 namespace Strings {
165 
167 extern Sawyer::Message::Facility mlog;
168 
169 typedef uint8_t Octet;
170 typedef std::vector<Octet> Octets;
171 typedef unsigned CodeValue;
172 typedef std::vector<CodeValue> CodeValues;
173 typedef unsigned CodePoint;
174 typedef std::vector<CodePoint> CodePoints;
177 class Exception: public Rose::Exception {
178 public:
179  Exception(const std::string &s): Rose::Exception(s) {}
180 };
181 
195 enum State {
196  FINAL_STATE = -1,
199  ERROR_STATE = -4,
204 };
205 
207 bool isDone(State st);
208 
210 void initDiagnostics();
211 
218 class ROSE_DLL_API CharacterEncodingForm: public Sawyer::SharedObject {
219 protected:
220  State state_;
221 public:
223  virtual ~CharacterEncodingForm() {}
224 
227 
229  virtual Ptr clone() const = 0;
230 
232  virtual std::string name() const = 0;
233 
237  virtual CodeValues encode(CodePoint) = 0;
238 
240  State state() const { return state_; }
241 
246  virtual State decode(CodeValue) = 0;
247 
251  virtual CodePoint consume() = 0;
252 
254  virtual void reset() = 0;
255 };
256 
261  CodePoint cp_;
262 protected:
263  NoopCharacterEncodingForm(): cp_(0) {}
264 public:
267 
268  static Ptr instance() { return Ptr(new NoopCharacterEncodingForm); }
269  virtual CharacterEncodingForm::Ptr clone() const ROSE_OVERRIDE { return Ptr(new NoopCharacterEncodingForm(*this)); }
270  virtual std::string name() const ROSE_OVERRIDE { return "no-op"; }
271  virtual CodeValues encode(CodePoint cp) ROSE_OVERRIDE;
272  virtual State decode(CodeValue) ROSE_OVERRIDE;
273  virtual CodePoint consume() ROSE_OVERRIDE;
274  virtual void reset() ROSE_OVERRIDE;
275 };
276 
279 
284  CodePoint cp_;
285 protected:
286  Utf8CharacterEncodingForm(): cp_(0) {}
287 public:
290 
291  static Ptr instance() { return Ptr(new Utf8CharacterEncodingForm); }
292  virtual CharacterEncodingForm::Ptr clone() const ROSE_OVERRIDE { return Ptr(new Utf8CharacterEncodingForm(*this)); }
293  virtual std::string name() const ROSE_OVERRIDE { return "UTF-8"; }
294  virtual CodeValues encode(CodePoint cp) ROSE_OVERRIDE;
295  virtual State decode(CodeValue) ROSE_OVERRIDE;
296  virtual CodePoint consume() ROSE_OVERRIDE;
297  virtual void reset() ROSE_OVERRIDE;
298 };
299 
302 
306 class ROSE_DLL_API Utf16CharacterEncodingForm: public CharacterEncodingForm {
307  CodePoint cp_;
308 protected:
309  Utf16CharacterEncodingForm(): cp_(0) {}
310 public:
313 
314  static Ptr instance() { return Ptr(new Utf16CharacterEncodingForm); }
315  virtual CharacterEncodingForm::Ptr clone() const ROSE_OVERRIDE { return Ptr(new Utf16CharacterEncodingForm(*this)); }
316  virtual std::string name() const ROSE_OVERRIDE { return "UTF-16"; }
317  virtual CodeValues encode(CodePoint cp) ROSE_OVERRIDE;
318  virtual State decode(CodeValue) ROSE_OVERRIDE;
319  virtual CodePoint consume() ROSE_OVERRIDE;
320  virtual void reset() ROSE_OVERRIDE;
321 };
322 
325 
331 class ROSE_DLL_API CharacterEncodingScheme: public Sawyer::SharedObject {
332 protected:
333  State state_;
334 public:
336  virtual ~CharacterEncodingScheme() {}
337 
340 
342  virtual Ptr clone() const = 0;
343 
345  virtual std::string name() const = 0;
346 
349  virtual Octets encode(CodeValue) = 0;
350 
352  State state() const { return state_; }
353 
358  virtual State decode(Octet) = 0;
359 
363  virtual CodeValue consume() = 0;
364 
366  virtual void reset() = 0;
367 };
368 
375  size_t octetsPerValue_;
376  ByteOrder::Endianness sex_;
377  CodeValue cv_;
378 protected:
379  BasicCharacterEncodingScheme(size_t octetsPerValue, ByteOrder::Endianness sex)
380  : octetsPerValue_(octetsPerValue), sex_(sex), cv_(0) {
381  ASSERT_require(1==octetsPerValue || sex!=ByteOrder::ORDER_UNSPECIFIED);
382  ASSERT_require(octetsPerValue <= sizeof(CodeValue));
383  }
384 public:
385  static Ptr instance(size_t octetsPerValue, ByteOrder::Endianness sex = ByteOrder::ORDER_UNSPECIFIED) {
386  return Ptr(new BasicCharacterEncodingScheme(octetsPerValue, sex));
387  }
388  virtual Ptr clone() const ROSE_OVERRIDE {
389  return Ptr(new BasicCharacterEncodingScheme(*this));
390  }
391  virtual std::string name() const ROSE_OVERRIDE;
392  virtual Octets encode(CodeValue) ROSE_OVERRIDE;
393  virtual State decode(Octet) ROSE_OVERRIDE;
394  virtual CodeValue consume() ROSE_OVERRIDE;
395  virtual void reset() ROSE_OVERRIDE;
396 };
397 
400  ByteOrder::Endianness sex = ByteOrder::ORDER_UNSPECIFIED);
401 
406 class ROSE_DLL_API LengthEncodingScheme: public Sawyer::SharedObject {
407 protected:
408  State state_;
409 public:
410  LengthEncodingScheme(): state_(INITIAL_STATE) {}
411  virtual ~LengthEncodingScheme() {}
412 
415 
417  virtual Ptr clone() const = 0;
418 
420  virtual std::string name() const = 0;
421 
423  virtual Octets encode(size_t) = 0;
424 
426  State state() const { return state_; }
427 
432  virtual State decode(Octet) = 0;
433 
437  virtual size_t consume() = 0;
438 
440  virtual void reset() = 0;
441 };
442 
449  size_t octetsPerValue_;
450  ByteOrder::Endianness sex_;
451  size_t length_;
452 protected:
453  BasicLengthEncodingScheme(size_t octetsPerValue, ByteOrder::Endianness sex)
454  : octetsPerValue_(octetsPerValue), sex_(sex), length_(0) {
455  ASSERT_require(1==octetsPerValue || sex!=ByteOrder::ORDER_UNSPECIFIED);
456  ASSERT_require(octetsPerValue <= sizeof(size_t));
457  }
458 public:
459  static Ptr instance(size_t octetsPerValue, ByteOrder::Endianness sex = ByteOrder::ORDER_UNSPECIFIED) {
460  return Ptr(new BasicLengthEncodingScheme(octetsPerValue, sex));
461  }
462  virtual Ptr clone() const ROSE_OVERRIDE {
463  return Ptr(new BasicLengthEncodingScheme(*this));
464  }
465  virtual std::string name() const ROSE_OVERRIDE;
466  virtual Octets encode(size_t) ROSE_OVERRIDE;
467  virtual State decode(Octet) ROSE_OVERRIDE;
468  virtual size_t consume() ROSE_OVERRIDE;
469  virtual void reset() ROSE_OVERRIDE;
470 };
471 
473 BasicLengthEncodingScheme::Ptr basicLengthEncodingScheme(size_t octetsPerValue,
474  ByteOrder::Endianness sex = ByteOrder::ORDER_UNSPECIFIED);
475 
479 class ROSE_DLL_API CodePointPredicate: public Sawyer::SharedObject {
480 public:
481  virtual ~CodePointPredicate() {}
482 
485 
487  virtual std::string name() const = 0;
488 
490  virtual bool isValid(CodePoint) = 0;
491 };
492 
497 class ROSE_DLL_API PrintableAscii: public CodePointPredicate {
498 protected:
499  PrintableAscii() {}
500 public:
501  static Ptr instance() {
502  return Ptr(new PrintableAscii);
503  }
504  virtual std::string name() const ROSE_OVERRIDE { return "printable ASCII"; }
505  virtual bool isValid(CodePoint) ROSE_OVERRIDE;
506 };
507 
510 
514 class ROSE_DLL_API AnyCodePoint: public CodePointPredicate {
515 protected:
516  AnyCodePoint() {}
517 public:
518  static Ptr instance() { return Ptr(new AnyCodePoint); }
519  virtual std::string name() const ROSE_OVERRIDE { return "any code point"; }
520  virtual bool isValid(CodePoint) ROSE_OVERRIDE { return true; }
521 };
522 
525 
530 class ROSE_DLL_API StringEncodingScheme: public Sawyer::SharedObject {
531 protected:
532  State state_; // decoding state
533  CodePoints codePoints_; // unconsumed code points
534  size_t nCodePoints_; // number of code points decoded since reset
538 
539 protected:
540  StringEncodingScheme(): state_(INITIAL_STATE), nCodePoints_(0) {}
541 
543  const CodePointPredicate::Ptr &cpp)
544  : cef_(cef), ces_(ces), cpp_(cpp) {}
545 
546 public:
547  virtual ~StringEncodingScheme() {}
548 
551 
553  virtual std::string name() const = 0;
554 
556  virtual Ptr clone() const = 0;
557 
559  virtual Octets encode(const CodePoints&) = 0;
560 
562  State state() const { return state_; }
563 
568  virtual State decode(Octet) = 0;
569 
576  CodePoints consume();
577 
579  const CodePoints& codePoints() const { return codePoints_; }
580 
582  size_t length() const { return nCodePoints_; }
583 
585  virtual void reset();
586 
596  void characterEncodingForm(const CharacterEncodingForm::Ptr &cef) { cef_ = cef; }
608  void characterEncodingScheme(const CharacterEncodingScheme::Ptr &ces) { ces_ = ces; }
619  void codePointPredicate(const CodePointPredicate::Ptr &cpp) { cpp_ = cpp; }
621 };
622 
626 class ROSE_DLL_API LengthEncodedString: public StringEncodingScheme {
628  Sawyer::Optional<size_t> declaredLength_; // decoded length
629 protected:
632  : StringEncodingScheme(cef, ces, cpp), les_(les) {}
633 public:
636 
637  static Ptr instance(const LengthEncodingScheme::Ptr &les, const CharacterEncodingForm::Ptr &cef,
638  const CharacterEncodingScheme::Ptr &ces, const CodePointPredicate::Ptr &cpp) {
639  return Ptr(new LengthEncodedString(les, cef, ces, cpp));
640  }
641  virtual StringEncodingScheme::Ptr clone() const ROSE_OVERRIDE {
642  LengthEncodingScheme::Ptr les = les_->clone();
643  CharacterEncodingForm::Ptr cef = cef_->clone();
644  CharacterEncodingScheme::Ptr ces = ces_->clone();
645  CodePointPredicate::Ptr cpp = cpp_; // not cloned since they have no state
646  LengthEncodedString *inst = new LengthEncodedString(les, cef, ces, cpp);
647  inst->state_ = state_;
648  inst->codePoints_ = codePoints_;
649  inst->nCodePoints_ = nCodePoints_;
650  inst->declaredLength_ = declaredLength_;
651  return Ptr(inst);
652  }
653  virtual std::string name() const ROSE_OVERRIDE;
654  virtual Octets encode(const CodePoints&) ROSE_OVERRIDE;
655  virtual State decode(Octet) ROSE_OVERRIDE;
656  virtual void reset() ROSE_OVERRIDE;
657 
663  Sawyer::Optional<size_t> declaredLength() const { return declaredLength_; }
664 
671  void lengthEncodingScheme(const LengthEncodingScheme::Ptr &les) { les_ = les; }
673 };
674 
678 
682  ByteOrder::Endianness order = ByteOrder::ORDER_UNSPECIFIED);
683 
685 LengthEncodedString::Ptr lengthEncodedPrintableAsciiWide(size_t lengthSize, ByteOrder::Endianness order, size_t charSize);
686 
691 class ROSE_DLL_API TerminatedString: public StringEncodingScheme {
692  CodePoints terminators_;
693  Sawyer::Optional<CodePoint> terminated_; // decoded termination
694 protected:
696  const CodePointPredicate::Ptr &cpp, const CodePoints &terminators)
697  : StringEncodingScheme(cef, ces, cpp), terminators_(terminators) {}
698 public:
701 
702  static Ptr instance(const CharacterEncodingForm::Ptr &cef, const CharacterEncodingScheme::Ptr &ces,
703  const CodePointPredicate::Ptr &cpp, const CodePoints &terminators) {
704  return Ptr(new TerminatedString(cef, ces, cpp, terminators));
705  }
706  static Ptr instance(const CharacterEncodingForm::Ptr &cef, const CharacterEncodingScheme::Ptr &ces,
707  const CodePointPredicate::Ptr &cpp, CodePoint terminator = 0) {
708  return Ptr(new TerminatedString(cef, ces, cpp, CodePoints(1, terminator)));
709  }
710  virtual StringEncodingScheme::Ptr clone() const ROSE_OVERRIDE {
711  CharacterEncodingForm::Ptr cef = cef_->clone();
712  CharacterEncodingScheme::Ptr ces = ces_->clone();
713  CodePointPredicate::Ptr cpp = cpp_; // not cloned since they have no state
714  TerminatedString *inst = new TerminatedString(cef, ces, cpp, terminators_);
715  inst->state_ = state_;
716  inst->codePoints_ = codePoints_;
717  inst->nCodePoints_ = nCodePoints_;
718  inst->terminated_ = terminated_;
719  return Ptr(inst);
720  }
721  virtual std::string name() const ROSE_OVERRIDE;
722  virtual Octets encode(const CodePoints&) ROSE_OVERRIDE;
723  virtual State decode(Octet) ROSE_OVERRIDE;
724  virtual void reset() ROSE_OVERRIDE;
725 
730  Sawyer::Optional<CodePoint> terminated() const { return terminated_; }
731 
739  const CodePoints& terminators() const { return terminators_; }
740  CodePoints& terminators() { return terminators_; }
742 };
743 
746 
748 TerminatedString::Ptr nulTerminatedPrintableAsciiWide(size_t charSize, ByteOrder::Endianness order);
749 
754 class ROSE_DLL_API EncodedString {
755  StringEncodingScheme::Ptr encoder_; // how string is encoded
756  AddressInterval where_; // where encoded string is located
757 public:
758  EncodedString() {}
759  EncodedString(const StringEncodingScheme::Ptr &encoder, const AddressInterval &where)
760  : encoder_(encoder), where_(where) {}
761 
763  StringEncodingScheme::Ptr encoder() const { return encoder_; }
764 
766  const AddressInterval& where() const { return where_; }
767 
769  rose_addr_t address() const { return where_.least(); }
770 
772  size_t size() const { return where_.size(); }
773 
775  size_t length() const { return encoder_->length(); }
776 
780  const CodePoints& codePoints() const { return encoder_->codePoints(); }
781 
785  std::string narrow() const;
786 
788  std::wstring wide() const;
789 
794  void decode(const MemoryMap&);
795 };
796 
803 class ROSE_DLL_API StringFinder {
804 public:
808  struct Settings {
813  size_t minLength;
814 
819  size_t maxLength;
820 
836  size_t maxOverlap;
837 
843 
844  Settings(): minLength(5), maxLength(-1), maxOverlap(8), keepingOnlyLongest(true) {}
845  };
846 
847 private:
848  Settings settings_; // command-line settings for this analysis
849  bool discardingCodePoints_; // whether to store decoded code points
850  std::vector<StringEncodingScheme::Ptr> encoders_; // encodings to use when searching
851  std::vector<EncodedString> strings_; // strings that have been found
852 
853 public:
858  StringFinder(): discardingCodePoints_(false) {}
859 
863  const Settings& settings() const { return settings_; }
864  Settings& settings() { return settings_; }
874  bool discardingCodePoints() const { return discardingCodePoints_; }
875  StringFinder& discardingCodePoints(bool b) { discardingCodePoints_=b; return *this; }
884  const std::vector<StringEncodingScheme::Ptr>& encoders() const { return encoders_; }
885  std::vector<StringEncodingScheme::Ptr>& encoders() { return encoders_; }
896  static Sawyer::CommandLine::SwitchGroup commandLineSwitches(Settings&);
897  Sawyer::CommandLine::SwitchGroup commandLineSwitches();
914  StringFinder& insertCommonEncoders(ByteOrder::Endianness);
915 
921  StringFinder& insertUncommonEncoders(ByteOrder::Endianness);
922 
926  StringFinder& reset() { strings_.clear(); return *this; }
927 
957 
961  const std::vector<EncodedString>& strings() const { return strings_; }
962  std::vector<EncodedString>& strings() { return strings_; }
968  std::ostream& print(std::ostream&) const;
969 };
970 
971 std::ostream& operator<<(std::ostream&, const StringFinder&);
972 
973 } // namespace
974 } // namespace
975 } // namespace
976 
977 #endif
PrintableAscii::Ptr printableAscii()
Returns a new printable ASCII predicate.
unsigned MatchFlags
Flags for matching constraints.
Definition: AddressMap.h:46
CodePointPredicate::Ptr codePointPredicate() const
Property: Code point predicate.
Definition: BinaryString.h:618
virtual CharacterEncodingForm::Ptr clone() const ROSE_OVERRIDE
Create a new encoder from this one.
Definition: BinaryString.h:315
size_t length() const
Number of code points decoded since reset.
Definition: BinaryString.h:582
void characterEncodingScheme(const CharacterEncodingScheme::Ptr &ces)
Property: Character encoding scheme.
Definition: BinaryString.h:608
virtual CharacterEncodingForm::Ptr clone() const ROSE_OVERRIDE
Create a new encoder from this one.
Definition: BinaryString.h:292
virtual Ptr clone() const ROSE_OVERRIDE
Create a new copy of this encoder.
Definition: BinaryString.h:462
Value size() const
Size of interval.
Definition: Interval.h:257
std::vector< CodePoint > CodePoints
A sequence of code points, i.e., a string.
Definition: BinaryString.h:174
LengthEncodedString::Ptr lengthEncodedPrintableAsciiWide(size_t lengthSize, ByteOrder::Endianness order, size_t charSize)
Returns a new encoder for multi-byte length-encoded printable ASCII strings.
size_t maxOverlap
Whether to allow overlapping strings.
Definition: BinaryString.h:836
Sawyer::SharedPointer< Utf16CharacterEncodingForm > Ptr
Shared-ownership pointer to a Utf16CharacterEncodingForm.
Definition: BinaryString.h:312
Settings & settings()
Property: Analysis settings often set from a command-line.
Definition: BinaryString.h:864
Defines the mapping between code values and octets.
Definition: BinaryString.h:331
size_t minLength
Minimum length of matched strings.
Definition: BinaryString.h:813
BasicLengthEncodingScheme::Ptr basicLengthEncodingScheme(size_t octetsPerValue, ByteOrder::Endianness sex=ByteOrder::ORDER_UNSPECIFIED)
Returns a new basic length encoding scheme.
void codePointPredicate(const CodePointPredicate::Ptr &cpp)
Property: Code point predicate.
Definition: BinaryString.h:619
void initDiagnostics()
Initialize the diagnostics facility.
const AddressInterval & where() const
Where the string is located in memory.
Definition: BinaryString.h:766
const Settings & settings() const
Property: Analysis settings often set from a command-line.
Definition: BinaryString.h:863
LengthEncodingScheme::Ptr lengthEncodingScheme() const
Property: Lengh encoding scheme.
Definition: BinaryString.h:670
Initial state just after a reset.
Definition: BinaryString.h:198
Terminated string encoding scheme.
Definition: BinaryString.h:691
Sawyer::SharedPointer< TerminatedString > Ptr
Shared ownership pointer to a TerminatedString.
Definition: BinaryString.h:700
const CodePoints & terminators() const
Property: string termination code points.
Definition: BinaryString.h:739
A collection of related switch declarations.
const CodePoints & codePoints() const
Return pending decoded code points without consuming them.
Definition: BinaryString.h:579
Analysis to find encoded strings.
Definition: BinaryString.h:803
unsigned CodePoint
One character in a coded character set.
Definition: BinaryString.h:173
bool keepingOnlyLongest
Whether to keep only longest non-overlapping strings.
Definition: BinaryString.h:842
Main namespace for the ROSE library.
BasicCharacterEncodingScheme::Ptr basicCharacterEncodingScheme(size_t octetsPerValue, ByteOrder::Endianness sex=ByteOrder::ORDER_UNSPECIFIED)
Returns a new basic character encoding scheme.
Sawyer::SharedPointer< CharacterEncodingScheme > Ptr
Shared ownership pointer to a CharacterEncodingScheme.
Definition: BinaryString.h:339
Sawyer::SharedPointer< CharacterEncodingForm > Ptr
Shared ownership pointer to a CharacterEncodingForm.
Definition: BinaryString.h:226
const std::vector< StringEncodingScheme::Ptr > & encoders() const
Property: List of string encodings.
Definition: BinaryString.h:884
virtual std::string name() const ROSE_OVERRIDE
Name of encoder.
Definition: BinaryString.h:293
StringFinder & reset()
Reset analysis results.
Definition: BinaryString.h:926
unsigned CodeValue
One value in a sequence that encodes a code point.
Definition: BinaryString.h:171
Name space for the entire library.
Sawyer::Message::Facility mlog
Diagnostics specific to string analysis.
std::vector< Octet > Octets
A sequence of octets.
Definition: BinaryString.h:170
Sawyer::SharedPointer< NoopCharacterEncodingForm > Ptr
Shared-ownership pointer to a NoopCharacterEncodingFormat.
Definition: BinaryString.h:266
size_t size() const
Size of encoded string in bytes.
Definition: BinaryString.h:772
virtual bool isValid(CodePoint) ROSE_OVERRIDE
Predicate.
Definition: BinaryString.h:520
StringFinder & discardingCodePoints(bool b)
Property: Whether to discard code points.
Definition: BinaryString.h:875
uint8_t Octet
One byte in a sequence that encodes a code value.
Definition: BinaryString.h:169
std::vector< CodeValue > CodeValues
A sequence of code values.
Definition: BinaryString.h:172
T least() const
Returns lower limit.
Definition: Interval.h:185
bool discardingCodePoints() const
Property: Whether to discard code points.
Definition: BinaryString.h:874
std::vector< EncodedString > & strings()
Obtain strings that were found.
Definition: BinaryString.h:962
size_t maxLength
Maximum length of matched strings.
Definition: BinaryString.h:819
Final state where nothing more can be decoded.
Definition: BinaryString.h:196
const std::vector< EncodedString > & strings() const
Obtain strings that were found.
Definition: BinaryString.h:961
Encoding for the length of a string.
Definition: BinaryString.h:406
void characterEncodingForm(const CharacterEncodingForm::Ptr &cef)
Property: Character encoding format.
Definition: BinaryString.h:596
An efficient mapping from an address space to stored data.
Definition: MemoryMap.h:109
Defines mapping between code points and code values.
Definition: BinaryString.h:218
virtual StringEncodingScheme::Ptr clone() const ROSE_OVERRIDE
Create a new copy of this encoder.
Definition: BinaryString.h:710
const CodePoints & codePoints() const
Code points associated with the string.
Definition: BinaryString.h:780
AnyCodePoint::Ptr anyCodePoint()
Returns a new predicate that matches all code points.
Completed state, but not a final state.
Definition: BinaryString.h:197
virtual StringEncodingScheme::Ptr clone() const ROSE_OVERRIDE
Create a new copy of this encoder.
Definition: BinaryString.h:641
Sawyer::SharedPointer< StringEncodingScheme > Ptr
Shared ownership pointer to a StringEncodingScheme.
Definition: BinaryString.h:550
TerminatedString::Ptr nulTerminatedPrintableAscii()
Returns a new encoder for NUL-terminated printable ASCII strings.
Constraints are used to select addresses from a memory map.
Definition: AddressMap.h:76
LengthEncodedString::Ptr lengthEncodedString(const LengthEncodingScheme::Ptr &les, const CharacterEncodingForm::Ptr &cef, const CharacterEncodingScheme::Ptr &ces, const CodePointPredicate::Ptr &cpp)
Returns a new length-prefixed string encoder.
CharacterEncodingScheme::Ptr characterEncodingScheme() const
Property: Character encoding scheme.
Definition: BinaryString.h:607
virtual std::string name() const ROSE_OVERRIDE
Name of encoder.
Definition: BinaryString.h:270
NoopCharacterEncodingForm::Ptr noopCharacterEncodingForm()
Returns a new no-op character encoding form.
size_t length() const
Length of encoded string in code points.
Definition: BinaryString.h:775
LengthEncodedString::Ptr lengthEncodedPrintableAscii(size_t lengthSize, ByteOrder::Endianness order=ByteOrder::ORDER_UNSPECIFIED)
Returns a new encoder for length-encoded printable ASCII strings.
Sawyer::SharedPointer< LengthEncodingScheme > Ptr
Shared ownership pointer to a LengthEncodingScheme.
Definition: BinaryString.h:414
Sawyer::SharedPointer< CodePointPredicate > Ptr
Shared ownership pointer to a CodePointPredicate.
Definition: BinaryString.h:484
Base class for reference counted objects.
Definition: SharedObject.h:64
virtual CharacterEncodingForm::Ptr clone() const ROSE_OVERRIDE
Create a new encoder from this one.
Definition: BinaryString.h:269
virtual std::string name() const ROSE_OVERRIDE
Name of encoder.
Definition: BinaryString.h:316
TerminatedString::Ptr nulTerminatedPrintableAsciiWide(size_t charSize, ByteOrder::Endianness order)
Returns a new encoder for multi-byte NUL-terminated printable ASCII strings.
rose_addr_t address() const
Starting address of string in memory.
Definition: BinaryString.h:769
CharacterEncodingForm::Ptr characterEncodingForm() const
Property: Character encoding format.
Definition: BinaryString.h:595
Errors for string analysis.
Definition: BinaryString.h:177
Sawyer::SharedPointer< LengthEncodedString > Ptr
Shared ownership pointer to a LengthEncodedString.
Definition: BinaryString.h:635
CodePoints & terminators()
Property: string termination code points.
Definition: BinaryString.h:740
void lengthEncodingScheme(const LengthEncodingScheme::Ptr &les)
Property: Lengh encoding scheme.
Definition: BinaryString.h:671
Sawyer::SharedPointer< Utf8CharacterEncodingForm > Ptr
Shared-ownership pointer to a Utf8CharacterEncodingForm.
Definition: BinaryString.h:289
Utf8CharacterEncodingForm::Ptr utf8CharacterEncodingForm()
Returns a new UTF-8 character encoding form.
Decoder is in an error condition.
Definition: BinaryString.h:199
Length-prefixed string encoding scheme.
Definition: BinaryString.h:626
std::vector< StringEncodingScheme::Ptr > & encoders()
Property: List of string encodings.
Definition: BinaryString.h:885
virtual std::string name() const ROSE_OVERRIDE
Name of predicate.
Definition: BinaryString.h:504
virtual std::string name() const ROSE_OVERRIDE
Name of predicate.
Definition: BinaryString.h:519
Base class for all ROSE exceptions.
Definition: RoseException.h:9
virtual Ptr clone() const ROSE_OVERRIDE
Create a new copy of this encoder.
Definition: BinaryString.h:388
bool isDone(State st)
Returns true for COMPLETED_STATE or FINAL_STATE.
Utf16CharacterEncodingForm::Ptr utf16CharacterEncodingForm()
Returns a new UTF-16 character encoding form.
StringEncodingScheme::Ptr encoder() const
Information about the string encoding.
Definition: BinaryString.h:763