Author Topic: Tim's tips  (Read 2590 times)

TWell

  • Member
  • ****
  • Posts: 748
Tim's tips
« on: August 05, 2016, 03:56:22 AM »
ml64 dll without def-file
ml64.exe  testdll64.asm -Fetestdll64.dll
Code: [Select]
...
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
Code: [Select]
; 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
« Last Edit: August 07, 2016, 03:49:12 AM by TWell »

Mikl__

  • Member
  • *****
  • Posts: 1017
Re: Tim's tips
« Reply #1 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?

jj2007

  • Member
  • *****
  • Posts: 10636
  • Assembler is fun ;-)
    • MasmBasic
Re: Tim's tips
« Reply #2 on: August 06, 2016, 04:02:02 PM »

Mikl__

  • Member
  • *****
  • Posts: 1017
Re: Tim's tips
« Reply #3 on: August 06, 2016, 11:09:14 PM »
Grazie mille, jj2007!

TWell

  • Member
  • ****
  • Posts: 748
Re: Tim's tips
« Reply #4 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.
Code: [Select]
; 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