.386
.model flat,stdcall
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
include windows.inc
include user32.inc
include kernel32.inc
include comdlg32.inc
includelib user32.lib
includelib kernel32.lib
includelib comdlg32.lib
.const
IDM_OPEN equ 1
IDM_SAVE equ 2
IDM_EXIT equ 3
MAXSIZE equ 260
.data
ClassName db "Win32ASMFileMappingClass",0
AppName db "Win32 ASM File Mapping Example",0
MenuName db "FirstMenu",0
ofn OPENFILENAME <>
FilterString db "All Files",0,"*.*",0
db "Text Files",0,"*.txt",0,0
buffer db MAXSIZE dup(0)
hMapFile HANDLE 0 ; Handle to the memory mapped file, must be
;initialized with 0 because we also use it as
;a flag in WM_DESTROY section too
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hFileRead HANDLE ? ; Handle to the source file
hFileWrite HANDLE ? ; Handle to the output file
hMenu HANDLE ?
pMemory DWORD ? ; pointer to the data in the source file
SizeWritten DWORD ? ; number of bytes actually written by WriteFile
.code
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,OFFSET MenuName
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR ClassName,\
ADDR AppName, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,300,200,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.WHILE TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.IF uMsg==WM_CREATE
invoke GetMenu,hWnd ;Obtain the menu handle
mov hMenu,eax
mov ofn.lStructSize,SIZEOF ofn
push hWnd
pop ofn.hWndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter, OFFSET FilterString
mov ofn.lpstrFile, OFFSET buffer
mov ofn.nMaxFile,MAXSIZE
.ELSEIF uMsg==WM_DESTROY
.if hMapFile!=0
call CloseMapFile
.endif
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_COMMAND
mov eax,wParam
.if lParam==0
.if ax==IDM_OPEN
mov ofn.Flags, OFN_FILEMUSTEXIST or \
OFN_PATHMUSTEXIST or OFN_LONGNAMES or\
OFN_EXPLORER or OFN_HIDEREADONLY
invoke GetOpenFileName, ADDR ofn
.if eax==TRUE
invoke CreateFile,ADDR buffer,\
GENERIC_READ ,\
0,\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
NULL
mov hFileRead,eax
invoke CreateFileMapping,hFileRead,NULL,PAGE_READONLY,0,0,NULL
mov hMapFile,eax
mov eax,OFFSET buffer
movzx edx,ofn.nFileOffset
add eax,edx
invoke SetWindowText,hWnd,eax
invoke EnableMenuItem,hMenu,IDM_OPEN,MF_GRAYED
invoke EnableMenuItem,hMenu,IDM_SAVE,MF_ENABLED
.endif
.elseif ax==IDM_SAVE
mov ofn.Flags,OFN_LONGNAMES or\
OFN_EXPLORER or OFN_HIDEREADONLY
invoke GetSaveFileName, ADDR ofn
.if eax==TRUE
invoke CreateFile,ADDR buffer,\
GENERIC_READ or GENERIC_WRITE ,\
FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,CREATE_NEW,FILE_ATTRIBUTE_ARCHIVE,\
NULL
mov hFileWrite,eax
invoke MapViewOfFile,hMapFile,FILE_MAP_READ,0,0,0
mov pMemory,eax
invoke GetFileSize,hFileRead,NULL
invoke WriteFile,hFileWrite,pMemory,eax,ADDR SizeWritten,NULL
invoke UnmapViewOfFile,pMemory
call CloseMapFile
invoke CloseHandle,hFileWrite
invoke SetWindowText,hWnd,ADDR AppName
invoke EnableMenuItem,hMenu,IDM_OPEN,MF_ENABLED
invoke EnableMenuItem,hMenu,IDM_SAVE,MF_GRAYED
.endif
.else
invoke DestroyWindow, hWnd
.endif
.endif
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
CloseMapFile PROC
invoke CloseHandle,hMapFile
mov hMapFile,0
invoke CloseHandle,hFileRead
ret
CloseMapFile endp
end start
Code Description Project Project Rank File Line Column Category Source Suppression State
MSB3721 The command "ml.exe /c /nologo /Zi /Fo"Debug\FileMemoryMap.obj" /I "c:\masm32\include" /I "c:\masm32\lib" /W3 /errorReport:prompt /TaFileMemoryMap.asm" exited with code 1. FileMemoryMap 1 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\masm.targets 50 5 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9155) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9155 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9168) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9168 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9058) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9058 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9097) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9097 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9104) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9104 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9070) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9070 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9175) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9175 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9111) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9111 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9183) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9183 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9190) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9190 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9200) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9200 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9075 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9080 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9085 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9090 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9116 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9122 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9141 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9148 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9201 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9206 1 Build
A2179 structure improperly initia2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9211 1 Build
A2179 structure improperly initiaarning A6006:structure containsBc:\masm32\include\windows.inc(9135) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9135 1 Build
A2179 structure improperly initiaarning A6006:structure containsBc:\masm32\include\windows.inc(9205) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9205 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(7835) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 7835 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9045) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9045 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9130) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9130 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9160) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9160 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9217) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9217 1 Build
A2179 structure improperly initiac:\masm32\include\windows.inc(9224) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9224 1 Build
A2179 structure improperly initiaTc:\masm32\include\windows.inc(9131) : error A2008:syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9131 1 Build
A2004 symbol type conflictc:\masm32\include\windows.inc(7835) size FileMemoryMap 1 c:\masm32\include\windows.inc 156 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9075 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9080 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9085 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9090 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9116 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9122 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9141 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9148 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9201 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9206 1 Build
A2008 syntax errortru FileMemoryMap 1 c:\masm32\include\windows.inc 9211 1 Build
Replace,
.386
.model flat,stdcall
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
include windows.inc
include user32.inc
include kernel32.inc
include comdlg32.inc
includelib user32.lib
includelib kernel32.lib
includelib comdlg32.lib
With,
include \masm32\include\masm32rt.inc
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
Builds OK here. I used the standard Assemble and Link in the MASM 32 editor.
I was about to post exactly the same solution, but Hutch was faster, as usual :bgrin:
Welcome to the forum - and ditch that behemoth of Visual Crap, it's an overkill for anything, in particular assemble. Use qEditor, RichMasm (http://masm32.com/board/index.php?topic=5314.0), Notepad++, whatever you like.
@redstone8415
option casemap:none was missing from that code.
another thing:
change pop ofn.hWndOwner
to pop ofn.hwndOwner
Possibly the Windows proc has to come after windows.inc not before it.
Tim's comment is the right one, 32 bit MASM code must be case sensitive.
.386
.model flat,stdcall
option casemap:none
include windows.inc
include masm32rt.inc
include user32.inc
include kernel32.inc
include comdlg32.inc
includelib user32.lib
includelib kernel32.lib
includelib comdlg32.lib
......
......
......
report: 1 error
Error MSB3721 The command "ml.exe /c /nologo /Zi /Fo"Debug\MemoryMap.obj" /I "c:\masm32\include" /I "c:\masm32\lib" /W3 /errorReport:prompt /TaMemoryMap.asm" exited with code 1. MemoryMap C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\masm.targets 50
My IDE: visual studio 2015! include path : c:\masm32\include;c:\masm32\lib
welcome Redstone,
You should only keep "include masm32rt.inc" and loose all the other includes.
I would try and place your PROTOS below the include.
Have you tried building it with qEditor? You should, and if it does build than it's the VS thing.
Disclaimer: I'm far from being an expert, but I'm learning with these guys above! :dazzled:
good luck
just now, have a try!
according to error prompt: exit code:1
there is not code wrong!
guess : rc files is wrong! after corrected!
it is OK! Pass!
thanks a lot ! My LOVLY MASM32 FANS
I assume this means it all worked out right. Nice!
Alex, your Masm32 fan :greensml:
this Visual Studio 2015 asm PICTURE
Quote from: redstone8415 on March 01, 2017, 03:30:14 PM
this Visual Studio 2015 asm PICTURE
Hey Redstone,
If you are only doing asm, you should follow the advice and give a dedicated asm editor a chance.
QEditor is the one to go. I would also recommend Johen´s Richmasm. Both are "plug & play", faaaast, light, stable and straight to the point. I´ve been doing most of my things in Richmasm, and couldn´t be happier. You can´t go wrong with qEditor too (it´s rock solid).
With these two, you can´t go wrong. Just include masm32rt and off you go (unless you are doing something fancy that needs something else :eusa_dance:).
Even if you plan on interfacing asm and C/C++, Hutch´s suggestion is to build the asm code separately and join to your C stuff.
Well, let´s hear the big dogs.
Cheers Alex
then Qeditor don,t support syntax highlighting display, just don't a bit habitual!
RIGHT?
by again, visual studio integrate the resource editor
Quote from: redstone8415 on March 01, 2017, 04:47:14 PM
then Qeditor don,t support syntax highlighting display, just don't a bit habitual!
RIGHT?
by again, visual studio integrate the resource editor
No, it doesn´t. Neither does Richmasm. If you are looking for an IDE you should have a look at RADasm:
http://masm32.com/board/index.php?board=24.0 (http://masm32.com/board/index.php?board=24.0)
good! i got your suggestion! have a trying use Richmasm!
Quote from: redstone8415 on March 01, 2017, 06:51:03 PM
good! i got your suggestion! have a trying use Richmasm!
Nice!! I love Richmasm!
By the way, you CAN manage your resource files in an absolutely easy way with Richmasm. You simply add your files references at the end, in between key words. It's EASIER than in VS. Look at the "Auto code" menu. Richmasm sets everything up for you.