Author Topic: Issue with the INCBIN statement  (Read 434 times)

Vortex

  • Member
  • *****
  • Posts: 2109
Issue with the INCBIN statement
« on: October 29, 2019, 05:30:42 AM »
Hi nidud,

Trying to assemble the code below, I receive an error message :

Code: [Select]
include windows.inc

RSRC_OFFSET equ 0
RSRC_SIZE equ 72

.data

DlgBox  LABEL byte
INCBIN  "Rsrc.res",RSRC_OFFSET,RSRC_SIZE

; Part of Rsrc.res encapsulated with INCBIN
;DlgBox db 1,0,255,255,128,0,26,1,0,0,0,0,68,8,202,16
;       db 0,0,20,0,10,0,200,0,120,0,0,0,0,0,68,0
;       db 105,0,97,0,108,0,111,0,103,0,32,0,98,0,111,0
;       db 120,0,0,0,12,0,188,2,0,1,83,0,121,0,115,0
;       db 116,0,101,0,109,0,0,0

.code

start:

    invoke  GetModuleHandle,0
    invoke  DialogBoxIndirectParam,eax,ADDR DlgBox,NULL,ADDR DlgProc,NULL
    ret

DlgProc PROC hwnd:HWND,uiMsg:UINT,wParam:WPARAM,lParam:LPARAM

    .IF uiMsg==WM_CLOSE

        invoke  EndDialog,hwnd,0
        mov     eax,1

    .ELSE

        xor     eax,eax

    .ENDIF

    ret

DlgProc ENDP

END start

Code: [Select]
\asmc-master\bin\asmc -pe -gui DlgBox.asm
Asmc Macro Assembler Version 2.30.24
Copyright (C) The Asmc Contributors. All Rights Reserved.
Portions Copyright (C) 1984-2002 Sybase, Inc. All Rights Reserved.

 Assembling: DlgBox.asm
DlgBox.asm(9) : fatal error A1000: cannot open file : Rsrc.resE

In some cases, it's possible to embed compiled resource data with the INCBIN statement.

nidud

  • Member
  • *****
  • Posts: 1853
    • https://github.com/nidud/asmc
Re: Issue with the INCBIN statement
« Reply #1 on: October 29, 2019, 07:15:54 AM »
Confirmed. This is fixed in version 2.30.25

However, i needed to set the offset to 76 to get the sample working.

RSRC_OFFSET     equ 76
RSRC_SIZE       equ 72

Vortex

  • Member
  • *****
  • Posts: 2109
Re: Issue with the INCBIN statement
« Reply #2 on: October 29, 2019, 08:16:10 PM »
Hi nidud,

Many thanks. Sorry for the wrong OFFSET value. RSRC_OFFSET equ 0 should be true for a binary file extracted from a compiled resource script. Correcting my calculation :

Code: [Select]
DLGBOX DIALOGEX DISCARDABLE 20, 10, 200, 120, 18481280
replaced by

Code: [Select]
10000 DIALOGEX DISCARDABLE 20, 10, 200, 120, 18481280
Code: [Select]
EMPTY_RSRC_SECT equ 32
RSRC_ENTRY      equ 32

RSRC_OFFSET     equ EMPTY_RSRC_SECT+RSRC_ENTRY

RSRC_SIZE       equ 72

.data

DlgBox  LABEL byte
INCBIN  "Rsrc.res",RSRC_OFFSET,RSRC_SIZE

It's possible to omit the RSRC_SIZE statement.

Attached is the corrected dialog box example.

nidud

  • Member
  • *****
  • Posts: 1853
    • https://github.com/nidud/asmc
Re: Issue with the INCBIN statement
« Reply #3 on: October 30, 2019, 03:01:03 AM »
Yes, works fine now  :thumbsup:

I fixed the command line issue as well and a few other things in version 2.30.26.

asmc --help
ASMC : fatal error A1006: invalid command-line option: --help

Vortex

  • Member
  • *****
  • Posts: 2109
Re: Issue with the INCBIN statement
« Reply #4 on: October 30, 2019, 05:11:01 AM »
Hi nidud,

Many thanks, I downloaded Asmc V2.30.26. I am thinking to prepare some other dialog box examples built with the -pe option.