flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [fixed] Parameter count macro fails on zero parameters

Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20335
Location: In your JS exploiting you and your system
revolution 25 Mar 2012, 13:29
Code:
include 'win64wxp.inc'
invoke GetCommandLine ;<--- Error: invalid count of parameters for GetCommandLine.    
BTW: I'm using an older version of fasm because, due to a different bug, the current version gives the wrong error message "error: undefined symbol 'MAX_PATH'."


Last edited by revolution on 25 Mar 2012, 14:17; edited 1 time in total
Post 25 Mar 2012, 13:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 25 Mar 2012, 13:54
I already fixed that (fasmw package is updated). And the insane error messaging experiment has been abandoned, 1.69.49 (released this morning) has it all back to usual.
Post 25 Mar 2012, 13:54
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 26 Mar 2012, 20:28
Decided post here, same subject matter. I've been getting unusual pcount errors also, 2 examples:
Code:
cominvk d3d9, [b]GetDeviceCaps[/b], D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, caps ;'GetDeviceCaps' parameter count error    

also with stdcall:
Code:
stdcall BigNumToString, [ms.dwMemoryLoad], addr szBuf ;pcount error    

Defining 'BigNumToString% = 2' at the start of the program solves the problem, but you didn't have to do this with the previous macros.
Post 26 Mar 2012, 20:28
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 26 Mar 2012, 20:45
I was able to hunt down the first one, it was a bug in COM64.INC
For the second one, however, you would have to provide more context, because I was not able to reproduce the bug.
Post 26 Mar 2012, 20:45
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 26 Mar 2012, 21:05
Sorry about that, here is the full source of the example (note: my win64a.inc combines all 'win64aXX.inc' into one) :
Code:
format PE64 GUI 5.0 on 'nul'
entry WINMAIN

include 'win64a.inc'
include 'equates\msvcrt.inc'
include 'equates\kernel32.inc'
include 'equates\gdi32.inc'
include 'equates\user32.inc'
include 'equates\comctl32.inc'
include 'equates\comdlg32.inc'

IDI_ICON = 101
IDT_TIMER1 = 1000

DLG_MEMSTAT = 1

ID_MEMLOAD = 1
ID_TOTALPHYS = 2
ID_AVAILPHYS = 3
ID_USEDPHYSICAL = 8
ID_TOTALPAGEFILE = 4
ID_AVAILPAGEFILE = 5
ID_USEDPAGEFILE = 9
ID_TOTALVIRTUAL = 6
ID_AVAILVIRTUAL = 7
ID_USEDVIRTUAL = 10

;BigNumToString% = 2

section '.data' data readable writeable
  icex INITCOMMONCONTROLSEX sizeof.INITCOMMONCONTROLSEX, ICC_ALL_CLASSES

section '.code' code readable executable

proc WINMAIN  hInstance, hprevinstance, lpszCmdLine, nCmdShow
     invoke  InitCommonControlsEx, icex
     invoke  GetModuleHandle, 0
     invoke  DialogBoxParam, rax, DLG_MEMSTAT, HWND_DESKTOP, DlgProc, WM_INITDIALOG
     invoke  ExitProcess, 0
endp

proc DlgProc  hDlg, uMsg, wParam, lParam
     local szBuf[128]:BYTE, ms:MEMORYSTATUSEX

     ;Note that first four parameters are passed in registers,
     ;while names given in the declaration of procedure refer to the stack
     ;space reserved for them - you may store them there to be later accessible
     ;if the contents of registers gets destroyed. This may look like:
     mov     [hDlg], rcx
     mov     [uMsg], rdx
     mov     [wParam], r8
     mov     [lParam], r9

     .if     rdx = WM_INITDIALOG
             invoke  SetTimer, rcx, IDT_TIMER1, 200, NULL

             ;Initialize the length of the structure before calling GlobalMemoryStatus.
             cinvoke memset, addr ms, 0, sizeof.MEMORYSTATUSEX
             mov     [ms.dwLength], sizeof.MEMORYSTATUSEX
             invoke  GlobalMemoryStatusEx, addr ms

             ;File the static controls in the listbox with the appropriate number.
             cinvoke strcat, addr szBuf, "%"
             stdcall BigNumToString, [ms.dwMemoryLoad], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_MEMLOAD, rax

             stdcall BigNumToString, [ms.ullTotalPhys], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_TOTALPHYS, rax

             stdcall BigNumToString, [ms.ullAvailPhys], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_AVAILPHYS, rax

             stdcall BigNumToString, [ms.ullTotalPageFile], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_TOTALPAGEFILE, rax

             stdcall BigNumToString, [ms.ullAvailPageFile], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_AVAILPAGEFILE, rax

             stdcall BigNumToString, [ms.ullTotalVirtual], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_TOTALVIRTUAL, rax

             stdcall BigNumToString, [ms.ullAvailExtendedVirtual], addr szBuf
             invoke  SetDlgItemText, [hDlg], ID_AVAILVIRTUAL, rax
             ;ullAvailExtendedVirtual
             return  NO_ERROR

     .elseif rdx = WM_TIMER
             .if     r8 = IDT_TIMER1
                     cinvoke memset, addr ms, 0, sizeof.MEMORYSTATUSEX
                     mov     [ms.dwLength], sizeof.MEMORYSTATUSEX
                     invoke  GlobalMemoryStatusEx, addr ms

                     stdcall BigNumToString, [ms.dwMemoryLoad], addr szBuf
                     cinvoke strcat, addr szBuf, "%"
                     invoke  SetDlgItemText, [hDlg], ID_MEMLOAD, addr szBuf

                     stdcall BigNumToString, [ms.ullTotalPhys], addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_TOTALPHYS, rax

                     stdcall BigNumToString, [ms.ullAvailPhys], addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_AVAILPHYS, rax

                     mov     rax, [ms.ullTotalPhys]
                     sub     rax, [ms.ullAvailPhys]
                     stdcall BigNumToString, rax, addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_USEDPHYSICAL, rax

                     stdcall BigNumToString, [ms.ullTotalPageFile], addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_TOTALPAGEFILE, rax

                     stdcall BigNumToString, [ms.ullAvailPageFile], addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_AVAILPAGEFILE, rax

                     mov     rax, [ms.ullTotalPageFile]
                     sub     rax, [ms.ullAvailPageFile]
                     stdcall BigNumToString, rax, addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_USEDPAGEFILE, rax

                     stdcall BigNumToString, [ms.ullTotalVirtual], addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_TOTALVIRTUAL, rax

                     stdcall BigNumToString, [ms.ullAvailVirtual], addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_AVAILVIRTUAL, rax

                     mov     rax, [ms.ullTotalVirtual]
                     sub     rax, [ms.ullAvailVirtual]
                     stdcall BigNumToString, rax, addr szBuf
                     invoke  SetDlgItemText, [hDlg], ID_USEDVIRTUAL, rax
                     ;ullAvailExtendedVirtual
             .endif
             return  NO_ERROR

     .elseif rdx = WM_COMMAND
             invoke  KillTimer, rcx, IDT_TIMER1
             invoke  EndDialog, [hDlg], NULL
             return  NO_ERROR
     .endif

     return  NO_ERROR
endp

;This function accepts a number and converts it to a string inserting commas where appropriate.
proc BigNumToString  lNum, szBuf
     local wNumDigits:QWORD, wNumChars:QWORD

     mov     [lNum], rcx
     mov     [szBuf], rdx

     xor     rax, rax
     mov     [wNumDigits], rax
     mov     [wNumChars], rax

     .repeat
             ;Put the last digit of the string in the character buffer.
             ;szBuf[wNumChars++] = lNum % 10 + '0'
             mov     rdx, 0
             mov     rcx, 10
             mov     rax, [lNum]
             idiv    rcx
             add     dl, '0'

             mov     rcx, [szBuf]
             mov     rax, [wNumChars]
             mov     [rcx + rax], dl
             add     [wNumChars], 1

             ;Increment the number of digits that we put in the string.
             add     [wNumDigits], 1

             ;For every three digits put in the string, add a comma ",".
             mov     rcx, 3
             mov     rdx, 0
             mov     rax, [wNumDigits]
             idiv    rcx
             .if     rdx = 0
                     mov     rcx, [szBuf]
                     mov     rax, [wNumChars]
                     mov     byte [rcx + rax], ','
                     add     [wNumChars], 1
             .endif

             ;Divide the number by 10 and repeat the process.
             mov     rcx, 10
             mov     rdx, 0
             mov     rax, [lNum]
             idiv    rcx
             mov     [lNum], rax
             ;Continue adding digits to the string until the number is zero.
     .until  [lNum] <= 0

     ;If the last character added to the string was a comma, truncate it.
     mov     rcx, [szBuf]
     mov     rax, [wNumChars]
     .if     byte [rcx + rax - 1] = ','
             mov     byte [rcx + rax - 1], 0
     .endif

     ;Make sure that the string is zero-terminated.
     mov     rcx, [szBuf]
     mov     rax, [wNumChars]
     mov     byte [rcx + rax], 0

     ;We added all of the chaaracters to the string in reverse order.
     ;We must reverse the contents of the string.
     ;strrev(szBuf);
     cinvoke _strrev, [szBuf]

     ;Returns the address of the string.  This is the same value that was
     ;passed to us initially.  Returning it here makes it easier for the
     ;calling function to use the string.
     return [szBuf]
endp

section '.rsrc' resource data readable

  directory RT_ICON, icons, RT_GROUP_ICON, group_icons, RT_DIALOG, dialogs, RT_MANIFEST, manifest

  resource dialogs, DLG_MEMSTAT, LANG_ENGLISH + SUBLANG_DEFAULT, memstatdialog
  resource icons, 1, LANG_NEUTRAL, icon_data
  resource group_icons, IDI_ICON, LANG_NEUTRAL, main_icon
  resource manifest, 1, LANG_NEUTRAL, xpstyle

  resdata xpstyle
          file '\..\fasmw64\v7include64\winxpstyle.xml'
  endres

  icon     main_icon, icon_data, 'MEMSTAT.ICO'

  ;macro dialogitem class, title, id, x, y, cx, cy, style, exstyle

  dialog memstatdialog, 'Memory Status', 60, 27, 136, 134, DS_MODALFRAME or WS_POPUP or WS_VISIBLE or WS_CAPTION or WS_SYSMENU,\
         NULL, NULL, "Arial Bold", 16
         dialogitem 'STATIC', 'Memory Load:', -1, 8, 4, 52, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_MEMLOAD, 70, 4, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP

         dialogitem 'STATIC', 'Total Physical:', -1, 0, 20, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_TOTALPHYS, 70, 20, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', 'Available Physical:', -1, 0, 32, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_AVAILPHYS, 70, 32, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', 'Used Physical:', -1, 0, 44, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_USEDPHYSICAL, 70, 44, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP

         dialogitem 'STATIC', 'Total Pagefile:', -1, 0, 60, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_TOTALPAGEFILE, 70, 60, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', 'Available Pagefile:', -1, 0, 72, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_AVAILPAGEFILE, 70, 72, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', 'Used Pagefile:', -1, 0, 84, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_USEDPAGEFILE, 70, 84, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP

         dialogitem 'STATIC', 'Total Virtual:', -1, 0, 100, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_TOTALVIRTUAL, 70, 100, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', 'Available Virtual:', -1, 0, 112, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_AVAILVIRTUAL, 70, 112, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', 'Used Virtual:', -1, 0, 124, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
         dialogitem 'STATIC', '', ID_USEDVIRTUAL, 70, 124, 60, 8, SS_RIGHT or WS_CHILD or WS_VISIBLE or WS_GROUP
  enddialog

section '.idata' import data readable writeable

  library msvcrt, 'MSVCRT.DLL',\
          kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL',\
          gdi32,'GDI32.DLL',\
          comctl32,'COMCTL32.DLL',\
          comdlg32,'COMDLG32.DLL'

  include 'apia/msvcrt.inc'
  include 'apia/kernel32.inc'
  include 'apia/user32.inc'
  include 'apia/gdi32.inc'
  include 'apia/comctl32.inc'
  include 'apia/comdlg32.inc'    
Post 26 Mar 2012, 21:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 26 Mar 2012, 21:21
This does not assemble with fasmw's include set, and if I cut it down to the version that I can test-assemble quickly, I still do not get a problem.
Post 26 Mar 2012, 21:21
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 26 Mar 2012, 21:55
I use my own custom includes (macros remain pretty much the same). Download the file with the underscore in front. the file hasn't been updated in about a month, so they use the older 64bit include sets):
http://board.flatassembler.net/topic.php?t=13931
I'll see if I can recreate the error with the standard fasmw includes.

[EDIT]
Couldn't recreate the error, so maybe the fix in the com64.inc will correct the problem. Have you uploaded the fix yet?
Post 26 Mar 2012, 21:55
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 27 Mar 2012, 10:23
I uploaded it at the same time that I was writing about it.
Post 27 Mar 2012, 10:23
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 28 Mar 2012, 21:32
Tomasz Grysztar wrote:
This does not assemble with fasmw's include set, and if I cut it down to the version that I can test-assemble quickly, I still do not get a problem.


I re-merged the new macro '.inc' files with my own and they seem to work now. No more problems.

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 28 Mar 2012, 21:32
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 18 Apr 2012, 11:22
Ok, one more minor problem. In the 'win64wxp.inc' the parameter count checker just gives a standard error, rather than a 'parameter count error'.
Post 18 Apr 2012, 11:22
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 18 Apr 2012, 11:24
In what context? Please post the minimal reproducing source.
Post 18 Apr 2012, 11:24
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 18 Apr 2012, 13:05
Did some more checking. And discovered that your macros work fine, it was a DISPLAY macro that was causing the problem. Sorry about that. anyways if your still curious, here is the source to the macro and the .asm file.

MACRO
Code:
macro __digit num {
   if num < 10
    display '0'+num
   else
    display 'A'+num-10
   end if
}

;DISPLAY "Offset: ", <$,16>, 13, 10
macro __display arg1, arg2 {
   if arg2 eq
    display arg1
   else
    local ..tmp
    ..tmp = arg1
    virtual at 0
     repeat 32
      if ..tmp > 0
       db ..tmp mod arg2
       ..tmp = ..tmp / arg2
      end if
     end repeat
     repeat $
      load ..tmp byte from $-%
      __digit ..tmp
     end repeat
     if $ = 0
      display '0'
     end if
    end virtual
   end if
}

macro DISPLAY [arg] { __display arg }
    


CODE
Code:
format PE64 GUI 5.0 on 'nul'
entry WinMain

include 'win64w.inc'
include 'equates\msvcrt.inc'      ;msvcrt.dll
include 'equates\kernel32.inc'    ;kernel32.dll
include 'equates\ole32.inc'       ;ole32.dll
include 'equates\gdi32.inc'       ;gdi32.dll
include 'equates\gdiplus.inc'     ;gdiplus.dll
include 'equates\wincodec.inc'    ;gdiplus.dll
include 'equates\user32.inc'      ;user32.dll
include 'equates\comctl32.inc'    ;comctl32.dll
include 'equates\comdlg32.inc'    ;comdlg32.dll
include 'equates\shell32.inc'     ;shell32.dll
include 'equates\winmm.inc'       ;winmm.dll
include 'equates\mmreg.inc'       ;winmm.dll, msvfw32.dll
include 'equates\winsock2.inc'    ;ws2_32.dll
include 'equates\dbghelp.inc'     ;dbghelp.dll
include 'equates\winspool.inc'    ;winspool.dll, localspl.dll
include 'equates\uiribbon.inc'    ;(COM OBJECTS ONLY)
include 'equates\propsys.inc'     ;propsys.dll
include 'equates\winscard.inc'    ;winscard.dll
include 'equates\riched20.inc'    ;riched20.dll
include 'equates\shlwapi.inc'     ;shlwapi.dll
include 'equates\vfw.inc'         ;msvfw32.dll, avifil32.dll, avicap32.dll
include 'equates\windns.inc'      ;dnsapi.dll
include 'equates\winioctl.inc'    ;kernel32.dll
include 'equates\wininet.inc'     ;wininet.dll <> winhttp.dll
include 'equates\wincrypt.inc'    ;crypt32.dll, advapi32.dll
include 'equates\shlobj.inc'      ;mpr.dll
include 'equates\sapi53.inc'      ;(COM OBJECTS ONLY)
include 'equates\ras.inc'         ;rasapi32.dll
include 'equates\mshtml.inc'      ;(COM OBJECTS ONLY)
include 'equates\msxml6.inc'       ;???
include 'equates\xpsobjectmodel.inc'
include 'equates\opmapi.inc'      ;dxva2.dll
include 'equates\mmdeviceapi.inc' ;mmdevapi.dll
include 'equates\mfapi.inc'       ;mf.dll
include 'equates\wmcontainer.inc' ;???
include 'equates\audioclient.inc' ;(COM OBJECTS ONLY)

include 'equates\gl\opengl32.inc'      ;opengl32.dll; glu32.dll; glut32.dll; glaux.dll
;include 'equates\directx\ddraw.inc'    ;ddraw.dll'
;include 'equates\directx\dshow.inc'    ;
;include 'equates\directx\dplay8.inc'   ;
include 'equates\directx\d3d9.inc'     ;d3d9.dll
include 'equates\directx\d3dx9.inc'    ;d3dx9_xx.dll
;include 'equates\directx\dsound8.inc'  ;dsound.dll
;include 'equates\directx\dmusic.inc'   ;dmusic.dll
include 'equates\directx\dinput8.inc'  ;dinput8.dll
;include 'equates\evr.inc'              ;evr.dll
;include 'equates\directx\d3d10.inc'    ;d3d10.dll  d3d10_1.dll
;include 'equates\directx\d3dx10.inc'   ;d3dx10_xx.dll
;include 'equates\directx\d3d11.inc'    ;d3d11.dll
;include 'equates\directx\d3dx11.inc'   ;d3dx11_4x.dll
include 'equates\directx\d2d1.inc'     ;d2d1.dll
include 'equates\directx\dwrite.inc'   ;dwrite.dll
include 'equates\directx\dxva2api.inc' ;dxva2.dll
include 'equates\directx\xaudio2.inc'  ;xaudio2_7.dll
include 'equates\directx\xapo.inc'     ;(COM OBJECTS ONLY)
include 'equates\fmodex64.inc'         ;fmodex.dll

WINDOWWIDTH  = 800
WINDOWHEIGHT = 600

;DISPLAY "SizeOf: ",<sizeof.XPS_COLOR, 10>,13,10
;DISPLAY "Value: ",<sizeof.DWORD, 10>,13,10

section '.data' data readable writeable
  szAppTitle du "All in one Shell 64W",0
  szAppClass du "WinShellW64",0
  _fontname  du "Courier New",0 ;"Tahoma"
  align 8

  hWnd      dq 0
  hInstance dq 0
  editfont  dq 0

  icex INITCOMMONCONTROLSEX sizeof.INITCOMMONCONTROLSEX, ICC_ALL_CLASSES

section '.code' code readable executable

proc WinMain hInst, hPrevInstance, lpCmdLine, nCmdShow
     local msg:MSG, winClass:WNDCLASSEXW, clientrectangle:RECT, startx:QWORD, starty:QWORD

     invoke  InitCommonControlsEx, icex
     cinvoke memset, addr winClass, 0, sizeof.WNDCLASSEXW
     invoke  GetModuleHandle, 0
     mov     [hInstance], rax
     mov     [winClass.hInstance], rax
     mov     [winClass.lpszClassName], szAppClass
     mov     [winClass.cbSize], sizeof.WNDCLASSEXA
     mov     [winClass.style], CS_HREDRAW or CS_VREDRAW
     mov     [winClass.lpfnWndProc], WindowProc
     invoke  LoadIcon, [hInstance], IDI_APPLICATION
     mov     [winClass.hIcon], rax
     mov     [winClass.hIconSm], rax
     invoke  LoadCursor, NULL, IDC_ARROW
     mov     [winClass.hCursor], rax
     invoke  GetStockObject, WHITE_BRUSH
     mov     [winClass.hbrBackground], rax
     mov     [winClass.lpszMenuName], NULL
     mov     [winClass.cbClsExtra], 0
     mov     [winClass.cbWndExtra], 0

     ;Register our window class.
     invoke  RegisterClassEx, addr winClass
     .if     rax = NULL
             invoke  MessageBox, NULL, "RegisterClassEx()", "ERROR", MB_OK or MB_ICONERROR
             return  FALSE
     .endif

     ;Create window for Direct3D FullScreen mode.
     invoke  GetSystemMetrics, SM_CXFULLSCREEN
     shr     rax, 1
     sub     rax, WINDOWWIDTH shr 1
     mov     [startx], rax

     invoke  GetSystemMetrics, SM_CYFULLSCREEN
     shr     rax, 1
     sub     rax, WINDOWHEIGHT shr 1
     mov     [starty], rax

     invoke  SetRect, addr clientrectangle, 0, 0, WINDOWWIDTH, WINDOWHEIGHT
     invoke  AdjustWindowRect, addr clientrectangle, WS_OVERLAPPEDWINDOW or WS_VISIBLE, FALSE
     movsxd  r10, [clientrectangle.right]
     movsxd  r11, [clientrectangle.left]
     sub     r10, r11
     movsxd  r11, [clientrectangle.bottom]
     movsxd  r12, [clientrectangle.top]
     sub     r11, r12
     invoke  CreateWindowEx, NULL;, szAppClass, szAppTitle, WS_OVERLAPPEDWINDOW or WS_VISIBLE, [startx], [starty], r10, r11,\
             NULL, NULL, [hInstance], NULL
     .if     rax = NULL
             invoke  MessageBox, NULL, "CreateWindowEx()", "ERROR", MB_OK or MB_ICONERROR
             return  FALSE
     .endif
     mov     [hWnd], rax

     mov     [msg.message], FALSE
     .while  [msg.message] <> WM_QUIT
             invoke  GetMessage, addr msg, NULL, 0, 0
             invoke  TranslateMessage, addr msg
             invoke  DispatchMessage, addr msg
     .endw

     invoke  ExitProcess, 0
     return
endp

proc WindowProc  hwnd, wmsg, wparam, lparam
     local hdc:QWORD, qfloat:DOUBLE, ps:PAINTSTRUCT, szBuffer[128]:WORD
     ;Note that first four parameters are passed in registers,
     ;while names given in the declaration of procedure refer to the stack
     ;space reserved for them - you may store them there to be later accessible
     ;if the contents of registers gets destroyed. This may look like:
     mov     [hwnd], rcx
     mov     [wmsg], rdx
     mov     [wparam], r8
     mov     [lparam], r9

     ;check for messages wanted here
     .if     rdx = WM_CREATE
             invoke  CreateFont, 24, 10, 0, 0, FW_BOLD, NULL, NULL, NULL, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,\
                     CLEARTYPE_QUALITY, VARIABLE_PITCH or FF_DONTCARE, _fontname
             mov     [editfont], rax
             return  0

     .elseif rdx = WM_PAINT
             invoke  BeginPaint, rcx, addr ps
             mov     [hdc], rax

             .if     [editfont]
                     invoke  SelectObject, [hdc], [editfont]
             .endif

             fldpi
             fstp    [qfloat]
             cinvoke swprintf, addr szBuffer, "Float: %7.10f", [qfloat]
             cinvoke wcslen, addr szBuffer
             invoke  TextOut, [hdc], 0, 0, addr szBuffer, rax

             invoke  EndPaint, [hwnd], addr ps
             return  0

     .elseif rdx = WM_KEYDOWN
             .if     r8 = VK_ESCAPE
                     .if     [editfont]
                             invoke  DeleteObject, [editfont]
                             mov     [editfont], NULL
                     .endif
                     invoke  PostQuitMessage, 0
             .endif
             return  0

     .elseif rdx = WM_CLOSE
             .if     [editfont]
                     invoke  DeleteObject, [editfont]
                     mov     [editfont], NULL
             .endif
             invoke  PostQuitMessage, NULL
             return  0
     .endif

     invoke  DefWindowProc, rcx, rdx, r8, r9
     return
endp

section '.rsrc' resource data readable
  directory RT_MANIFEST, manifest

  resource manifest, 1, LANG_NEUTRAL, xpstyle

  resdata xpstyle
          file '\..\fasmw64\v7include64\winxpstyle.xml'
  endres

section '.idata' import data readable writeable

  library msvcrt,'MSVCRT.DLL',\
          kernel32,'KERNEL32.DLL',\
          gdi32,'GDI32.DLL',\
          gdiplus,'GDIPLUS.DLL',\
          user32,'USER32.DLL',\
          winspool,'WINSPOOL.DLL',\
          comctl32,'COMCTL32.DLL',\
          comdlg32,'COMDLG32.DLL',\
          shell32,'SHELL32.DLL',\
          dbghelp,'DBGHELP.DLL',\
          propsys,'PROPSYS.DLL',\
          ole32,'OLE32.DLL',\
          oleaut32,'OLEAUT32.DLL',\
          ws2_32,'WS2_32.DLL',\
          winscard,'WINSCARD.DLL',\
          winmm,'WINMM.DLL',\
          riched20,'RICHED20.DLL',\
          shlwapi,'SHLWAPI.DLL',\
          msvfw32,'MSVFW32.INC',\
          avifil32,'AVIFIL32.DLL',\
          advapi32,'ADVAPI32.DLL',\
          avicap32,'AVICAP32.DLL',\
          urlmon,'URLMON.DLL',\
          dnsapi,'DNSAPI.DLL',\
          mapi,'MAPI32.DLL',\
          wininet,'WININET.DLL',\
          winhttp,'WINHTTP.DLL',\
          rasapi32,'RASAPI32.DLL',\
          Crypt32,'CRYPT32.DLL',\
          uxtheme,'UXTHEME.DLL',\
          mpr,'MPR.DLL',\
          mshtml,'MSHTML.DLL',\
          odbc32,'ODBC32.DLL',\
          localspl,'LOCALSPL.DLL',\
          avrt,'AVRT.DLL',\
          mmdevapi,'MMDEVAPI.DLL',\
          mf,'MF.DLL',\
          mfplat,'MFPLAT.DLL',\
          mfreadwrite,'MFREADWRITE.DLL',\
          dwmapi,'DWMAPI.DLL',\
          \
          opengl32,'OPENGL32.DLL',\
          glu32,'GLU32.DLL',\
          ddraw,'DDRAW.DLL',\
          dinput8,'DINPUT8.DLL',\
          dsound8,'DSOUND8.DLL',\
          dplayx,'DPLAYX.DLL',\
          d3d10,'D3D10.DLL',\
          d3dx10_33,'D3DX10_33.DLL',\
          evr,'EVR.DLL',\
          dxva2,'DXVA2.DLL',\
          fmodex,'FMODEX.DLL'

  COMMENT  {
          d3d9,'D3D9.DLL',\
          d3dx9_24,'D3DX9_24.DLL',\
          d3d11,'D3D11.DLL',\
          d3dx11,'D3DX11.DLL',\
          }

  include 'apiw\msvcrt.inc'
  include 'apiw\kernel32.inc'
  include 'apiw\gdi32.inc'
  include 'apiw\gdiplus.inc'
  include 'apiw\user32.inc'
  include 'apiw\winspool.inc'
  include 'apiw\comctl32.inc'
  include 'apiw\comdlg32.inc'
  include 'apiw\shell32.inc'
  include 'apiw\dbghelp.inc'
  include 'apiw\propsys.inc'
  include 'apiw\ole32.inc'
  include 'apiw\oleaut32.inc'
  include 'apiw\ws2_32.inc'
  include 'apiw\winscard.inc'
  include 'apiw\winmm.inc'
  include 'apiw\riched20.inc'
  include 'apiw\shlwapi.inc'
  include 'apiw\msvfw32.inc'
  include 'apiw\avifil32.inc'
  include 'apiw\avicap32.inc'
  include 'apiw\advapi32.inc'
  include 'apiw\dnsapi.inc'
  include 'apiw\mapi32.inc'
  include 'apiw\wininet.inc'
  include 'apiw\winhttp.inc'
  include 'apiw\rasapi32.inc'
  include 'apiw\crypt32.inc'
  include 'apiw\uxtheme.inc'
  include 'apiw\mpr.inc'
  include 'apiw\mshtml.inc'
  include 'apiw\avrt.inc'
  include 'apiw\mmdevapi.inc'
  include 'apiw\mf.inc'
  include 'apiw\mfplat.inc'
  include 'apiw\mfreadwrite.inc'

  include 'apiw\gl\opengl32.inc'
  include 'apiw\gl\glu32.inc'
  include 'apiw\directx\ddraw.inc'
  include 'apiw\directx\dinput8.inc'
  include 'apiw\directx\dsound8.inc'
  include 'apiw\directx\d3d9.inc'
  ;include 'apiw\directx\d3dx9_24.inc'
  include 'apiw\directx\d3d10_1.inc'
  ;include 'apiw\directx\d3d10.inc'
  include 'apiw\directx\d3dx10_33.inc'
  ;include 'apiw\directx\d3d11.inc'
  ;include 'apiw\directx\d3dx11_43.inc'
  include 'apiw\directx\d2d1.inc'
  include 'apiw\directx\dwrite.inc'
  include 'apiw\directx\dxva2.inc'
  include 'apiw\evr.inc'
  include 'apiw\fmodex64.inc'
  ;include 'apiw\fmod64.inc'
    
[/b]
Post 18 Apr 2012, 13:05
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.