2008-10-29 9 views
6

द्वारा देखा गया है, मैं फ़ाइल को लिखने के लिए फ़ाइलस्ट्रीम का उपयोग कर रहा हूं और Process Monitor का उपयोग कर अंतर्निहित सिस्टम कॉल देख रहा हूं। मुझे उत्पादन परिनियोजन में कुछ फ़ाइल लॉकिंग समस्याओं के साथ परेशानी हो रही है, इसलिए मैं विवरणों को बारीकी से देख रहा हूं।एक फ़ाइलस्ट्रीम को लिखना अजीब तरीके से व्यवहार करता है, जैसा कि प्रक्रिया मॉनीटर

यह नमूना कोड:

 using (FileStream fs = new FileStream("c:\\temp\\test.txt", FileMode.Create, FileAccess.Write, FileShare.Read)) 
     { 
      fs.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); 
      fs.Close(); 
     } 

कारण निम्नलिखित सिस्टम कॉल:

9:27:09.4561092 AM ConsoleApplication1.vshost.exe 2320 CreateFile C:\temp\test.txt SUCCESS Desired Access: Generic Read/Write, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, AllocationSize: 0, OpenResult: Overwritten 
9:27:12.2217409 AM ConsoleApplication1.vshost.exe 2320 WriteFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2219901 AM ConsoleApplication1.vshost.exe 2320 CloseFile C:\temp\test.txt SUCCESS 
9:27:12.2234484 AM ConsoleApplication1.vshost.exe 2320 CreateFile C:\temp\test.txt SUCCESS Desired Access: Generic Read, Write Attributes, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Complete If Oplocked, Random Access, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened 
9:27:12.2248664 AM ConsoleApplication1.vshost.exe 2320 QueryBasicInformationFile C:\temp\test.txt SUCCESS CreationTime: 10/29/2008 9:04:14 AM, LastAccessTime: 10/29/2008 9:27:12 AM, LastWriteTime: 10/29/2008 9:27:12 AM, ChangeTime: 10/29/2008 9:27:12 AM, FileAttributes: A 
9:27:12.2250075 AM ConsoleApplication1.vshost.exe 2320 SetBasicInformationFile C:\temp\test.txt SUCCESS CreationTime: -1, LastAccessTime: -1, LastWriteTime: -1, ChangeTime: -1, FileAttributes: n/a 
9:27:12.2255889 AM ConsoleApplication1.vshost.exe 2320 QueryStandardInformationFile C:\temp\test.txt SUCCESS AllocationSize: 8, EndOfFile: 5, NumberOfLinks: 1, DeletePending: False, Directory: False 
9:27:12.2257571 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2259825 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2261588 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2265161 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 2 
9:27:12.2268237 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2271332 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2272841 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2274779 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2276249 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2278766 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2282577 AM ConsoleApplication1.vshost.exe 2320 ReadFile C:\temp\test.txt SUCCESS Offset: 0, Length: 5 
9:27:12.2284476 AM ConsoleApplication1.vshost.exe 2320 QueryFileInternalInformationFile C:\temp\test.txt SUCCESS IndexNumber: 0x2d000000016b88 
9:27:12.2286183 AM ConsoleApplication1.vshost.exe 2320 CloseFile C:\temp\test.txt SUCCESS 
9:27:12.2288759 AM ConsoleApplication1.vshost.exe 2320 CreateFile C:\temp\test.txt SUCCESS Desired Access: Read Attributes, Write Attributes, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened 
9:27:12.2305722 AM ConsoleApplication1.vshost.exe 2320 QueryBasicInformationFile C:\temp\test.txt SUCCESS CreationTime: 10/29/2008 9:04:14 AM, LastAccessTime: 10/29/2008 9:27:12 AM, LastWriteTime: 10/29/2008 9:27:12 AM, ChangeTime: 10/29/2008 9:27:12 AM, FileAttributes: A 
9:27:12.2307379 AM ConsoleApplication1.vshost.exe 2320 CloseFile C:\temp\test.txt SUCCESS 

पहले तीन आईओ कॉल उम्मीद कर रहे हैं (तैयार करते हैं, लिखते हैं, करीब), लेकिन इस प्रक्रिया पर चला जाता है फ़ाइल को एक दर्जन और बार पढ़ें और इसे बार-बार खोलें और बंद करें।

अब मैंने Win XP SP2, और Win 2003 x64 पर यह व्यवहार देखा है। हालांकि, घर पर मेरी विंडोज़ विस्टा मशीन अपेक्षित व्यवहार करती है (केवल पहली तीन पंक्तियां)।

गैर-विस्टा रनटाइम पर यह क्यों हो रहा है पर कोई संकेत?

उत्तर

6

एक संभावना यह है कि आपके पास एक वायरस स्कैनर स्थापित है जो प्रत्येक चल रही प्रक्रिया में खुद को इंजेक्ट करता है?

+0

जबकि मैं इसकी पुष्टि नहीं कर सकता, यह सही समझ में आता है। मुझे संदेह था कि शुरुआत के कारण इसे समाप्त कर दिया गया था और यह दिखाया गया था कि यह मेरे EXE से आ रहा था, न कि वायरस स्कैनर। मुझे पता नहीं था कि वायरस स्कैनर मेरी प्रक्रिया में खुद को इंजेक्ट कर सकता है। – TheSoftwareJedi

+0

यह भी ध्यान दें कि एक पीओएस वायरस स्कैनर है अगर इसे फ़ाइल को 11 बार पढ़ने की जरूरत है। – TheSoftwareJedi

+0

वायरस स्कैनर का पठन ConsoleApplication1.vshost.exe से कैसे उत्पन्न होता है? – configurator

संबंधित मुद्दे