/// <summary> /// Update SMB_COM_NT_CREATE_ANDX response. /// </summary> /// <param name="connection">It represents the SMB connection.</param> /// <param name="messageId">This is used to associate a response with a request.</param> /// <param name="fId">The SMB file identifier of the target directory.</param> /// <param name="createAction">The action taken for the specified file.</param> public static void UpdateCreateResponse( SmbConnection connection, int messageId, int fId, List <CreateAction> createAction) { CreateRequest request = (CreateRequest)connection.sentRequest[messageId]; bool isOpened = false; if (createAction.Contains(CreateAction.FileCreated) || createAction.Contains(CreateAction.FileSuperseded)) { isOpened = false; } else if (createAction.Contains(CreateAction.FileOpened) || createAction.Contains(CreateAction.FileOverwritten)) { isOpened = true; } switch (request.shareType) { case ShareType.Disk: SmbFile file = new SmbFile( request.shareType, request.name, request.treeId, request.desiredAccess, isOpened); Console.WriteLine(fId); connection.openedFiles.Add(fId, file); break; case ShareType.NamedPipe: if (Parameter.pipeNames.Contains(request.name)) { SmbPipe pipe = new SmbPipe( request.shareType, request.name, request.treeId, request.desiredAccess, isOpened); connection.openedPipes.Add(fId, pipe); connection.openedPipes[fId].isRequireReadModePipeState = Parameter.isMessageModePipe; } else if (Parameter.mailslotNames.Contains(request.name)) { SmbMailslot mailslot = new SmbMailslot( request.shareType, request.name, request.treeId, request.desiredAccess, isOpened); connection.openedMailslots.Add(fId, mailslot); } break; default: break; } connection.SutSendSequenceNumber.Remove(messageId); connection.sentRequest.Remove(messageId); connection.SutNextReceiveSequenceNumber++; connection.fId++; }
/// <summary> /// Update SMB_COM_NT_CREATE_ANDX response. /// </summary> /// <param name="connection">It represents the SMB connection.</param> /// <param name="messageId">This is used to associate a response with a request.</param> /// <param name="fId">The SMB file identifier of the target directory.</param> /// <param name="createAction">The action taken for the specified file.</param> public static void UpdateCreateResponse( SmbConnection connection, int messageId, int fId, Set<CreateAction> createAction) { CreateRequest request = (CreateRequest)connection.sentRequest[messageId]; bool isOpened = false; if(createAction.Contains(CreateAction.FileCreated) || createAction.Contains(CreateAction.FileSuperseded)) { isOpened = false; } else if(createAction.Contains(CreateAction.FileOpened) || createAction.Contains(CreateAction.FileOverwritten )) { isOpened = true; } switch (request.shareType) { case ShareType.Disk: SmbFile file = new SmbFile( request.shareType, request.name, request.treeId, request.desiredAccess, isOpened); Console.WriteLine(fId); connection.openedFiles.Add(fId, file); break; case ShareType.NamedPipe: if(Parameter.pipeNames.Contains(request.name)) { SmbPipe pipe = new SmbPipe( request.shareType, request.name, request.treeId, request.desiredAccess, isOpened); connection.openedPipes.Add(fId, pipe); connection.openedPipes[fId].isRequireReadModePipeState = Parameter.isMessageModePipe; } else if(Parameter.mailslotNames.Contains(request.name)) { SmbMailslot mailslot = new SmbMailslot( request.shareType, request.name, request.treeId, request.desiredAccess, isOpened); connection.openedMailslots.Add(fId,mailslot); } break; default: break; } connection.SutSendSequenceNumber.Remove(messageId); connection.sentRequest.Remove(messageId); connection.SutNextReceiveSequenceNumber++; connection.fId++; }