Microsoft系统可执行副本不一致

Microsoft system executable copy discrepency

本文关键字:不一致 副本 可执行 系统 Microsoft      更新时间:2023-10-16

我一直在探索Windows系统文件的内部和外部,注意到奇怪的事情:如果我执行Windows系统的低级别逐位复制可执行到我选择的目标位置的结果文件小于原件。

示例:我写了一个小程序来复制无处不在的calc.exe可执行文件。。。

C:test> copyit c:windowssystem32calc.exe c:testcalc.exe

这是生成的文件:

C:test>dir
Volume in drive C is OS
Volume Serial Number is DEAD-BEEF
Directory of C:test
02/08/2014  03:37 PM    <DIR>          .
02/08/2014  03:37 PM    <DIR>          ..
02/08/2014  03:37 PM           798,720 calc.exe
1 File(s)        798,720 bytes
2 Dir(s)  291,059,347,456 bytes free

这很有趣,因为查看C:\windows\system32\calc.exe会给我…

C:test>dir c:WindowsSystem32calc.exe
Volume in drive C is OS
Volume Serial Number is DEAD-BEEF
Directory of c:WindowsSystem32
08/22/2013  05:51 AM           922,112 calc.exe     <------Why is this larger?
1 File(s)        922,112 bytes
0 Dir(s)  291,059,322,880 bytes free

为了您的观看乐趣,我用C++编写的"copyit"程序:

int main(int argc, char* argv[])
{  
std::ifstream is( argv[0], std::ios::in | std::ios::binary );
std::ofstream os( argv[1], std::ios::out| std::ios::binary );
is.seekg(0, std::ios::end);
std::streampos size = is.tellg();
is.seekg(0);
char* buffer = new char[(size_t)size];
is.read(buffer, size);
os.write(buffer, size);
delete [] buffer;
os.close();
is.close();
return 0;
}

如果我在应用程序中设置了一个断点,并在tellg()调用后检查大小变量参见798720。

请注意,生成的calc.exe不会在我的测试目录中运行,但如果我降低它将运行的UAC安全设置。

是什么原因造成了这种尺寸差异?一些元数据的软件与system32\calc.exe?如果是这样的话,为什么我的小复制程序不直接复制因为它在同一个文件中?微软是否为TrustedInstaller捆绑了一些证书使用?如果是这样,为什么我的小应用程序没有复制?

如果我使用peexplorer查看这两个文件。。。它们看起来完全相同。与相同使用hexeditor。

使用Cywin的md5sum,文件会产生不同的散列。

在其他非MS系统可执行文件上运行我的应用程序会产生一个完美的副本,大小和hash和execuatbles在不接触UAC控件的情况下运行。

我使用CopyFile API重写了copyit。。。同样的结果。也使用_fopen()。同上。我非常怀疑我遇到了一些未记录的安全功能。

您可能正在运行64位版本的windows,而您的程序是32位的。当您在c:WindowsSystem32中打开一个文件时,它将被重定向到C:WindowsSysWOW64。因此,您不是在复制c:windowssystem32calc.exe,而是在复制C:WindowsSysWOW64calc.exe。我估计calc.exe的文件大小为798720。

另请参见文件系统重定向器。