Microsoft系统可执行副本不一致
Microsoft system executable copy discrepency
我一直在探索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。
另请参见文件系统重定向器。
- 大于65535的C++数组[size]引发不一致的溢出
- 在 C++(和 C)中进行类型转换时明显不一致
- 填充上编译器生成的复制构造函数之间的不一致
- 犰狳的 print() 方法和 cout 在从 Rcpp 调用时顺序不一致
- CreateDIBSection为同一图像返回不一致的位图位值
- 在 Qml 中从 QSqlTableModel 中删除单行时视图不一致
- 模板参数推导不一致
- 声明中不一致的no是否违反ODR?
- 如何删除分支因子不一致的树,最大为 30,40
- 为什么 std::string s = "123" 当不涉及副本时被视为复制初始化?
- 从 C++ 函数与 Python 函数返回的不一致值用于偏斜正态分布
- 从 C 字符串构造 std::string 与从另一个 std::string 构造 std::string 不一致
- 这种比较是否不一致(或者存在其他问题)?
- 以下可变参数模板行为是否不一致?
- 如何修复我的链表读数不一致的问题?
- 在C++17中,为什么类模板和函数模板的指针类型推导明显不一致
- void 函数中的指针参数返回不一致的值
- 如何查找导致结果不一致的代码
- 跨平台 mySQL 与字符集不一致
- Microsoft系统可执行副本不一致