diff --git a/Types/PDF/include/pdf.hpp b/Types/PDF/include/pdf.hpp index 650e36b0..1c01100b 100644 --- a/Types/PDF/include/pdf.hpp +++ b/Types/PDF/include/pdf.hpp @@ -38,6 +38,7 @@ namespace Type constexpr uint8 RIGHT_CURLY_BRACKET = 0x7D; // } constexpr uint8 SOLIUDS = 0x2F; // / constexpr uint8 PERCENT = 0x25; // % + constexpr uint8 REVERSE_SOLIDUS = 0x5C; // '\' } // namespace DC namespace FILTER @@ -85,6 +86,8 @@ namespace Type constexpr uint8_t PDF_TRUE_SIZE = 4; constexpr uint8_t PDF_FALSE[] = "false"; constexpr uint8_t PDF_FALSE_SIZE = 5; + constexpr uint8_t PDF_NULL[] = "null"; + constexpr uint8_t PDF_NULL_SIZE = 4; constexpr uint8_t PDF_XREF[] = "xref"; constexpr uint8_t PDF_TRAILER[] = "trailer"; @@ -107,6 +110,7 @@ namespace Type constexpr uint8_t PDF_XREF_ENTRY = 20; constexpr uint8_t PDF_FREE_ENTRY = 'f'; constexpr uint8_t ZERO = 0; + constexpr uint8_t PDF_INDIRECTOBJ = 'R'; } // namespace KEY namespace PREDICTOR diff --git a/Types/PDF/src/pdf.cpp b/Types/PDF/src/pdf.cpp index 9e1dd489..6df706f5 100644 --- a/Types/PDF/src/pdf.cpp +++ b/Types/PDF/src/pdf.cpp @@ -329,11 +329,16 @@ void HighlightObjectTypes(GView::Utils::DataCache& data, BufferViewer::Settings& } switch (buffer) { case PDF::WSC::SPACE: + case PDF::WSC::LINE_FEED: + case PDF::WSC::FORM_FEED: + case PDF::WSC::CARRIAGE_RETURN: case PDF::DC::SOLIUDS: case PDF::DC::RIGHT_SQUARE_BRACKET: case PDF::DC::LEFT_SQUARE_BRACKET: case PDF::DC::LESS_THAN: case PDF::DC::GREATER_THAN: + case PDF::DC::LEFT_PARETHESIS: + case PDF::DC::RIGHT_PARETHESIS: end_name = true; break; default: @@ -342,6 +347,9 @@ void HighlightObjectTypes(GView::Utils::DataCache& data, BufferViewer::Settings& } settings.AddZone(start_segment, object_offset - start_segment, ColorPair{ Color::Red, Color::DarkBlue }, "Name"); } + } else if (buffer == PDF::KEY::PDF_INDIRECTOBJ) { + settings.AddZone(object_offset, 1, ColorPair{ Color::Yellow, Color::Blue }, "Indirect Obj"); + object_offset++; } else if (CheckType(data, object_offset, PDF::KEY::PDF_STREAM_SIZE, PDF::KEY::PDF_STREAM)) { if (found_length) { const uint64_t start_segment = object_offset; @@ -364,6 +372,32 @@ void HighlightObjectTypes(GView::Utils::DataCache& data, BufferViewer::Settings& object_offset++; } settings.AddZone(start_segment, object_offset - start_segment, ColorPair{ Color::Green, Color::DarkBlue }, "Numeric"); + } else if (buffer == PDF::DC::LEFT_PARETHESIS) { + const uint64_t start_segment = object_offset; + object_offset++; + while (object_offset < dataSize && data.Copy(object_offset, buffer) && buffer != PDF::DC::RIGHT_PARETHESIS) { + if (buffer == PDF::DC::REVERSE_SOLIDUS) { + object_offset++; + } + object_offset++; + } + settings.AddZone(start_segment, object_offset - start_segment + 1, ColorPair{ Color::DarkGreen, Color::DarkBlue }, "Literal String"); + } else if (buffer == PDF::DC::LESS_THAN) { + const uint64_t start_segment = object_offset; + object_offset++; + while (object_offset < dataSize && data.Copy(object_offset, buffer) && buffer != PDF::DC::GREATER_THAN) { + object_offset++; + } + settings.AddZone(start_segment, object_offset - start_segment + 1, ColorPair{ Color::DarkGreen, Color::DarkBlue }, "Hex String"); + } else if (CheckType(data, object_offset, PDF::KEY::PDF_TRUE_SIZE, PDF::KEY::PDF_TRUE)) { + settings.AddZone(object_offset, PDF::KEY::PDF_TRUE_SIZE, ColorPair{ Color::DarkRed, Color::DarkBlue }, "Boolean"); + object_offset += PDF::KEY::PDF_TRUE_SIZE; + } else if (CheckType(data, object_offset, PDF::KEY::PDF_FALSE_SIZE, PDF::KEY::PDF_FALSE)) { + settings.AddZone(object_offset, PDF::KEY::PDF_FALSE_SIZE, ColorPair{ Color::DarkRed, Color::DarkBlue }, "Boolean"); + object_offset += PDF::KEY::PDF_FALSE_SIZE; + } else if (CheckType(data, object_offset, PDF::KEY::PDF_NULL_SIZE, PDF::KEY::PDF_NULL)) { + settings.AddZone(object_offset, PDF::KEY::PDF_NULL_SIZE, ColorPair{ Color::White, Color::Blue }, "Null"); + object_offset += PDF::KEY::PDF_NULL_SIZE; } else if (CheckType(data, object_offset, PDF::KEY::PDF_ENDOBJ_SIZE, PDF::KEY::PDF_ENDOBJ)) { break; } else { @@ -386,8 +420,6 @@ void CreateBufferView(Reference win, Reference objectOffsets; - const std::vector colors = { ColorPair{ Color::Teal, Color::DarkBlue }, ColorPair{ Color::Yellow, Color::DarkBlue } }; - // HEADER settings.AddZone(0, sizeof(PDF::Header), ColorPair{ Color::Magenta, Color::DarkBlue }, "Header"); @@ -653,7 +685,7 @@ void CreateBufferView(Reference win, Reference