¿À¸²ÆÇ È¥µ·!
ÁÖ: ¿ø·¡ÀÇ ÀÌ ³»¿ë¿¡¼ http://mygreenpaste.blogspot.com. ´ç½ÅÀÌ µ¶¼ ´Ù¸¥ ¾î¶² À§Ä¡¿¡¼ ±×°ÍÀÎ °æ¿ì¿¡, ¹æ¹®ÇÏ´Â ½Ã°£À» °É¸®½Ê½Ã¿À ³ªÀÇ ³ì»ö Ç®, Inc. ´ç½ÅÀ» °¨»çÇϽʽÿÀ.
ÁÁ¾Æ¿ä´Â ±×·¡¼ ¾Æ¸¶ È¥µ· ¼Ò·® °ÅÄ£ ¸» ¿©±â¿¡¼ ÀÌ´Ù. ±×·¯³ª ¿À¸²ÆÇÀº ÃÖ±Ù¿¡ Àú¸¦ °ß°ú ¸ô°í ÀÖ¾ú´Ù! ³ª°¡ ÇÏ´Â °ÍÀ» ½ÃµµÇϰí ÀÖ´ø ¸ðµÎ´Â ±×°Í¿¡ ¾à°£ ¿øº»À» º£³¢±â À§ÇÑ °ÍÀ̰í, °¡µ¿Àº ½ÇÆÐÇϰí ÀÖ¾ú´Ù. ´ç¿¬È÷, Ưº°ÇÑ appÀ̱⠶§¹®¿¡, ³ª´Â ¿À·ù ó¸®ÀÇ ¾î¶² Á¾·ùµµ ¾ø¾ú´Ù. app´Â 1°³ÀÇ Ã¼°è¿¡ Á¤´çÇÑ °ú·á¸¦ ÀÛµ¿Çß´Ù, ±×·¯³ª ´Ù¸¥ ü°è (°¡»ó ±â°è)¿¡ app¸¦ ´Þ¸®´Â °ÍÀº ¿À¸²ÆÇ¿¡ ¿øº»À» º£³¢´Â ½ÇÆÐ ÀϰüµÇ°Ô ±ÍÂøµÇ¾ú´Ù.
±Ã±ØÀûÀ¸·Î, ³ª´Â ¹«½¼ °úÁ¤ÀÌ ¿À¸²ÆÇ¿¡ ÀÖ´Â ÀڷḦ µÎ±â¿¡¼ ³ªÀÇ app¸¦ ¹æÁöÇϰí ÀÖ´ø °áÁ¤ÇÒ ¼ö ÀÖ¾ú´Ù, ±×·¯³ª ¹®Á¦°¡ ÀϾ ¶§ ³ª´Â ¾ÆÁ÷ ¾Ë¸ÂÀº workaround¸¦ ¸¦ À§ÇÑ Ã£¾Æ³»Áö ¾Ê¾Ò´Ù. ¿À¸²ÆÇ¿¡ ¿øº»À» º£³¢±âÀÇ ÇàÀ§·Î Àú¸¦ À§ÇØ ±ä¿äÇÏÁö ¾Ê´Ù, ÀÌ´Ù ÇÊ¿äÁ¶°Ç º¸´Ù´Â Á¤È®ÀÇ ´õ ¸¹Àº °Í.
¾î·µç, P/Invoke¸¦ »ç¿ëÇÏ´Â System.Diagnostics, ³ª´Â vmusrvc.exe - »ç½Ç»ó PC "°¡»ó ±â°è »ç¿ëÀÚ" ¼ºñ½ºÇÑ´Ù -¿¡´Â ¿·ÁÀÖ´ø ¿À¸²ÆÇÀÌ ÀÖ¾ú´Ù´Â °ÍÀ» °ÍÀ»ÀÌ ¹ß°ßÇß´Ù. ŸÀÓ ½ºÅÆÇÁ »ç¿ëÇϱ⿡¼ °¡°ø °¨½ÃÀÚ'(100ÀÇ Ms °£°ÝÀ¸·Î »ý¼ºµÇ´Â) »ç°ÇÀ» À±°ûÀ» ±×¸®´Â s, ±×¸®°í ³ªÀÇ app¿¡¼ °íÀ峪´Â °¡µ¿ÀÇ Å¸ÀÓ ½ºÅÆÇÁ, ³ª´Â vmusrvc.exeÀÇ ´õ¹Ì¸¦ °áÁ¤ÇÒ ¼ö ÀÖ¾ú´Ù:
| ntdll.dll | KiFastSystemCallRet |
| vmusrvc.exe | vmusrvc.exe + 0x9a17 |
| vmusrvc.exe | vmusrvc.exe + 0x9c24 |
| vmusrvc.exe | vmusrvc.exe + 0x91f8 |
| vmusrvc.exe | vmusrvc.exe + 0x907f |
| USER32.dll | InternalCallWinProc + 0x28 |
| USER32.dll | UserCallWinProcCheckWow + 0x150 |
| USER32.dll | DispatchClientMessage + 0xa3 |
| USER32.dll | __fnDWORD + 0x24 |
| ntdll.dll | KiUserCallbackDispatcher + 0x13 |
| vmusrvc.exe | vmusrvc.exe + 0x2d29 |
| vmusrvc.exe | vmusrvc.exe + 0xdba6 |
| kernel32.dll | BaseProcessStart + 0x23 |
¾Æ¹« ¸Å°³º¯¼öµµ, ´ç¿¬È÷, vmusrvc.exe¸¦ À§ÇÑ »ó¡ Á¤º¸´Â À¯È¿ÇÑ °Íó·³ º¸ÀÌÁö ¾ÊÀ¸¸ç, ±×·¯³ª ¸í¹éÇÏ°Ô user32.dll ¾î¶² ¸Þ½ÃÁö¸¦ °¡°øÇϰí ÀÖÁö ¾Ê´Ù. ³ª´Â ÃֽŠÁ¡À» ÀÌ ´õ ¸¹Àº °ÍÀ¸·Î º¼Áöµµ ¸ð¸¥´Ù.
³ªÀÇ ¿À¸²ÆÇ Àϰú ¹æÇØÇϰí ÀÖ´ø °úÁ¤À» ã¾Æ³»±â À§ÇÏ¿©´Â, ³ª´Â ºÎ¸£µµ·Ï P/Invoke¸¦ ÀÌ¿ëÇß´Ù GetOpenClipboardWindow()¿Í ±× ÈÄ¿¡ GetWindowThreadProcessId(), GetOpenClipboardWindowÀÇ µ¹·Áº¸³»Áö´Â ¼ÕÀâÀÌ¿¡¼ Åë°ú (). ±× ÈÄ¿¡, °úÁ¤ÀÇ ½ÇÇàÇÒ ¼ö ÀÖ´Â À̸§À» ã¾Æ³»´Â °ÍÀº »ç¿ëÀÇ ´Ù¸¸ »çÁ¤À̾ú´Ù ´ÜÀ§ ÀÇ ¼öÁý °úÁ¤ °æ¿ì´Â ()¸¦ GetWindowThreadProcessId¸¦ ¸¸È¸µÈ °úÁ¤ I.D¿¡¼ Åë°úÇØ¼ µ¹·Áº¸³Â´Ù System.Diagnostics.Process.GetProcessById().
µÚ¿¡ ¿À´Â ºÎÈ£:
System.Runtime.InteropServices »ç¿ëÇϱâ;
System.Diagnostics »ç¿ëÇϱâ;
...
²ö ÀÚ·á = "aasdlkjasdlk alkjsdl kajsdlkj ¾Ë·ç¹Ì´½";
½ÃÇè
{
Clipboard.SetData (System.Windows.Forms.DataFormats.Text ÀÇ ÀÚ·á);
}
ijġ (ExternalException ee)
{
LogIt (ee.ToString ());
IntPtr hWnd = GetOpenClipboardWindow ();
¸¸¾à¿¡ (IntPtr.Zero! = hWnd)
{
uint pid = 0;
uint tid = GetWindowThreadProcessId (hWnd, ¹ÛÀ¸·Î pid);
LogIt ("hWnd {0}¸¦ °¡Áø °úÁ¤, PID {1} ({1: x}), TID {2} ({2: x})," +
"À̸§ {3} ¿À¸²ÆÇ"°¡, hWnd, pid, tid´Â ÀÖ´Ù,
Process.GetProcessById( (int)pid ).Modules[0].FileName );
}
}
Resulted in the following output:
2008-03-25 00:54:45.4938864--> System.Runtime.InteropServices.ExternalException: Requested Clipboard operation did not succeed.
at System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay)
at System.Windows.Forms.Clipboard.SetData(String format, Object data)
at Clippy.Form1.button1_Click(Object sender, EventArgs e)
2008-03-25 00:54:45.5339440--> Process with hWnd 65716 (65716), PID 1492 (5d4), TID 1496 (5d8), name C:\Program Files\Virtual Machine Additions\vmusrvc.exe has the clipboard
Interestingly, trying an alternative method of the Clipboard to set the content also failed. The Clipboard.SetDataObject() overload that takes a retryTimes and retryDelay parameter failed in the same fashion after roughly ten seconds when invoked as follows:
Clipboard.SetDataObject( data, false, 100, 100 );
I tried variations on retryTimes and retryDelay, to no avail.
Not sure what vmusrvc.exe is doing with the clipboard (probably has to do with monitoring it for host / guest VM interaction), but the act of setting the contents of the clipboard didn't fail 100% of the time in the VM. Often enough to make it extremely unreliable, though. During "normal" system usage, I was not able to cause a failure when running the app on a non-virtual (actual?) system.
Popularity: 2%
Written by «/\/\Ø|âÒ¡¾Ã©÷\/»®©. Read more great feeds at is source WEBSITE
no comments.
Read more articles on P/Invoke and GetOpenClipboardWindow and System.Diagnostics and Clipboard and GetWindowThreadProcessId and Process Monitor and c# and processes and Virtual Machine and otherSoftware and Virtual PC.
- [+] Digg: Feature this article
- [+] Del.icio.us: Bookmark this article
- [+] Furl: Bookmark this article














