I wrote this small C++ program and built it(Release)
#include<iostream>
int main(){
std::cout<<"Hello World";
return 0;
}
When I disassemble it, it has a lot of extra code(security cookie etc..). I believe Visual Studio is adding all those. How can I compile this program without any extra information, so that its easy to understand its disassembled code?
I know assembly is comparatively harder, but what I mean is getting a hello world asm code out of a hello world c++ program. Is this possible?
You're starting with a huge code base with <iostream>
. What you might want to do is avoid the use of a runtime library entirely. Try something like this:
#include <windows.h>
int main() {
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
WriteFile(stdout, "Hello world\n", 12, NULL, NULL);
return 0;
}
Compile that with assembly listing turned on, and that should give you some "raw" Win32 code to start with.
you can generate assembly output in Project Properties -> Configuration Properties -> Output Files -> Assembler Output
This will let you see the assembly for the code you wrote.
Diassembling, you are going to get a bunch of other things that are linked in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With