News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Strange behavior with direct2d and ml64

Started by BugCatcher, June 28, 2023, 01:36:25 AM

Previous topic - Next topic

BugCatcher

This program will draw a bitmap right after it is loaded, but only once then the bitmap seems to destroy itself or the render target. Moving the drawbitmap function any where else doesn't work. Just draws a blank. Works fine in 32 bits....weird.

zedd151

Are your structures if used appropriate for 64 bit? I only have 32 bit at the moment so I can't run the program.
I am sure it is something simple due to conversion maybe. Also, I am outside on my iPad so can't directly look at the source code just yet.

BugCatcher

Thats always tough to do because theres really no 64 bit help files. So I'm always experimenting with the pesky structure types.

HSE

Equations in Assembly: SmplMath

zedd151

Quote from: BugCatcher on June 28, 2023, 01:57:27 AM
Thats always tough to do because theres really no 64 bit help files. So I'm always experimenting with the pesky structure types.
aha... possibly a good starting point for troubleshooting. When I get back inside, I'll take a looksee

zedd151

QuoteThe system cannot find the path specified.
Assembling: screenbitmap.asm
Dx2Includes\d2d1.inc(3) : fatal error A1000:cannot open file : c:/Dx64Includes/D2DBaseTypes.inc
Microsoft (R) Incremental Linker Version 14.33.31629.0
Copyright (C) Microsoft Corporation.  All rights reserved.


actually missing 2 includes


;--- include file created by h2incx v0.99.20 (copyright 2005-2009 japheth)


include   D2DBaseTypes.inc
include   dcommon.inc



I also corrected path for includes. Should not have drive letter

zedd151

Okay, you updated the download...


do not put the path "Dx64Includes/D2DBaseTypes.inc" its already in the Dx64Includes directory:


include   Dx64Includes/D2DBaseTypes.inc
include   Dx64Includes/dcommon.inc


include   D2DBaseTypes.inc
include   dcommon.inc

the code though still has errors...


Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.


Assembling: screenbitmap.asm
screenbitmap.asm(107) : error A2022:instruction operands must be the same size
Microsoft (R) Incremental Linker Version 14.33.31629.0
Copyright (C) Microsoft Corporation.  All rights reserved.




Okay I must have an old win64.inc I corrected MSG  struct it was     'message     DWORD'


MSG STRUCT STRUCT_ALIGN
   hwnd  HWND ?
   message QWORD ?
   wParam  WPARAM ?
   lParam  LPARAM ?
   time  DWORD ?
   pt  POINT<>
MSG ENDS



I changed message to qword. It assembles but same result as yours.
We need a DX expert. Siekmanski... where art thou? I know exactly nothing about the api's involved

zedd151

Sorry that I couldn't be more help. Only to watch the paths. Most of us here do not put the drive letter in the path. Also the include files that are already in the "Dx64Includes" folder do not need "Dx64Includes" in the path there
I thought this might be a simple conversion error. Seems not. I had reinstalled my copy of Win 10 64 bit to look at it. Unfortunately it (my masm64 install) has an old buggy win64.inc in the masm64 directory. my bad on that bit.


Siekmanski and a few others are pretty good with this stuff. My graphics knowledge is limited to gdi and just barely  :tongue:

jj2007

First, I've got the old version assembled, and indeed, some paths need to be fixed. Inter alia, it should be known by everybody in this forum that not all members place their masm32 or masm64 folders in C:

include c:\masm64\include64\masm64rt.inc is thus bad style.

Use include \masm64\include64\masm64rt.inc

Second, there are absolutely no error checks. I refuse to even look at this code.

Post your coinvoke macro, so that we can use it to check for errors.

HSE

Quote from: BugCatcher on June 28, 2023, 01:36:25 AM
Works fine in 32 bits....weird.

In 64 bits you can't use OFFSET to point things in .data? section.

You must use lea in coinvoke macro, or you can just put that structures in .data section and must work:.data
    g_pDirect2dFactory LPID2D1FACTORY       NULL
    g_pIWICImagingFactory LPIWICIMAGINGFACTORY NULL
    g_pRenderTarget LPID2D1RENDERTARGET  NULL

;.data?
    RTP  D2D1_RENDER_TARGET_PROPERTIES      <>
    HRT  D2D1_HWND_RENDER_TARGET_PROPERTIES <>
    sizeRenderTarget  D2D1_SIZE_F           <>


Indead really strange behavior, work well from x64dbg but not from command or explorer  :biggrin:

I used Hutch's loop:; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

msgloop proc

    LOCAL msg    :MSG
    LOCAL pmsg   :QWORD

    mov pmsg, ptr$(msg)                     ; get the msg structure address
    jmp gmsg                                ; jump directly to GetMessage()

  mloop:
    invoke TranslateMessage,pmsg
    invoke DispatchMessage,pmsg
  gmsg:
    test rax, rv(GetMessage,pmsg,0,0,0)     ; loop until GetMessage returns zero
    jnz mloop

    ret

msgloop endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤


but no difference making:    mov eax,msg.message

Equations in Assembly: SmplMath

jj2007

This fails. Look for errcounter in the sources, especially in the coinvoke macro.

      coinvoke g_pRenderTarget,ID2D1RenderTarget,DrawBitmap,\
g_pStartBitmap,\
offset dRect,\
Opacity,\
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR,\
NULL;offset sRect

BugCatcher

Coinvoke is in the Dx2includes/Dx64MacroHelpers. I know the second one fails, thats why I put in there and thats the problem.

jj2007

No, it's not the second one, it's the 17th coinvoke, as demonstrated by the code I posted above. I caught the bug for you, BugCatcher, now it's your turn.

HSE

Quote from: BugCatcher on June 28, 2023, 06:40:48 AM
I know the second one fails, thats why I put in there and thats the problem.

I think nothing fail  :biggrin:

Using india.jpg file only requiere just a little thing:    .case WM_PAINT
            invoke LoadD2Resources,hWnd
          invoke Render
   


Perhaps there is a bad factory converter setting using buttonatlas.png (or very slow?).
Equations in Assembly: SmplMath

BugCatcher