2010-02-23 14 views
8

我在這裏有一個整潔的問題。爲什麼在Windows Server 2008 x64上重命名reg.exe會導致它無法運行?

有一個叫做reg.exe的實用程序,它已經在Windows上運行了一段時間。它非常方便從腳本導入.reg文件,修改腳本中的值等。因此,當爲腳本場景製作副本時(「爲什麼不使用system32中的副本?」 - >「軟件限制策略」,個人pref等),我注意到,重命名它使靜默失敗:

Windows Server 2008的64:

Microsoft Windows [Version 6.0.6001] 
Copyright (c) 2006 Microsoft Corporation. All rights reserved. 

C:\Windows\system32>reg.exe 
ERROR: Invalid syntax. 
Type "REG /?" for usage. 

C:\Windows\system32>copy reg.exe reg2.exe 
     1 file(s) copied. 

C:\Windows\system32>reg2.exe 

C:\Windows\system32>reg2.exe /? 


C:\Windows\system32>reg.exe /? 

REG Operation [Parameter List] 

    Operation [ QUERY | ADD | DELETE | COPY | 
       SAVE | LOAD | UNLOAD | RESTORE | 
       COMPARE | EXPORT | IMPORT | FLAGS ] 

Return Code: (Except for REG COMPARE) 

    0 - Successful 
    1 - Failed 

For help on a specific operation type: 

    REG Operation /? 

Examples: 

    REG QUERY /? 
    REG ADD /? 
    REG DELETE /? 
    REG COPY /? 
    REG SAVE /? 
    REG RESTORE /? 
    REG LOAD /? 
    REG UNLOAD /? 
    REG COMPARE /? 
    REG EXPORT /? 
    REG IMPORT /? 
    REG FLAGS /? 

C:\Windows\system32> 

但與Windows XP x86:在

Microsoft Windows XP [Version 5.1.2600] 
(C) Copyright 1985-2001 Microsoft Corp. 

C:\Documents and Settings\chris>cd \WINDOWS\system32 

C:\WINDOWS\system32>reg.exe 

Console Registry Tool for Windows - version 3.0 
Copyright (C) Microsoft Corp. 1981-2001. All rights reserved 


REG Operation [Parameter List] 

    Operation [ QUERY | ADD | DELETE | COPY | 
       SAVE | LOAD | UNLOAD | RESTORE | 
       COMPARE | EXPORT | IMPORT ] 

Return Code: (Except of REG COMPARE) 

    0 - Succussful 
    1 - Failed 

For help on a specific operation type: 

    REG Operation /? 

Examples: 

    REG QUERY /? 
    REG ADD /? 
    REG DELETE /? 
    REG COPY /? 
    REG SAVE /? 
    REG RESTORE /? 
    REG LOAD /? 
    REG UNLOAD /? 
    REG COMPARE /? 
    REG EXPORT /? 
    REG IMPORT /? 

C:\WINDOWS\system32>copy reg.exe reg2.exe 
     1 file(s) copied. 

C:\WINDOWS\system32>reg2.exe 

Console Registry Tool for Windows - version 3.0 
Copyright (C) Microsoft Corp. 1981-2001. All rights reserved 


REG Operation [Parameter List] 

    Operation [ QUERY | ADD | DELETE | COPY | 
       SAVE | LOAD | UNLOAD | RESTORE | 
       COMPARE | EXPORT | IMPORT ] 

Return Code: (Except of REG COMPARE) 

    0 - Succussful 
    1 - Failed 

For help on a specific operation type: 

    REG Operation /? 

Examples: 

    REG QUERY /? 
    REG ADD /? 
    REG DELETE /? 
    REG COPY /? 
    REG SAVE /? 
    REG RESTORE /? 
    REG LOAD /? 
    REG UNLOAD /? 
    REG COMPARE /? 
    REG EXPORT /? 
    REG IMPORT /? 

C:\WINDOWS\system32> 

的WinDbg似乎在告訴我,CRT正在殺死它:

Child-SP   RetAddr   Call Site 
00000000`0016f798 00000000`779d2f8b ntdll!ZwTerminateProcess+0xa 
00000000`0016f7a0 000007fe`fe97d832 ntdll!RtlExitUserProcess+0x8b 
00000000`0016f7d0 00000000`ffe7f710 msvcrt!cinit+0x13b 
00000000`0016f810 00000000`778a495d reg!DynArrayGetItemType2+0x1fc 
00000000`0016f850 00000000`779d8791 kernel32!BaseThreadInitThunk+0xd 
00000000`0016f880 00000000`00000000 ntdll!RtlUserThreadStart+0x1d 

但是因爲我對WinDbg不太熟悉(而且這個是64位,所以說,Ollydbg失敗了),我在這裏有點不知所措。感謝您提供的任何信息。

編輯

由於Cyber​​Shadow的幫助和Google檢索的,我找到了解決方案:它查找的.mui(這是翻譯)在安裝當前語言的子文件夾。

Microsoft Windows [Version 6.0.6001] 
Copyright (c) 2006 Microsoft Corporation. All rights reserved. 

C:\Windows\system32>cd en-US 

C:\Windows\System32\en-US>copy reg.exe.mui reg2.exe.mui 
     1 file(s) copied. 

C:\Windows\System32\en-US>cd .. 

C:\Windows\System32>reg2 
ERROR: Invalid syntax. 
Type "REG /?" for usage. 

C:\Windows\System32>del en-US\reg2.exe.mui 

C:\Windows\System32>reg2 

C:\Windows\System32> 
+0

我在Win7 x64上看到了同樣的情況。將reg.exe複製到另一個目錄將以同樣的方式失敗。看起來像一個安全檢查,以確保您正在從系統目錄正確運行「reg.exe」。 – karoberts 2010-02-23 18:09:36

回答

2

通過使用調試器玩一下,我發現LoadString(用於獲取使用情況和錯誤消息)返回ERROR_MUI_FILE_NOT_LOADED。我認爲,有些解釋吧:)

注:

  • 該棧跟蹤似乎是誤導(或至少我們看到具有相同效果的不同的問題)。當複製/重命名時,應用程序正常退出而不打印任何內容。
  • 除了不能顯示消息,該實用程序繼續工作得很好。
  • 這也會影響到32位版本(可以在SysWOW64中找到)。
+0

感謝您的信息,我認爲這是一件愚蠢的事情。任何想法如何重新關聯MUI文件與重命名的副本? 只要可執行程序仍然繼續,並做它的事情,這是很好的知道。謝謝你的幫助! – NoName 2010-02-24 15:29:39

+0

再次感謝,我找到了它想要的MUI。我意識到我發佈的堆棧跟蹤是在進程退出之後發生的 - 這意味着在完成所有操作之後,它會調用ExitProcess。抱歉有誤導性的痕跡。用解決方案更新了問題。 – NoName 2010-02-24 15:44:35

+1

啊,是的,那樣做。找到reg.exe.mui並重命名它,它會一切正常。 – 2010-02-24 18:34:12

0

胡亂猜測這裏,但有些應用程序使用的應用程序的名稱,以確定它應該做的 - 這是一個老的UNIX把戲;例如,/bin/false/bin/true是相同的二進制文件,但名稱決定返回哪個結果。

當您最終編寫99.9%完全相同的2+程序並且您不想爲每個程序維護不同的代碼庫時,可以這樣做。

+1

我以爲這可能是這樣,但我不認爲MS會這樣做(而且看起來他們沒有,請參閱Cyber​​Shadow的回覆) – NoName 2010-02-24 15:26:33

相關問題