VOID SendEventInformation( HANDLE Handle, PEVENT_INFORMATION EventInfo, ULONG EventLength, PDOKAN_INSTANCE DokanInstance) { BOOL status; ULONG returnedLength; //DbgPrint("###EventInfo->Context %X\n", EventInfo->Context); if (DokanInstance != NULL) { ReleaseDokanOpenInfo(EventInfo, DokanInstance); } // send event info to driver status = DeviceIoControl( Handle, // Handle to device IOCTL_EVENT_INFO, // IO Control code EventInfo, // Input Buffer to driver. EventLength, // Length of input buffer in bytes. NULL, // Output Buffer from driver. 0, // Length of output buffer in bytes. &returnedLength, // Bytes placed in buffer. NULL // synchronous call ); if (!status) { DWORD errorCode = GetLastError(); DbgPrint("Dokan Error: Ioctl failed with code %d\n", errorCode ); } }
VOID DispatchClose( HANDLE Handle, PEVENT_CONTEXT EventContext, PDOKAN_INSTANCE DokanInstance) { PEVENT_INFORMATION eventInfo; DOKAN_FILE_INFO fileInfo; PDOKAN_OPEN_INFO openInfo; ULONG sizeOfEventInfo = sizeof(EVENT_INFORMATION); CheckFileName(EventContext->Close.FileName); eventInfo = DispatchCommon( EventContext, sizeOfEventInfo, DokanInstance, &fileInfo, &openInfo); eventInfo->Status = STATUS_SUCCESS; // return success at any case DbgPrint("###Close %04d\n", openInfo != NULL ? openInfo->EventId : -1); if (DokanInstance->DokanOperations->CloseFile) { // ignore return value DokanInstance->DokanOperations->CloseFile( EventContext->Close.FileName, &fileInfo); } // do not send it to the driver //SendEventInformation(Handle, eventInfo, length); if (openInfo != NULL) { EnterCriticalSection(&DokanInstance->CriticalSection); openInfo->OpenCount--; LeaveCriticalSection(&DokanInstance->CriticalSection); } ReleaseDokanOpenInfo(eventInfo, DokanInstance); free(eventInfo); return; }