Author Topic: INCBIN example crashing  (Read 2762 times)

Vortex

  • Member
  • *****
  • Posts: 2090
INCBIN example crashing
« 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

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: INCBIN example crashing
« Reply #1 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 ?

Vortex

  • Member
  • *****
  • Posts: 2090
Re: INCBIN example crashing
« Reply #2 on: March 23, 2017, 06:31:27 AM »
Hi johnsa,

The project is built on a XP 64-bit system.

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: INCBIN example crashing
« Reply #3 on: March 23, 2017, 07:46:46 AM »
Just to clarify, is it the final exe that crashes not the assembly process?

jj2007

  • Member
  • *****
  • Posts: 10026
  • Assembler is fun ;-)
    • MasmBasic
Re: INCBIN example crashing
« Reply #4 on: March 23, 2017, 07:50:24 AM »
You could use RC_DATA instead.

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: INCBIN example crashing
« Reply #5 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:

Code: [Select]
   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

TWell

  • Member
  • ****
  • Posts: 748
Re: INCBIN example crashing
« Reply #6 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.

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: INCBIN example crashing
« Reply #7 on: March 23, 2017, 06:17:25 PM »
I don't believe it's INCBIN , I've taken that out and the exe still crashes.. the problem comes from here:

Code: [Select]
   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.

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: INCBIN example crashing
« Reply #8 on: March 23, 2017, 07:11:53 PM »
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.

jj2007

  • Member
  • *****
  • Posts: 10026
  • Assembler is fun ;-)
    • MasmBasic
Re: INCBIN example crashing
« Reply #9 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:
Code: [Select]
    mov ecx, offset Dlgbox
    int 3
    add ecx, 64
    invoke  DialogBoxIndirectParam,eax, ecx, NULL, ADDR DlgProc,NULL

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: INCBIN example crashing
« Reply #10 on: March 23, 2017, 08:20:30 PM »
    add ecx, 64
    invoke  DialogBoxIndirectParam,eax, ecx, NULL, ADDR DlgProc,NULL
add ecx, 64 will properly fix the INCBIN malfunction.  :t

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: INCBIN example crashing
« Reply #11 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

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 ) :)

jj2007

  • Member
  • *****
  • Posts: 10026
  • Assembler is fun ;-)
    • MasmBasic
Re: INCBIN example crashing
« Reply #12 on: March 23, 2017, 10:42:26 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

AW

  • Member
  • *****
  • Posts: 2550
  • Let's Make ASM Great Again!
Re: INCBIN example crashing
« Reply #13 on: March 23, 2017, 11:02:02 PM »
No, that's not enough, see screenshots below

You are right!  :t

johnsa

  • Member
  • ****
  • Posts: 799
    • Uasm
Re: INCBIN example crashing
« Reply #14 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.