flat assembler
Message board for the users of flat assembler.

Index > Main > Strange ! Why not include api ole\winmm.inc ?!

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 23 Nov 2020, 09:07
I download from this site fasmw new version 1.73.25 for Windows and not found in include\API:
Code:
msvcrt.inc
winmm.inc
ole32.inc
    


This is not convenient. Because for this reason, my examples not compiled !
I think like user32.inc , ole32.inc\winmm.inc\msvcrt.inc must be too !

Now i search madmatt fasm includes.
https://board.flatassembler.net/topic.php?t=13931
I use 2012 year http://www.mediafire.com/?6m3ws8anl9p0lk9
And this work in my programs.


But this solution create confusion (i am about madmatt fasm includes)

Maybe in zip apply new dir FasmAPI ?
And remove dir from fasm version include\API

Then in code easy write:
Code:
section '.idata' import data readable

  library msvcrt,   'MSVCRT.DLL',\
          kernel32, 'KERNEL32.DLL',\
          user32,   'USER32.DLL',\
          gdi32,    'GDI32.DLL',\
          comctl32, 'COMCTL32.DLL',\
          winmm,    'WINMM.DLL',\          
          ole32,    'OLE32.DLL'     

  ;include 'C:\fasmw17316\INCLUDE\API\msvcrt.inc'
  ;include 'C:\fasmw17316\INCLUDE\API\kernel32.inc'
  ;include 'C:\fasmw17316\INCLUDE\API\user32.inc'
  ;include 'C:\fasmw17316\INCLUDE\API\gdi32.inc'
  ;include 'C:\fasmw17316\INCLUDE\API\comctl32.inc'
  ;include 'C:\fasmw17316\INCLUDE\API\ole32.inc'
  ;include 'C:\fasmw17316\INCLUDE\API\winmm.inc' 
  include 'C:\fasmAPI\msvcrt.inc'
  include 'C:\fasmAPI\kernel32.inc'
  include 'C:\fasmAPI\user32.inc'
  include 'C:\fasmAPI\gdi32.inc'
  include 'C:\fasmAPI\comctl32.inc'
  include 'C:\fasmAPI\ole32.inc'
  include 'C:\fasmAPI\winmm.inc' 
    


Last edited by Roman on 23 Nov 2020, 10:51; edited 1 time in total
Post 23 Nov 2020, 09:07
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 23 Nov 2020, 10:44
I could understand ole32.inc & winmm.inc.
But what for msvcrt.inc? everything what it could gain thou could code manualy.
if thou need msvcrt so code in C or C++.

As I remember Tomasz says that not going to change official fasm package (only bugfixies if any).

Roman, from thou couple of examples for using of ole32 & winmm & I can include them in my fasmpack (I mostly trying to not include headers that not used atleast in one demo). But even I never will add anything for C layer.
C is C. Assembly is assembly.


Last edited by ProMiNick on 23 Nov 2020, 10:54; edited 1 time in total
Post 23 Nov 2020, 10:44
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 23 Nov 2020, 10:50
Quote:

I could understand ole32.inc & winmm.inc.

You too agree with me.
Post 23 Nov 2020, 10:50
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 23 Nov 2020, 11:01
(ou remember:)CRTDLL.INC present in my fasmpack but it only for patching needs left from times when I reversed COM server from HLL to assembly. (not included in any of win32a,win32w,win64a...)
Roman thou could provide thour own package or cooperate with me.

Both hands for ole presence but needed interesting examples.
Post 23 Nov 2020, 11:01
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 23 Nov 2020, 11:11
Quote:

ole presence but needed interesting examples.

Ole using in many examples.
Decoding images or XAUDIO2 or MediaFoundation Video.
Or initialized somthing from GUID key
Post 23 Nov 2020, 11:11
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 23 Nov 2020, 11:27
for a current momment I trying to recode this in assembly https://docs.microsoft.com/en-us/windows/win32/dataxchg/using-the-clipboard#example-of-a-clipboard-viewer
and compare how it is close to https://www.freeclipboardviewer.com/windowsclipboard/ by functional.
realize that just like demo.
than interested tools from times 90s: DOBJVIEW & IROTVIEW (they present in many compilers of 90s: VC6, Forth, ...) - implement them in assembly is interesting too (I have too few examples that demonstrates interfaces stuff, but these ones would be perfect demos). DOBJVIEW partially crossed with clipdoard viewer.

From other hand I a bit interested in COFF format & more examples for it.
Post 23 Nov 2020, 11:27
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 23 Nov 2020, 12:02
Windows Clipboard Viewer Help nice tool.
Post 23 Nov 2020, 12:02
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 23 Nov 2020, 14:21
realization in this state (it is not applicable to be demo)
but is is succesfuly compiled & executed, correctly displayed single chars passed to buffer & images (prnt scr etc.), but sequences of chars displayed as chinese (for unicode version) (if we built that as win32a.inc - all displayed correct)
Code:
; Template for program using standard Win32 headers

format PE GUI 4.0
entry start

include 'win32w.inc'

IDM_AUTO  = $11

section '.text' code readable executable

start:
        invoke  LoadIcon, 0, IDI_APPLICATION
        mov     [wc.hIcon], eax
        invoke  LoadCursor, 0, IDC_ARROW
        mov     [wc.hCursor], eax
        invoke  RegisterClass, wc
        test    eax, eax
        jz      error

        invoke  CreateWindowEx, 0, _class, _title, WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU, 128, 128, 256, 192, NULL, NULL, PE_IMAGE_BASE, NULL
        test    eax,eax
        jz      error

  msg_loop:
        invoke  GetMessage, msg, NULL, 0, 0
        cmp     eax, 1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  error:
        invoke  MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam
        mov     eax,[wmsg]
        cmp     eax,WM_CREATE
        je      .wmcreate
        cmp     eax,WM_SIZE
        je      .wmsize
        cmp     eax,WM_PAINT
        je      .wmpaint
        cmp     eax,WM_CHANGECBCHAIN
        je      .wmchangecbchain
        cmp     eax,WM_DRAWCLIPBOARD
        je      .wmdrawclipboard
        cmp     eax,WM_INITMENUPOPUP
        je      .wminitmenupopup
        cmp     eax,WM_CLOSE
        je      .wmclose
        cmp     eax,WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc, [hwnd], [wmsg], [wparam], [lparam]
        jmp     .finish
  .wmpaint:
        invoke  BeginPaint, [hwnd], ps
        mov     [hDC], eax
        mov     eax, [uFormat]
        cmp     eax, CF_OWNERDISPLAY
        jnz     @F
 ; CF_OWNERDISPLAY:
        ;invoke  GetClipboardOwner
        xor     eax,eax
        mov     [hwndOwner], eax
        invoke  GlobalAlloc, GMEM_MOVEABLE, sizeof.PAINTSTRUCT
        mov     [hmem], eax
        invoke  GlobalLock, eax
        mov     edi, eax
        mov     esi, ps
        mov     ecx, sizeof.PAINTSTRUCT / 4
        rep movsd
        invoke  GlobalUnlock, [hmem]
        invoke  SendMessage, [hwndOwner], WM_PAINTCLIPBOARD, [hwnd], [hmem]
        invoke  GlobalFree, [hmem]
        jmp     .wmpaint.end
      @@:
        cmp     eax, CF_BITMAP
        jnz     @F
 ; CF_BITMAP:
        invoke  CreateCompatibleDC, [hDC]
        test    eax, eax
        jz      @F
        mov     [hDCmem], eax
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      .wmpaint.cleanup_DCmem
        invoke  GetClipboardData, [uFormat]
        invoke  SelectObject, [hDCmem], eax
        invoke  BitBlt, [hDC], 0, 0, [rc.right], [rc.bottom], [hDCmem], 0, 0, SRCCOPY
        invoke  CloseClipboard
  .wmpaint.cleanup_DCmem:
        invoke  DeleteDC, [hDCmem]
        jmp     .wmpaint.end
      @@:
        cmp     eax, CF_TEXT
        jnz     @F
 ; CF_TEXT:
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      @F
        invoke  GetClipboardData, [uFormat]
        mov     [hmem], eax
        invoke  GlobalLock, eax
        invoke  DrawText, [hDC], eax, -1, rc, DT_LEFT
        invoke  GlobalUnlock, [hmem]
        invoke  CloseClipboard
        jmp     .wmpaint.end
      @@:
        cmp     eax, CF_ENHMETAFILE
        jnz     @F
 ; CF_ENHMETAFILE:
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      @F
        invoke  GetClipboardData, [uFormat]
        invoke  PlayEnhMetaFile, [hDC], eax, rc
        invoke  CloseClipboard
        jmp     .wmpaint.end
      @@:
        test    eax, eax
        jnz     @F
 ; No Format:
        invoke  DrawText, [hDC], _empty_cb, -1, rc, DT_CENTER or DT_SINGLELINE or DT_VCENTER
        jmp     .wmpaint.end
      @@:
 ; Unrecognized Format:
        invoke  DrawText, [hDC], _unable_display_cb, -1, rc, DT_CENTER or DT_SINGLELINE or DT_VCENTER

  .wmpaint.end:
        invoke  EndPaint, [hwnd], ps
        jmp     .retZERO
  .wmcreate:
        invoke  SetClipboardViewer, [hwnd]
  .wmsize:
        invoke  GetClientRect, [hwnd], rc
        cmp     [uFormat], CF_OWNERDISPLAY
        jnz     .retZERO
        invoke  GetClipboardViewer
        mov     [hwndOwner], eax
        invoke  GlobalAlloc, GMEM_MOVEABLE, sizeof.RECT
        mov     [hmem], eax
        invoke  GlobalLock, eax
        mov     edi, eax
        mov     esi, rc
        mov     ecx, sizeof.RECT / 4
        rep movsd
        invoke  GlobalUnlock, [hmem]
        invoke  SendMessage, [hwndOwner], WM_SIZECLIPBOARD, [hwnd], [hmem]
        invoke  GlobalFree, [hmem]
        jmp     .retZERO

  .wmchangecbchain:
        mov     eax, [hwndNextViewer]
        cmp     eax, [wparam]
        jz      .wmchangecbchain.repair
        test    eax, eax
        jz      .retZERO
  .passmsgcbchain:
        invoke  SendMessage, eax, [wmsg], [wparam], [lparam]
        jmp     .retZERO
  .wmchangecbchain.repair:
        mov     eax, [lparam]
        mov     [hwndNextViewer], eax
        jmp     .retZERO

  .wmdrawclipboard:
        invoke  GetPriorityClipboardFormat, auPriorityList, 4
        mov     [uFormat], eax
        mov     [fAuto], TRUE
        invoke  InvalidateRect, [hwnd], NULL, TRUE
        invoke  UpdateWindow, [hwnd]
        mov     eax, [hwndNextViewer]
        jmp     .passmsgcbchain

  .wminitmenupopup:
        mov     eax,[lparam+2]
        test    ax,ax
        jnz     .retZERO
        invoke  GetMenuItemID, [wparam], 0
        cmp     eax, IDM_AUTO
        jnz     .retZERO

        invoke  GetMenuItemCount, [wparam]
        mov     ebx, eax
      @@:
        dec     ebx
        jz      @F
        invoke  DeleteMenu, [wparam], 1, MF_BYPOSITION
        jmp     @B

        mov     eax, MF_CHECKED
        cmp     [fAuto],0
        jnz     @F
        xor     eax, eax
      @@:
        invoke  CheckMenuItem, [wparam], IDM_AUTO, eax
        invoke  CountClipboardFormats
        test    eax, eax
        jz      .retZERO
        invoke  OpenClipboard, [hwnd]
        test    eax,eax
        jz      .retZERO
        invoke  AppendMenu, [wparam], MF_SEPARATOR, 0, NULL

        xor     eax, eax
  .fmt_loop:
        invoke  EnumClipboardFormats, eax
        mov     [uFormat], eax
        stdcall GetPredefinedClipboardFormatName, eax ; Definition at line 31 of file cliputils.c (https://doxygen.reactos.org/da/d58/cliputils_8c.html)
        test    eax, eax
        jnz     @F
        invoke  GetClipboardFormatName, [uFormat], szFormatName, 80 ; similar RetrieveClipboardFormatName() - Definition at line 95 of file cliputils.c
        test    eax, eax
        mov     eax, szFormatName
        jnz     @F
        mov     eax, szUnknwnFormat
      @@:
        mov     [lpFormatName], eax
        mov     ebx, MF_STRING
        mov     eax, [uFormat]
        cmp     eax, CF_OWNERDISPLAY
        jz      @F
        cmp     eax, CF_TEXT
        jz      @F
        cmp     eax, CF_ENHMETAFILE
        jz      @F
        cmp     eax, CF_BITMAP
        jz      @F
        xor     eax, eax
        or      ebx, MF_GRAYED
      @@:
        invoke  AppendMenu, [wparam], ebx, eax, lpFormatName
        mov     eax, [uFormat]
        test    eax, eax
        jnz     .fmt_loop
        invoke  CloseClipboard
        jmp     .retZERO

  .wmclose:
        invoke  ChangeClipboardChain, [hwnd], [hwndNextViewer]
        invoke  PostQuitMessage, 0
        jmp     .retZERO

  .wmdestroy:
        invoke  DestroyWindow, [hwnd]
  .retZERO:
        xor     eax, eax
  .finish:
        ret
endp

proc GetPredefinedClipboardFormatName, _uFormat
        xor     eax, eax
        cmp     [_uFormat], CF_DIBV5
        ja      @F
        mov     eax, [_uFormat]
        test    eax, eax
        jz      @F
        mov     eax, [uFormatList+eax*4]
      @@:
        ret
endp

section '.data' data readable writeable

  _class                        TCHAR 'FASMWIN32',0
  _title                        TCHAR 'Win32 program template',0
  _error                        TCHAR 'Startup failed.',0
  _empty_cb                     TCHAR 'The clipboard is empty.',0
  _unable_display_cb            TCHAR 'Unable to display format.',0
  szUnknwnFormat                TCHAR '(unknown)',0
  STRING_CF_TEXT                TCHAR 'CF_TEXT',0
  STRING_CF_BITMAP              TCHAR 'CF_BITMAP',0
  STRING_CF_METAFILEPICT        TCHAR 'CF_METAFILEPICT',0
  STRING_CF_SYLK                TCHAR 'CF_SYLK',0
  STRING_CF_DIF                 TCHAR 'CF_DIF',0
  STRING_CF_TIFF                TCHAR 'CF_TIFF',0
  STRING_CF_OEMTEXT             TCHAR 'CF_OEMTEXT',0
  STRING_CF_DIB                 TCHAR 'CF_DIB',0
  STRING_CF_PALETTE             TCHAR 'CF_PALETTE',0
  STRING_CF_PENDATA             TCHAR 'CF_PENDATA',0
  STRING_CF_RIFF                TCHAR 'CF_RIFF',0
  STRING_CF_WAVE                TCHAR 'CF_WAVE',0
  STRING_CF_UNICODETEXT         TCHAR 'CF_UNICODETEXT',0
  STRING_CF_ENHMETAFILE         TCHAR 'CF_ENHMETAFILE',0
  STRING_CF_HDROP               TCHAR 'CF_HDROP',0
  STRING_CF_LOCALE              TCHAR 'CF_LOCALE',0
  STRING_CF_DIBV5               TCHAR 'CF_DIBV5',0

  auPriorityList dd CF_OWNERDISPLAY, CF_TEXT, CF_ENHMETAFILE, CF_BITMAP
  uFormatList   dd 0,\
                   STRING_CF_TEXT,\
                   STRING_CF_BITMAP,\
                   STRING_CF_METAFILEPICT,\
                   STRING_CF_SYLK,\
                   STRING_CF_DIF,\
                   STRING_CF_TIFF,\
                   STRING_CF_OEMTEXT,\
                   STRING_CF_DIB,\
                   STRING_CF_PALETTE,\
                   STRING_CF_PENDATA,\
                   STRING_CF_RIFF,\
                   STRING_CF_WAVE,\
                   STRING_CF_UNICODETEXT,\
                   STRING_CF_ENHMETAFILE,\
                   STRING_CF_HDROP,\
                   STRING_CF_LOCALE,\
                   STRING_CF_DIBV5




  wc            WNDCLASS 0,WindowProc,0,0,PE_IMAGE_BASE,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
  uFormat       dd -1

  msg           MSG
  hDC           dd ?
  hDCmem        dd ?
  ps            PAINTSTRUCT
  hmem          dd ?
  hbmp          dd ?
  rc            RECT
  hwndNextViewer dd ?
  hwndOwner     dd ?
  fuFlags       dd ?
  fAuto         dd ?
  lpFormatName  dd ?
  idMenuItem    dd ?
  szFormatName  TCHAR 80 dup (?)

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          gdi32,'GDI32.DLL',\
          user32,'USER32.DLL'

  include 'os_specs/windows/api/x86/kernel32.inc'
  include 'os_specs/windows/api/x86/gdi32.inc'
  include 'os_specs/windows/api/x86/user32.inc'    


Code:
        cmp     eax, CF_TEXT
        jnz     @F
 ; CF_TEXT:
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      @F
        invoke  GetClipboardData, [uFormat]
        mov     [hmem], eax
        invoke  GlobalLock, eax
        invoke  DrawTextA, [hDC], eax, -1, rc, DT_LEFT
        invoke  GlobalUnlock, [hmem]
        invoke  CloseClipboard
        jmp     .wmpaint.end    
that is solves chinese ierogliphs, no matter window is unicode or not - content of buffer with CF_TEXT format is always ascii. so DrawTextA instead of DrawText in that place.

[EDITED]: this one is exatly matched to MS designed one:
Code:
; demonstration of windows clipboard viewing

format PE GUI 4.0
entry start

include 'win32w.inc'

IDM_EXIT  = $10
IDM_AUTO  = $11

section '.text' code readable executable

start:
        invoke  LoadIcon, 0, IDI_APPLICATION
        mov     [wc.hIcon], eax
        invoke  LoadCursor, 0, IDC_ARROW
        mov     [wc.hCursor], eax
        invoke  RegisterClass, wc
        test    eax, eax
        jz      error

        invoke  CreatePopupMenu
        mov     [hSubMenu], eax
        invoke  AppendMenu, eax, 0, IDM_AUTO,_mn_auto
        invoke  CreateMenu
        mov     [hMenu], eax
        invoke  AppendMenu, eax, 0, IDM_EXIT,_mn_exit
        invoke  AppendMenu, [hMenu], MF_POPUP, [hSubMenu],_mn_format

        invoke  CreateWindowEx, 0, _class, _title, WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU, 128, 128, 256, 192, NULL, [hMenu], PE_IMAGE_BASE, NULL
        test    eax,eax
        jz      error

  msg_loop:
        invoke  GetMessage, msg, NULL, 0, 0
        cmp     eax, 1
        jb      end_loop
        jne     msg_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

  error:
        invoke  MessageBox,NULL,_error,NULL,MB_ICONERROR+MB_OK

  end_loop:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc uses ebx esi edi, hwnd,wmsg,wparam,lparam
        mov     eax,[wmsg]
        cmp     eax,WM_CREATE
        je      .wmcreate
        cmp     eax,WM_SIZE
        je      .wmsize
        cmp     eax,WM_PAINT
        je      .wmpaint
        cmp     eax,WM_CHANGECBCHAIN
        je      .wmchangecbchain
        cmp     eax,WM_DRAWCLIPBOARD
        je      .wmdrawclipboard
        cmp     eax,WM_INITMENUPOPUP
        je      .wminitmenupopup
        cmp     eax,WM_COMMAND
        je      .wmcommand
        cmp     eax,WM_CLOSE
        je      .wmclose
        cmp     eax,WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc, [hwnd], [wmsg], [wparam], [lparam]
        jmp     .finish
  .wmpaint:
        invoke  BeginPaint, [hwnd], ps
        mov     [hDC], eax
        mov     eax, [uFormat]
        cmp     eax, CF_OWNERDISPLAY
        jnz     @F
 ; CF_OWNERDISPLAY:
        ;invoke  GetClipboardOwner
        xor     eax,eax
        mov     [hwndOwner], eax
        invoke  GlobalAlloc, GMEM_MOVEABLE, sizeof.PAINTSTRUCT
        mov     [hmem], eax
        invoke  GlobalLock, eax
        mov     edi, eax
        mov     esi, ps
        mov     ecx, sizeof.PAINTSTRUCT / 4
        rep movsd
        invoke  GlobalUnlock, [hmem]
        invoke  SendMessage, [hwndOwner], WM_PAINTCLIPBOARD, [hwnd], [hmem]
        invoke  GlobalFree, [hmem]
        jmp     .wmpaint.end
      @@:
        cmp     eax, CF_BITMAP
        jnz     @F
 ; CF_BITMAP:
        invoke  CreateCompatibleDC, [hDC]
        test    eax, eax
        jz      @F
        mov     [hDCmem], eax
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      .wmpaint.cleanup_DCmem
        invoke  GetClipboardData, [uFormat]
        invoke  SelectObject, [hDCmem], eax
        invoke  BitBlt, [hDC], 0, 0, [rc.right], [rc.bottom], [hDCmem], 0, 0, SRCCOPY
        invoke  CloseClipboard
  .wmpaint.cleanup_DCmem:
        invoke  DeleteDC, [hDCmem]
        jmp     .wmpaint.end
      @@:
        cmp     eax, CF_TEXT
        jnz     @F
 ; CF_TEXT:
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      @F
        invoke  GetClipboardData, [uFormat]
        mov     [hmem], eax
        invoke  GlobalLock, eax
        invoke  DrawTextA, [hDC], eax, -1, rc, DT_LEFT
        invoke  GlobalUnlock, [hmem]
        invoke  CloseClipboard
        jmp     .wmpaint.end
      @@:
        cmp     eax, CF_ENHMETAFILE
        jnz     @F
 ; CF_ENHMETAFILE:
        invoke  OpenClipboard, [hwnd]
        test    eax, eax
        jz      @F
        invoke  GetClipboardData, [uFormat]
        invoke  PlayEnhMetaFile, [hDC], eax, rc
        invoke  CloseClipboard
        jmp     .wmpaint.end
      @@:
        test    eax, eax
        jnz     @F
 ; No Format:
        invoke  DrawText, [hDC], _empty_cb, -1, rc, DT_CENTER or DT_SINGLELINE or DT_VCENTER
        jmp     .wmpaint.end
      @@:
 ; Unrecognized Format:
        invoke  DrawText, [hDC], _unable_display_cb, -1, rc, DT_CENTER or DT_SINGLELINE or DT_VCENTER

  .wmpaint.end:
        invoke  EndPaint, [hwnd], ps
        jmp     .retZERO
  .wmcreate:
        invoke  SetClipboardViewer, [hwnd]
  .wmsize:
        invoke  GetClientRect, [hwnd], rc
        cmp     [uFormat], CF_OWNERDISPLAY
        jnz     .retZERO
        invoke  GetClipboardViewer
        mov     [hwndOwner], eax
        invoke  GlobalAlloc, GMEM_MOVEABLE, sizeof.RECT
        mov     [hmem], eax
        invoke  GlobalLock, eax
        mov     edi, eax
        mov     esi, rc
        mov     ecx, sizeof.RECT / 4
        rep movsd
        invoke  GlobalUnlock, [hmem]
        invoke  SendMessage, [hwndOwner], WM_SIZECLIPBOARD, [hwnd], [hmem]
        invoke  GlobalFree, [hmem]
        jmp     .retZERO

  .wmchangecbchain:
        mov     eax, [hwndNextViewer]
        cmp     eax, [wparam]
        jz      .wmchangecbchain.repair
        test    eax, eax
        jz      .retZERO
  .passmsgcbchain:
        invoke  SendMessage, eax, [wmsg], [wparam], [lparam]
        jmp     .retZERO
  .wmchangecbchain.repair:
        mov     eax, [lparam]
        mov     [hwndNextViewer], eax
        jmp     .retZERO

  .wmdrawclipboard:
        invoke  GetPriorityClipboardFormat, auPriorityList, 4
        mov     [uFormat], eax
        mov     [fAuto], TRUE
        invoke  InvalidateRect, [hwnd], NULL, TRUE
        invoke  UpdateWindow, [hwnd]
        cmp     [wmsg], WM_DRAWCLIPBOARD
        jnz     .retZERO
        mov     eax, [hwndNextViewer]
        jmp     .passmsgcbchain

  .wminitmenupopup:
        mov     eax,[lparam+2]
        test    ax,ax
        jnz     .retZERO
        invoke  GetMenuItemID, [wparam], 0
        cmp     eax, IDM_AUTO
        jnz     .retZERO

        invoke  GetMenuItemCount, [wparam]
        mov     ebx, eax
      @@:
        dec     ebx
        jz      @F
        invoke  DeleteMenu, [wparam], 1, MF_BYPOSITION
        jmp     @B

        mov     eax, MF_CHECKED
        cmp     [fAuto],0
        jnz     @F
        xor     eax, eax
      @@:
        invoke  CheckMenuItem, [wparam], IDM_AUTO, eax
        invoke  CountClipboardFormats
        test    eax, eax
        jz      .retZERO
        invoke  OpenClipboard, [hwnd]
        test    eax,eax
        jz      .retZERO
        invoke  AppendMenu, [wparam], MF_SEPARATOR, 0, NULL

        xor     eax, eax
  .fmt_loop:
        invoke  EnumClipboardFormats, eax
        mov     [uFormat], eax
        stdcall GetPredefinedClipboardFormatName, eax ; Definition at line 31 of file cliputils.c (https://doxygen.reactos.org/da/d58/cliputils_8c.html)
        test    eax, eax
        jnz     @F
        invoke  GetClipboardFormatName, [uFormat], szFormatName, 80 ; similar RetrieveClipboardFormatName() - Definition at line 95 of file cliputils.c
        test    eax, eax
        mov     eax, szFormatName
        jnz     @F
        cinvoke wsprintf,szFormatName,szUnknwnFormat,[uFormat]
        mov     eax, szFormatName
      @@:
        mov     [lpFormatName], eax
        mov     ebx, MF_STRING
        mov     eax, [uFormat]
        cmp     eax, CF_OWNERDISPLAY
        jz      @F
        cmp     eax, CF_TEXT
        jz      @F
        cmp     eax, CF_ENHMETAFILE
        jz      @F
        cmp     eax, CF_BITMAP
        jz      @F
        xor     eax, eax
        or      ebx, MF_GRAYED
      @@:
        invoke  AppendMenu, [wparam], ebx, eax, [lpFormatName]
        mov     eax, [uFormat]
        test    eax, eax
        jnz     .fmt_loop
        invoke  CloseClipboard
        jmp     .retZERO

  .wmcommand:
        mov     eax, [wparam]
        and     eax,$FFFF
        cmp     eax, IDM_AUTO
        jz      .wmdrawclipboard
        cmp     eax, IDM_EXIT
        jz      .wmclose
        mov     [fAuto],0
        mov     [uFormat], eax
        invoke  InvalidateRect, [hwnd], NULL, TRUE
        jmp     .retZERO

  .wmclose:
        invoke  ChangeClipboardChain, [hwnd], [hwndNextViewer]
        invoke  PostQuitMessage, 0
        jmp     .retZERO

  .wmdestroy:
        invoke  DestroyWindow, [hwnd]
  .retZERO:
        xor     eax, eax
  .finish:
        ret
endp

proc GetPredefinedClipboardFormatName, _uFormat
        xor     eax, eax
        cmp     [_uFormat], CF_DIBV5
        ja      @F
        mov     eax, [_uFormat]
        test    eax, eax
        jz      @F
        mov     eax, [uFormatList+eax*4]
      @@:
        ret
endp

section '.data' data readable writeable

  _class                        TCHAR 'FASMWIN32',0
  _title                        TCHAR 'Clipboard Viewer demo',0
  _error                        TCHAR 'Startup failed.',0
  _empty_cb                     TCHAR 'The clipboard is empty.',0
  _unable_display_cb            TCHAR 'Unable to display format.',0
  _mn_auto                      TCHAR 'auto',0
  _mn_exit                      TCHAR 'exit',0
  _mn_format                    TCHAR 'format',0
  szUnknwnFormat                TCHAR 'unknown: $%08X',0
  STRING_CF_TEXT                TCHAR 'CF_TEXT',0
  STRING_CF_BITMAP              TCHAR 'CF_BITMAP',0
  STRING_CF_METAFILEPICT        TCHAR 'CF_METAFILEPICT',0
  STRING_CF_SYLK                TCHAR 'CF_SYLK',0
  STRING_CF_DIF                 TCHAR 'CF_DIF',0
  STRING_CF_TIFF                TCHAR 'CF_TIFF',0
  STRING_CF_OEMTEXT             TCHAR 'CF_OEMTEXT',0
  STRING_CF_DIB                 TCHAR 'CF_DIB',0
  STRING_CF_PALETTE             TCHAR 'CF_PALETTE',0
  STRING_CF_PENDATA             TCHAR 'CF_PENDATA',0
  STRING_CF_RIFF                TCHAR 'CF_RIFF',0
  STRING_CF_WAVE                TCHAR 'CF_WAVE',0
  STRING_CF_UNICODETEXT         TCHAR 'CF_UNICODETEXT',0
  STRING_CF_ENHMETAFILE         TCHAR 'CF_ENHMETAFILE',0
  STRING_CF_HDROP               TCHAR 'CF_HDROP',0
  STRING_CF_LOCALE              TCHAR 'CF_LOCALE',0
  STRING_CF_DIBV5               TCHAR 'CF_DIBV5',0

  auPriorityList dd CF_OWNERDISPLAY, CF_TEXT, CF_ENHMETAFILE, CF_BITMAP
  uFormatList   dd 0,\
                   STRING_CF_TEXT,\
                   STRING_CF_BITMAP,\
                   STRING_CF_METAFILEPICT,\
                   STRING_CF_SYLK,\
                   STRING_CF_DIF,\
                   STRING_CF_TIFF,\
                   STRING_CF_OEMTEXT,\
                   STRING_CF_DIB,\
                   STRING_CF_PALETTE,\
                   STRING_CF_PENDATA,\
                   STRING_CF_RIFF,\
                   STRING_CF_WAVE,\
                   STRING_CF_UNICODETEXT,\
                   STRING_CF_ENHMETAFILE,\
                   STRING_CF_HDROP,\
                   STRING_CF_LOCALE,\
                   STRING_CF_DIBV5




  wc            WNDCLASS 0,WindowProc,0,0,PE_IMAGE_BASE,NULL,NULL,COLOR_BTNFACE+1,NULL,_class
  uFormat       dd -1

  msg           MSG
  hDC           dd ?
  hDCmem        dd ?
  ps            PAINTSTRUCT
  hmem          dd ?
  hbmp          dd ?
  rc            RECT
  hwndNextViewer dd ?
  hwndOwner     dd ?
  fuFlags       dd ?
  fAuto         dd ?
  lpFormatName  dd ?
  idMenuItem    dd ?
  hSubMenu      dd ?
  hMenu         dd ?
  szFormatName  TCHAR 80 dup (?)

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          gdi32,'GDI32.DLL',\
          user32,'USER32.DLL'

  include 'os_specs/windows/api/x86/kernel32.inc'
  include 'os_specs/windows/api/x86/gdi32.inc'
  include 'os_specs/windows/api/x86/user32.inc'     

ImageImage


Last edited by ProMiNick on 23 Nov 2020, 20:58; edited 2 times in total
Post 23 Nov 2020, 14:21
View user's profile Send private message Send e-mail Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 23 Nov 2020, 17:52
ProMiNick you cool man !
I write simple 64 bits Directx 12 Windows 10.
https://www.youtube.com/watch?v=s2K3VK7BsO0&feature=youtu.be[/b]
Post 23 Nov 2020, 17:52
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 24 Nov 2020, 17:41
Another mistake !
Not found GetFileSizeEx in fasm17325\include\API\kernel32.inc
Post 24 Nov 2020, 17:41
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 03 Dec 2020, 17:17
Fasm 173 get Error fldd 0.25 !
Post 03 Dec 2020, 17:17
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 04 Dec 2020, 06:10
GetFileSizeEx - may be present not in all windowses. Fasm not targeted to be win10 specific.
fldd - see Intel manuals - no such command
fld [double_0.25] - only memory could be send to fpu & predefined values 1,0,e
and define somewhere
double_0.25 dq 0.25
Post 04 Dec 2020, 06:10
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20513
Location: In your JS exploiting you and your system
revolution 04 Dec 2020, 06:22
Check the Intel/AMD manuals to see if the instructions are official or not.

Other assemblers or compilers often use different names for instructions. fasm doesn't support those non-standard names.
Post 04 Dec 2020, 06:22
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 04 Dec 2020, 12:58
Quote:

Fasm not targeted to be win10 specific.

GetFileSizeEx exist in Win 7
Post 04 Dec 2020, 12:58
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 04 Dec 2020, 13:03
FLDD
or this
PUSH value or register
FLD QWORD [RSP] ; load eight byte integer onto FP stack
ADD RSP,8 ; release storage from stack
Post 04 Dec 2020, 13:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20513
Location: In your JS exploiting you and your system
revolution 04 Dec 2020, 13:50
Code:
mov rax,0.25
push rax
fld qword[rsp]
pop rax    
Using mov means you can use all 64-bits to encode any qword value.
Post 04 Dec 2020, 13:50
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 04 Dec 2020, 14:37
any macro that will represent fldd would be ugly.

I can suggest this 8-byte pseudoinstruction with qword operand only for 64bit mode
Code:
macro fldd opnd{
assert ~opnd eqtype ax
db $DD,$05,$02,$00,$00,$00,$EB,$08
dq opnd}    


but

It is more better to see how exactly value passed
Code:
mov rax,0.25
push rax
fld qword[rsp]
pop rax    

or
Code:
fld qword[$+8]
jmp $+10
dq 0.25    

one trashes register
other breaches execution continuum (but applicable for any bitness) (in 64 bit first 8 bytes are constant always - so upper pseudoinstruction is that case)
Post 04 Dec 2020, 14:37
View user's profile Send private message Send e-mail Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 04 Dec 2020, 21:21
ProMiNick wrote:
GetFileSizeEx - may be present not in all windowses. Fasm not targeted to be win10 specific.

Just to make the information more precise, GetFileSizeEx has been around since at least Windows 2000.
Post 04 Dec 2020, 21:21
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 05 Dec 2020, 10:27
ProMiNick thanks nice macro !
Code:
macro fldq chP {
  fld qword[$+8]
  jmp $+10
  dq chP   }

macro fldd chP { 
  fld dword[$+8]
  jmp $+6
  dd chP   }
    
Post 05 Dec 2020, 10:27
View user's profile Send private message Reply with quote
Melissa



Joined: 12 Apr 2012
Posts: 125
Melissa 05 Dec 2020, 12:24
COM is specification for M$ vtable in C++ compiler. That's just struct of pointers to functions. Spec is hard to find as last book dthat describes how t odo it is
out of print at least 20 years Wink
Post 05 Dec 2020, 12:24
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.