1 17 package org.alfresco.filesys.smb.dcerpc; 18 19 import org.alfresco.filesys.util.DataPacker; 20 21 24 public class DCEDataPacker 25 { 26 27 35 public final static String getDCEString(byte[] buf, int off) throws IndexOutOfBoundsException 36 { 37 38 40 if (buf.length < off + 12) 41 throw new IndexOutOfBoundsException (); 42 43 45 int maxLen = DataPacker.getIntelInt(buf, off); 46 int strLen = DataPacker.getIntelInt(buf, off + 8); 47 48 50 return DataPacker.getUnicodeString(buf, off + 12, strLen); 51 } 52 53 62 public final static int putDCEString(byte[] buf, int off, String str, boolean incNul) 63 { 64 65 67 DataPacker.putIntelInt(str.length() + 1, buf, off); 68 DataPacker.putZeros(buf, off + 4, 4); 69 70 if (incNul == false) 71 DataPacker.putIntelInt(str.length(), buf, off + 8); 72 else 73 DataPacker.putIntelInt(str.length() + 1, buf, off + 8); 74 75 77 return DataPacker.putUnicodeString(str, buf, off + 12, incNul); 78 } 79 80 86 public final static int wordAlign(int pos) 87 { 88 return (pos + 1) & 0xFFFFFFFE; 89 } 90 91 97 public final static int longwordAlign(int pos) 98 { 99 return (pos + 3) & 0xFFFFFFFC; 100 } 101 } 102 | Popular Tags |