1 18 19 package jcifs.smb; 20 21 import jcifs.util.Hexdump; 22 23 class SmbComNTCreateAndX extends AndXServerMessageBlock { 24 25 static final int FILE_READ_DATA = 0x00000001; static final int FILE_WRITE_DATA = 0x00000002; static final int FILE_APPEND_DATA = 0x00000004; static final int FILE_READ_EA = 0x00000008; static final int FILE_WRITE_EA = 0x00000010; static final int FILE_EXECUTE = 0x00000020; static final int FILE_DELETE = 0x00000040; static final int FILE_READ_ATTRIBUTES = 0x00000080; static final int FILE_WRITE_ATTRIBUTES = 0x00000100; static final int DELETE = 0x00010000; static final int READ_CONTROL = 0x00020000; static final int WRITE_DAC = 0x00040000; static final int WRITE_OWNER = 0x00080000; static final int SYNCHRONIZE = 0x00100000; static final int GENERIC_ALL = 0x10000000; static final int GENERIC_EXECUTE = 0x20000000; static final int GENERIC_WRITE = 0x40000000; static final int GENERIC_READ = 0x80000000; 45 47 49 51 52 static final int FILE_SUPERSEDE = 0x0; 53 54 57 58 static final int FILE_OPEN = 0x1; 59 60 63 64 static final int FILE_CREATE = 0x2; 65 66 69 70 static final int FILE_OPEN_IF = 0x3; 71 72 75 76 static final int FILE_OVERWRITE = 0x4; 77 78 81 82 static final int FILE_OVERWRITE_IF = 0x5; 83 84 85 static final int FILE_WRITE_THROUGH = 0x00000002; 87 static final int FILE_SEQUENTIAL_ONLY = 0x00000004; 88 static final int FILE_SYNCHRONOUS_IO_ALERT = 0x00000010; 89 static final int FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020; 90 91 static final int SECURITY_CONTEXT_TRACKING = 0x01; 93 static final int SECURITY_EFFECTIVE_ONLY = 0x02; 94 95 private int flags, 96 rootDirectoryFid, 97 desiredAccess, 98 extFileAttributes, 99 shareAccess, 100 createDisposition, 101 createOptions, 102 impersonationLevel; 103 private long allocationSize; 104 private byte securityFlags; 105 private int namelen_index; 106 107 SmbComNTCreateAndX( String name, int flags, 108 int shareAccess, 109 int extFileAttributes, 110 int createOptions, 111 ServerMessageBlock andx ) { 112 super( andx ); 113 this.path = name; 114 command = SMB_COM_NT_CREATE_ANDX; 115 116 desiredAccess = ( flags >>> 16 ) & 0xFFFF; 118 desiredAccess |= FILE_READ_EA | FILE_READ_ATTRIBUTES; 119 120 this.extFileAttributes = extFileAttributes; 122 123 this.shareAccess = shareAccess; 125 126 if(( flags & SmbFile.O_TRUNC ) == SmbFile.O_TRUNC ) { 128 if(( flags & SmbFile.O_CREAT ) == SmbFile.O_CREAT ) { 130 createDisposition = FILE_OVERWRITE_IF; 132 } else { 133 createDisposition = FILE_OVERWRITE; 134 } 135 } else { 136 if(( flags & SmbFile.O_CREAT ) == SmbFile.O_CREAT ) { 138 if ((flags & SmbFile.O_EXCL ) == SmbFile.O_EXCL ) { 140 createDisposition = FILE_CREATE; 142 } else { 143 createDisposition = FILE_OPEN_IF; 144 } 145 } else { 146 createDisposition = FILE_OPEN; 147 } 148 } 149 150 if ((createOptions & 0x0001) == 0) { 151 this.createOptions = createOptions | 0x0040; 152 } else { 153 this.createOptions = createOptions; 154 } 155 impersonationLevel = 0x02; securityFlags = (byte)0x03; } 158 159 int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { 160 int start = dstIndex; 161 162 dst[dstIndex++] = (byte)0x00; 163 namelen_index = dstIndex; 165 dstIndex += 2; 166 writeInt4( flags, dst, dstIndex ); 167 dstIndex += 4; 168 writeInt4( rootDirectoryFid, dst, dstIndex ); 169 dstIndex += 4; 170 writeInt4( desiredAccess, dst, dstIndex ); 171 dstIndex += 4; 172 writeInt8( allocationSize, dst, dstIndex ); 173 dstIndex += 8; 174 writeInt4( extFileAttributes, dst, dstIndex ); 175 dstIndex += 4; 176 writeInt4( shareAccess, dst, dstIndex ); 177 dstIndex += 4; 178 writeInt4( createDisposition, dst, dstIndex ); 179 dstIndex += 4; 180 writeInt4( createOptions, dst, dstIndex ); 181 dstIndex += 4; 182 writeInt4( impersonationLevel, dst, dstIndex ); 183 dstIndex += 4; 184 dst[dstIndex++] = securityFlags; 185 186 return dstIndex - start; 187 } 188 int writeBytesWireFormat( byte[] dst, int dstIndex ) { 189 int n; 190 n = writeString( path, dst, dstIndex ); 191 writeInt2( ( useUnicode ? path.length() * 2 : n ), dst, namelen_index ); 192 return n; 193 } 194 int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { 195 return 0; 196 } 197 int readBytesWireFormat( byte[] buffer, int bufferIndex ) { 198 return 0; 199 } 200 public String toString() { 201 return new String ( "SmbComNTCreateAndX[" + 202 super.toString() + 203 ",flags=0x" + Hexdump.toHexString( flags, 2 ) + 204 ",rootDirectoryFid=" + rootDirectoryFid + 205 ",desiredAccess=0x" + Hexdump.toHexString( desiredAccess, 4 ) + 206 ",allocationSize=" + allocationSize + 207 ",extFileAttributes=0x" + Hexdump.toHexString( extFileAttributes, 4 ) + 208 ",shareAccess=0x" + Hexdump.toHexString( shareAccess, 4 ) + 209 ",createDisposition=0x" + Hexdump.toHexString( createDisposition, 4 ) + 210 ",createOptions=0x" + Hexdump.toHexString( createOptions, 8 ) + 211 ",impersonationLevel=0x" + Hexdump.toHexString( impersonationLevel, 4 ) + 212 ",securityFlags=0x" + Hexdump.toHexString( securityFlags, 2 ) + 213 ",name=" + path + "]" ); 214 } 215 } 216 | Popular Tags |