1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.RPC
- {
- public class NDRUnicodeString : INDRStructure
- {
- public string Value;
- public NDRUnicodeString()
- {
- Value = String.Empty;
- }
- public NDRUnicodeString(string value)
- {
- Value = value;
- }
- public NDRUnicodeString(NDRParser parser)
- {
- Read(parser);
- }
-
- public void Read(NDRParser parser)
- {
- uint maxCount = parser.ReadUInt32();
-
- uint index = parser.ReadUInt32();
-
- uint actualCount = parser.ReadUInt32();
- StringBuilder builder = new StringBuilder();
- for (int position = 0; position < actualCount - 1; position++)
- {
- builder.Append((char)parser.ReadUInt16());
- }
- this.Value = builder.ToString();
- parser.ReadUInt16();
- }
- public void Write(NDRWriter writer)
- {
- int length = 0;
- if (Value != null)
- {
- length = Value.Length;
- }
-
- uint maxCount = (uint)(length + 1);
- writer.WriteUInt32(maxCount);
-
- uint index = 0;
- writer.WriteUInt32(index);
-
- uint actualCount = (uint)(length + 1);
- writer.WriteUInt32(actualCount);
- for (int position = 0; position < length; position++)
- {
- writer.WriteUInt16((ushort)Value[position]);
- }
- writer.WriteUInt16(0);
- }
- }
- }
|