C++、ASM 和 cout
我正在使用 VC++ 反汇编我编写的一个非常简单的程序:
#include <iostream>
using namespace std;
int main()
{
for(int i = 0; i < 11; i++)
{
cout << i << endl;
}
return 0;
}
我希望能够阐明 cout 的工作原理,但经过检查,生成的 ASM 指向外部源(我假设):
EXTRN __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
有没有办法从上面的行中可以看出 this 具体指向哪里,以及如何访问它?即使如此,如何阅读上面的行?
I'm using VC++ to disassemble a very simple program I've written:
#include <iostream>
using namespace std;
int main()
{
for(int i = 0; i < 11; i++)
{
cout << i << endl;
}
return 0;
}
I was hoping to shed some light on how cout works, but upon inspection, the resulting ASM points to an external source (I assume):
EXTRN __imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A
Is there a way to identify, from the above line, where specifically this points to, and how to access it? Even still, how to read the above line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不必拆解它。流的 MS 源是 Visual Studio 安装的一部分。请参阅:“C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src”
You don't have to disassemble that. The MS sources of the streams are part of Visual Studio installation. See: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src"
cout
由 C++ 运行时提供。如果是 Visual C++,则为 MSVCPxxxx.dll(xxxx 取决于版本和调试/发布)。您可以使用“CFF Explorer”或“depedency walker”之类的工具来查找这些内容,然后查看程序导入目录。
cout
is provided by the C++ runtime. In the case of Visual C++ that would be MSVCPxxxx.dll (xxxx depending on the version and debug/release).You can lookup that stuff by using something like "CFF Explorer" or "depedency walker" and look at the program import directory.