News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

An exception is thrown after running this simple assembly program

Started by assembler, December 02, 2016, 05:29:15 AM

Previous topic - Next topic

assembler


.386
.model flat, c
option casemap:none

.stack 4096

includelib libucrt.lib
includelib libucrtd.lib
includelib ucrt.lib
includelib ucrtd.lib
includelib libvcruntime.lib
includelib libvcruntimed.lib
includelib vcruntime.lib
includelib vcruntimed.lib
includelib libcmt.lib
includelib libcmtd.lib
includelib msvcrt.lib
includelib msvcrtd.lib
includelib msvcmrt.lib
includelib msvcmrtd.lib
includelib msvcurt.lib
includelib msvcurtd.lib
includelib kernel32.lib
includelib user32.lib
includelib gdi32.lib
includelib winspool.lib
includelib comdlg32.lib
includelib advapi32.lib
includelib shell32.lib
includelib ole32.lib
includelib oleaut32.lib
includelib uuid.lib
includelib odbc32.lib
includelib odbccp32.lib
includelib legacy_stdio_definitions.lib
includelib iso_stdio_wide_specifiers.lib
includelib legacy_stdio_wide_specifiers.lib

getchar proto

.data
string db "string",0

.code
main proc
call getchar
ret
main endp
end

The thrown exception is
Quote
Unhandled exception at 0x771C8E19 (ntdll.dll) in foreach.exe: 0xC0000005: Access violation writing location 0x00000014.
I must mention that Visual Studio Enterprise 2017 RC1 compiles and assembles this program.

jj2007

You can shorten your code a lot - most of the includes are not necessary, and will not be used:.386
.model flat, c
option casemap:none

includelib msvcrt.lib
includelib kernel32.lib
includelib user32.lib

getchar proto

.data
string db "string",0

.code
main proc

call getchar
ret
main endp
end main


And it doesn't throw any exception here, on Win7-64. Perhaps you could zip your exe and post it here?

Welcome to the forum :icon14:

mabdelouahab

Quote

What problems exist if an application uses more than one CRT version?

If you have more than one DLL or EXE, then you may have more than one CRT, whether or not you are using different versions of Visual C++. For example, statically linking the CRT into multiple DLLs can present the same problem. Developers encountering this problem with static CRTs have been instructed to compile with /MD to use the CRT DLL. If your DLLs pass CRT resources across the DLL boundary, you may encounter issues with mismatched CRTs and need to recompile your project with Visual C++.
If your program is using more than one version of the CRT, some care is needed when passing certain CRT objects (such as file handles, locales and environment variables) across DLL boundaries. For more information on the issues involved and how to resolve them, see Potential Errors Passing CRT Objects Across DLL Boundaries.