The MASM Forum

64 bit assembler => 64 bit assembler. Conceptual Issues => Topic started by: TWell on August 05, 2016, 03:56:22 AM

Title: Tim's tips
Post by: TWell on August 05, 2016, 03:56:22 AM
ml64 dll without def-file
ml64.exe  testdll64.asm -Fetestdll64.dll
...
Myfunc proc export
...
Myfunc  endp
end
Plain commandline as subsystem comes from obj-file and WinMainCRTStartup is default name for GUI entry function in link
ml64.exe Hello64-3.asm; Sample x64 Assembly Program
extern ExitProcess: PROC
includelib kernel32.lib
extern MessageBoxA: PROC
includelib user32.lib
public WinMainCRTStartup

option dotname
.drectve segment byte info
db "-subsystem:windows ",0
.drectve ends

.data
caption db 'Hello64', 0
message db 'Hello 64-bit World!', 0
.code
WinMainCRTStartup:
  sub    rsp, 28h     ; shadow space, aligns stack
  mov    rcx, 0       ; hWnd = HWND_DESKTOP
  mov    rdx, offset message ; LPCSTR lpText
  mov    r8,  offset caption ; LPCSTR lpCaption
  mov    r9d, 0       ; uType = MB_OK
  call   MessageBoxA  ; call MessageBox API function
  mov    ecx, eax     ; uExitCode = MessageBox(...)
  call ExitProcess
end
Title: Re: Tim's tips
Post by: Mikl__ on August 06, 2016, 08:56:35 AM
Hi, Tim!
Thank you for information! Where it can be found? Or did you know that by experience?
Title: Re: Tim's tips
Post by: jj2007 on August 06, 2016, 04:02:02 PM
http://masm32.com/board/index.php?topic=5150.msg55398#msg55398
Title: Re: Tim's tips
Post by: Mikl__ on August 06, 2016, 11:09:14 PM
Grazie mille, jj2007!
Title: Re: Tim's tips
Post by: TWell on October 01, 2016, 10:24:30 PM
Reading Windows ProductId from bios.
I put this hjwasm example to here too.
Only hjwasm is needed for this example.
; hjwasm64 -win64 -pe ReadProdId64hja.asm
    .x64                ; -pe requires to set cpu, model & language
    .model flat, fastcall

option casemap :none
option epilogue:none
option prologue:none

    option dllimport:<kernel32.dll>
GetSystemFirmwareTable proto :dword,:dword,:qword,:dword
    option dllimport:<msvcrt.dll>
;includelib msvcrt.lib
exit proto :dword
printf proto args:vararg

public mainCRTStartup
.data
msg  db "ACPI not found",13,10,0

.code
mainCRTStartup proc
  sub rsp, 428h ; local buffer
  invoke GetSystemFirmwareTable,'ACPI','MDSM',addr [rsp+20h],400h
  .if rax
    invoke printf,addr [rsp+58h]
  .else
    invoke printf,offset msg
  .endif
  invoke exit,0
mainCRTStartup endp
;msg  db "ACPI not found",13,10,0

end mainCRTStartup