The MASM Forum

64 bit assembler => UASM Assembler Development => Topic started by: Vortex on March 23, 2017, 05:18:27 AM

Title: INCBIN example crashing
Post by: Vortex on March 23, 2017, 05:18:27 AM
I have a Jwasm example using the INCBIN statement reading from .res files to setup binary resource templates. The same example reassembled with HJwasm 32-bit v2.21 is crashing. Is there an option that I miss while using the INCBIN statement?

The attached project contains the project assembled with Jwasm v2.12pre and HJwasm 2.21
Title: Re: INCBIN example crashing
Post by: johnsa on March 23, 2017, 06:15:01 AM
I've tried using both hjwasm32 and hjwasm64(version 2.21) to build this and it's been absolutely fine.

Habran can you try your side as well ?
Title: Re: INCBIN example crashing
Post by: Vortex on March 23, 2017, 06:31:27 AM
Hi johnsa,

The project is built on a XP 64-bit system.
Title: Re: INCBIN example crashing
Post by: johnsa on March 23, 2017, 07:46:46 AM
Just to clarify, is it the final exe that crashes not the assembly process?
Title: Re: INCBIN example crashing
Post by: jj2007 on March 23, 2017, 07:50:24 AM
You could use RC_DATA instead.
Title: Re: INCBIN example crashing
Post by: johnsa on March 23, 2017, 08:02:56 AM
I don't believe it's INCBIN , I've taken that out and the exe still crashes.. the problem comes from here:


   invoke  GetModuleHandle,NULL
008D101C 6A 00                push        0 
008D101E FF 15 34 60 8D 00    call        dword ptr ds:[8D6034h] 
    invoke  DialogBoxIndirectParam,eax,ADDR Dlgbox,NULL,ADDR DlgProc,NULL
008D1024 6A 00                push        0 
008D1026 68 05 10 8D 00       push        8D1005h 
008D102B 6A 00                push        0 
008D102D 68 00 50 8D 00       push        8D5000h 
008D1032 50                   push        eax 
008D1033 FF 15 74 60 8D 00    call        dword ptr ds:[8D6074h] 
    invoke  ExitProcess,eax
008D1039 50                   push        eax 
008D103A FF 15 38 60 8D 00    call        dword ptr ds:[8D6038h] 

DlgProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
008D1040 55                   push        ebp 
008D1041 8B EC                mov         ebp,esp 
   


The pushed address and the address of DlgProc are not the same
Title: Re: INCBIN example crashing
Post by: TWell on March 23, 2017, 08:05:19 AM
HJWasm32 INCBIN forgot OFFSET ?

INCBIN filename [, starting offset[, max size]]

Easy to check with PEView from obj-file.
Title: Re: INCBIN example crashing
Post by: aw27 on March 23, 2017, 06:17:25 PM
Quote from: johnsa on March 23, 2017, 08:02:56 AM
I don't believe it's INCBIN , I've taken that out and the exe still crashes.. the problem comes from here:


   invoke  GetModuleHandle,NULL
008D101C 6A 00                push        0 
008D101E FF 15 34 60 8D 00    call        dword ptr ds:[8D6034h] 
    invoke  DialogBoxIndirectParam,eax,ADDR Dlgbox,NULL,ADDR DlgProc,NULL
008D1024 6A 00                push        0 
008D1026 68 05 10 8D 00       push        8D1005h 
008D102B 6A 00                push        0 
008D102D 68 00 50 8D 00       push        8D5000h 
008D1032 50                   push        eax 
008D1033 FF 15 74 60 8D 00    call        dword ptr ds:[8D6074h] 
    invoke  ExitProcess,eax
008D1039 50                   push        eax 
008D103A FF 15 38 60 8D 00    call        dword ptr ds:[8D6038h] 

DlgProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
008D1040 55                   push        ebp 
008D1041 8B EC                mov         ebp,esp 
   


The pushed address and the address of DlgProc are not the same

From what I have seen in WinDbg the first 64 bytes of the resource file are not skipped as expected. In JWasm they are.
Title: Re: INCBIN example crashing
Post by: aw27 on March 23, 2017, 07:11:53 PM
Quote from: johnsa on March 23, 2017, 06:15:01 AM
I've tried using both hjwasm32 and hjwasm64(version 2.21) to build this and it's been absolutely fine.

Habran can you try your side as well ?

I suspect Habran will find everything shinning and well lubricated.
Title: Re: INCBIN example crashing
Post by: jj2007 on March 23, 2017, 07:55:10 PM
Attached a version that uses RC_DATA - plain Masm32. You can play with the useRcData switch on top.

It works fine with useRcData=1, built with JWasm, HJWasm or MASM.
It works fine with useRcData=0 and JWasm.

I suggest building it with HJWasm with useRcData=0. and an int 3 here:
    mov ecx, offset Dlgbox
    int 3
    add ecx, 64
    invoke  DialogBoxIndirectParam,eax, ecx, NULL, ADDR DlgProc,NULL
Title: Re: INCBIN example crashing
Post by: aw27 on March 23, 2017, 08:20:30 PM
Quote from: jj2007 on March 23, 2017, 07:55:10 PM
    add ecx, 64
    invoke  DialogBoxIndirectParam,eax, ecx, NULL, ADDR DlgProc,NULL
add ecx, 64 will properly fix the INCBIN malfunction.  :t
Title: Re: INCBIN example crashing
Post by: johnsa on March 23, 2017, 09:02:40 PM
Hi,

I believe this is all fixed now.

I've created a test / beta version of this which you can grab from:

www.terraspace.co.uk/hjwasm32.zip (http://www.terraspace.co.uk/hjwasm32.zip)

Nb this is now v2.22 (it includes a LOT of other new stuff which I won't tell you about yet until we know the bugs are fixed ) :)
Title: Re: INCBIN example crashing
Post by: jj2007 on March 23, 2017, 10:42:26 PM
Quote from: aw27 on March 23, 2017, 08:20:30 PM
add ecx, 64 will properly fix the INCBIN malfunction.  :t

No, that's not enough, see screenshots below: important parts are missing, see "About" at 403060.

Anyway, @johnsa: New version works like a charm :t
Title: Re: INCBIN example crashing
Post by: aw27 on March 23, 2017, 11:02:02 PM
Quote from: jj2007 on March 23, 2017, 10:42:26 PM
No, that's not enough, see screenshots below

You are right!  :t
Title: Re: INCBIN example crashing
Post by: johnsa on March 23, 2017, 11:17:07 PM
Excellent :)

I'll close this one on my side and continue looking into the other issues. Hopefully we can get the rest resolved today and put out the 2.22 update plus details of the new features.
Title: Re: INCBIN example crashing
Post by: Vortex on March 24, 2017, 04:27:33 AM
Hi johnsa,

The final executable was crashing because of the INCBIN issue. Thanks for the new version 2.22, it works fine. :t