News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

2.46.8 available

Started by johnsa, January 27, 2018, 12:58:02 AM

Previous topic - Next topic

Biterider

Hi
Just downloaded UASM 2.46.9 and recompiled some major sources without problems.  :t
Biterider

ragdog

Hello

I have some problems with my x64 project, if i use GetOpenFilename commdlg.inc ( WinInc209.zip).
It crash in GetOpenfileName if i use your OPENFILENAME structur.

The stuctur must alignment by 8


OPENFILENAME_ struct 8   ;-- padding (8 qword size) Thanks to fearless


In x86 works fine without alignment by 8

Regards,

jj2007

Hi ragdog,
With x64, your assembler commandline must specify /Zp8

ragdog

Thank you Jochen for this Information  :t

ragdog

Hello

I have try with the switch -zp8 it works but if i close my dialog crash it on WM_CLOSE or use i Uasm64 works not


.686
.MMX
.XMM
.x64

option casemap : none
option win64 : 15
option frame : auto
;option stackbase : rsp

_WIN64 EQU 1
WINVER equ 0501h



my settings is

C:\jWasm\bin\rc /v "DlgMain.Rc"
C:\jWasm\bin\uasm64.exe /c -win64 -Zp8 /win64 /Cp /nologo "DlgMain.Asm"
C:\jWasm\bin\link /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /MACHINE:X64 /OUT:"DlgMain.exe" /LIBPATH:C:\jWasm\Lib\x64 "DlgMain.obj"  "DlgMain.res"




Regards,

fearless

entry point in x64 needs:

WinMainCRTStartup proc FRAME
    invoke    GetModuleHandle,NULL
    mov       hInstance,rax;eax
    invoke    InitCommonControls
    invoke    DialogBoxParam,hInstance,IDD_DIALOG,NULL,addr DlgProc,NULL
    invoke    ExitProcess,0
    ret
WinMainCRTStartup ENDP

...
; code
...

end WinMainCRTStartup


which replaces the start: and end start label entry point used in x86

ragdog

Thank you Fearless i try out.

johnsa

Fearless beat me to it.. :)


.686
.MMX
.XMM
.x64

option casemap : none
option win64 : 7
option frame : auto
option stackbase : rbp

include DlgMain.Inc

.code

WinMainCRTStartup PROC FRAME

invoke GetModuleHandle,NULL
mov hInstance,rax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG,NULL,addr DlgProc,NULL
invoke ExitProcess,0

ret
WinMainCRTStartup ENDP

;########################################################################

DlgProc proc frame hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

.if uMsg == WM_NCCREATE


.elseif uMsg == WM_INITDIALOG

   ; Browse for JSON file to open
Invoke RtlZeroMemory, Addr JsonBrowseFilename, SIZEOF JsonBrowseFilename
push hWnd
pop BrowseFile.hwndOwner
lea rax, JsonBrowseFilter
mov BrowseFile.lpstrFilter, rax
lea rax, JsonBrowseFilename
mov BrowseFile.lpstrFile, rax
lea rax, JsonBrowseFileTitle
mov BrowseFile.lpstrTitle, rax
mov BrowseFile.nMaxFile, SIZEOF JsonBrowseFilename
mov BrowseFile.lpstrDefExt, 0
mov BrowseFile.Flags, OFN_EXPLORER
mov BrowseFile.lStructSize, SIZEOF BrowseFile
Invoke GetOpenFileName, Addr BrowseFile

; If user selected an JSON and didnt cancel browse operation...
.IF rax !=0
mov rax, TRUE
.ELSE
mov rax, FALSE
.ENDIF


.elseif uMsg==WM_COMMAND

.elseif uMsg==WM_CLOSE

invoke EndDialog,hWnd,0
invoke PostQuitMessage,0

.else

.endif

mov rax,TRUE
ret
DlgProc endp
end WinMainCRTStartup



under x64 you should always start with a proper PROC as the entry point, that way the assembler can correctly setup the stack and alignment.

jj2007

You can use whatever you want, no need to pull in the CRT. This one, for example, just creates an enter 50h, 0:
include \Masm32\MasmBasic\Res\JBasic.inc ; ## builds in 32- or 64-bit mode with ML, AsmC, JWasm, HJWasm ##
Init ; OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
  Inkey Chr$("This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format")
EndOfCode


This code was assembled with UAsm64 in 64-bit format

The Init stands for:.code
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
  start proc
  enter 50h, 0 ; align stack
  start endp

johnsa

Yep, you can definitely do it yourself, I just call the proc WinmainCRTStartup for convention, but that isn't actually linked with the CRT.