B
Belloc
Guest
Please consider the following code in assembly:
.386
.MODEL flat, stdcall
.stack 4096
ExitProcess PROTO STDCALL, dwExitCode: DWORD
.CODE
WinMain PROC
mov eax, -1
invoke ExitProcess, 0
WinMain ENDP
END
When I try to build this code I get the linker error LNK1221: a subsystem can't be inferred and must be defined. I can understand that now, as the mangled name obtained by the compiler for the code is `_WinMain@0` and not the expected `_WinMain@16` and this is due to the `stdcall` option above in the `.MODEL` directive. However, when I erase the `stdcall` from this directive, as shown below, I get from `DUMPBIN` the same name `WinMain` and not `_WinMain` as I was expecting for a `_cdecl` function. Why is this?
.386
.MODEL flat ;, stdcall
.stack 4096
ExitProcess PROTO STDCALL, dwExitCode: DWORD
.CODE
WinMain PROC
mov eax, -1
invoke ExitProcess, 0
WinMain ENDP
END
For both runs I used /SUBSYSTEM = Not set in the linker property page and `WinMain` as the entry point for the code.
Continue reading...
.386
.MODEL flat, stdcall
.stack 4096
ExitProcess PROTO STDCALL, dwExitCode: DWORD
.CODE
WinMain PROC
mov eax, -1
invoke ExitProcess, 0
WinMain ENDP
END
When I try to build this code I get the linker error LNK1221: a subsystem can't be inferred and must be defined. I can understand that now, as the mangled name obtained by the compiler for the code is `_WinMain@0` and not the expected `_WinMain@16` and this is due to the `stdcall` option above in the `.MODEL` directive. However, when I erase the `stdcall` from this directive, as shown below, I get from `DUMPBIN` the same name `WinMain` and not `_WinMain` as I was expecting for a `_cdecl` function. Why is this?
.386
.MODEL flat ;, stdcall
.stack 4096
ExitProcess PROTO STDCALL, dwExitCode: DWORD
.CODE
WinMain PROC
mov eax, -1
invoke ExitProcess, 0
WinMain ENDP
END
For both runs I used /SUBSYSTEM = Not set in the linker property page and `WinMain` as the entry point for the code.
Continue reading...