flat assembler
Message board for the users of flat assembler.

Index > Windows > [solved]:playing with 16bit winincludes

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 24 Mar 2020, 19:14
Parameter preparation for CreateWindow looks like the author(s) tried being 8086-compatible too hard.
Post 24 Mar 2020, 19:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 24 Mar 2020, 19:29
DimonSoft wrote:
Parameter preparation for CreateWindow looks like the author(s) tried being 8086-compatible too hard.
AFAIK Windows 3.0 could run on 8086.
Post 24 Mar 2020, 19:29
View user's profile Send private message Visit poster's website Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 24 Mar 2020, 21:04
But 8086 did support push mem instruction.
Post 24 Mar 2020, 21:04
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 24 Mar 2020, 21:11
DimonSoft wrote:
But 8086 did support push mem instruction.
I see PUSH mem used in the SHOWWINDOW and UPDATEWINDOW calls, so my guess would be that it is not used in preparation of CREATEWINDOW for some other reason, perhaps simply a symmetry of code and easier tweaking.
Post 24 Mar 2020, 21:11
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 25 Mar 2020, 00:18
https://yadi.sk/d/f3kzyjRlFrocHQ updated according to header sets with 8.3 filenames.
Fore folders same restriction?

I found sources with edit creation (hope pascal calling convention mean they are win16)
https://yadi.sk/i/crPorEoRQqtddw (everything exept code in russian)

And I download Microsoft Windows 3.1 DDK, Microsoft Windows 3.1 SDK, Microsoft Windows 95 DDK, Windows Chicago - Build 331 SDK, Borland C++ 4.0 (CD), Borland C++ 4.52, Borland Turbo CPP 4.5 for Windows, Turbo C++ For Win3.1 (5.25)
Hope in one of this toolset I will be able to compile edit sources or found something analogy usefull.
And than reversing output will be simple task.

I am not from generation which had books about assembly (I hope only for internet, accessibility of ancient tools & my code reversing skills).
Post 25 Mar 2020, 00:18
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 25 Mar 2020, 09:36
ProMiNick wrote:
https://yadi.sk/d/f3kzyjRlFrocHQ updated according to header sets with 8.3 filenames.
Fore folders same restriction?
Yes, because 8.3 is the limitation of FAT file system structures, and a directory entry is just like a file entry (but with "directory" attribute set).

ProMiNick wrote:
I am not from generation which had books about assembly (I hope only for internet, accessibility of ancient tools & my code reversing skills).
The internet is amazing for this - I can attest, since when I was writing the first versions of fasm I generally had no access to internet and I had to rely on things like RBIL (with its OPCODES.LST) brought home on a bunch of floppies (often failing). I might have not even known that there were new versions of the documents available, and if there was something missing or wrong there I had no one to talk to. And even professional books often did not explain many of the details, or had actual errors, so sometimes experimentation was the only way (even though it was a bad way - just because something works on one machine does not mean that it is a correct method).

So yes, the internet has changed it all for the better. I only brought this old book here, because for legacy stuff the books from that era may sometimes have interesting little insights or clues that might be missing from the later content. But even then the internet might probably give much more - you could for example search Usenet archives. While writing my file formats tutorial I was digging through old Usenet messages to find some information on the history of formats like PE/ELF/Mach-O, and it was truly a fascinating journey.
Post 25 Mar 2020, 09:36
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 25 Mar 2020, 23:18
https://yadi.sk/d/HTs1wxZvp6BmYw name of package shortened to 8 symbols, (mostly) all content except contents of DOC & PROJECTS are forced to 8.3 format.
PROJECTS are same as DEMOS but in unfinished state. I moved minipad there.
Moreover I found working donor (5kb) with asm source code with EDIT control.

[EDITED]: https://yadi.sk/d/HTs1wxZvp6BmYw package updated - absolutely all names are in 8.3 format.
new part to 32/64:
Code:
HRESULT equ -$80000000+$80000000 xor ;SignExt that looks very nice for eye
S_OK                            = HRESULT(0)
S_FALSE                         = HRESULT(1)
E_NOTIMPL                       = HRESULT($80004001)    
Post 25 Mar 2020, 23:18
View user's profile Send private message Send e-mail Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 28 Mar 2020, 16:04
ProMiNick wrote:
Code:
HRESULT equ -$80000000+$80000000 xor ;SignExt that looks very nice for eye
S_OK                            = HRESULT(0)
S_FALSE                         = HRESULT(1)
E_NOTIMPL                       = HRESULT($80004001)    

Why would one need to sign-extend an HRESULT? It’s not a number but a well defined set of bit fields, some of which are numbers.
Post 28 Mar 2020, 16:04
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 28 Mar 2020, 16:05
https://yadi.sk/d/HTs1wxZvp6BmYw updated
all examples above require run as admin on systems with UAC - fixed:
NE..ProgramFlags db NE_I086; was NE_INST - it is assumed to make modifications in registry and so on

invoke LoadIcon,0,IDI_APPLICATION & invoke LoadCursor,0,IDC_ARROW got garbage from stack & trash it - fixed
invoke LoadIcon,0,dword IDI_APPLICATION ; added dword that makes param occupy 2 words
invoke LoadCursor,0,dword IDC_ARROW

however no one of that fixes dosn`t fix minipad crash on EDIT CreateWindow.
(donor shrinked from $1200+ bytes to $800+ bytes, Borland HLL logic cuted & zerofilled)
all still in process...
Post 28 Mar 2020, 16:05
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 28 Mar 2020, 17:26
DimonSoft wrote:

Why would one need to sign-extend an HRESULT? It’s not a number but a well defined set of bit fields, some of which are numbers.


No matter in what mode 32 or 64 bit HRESULT is always 32bit set.

Its extension no matter zero extension or sign extension because extension is ignored.

BUT!
Only sign extended values could be encoded in large amount of instructions.

So sign extension it is only encode trick (specificaly required by fasm in 64bit mode).
Only one instruction type allow zero extended: mov REG,uint64, all the rest like passing value to stack directly require sign extension.
Code:
use64
HRESULT equ -$80000000+$80000000 xor
E_FAIL                          = HRESULT($80004005)
push E_FAIL ; OK, the reason force fasm to compile things that we need
; we need to pass 32 bit value of HRESULT to stack with indeterminant high part and we did this
push $80004005 ; error
    

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 28 Mar 2020, 17:26
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 31 Mar 2020, 01:11
https://yadi.sk/d/HTs1wxZvp6BmYw updated
fix: errorcausing visual controls required NE.InitHeapSize other than zero, I don`t search minimal acepted value, just set it to $400 and error is gone.
[img]https://ibb.co/z6ZHxtT[/img]single instance example with try to launch second one
[EDITED] https://yadi.sk/d/HTs1wxZvp6BmYw again updated [2020/04/01]
added support for cdecl calling convention in addition to pascal (direct & indirect calls)
added even stdcall (ONLY for direct call - win16 have no such api so no needance in indirect calls)
fix: rudiment from 32bit in proc16.inc completely cleared (initialization of locals was with dword cells - now with word ones)
fix: in proc16 macro was code for detection not pascal calling convention, but args allways were defined in that convention, now definition corresponds to convention.
Post 31 Mar 2020, 01:11
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 03 Apr 2020, 03:08
https://yadi.sk/d/HTs1wxZvp6BmYw updated again
some common parts of NE format goes from final files to format includes & increased format flexibility
Code:
macro entry address* {
        match any:rest,address:: \{
                match off::,rest \\{ store dword idxof@\#any shl 16 + off at :NewExe+NE.EntryPoint \\}
                match :,rest \\{ store word any at :NewExe+NE.EntryPoint \\} \}
        purge entry }

macro stack size* {
        store word size at :NewExe+NE.InitStackSize
        purge stack }

macro heap size* { store word size at :NewExe+NE.InitHeapSize
        purge heap }

macro filealign value* {
        assert value>=0
        assert bsr value = bsf value
        assert value <513
        if value
                FORCE_FILE_ALIGN_SHIFT = bsr value
        else
                FORCE_FILE_ALIGN_SHIFT = 0
        end if
        purge filealign }

macro rsrcalign value* {
        assert value>=0
        assert bsr value = bsf value
        assert value <513
        if value
                FORCE_RSRC_ALIGN_SHIFT = bsr value
        else
                FORCE_RSRC_ALIGN_SHIFT = 0
        end if
        purge rsrcalign }

FILE_ALIGN_SHIFT = 4
RSRC_ALIGN_SHIFT = 4
REAL_FILE_ALIGN_SHIFT = 4
REAL_RSRC_ALIGN_SHIFT = 4
ERROR_LEVEL equ

if defined FORCE_FILE_ALIGN_SHIFT
        FILE_ALIGN_SHIFT = FORCE_FILE_ALIGN_SHIFT
        if FILE_ALIGN_SHIFT
                REAL_FILE_ALIGN_SHIFT = FILE_ALIGN_SHIFT
        else
                REAL_FILE_ALIGN_SHIFT = 9
        end if
end if

if defined FORCE_RSRC_ALIGN_SHIFT
        RSRC_ALIGN_SHIFT = FORCE_RSRC_ALIGN_SHIFT
        if RSRC_ALIGN_SHIFT
                REAL_RSRC_ALIGN_SHIFT = RSRC_ALIGN_SHIFT
        else
                REAL_RSRC_ALIGN_SHIFT = 9
        end if
end if     

and atleast ready win16 NE prototype of resource macros (fasm legacy as base):
Code:
; Macroinstructions for making resources

macro directory [type,label]
 { common
    local max,count,prev
    count = 0
    max = 0
   forward
    count = count + 1
    if type eqtype 1
     label#.@type = -8000 or type
     if type > max
      max = type
     end if
    else
     local ..end
     label#.@type =$%-root@resource
     db ..end-$-1,type
     ..end:
    end if 
   common
    resource@typecount = count
    prev = root@resource+2
    repeat max
   forward
    if type eqtype 1
     if % = type
      label#.@start = prev
      prev = label#.@start+label#.@size
     end if
    end if
   common
    end repeat
   forward
    if type eqtype ''
      label#.@start = prev
      prev = label#.@start+label#.@size
    end if }

macro resource dir,[id,lang,label]
 { common

    local min,max,count,current
    count = 0
    max   = 0
    min   = $7FFF
   forward
    count = count + 1
    if id eqtype 1
     label#.@id = -8000 or id
     if id > max
      max = id
     end if
     if id < min
      min = id
     end if
    else
     local ..end
     label#.@id =$%-root@resource
     db ..end-$-1,id
     ..end:
    end if 
   common
    resource@idx = resource@idx + count
    dir#.@size = sizeof.RESTYPEINFO + count * sizeof.RESNAMEINFO
    store word dir#.@type at :dir#.@start+RESTYPEINFO.rtTypeID
    store word count at :dir#.@start+RESTYPEINFO.rtResourceCount
    current = dir#.@start + sizeof.RESTYPEINFO
    repeat max-min+1
   forward
    if id eqtype 1
     if min+%-1 = id
      store word label#.@offset shr REAL_RSRC_ALIGN_SHIFT at :current +RESTYPEINFO.rnOffset
      store word label#.@length shr REAL_RSRC_ALIGN_SHIFT at :current +RESTYPEINFO.rnLength
      store word label#.@flags at :current +RESTYPEINFO.rnFlags
      store word label#.@id at :current +RESTYPEINFO.rnID
      current = current + sizeof.RESNAMEINFO
     end if
    end if
   common
    end repeat
   forward
    if id eqtype ''
      store word label#.@offset shr REAL_RSRC_ALIGN_SHIFT at :current +RESTYPEINFO.rnOffset
      store word label#.@length shr REAL_RSRC_ALIGN_SHIFT at :current +RESTYPEINFO.rnLength
      store word label#.@flags at :current +RESTYPEINFO.rnFlags
      store word label#.@id at :current +RESTYPEINFO.rnID
      current = current + sizeof.RESNAMEINFO
    end if }

macro bitmap label,bitmap_file
 { align 1 shl REAL_RSRC_ALIGN_SHIFT
   label#.@offset file bitmap_file:0Eh
   label#.@length = $ - label#.@offset
   label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
   align 4 }

macro icon group,[label,icon_file]
 { common local count
    count = 0
   forward local size,position
    virtual at 0
     file icon_file:6,16
     load size dword from 8
     load position dword from 12
    end virtual
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset file icon_file:position,size
    label#.@length = size
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
    count = count+1
   common local header
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    group#.@offset dw 0,1,count
    group#.@length = 6 + count*14
    group#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
   forward
    file icon_file:6,12
    dw label#.@id
   common
    align 1 shl REAL_RSRC_ALIGN_SHIFT }

macro cursor group,[label,cursor_file]
 { common local count
    count = 0
   forward local width,height,size,position
    virtual at 0
     file cursor_file:6,16
     load width byte from 0
     load height byte from 1
     load size dword from 8
     load position dword from 12
    end virtual
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset file cursor_file:10,4
                   file cursor_file:position,size
    label#.@length = size+4
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
    count = count+1
   common local header
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    group#.@offset dw 0,2,count
    group#.@length = 6 + count*14
    group#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
   forward
    dw width,height,1,0
    dd size+4
    dw label#.@id
   common
    align 1 shl REAL_RSRC_ALIGN_SHIFT }

macro dialog label,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize
 { local size,items
   align 1 shl REAL_RSRC_ALIGN_SHIFT
   label#.@offset dd style or DS_SETFONT,exstyle +0
   label#.@length = size
   label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
   dw items,x,y,cx,cy
   if menu+0 <> 0
    dw 0FFFFh
   end if
   du menu+0,0,title,0
   if fontname eq
    du 8,'MS Sans Serif',0
   else
    du fontsize+0,fontname,0
   end if
   align 4
   dialog_size equ size = $ - data
   dialog_items equ items = dialog_items_counter
   dialog_items_counter = 0 }

macro dialogitem class,title,id,x,y,cx,cy,style,exstyle
 { dd style or WS_CHILD,exstyle +0
   dw x,y,cx,cy,id
   if class eq 'BUTTON'
    dw 0FFFFh,80h
   else if class eq 'EDIT'
    dw 0FFFFh,81h
   else if class eq 'STATIC'
    dw 0FFFFh,82h
   else if class eq 'LISTBOX'
    dw 0FFFFh,83h
   else if class eq 'SCROLLBAR'
    dw 0FFFFh,84h
   else if class eq 'COMBOBOX'
    dw 0FFFFh,85h
   else
    du class,0
   end if
   if title eqtype 0
    dw 0FFFFh,title
   else
    if ~ title eq
     du title
    end if
    dw 0
   end if
   dw 0
   align 4
   dialog_items_counter = dialog_items_counter + 1 }

macro enddialog
 { dialog_items
   dialog_size }

macro accelerator label,[fvirt,key,cmd]
 { common
    local size
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset:
    accel_count = 0
   forward
    accel_count = accel_count + 1
   common
    size = accel_count * 8
    label#.@length = size
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
   forward
    accel_count = accel_count - 1
    if accel_count = 0
     dw fvirt or 80h,key
    else
     dw fvirt,key
    end if
    dd cmd }

macro versioninfo label,fileos,filetype,filesubtype,lang,cp,[name,value]
 { common
    local size,vivalue,visize
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset dw size,visize,0
    label#.@length = size
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
    du 'VS_VERSION_INFO',0,0
    vivalue dd 0FEEF04BDh,00010000h
    local version,count,shift,char,filever,productver
    filever = 0
    productver = 0
   forward
    if name eq 'FileVersion' | name eq 'ProductVersion'
     virtual at 0
      db value
      count = $
      version = 0
      shift = 16
      repeat count
       load char from %-1
       if char='.'
        if shift mod 32
         shift = shift-16
        else
         shift = shift+32+16
        end if
       else
        version = (version and not (0FFFFh shl shift)) or ((version shr shift and 0FFFFh)*10+char-'0') shl shift
       end if
      end repeat
     end virtual
     if name eq 'FileVersion'
      filever = version
     else if name eq 'ProductVersion'
      productver = version
     end if
    end if
   common
    dq filever,productver
    dd 0,0,fileos,filetype+0,filesubtype+0,0,0
    visize = $ - vivalue
    local sfi_data,sfi_size
    sfi_data dd sfi_size
    du 1,'StringFileInfo',0
    local str_data,str_size
    str_data dd str_size
    du 1,'040904E4',0
   forward
    local vs_data,vs_size,value_data,value_size
    align 4
    vs_data dw vs_size,value_size/2
    du 1,name,0
    align 4
    value_data du value,0
    value_size = $ - value_data
    vs_size = $ - vs_data
   common
    align 4
    str_size = $ - str_data
    sfi_size = $ - sfi_data
    local vfi_data,vfi_size,var_data,var_size
    vfi_data dd vfi_size
    du 1,'VarFileInfo',0,0
    var_data dw var_size,4
    du 0,'Translation',0,0
    dw lang,cp+0
    var_size = $ - var_data
    vfi_size = $ - vfi_data
    size = $ - data }macro versioninfo label,fileos,filetype,filesubtype,lang,cp,[name,value]
 { common
    local data,size,vivalue,visize
    label dd RVA data,size,0,0
    data dw size,visize,0
    du 'VS_VERSION_INFO',0,0
    vivalue dd 0FEEF04BDh,00010000h
    local version,count,shift,char,filever,productver
    filever = 0
    productver = 0
   forward
    if name eq 'FileVersion' | name eq 'ProductVersion'
     virtual at 0
      db value
      count = $
      version = 0
      shift = 16
      repeat count
       load char from %-1
       if char='.'
        if shift mod 32
         shift = shift-16
        else
         shift = shift+32+16
        end if
       else
        version = (version and not (0FFFFh shl shift)) or ((version shr shift and 0FFFFh)*10+char-'0') shl shift
       end if
      end repeat
     end virtual
     if name eq 'FileVersion'
      filever = version
     else if name eq 'ProductVersion'
      productver = version
     end if
    end if
   common
    dq filever,productver
    dd 0,0,fileos,filetype+0,filesubtype+0,0,0
    visize = $ - vivalue
    local sfi_data,sfi_size
    sfi_data dd sfi_size
    du 1,'StringFileInfo',0
    local str_data,str_size
    str_data dd str_size
    du 1,'040904E4',0
   forward
    local vs_data,vs_size,value_data,value_size
    align 4
    vs_data dw vs_size,value_size/2
    du 1,name,0
    align 4
    value_data du value,0
    value_size = $ - value_data
    vs_size = $ - vs_data
   common
    align 4
    str_size = $ - str_data
    sfi_size = $ - sfi_data
    local vfi_data,vfi_size,var_data,var_size
    vfi_data dd vfi_size
    du 1,'VarFileInfo',0,0
    var_data dw var_size,4
    du 0,'Translation',0,0
    dw lang,cp+0
    var_size = $ - var_data
    vfi_size = $ - vfi_data
    size = $ - data }

macro resdata label
{ local size
  align 1 shl REAL_RSRC_ALIGN_SHIFT
  label#.@offset = $
  label#.@length = size
  label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
  ressize equ size = $ - data }

macro endres
{ ressize
  align 1 shl REAL_RSRC_ALIGN_SHIFT }

    

for now missed menu (fasm legacy menuex but called menu)
versioninfo I guess for now a bit incorrect - later I will test & fix
room for resource table now looks like this:
Code:
ResourceTable: root@resource = $%
        if resource@typecount
                .rscAlignShift  dw REAL_RSRC_ALIGN_SHIFT
                .rscTypes       db resource@typecount*sizeof.RESTYPEINFO+resource@count*sizeof.RESNAMEINFO dup(0)
                .rscEndTypes    dw 0
        end if     

Code:
postpone {
        segment@count           = segment@idx
        resource@count          = resource@idx
        resource@typecount      = resource@typeidx }

segment@idx             = 0
resource@typeidx        = 0
resource@idx            = 0
code@idx                = 0
data@idx                = 0
cseg1st                 = 0    


added RT_NAME_TABLE = 15 (New(or not new, but bit obsolete) predefined resource it gives ability to define IDs of resources as integers but makes to them literal aliases so way that resource could be loaded as ID as alias.

[EDITED] https://yadi.sk/d/HTs1wxZvp6BmYw updated again [2020/04/03/14:31] add resources.inc to win16.inc & tryed to make resources.
fixes: resource@typecount = count replaced to resource@typeidx = count
add to minipad win16 2 resources (that already implemented icon & group_icon)
all compiled succes (even IDA Pro see 2 resources in file with expected content) BUT app logo dosn`t changed & wintitle logo changed to windefault
Post 03 Apr 2020, 03:08
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 03 Apr 2020, 13:03
https://yadi.sk/d/HTs1wxZvp6BmYw updated again
now NT host systems draws app icon, but 9x host systems dosn`t draw it.
wintitle logo still changed to windefault (checked combinations with addition to ID $8000 and addition $80000000)
fixes
in resources -8000 replaced on $8000
all resource size calculations corrected with adder - 1 + 1 shl REAL_RSRC_ALIGN_SHIFT

[EDITED] https://yadi.sk/d/HTs1wxZvp6BmYw updated again [2020/04/03/17:50]
fix in macro icon group
replaced dw label#.@id with dw label#.@id and $7FFF
(solution maybe not universal, but for current state it is OK)
now all NT & 9x systems draws app icon, wintitle logo still errored.

format for resource RT_NAME_TABLE = 15
for NE
Code:
macro nametable label,[type,ID,alias]
 { common
    local data,size
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset:
    label#.@length = size - 1 + 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSSHARED + NE_NSMOVE
   forward
    local ..end
    dw ..end-$,type,ID
    db 0,alias,0
    ..end:
   common
    dw 0 ; included in size or not?
    size = $ - label#.@offset
    align 1 shl REAL_RSRC_ALIGN_SHIFT }    


for PE(what if exists):
Code:
macro nametable label,[type,ID,alias]
 { common
    local data,size
    label dd RVA data,size,0,0
    data:
   forward
    local ..end
    dw ..end-$,type,ID
    db 0,alias,0
    ..end:
   common
    dw 0
    align 4 }    
Post 03 Apr 2020, 13:03
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 04 Apr 2020, 17:41
https://yadi.sk/d/HTs1wxZvp6BmYw updated again
little victory: minipad in projects created with icon in title, with menu (all behavior same as 32bit variant has).
Fact that it work a kind of miracle - because of that it still in projects not in demos.
menu resource for NE realized this way:
Code:
macro menu label,helpID
 { common local size,items
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset dw 0 ; menu version
    label#.@length = size - 1 + 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSSHARED + NE_NSMOVE
    macro menuitem string,id:0,option:0
     \{ dw option
         if option and MF_POPUP
           menu_level = menu_level +1
         else
           dw id
         end if
         if option and MF_END
           menu_level = menu_level -1
         end if
         match any,string \\{ db string \\}
         db 0 \}
     macro menuseparator option:0
      \{ dw option or MF_SEPARATOR ; direct separator
         if option and MF_POPUP
           menu_level = menu_level +1
         else
           dw 0
         end if
         if option and MF_END
           menu_level = menu_level -1
         end if
         db 0 \}                   ; no string - indirect separator
    match any,helpID \{ dw helpID+0 \}
    items:
     menu_size equ size = $ - label#.@offset
     menu_level = 1
     macro endmenu \{
       if menu_level
         err unresolved internal menu structure
       end if
       menu_size
       purge menuitem, menuseparator, endmenu \} }    

in donor I added one more example - smartpad (tryed to clone abilities & behavior of that donor, there are used names table resource & toolbar) i going finaly update minipad to support all such features before it will be moved to demo.
Post 04 Apr 2020, 17:41
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 04 Apr 2020, 23:21
https://yadi.sk/d/HTs1wxZvp6BmYw updated again

2 more resource type validated (dialog & accelerators):
Code:
macro dlgdefprop prop:''& {
   local ..done
   ..done = $
   match  any =, more,prop \{ db prop,0 \}
   if $ = ..done
     if prop eqtype ''
       if prop eq ''
         db 0
       else
         db prop,0
       end if
     else
       if ~prop
         db 0
       else
         dw -1,prop ;maybe not
       end if
     end if
   end if }

macro dlgdefchild class:''& {
   local ..done,tmpclass
   ..done = $
   ;match  any =, more,class \{ db class,0 \} ;need testing
   if $ = ..done
       if class eqtype ''
         if class eq 'BUTTON'
           db 80h
         else if class eq 'EDIT'
           db 81h
         else if class eq 'STATIC'
           db 82h
         else if class eq 'LISTBOX'
           db 83h
         else if class eq 'SCROLLBAR'
           db 84h
         else if class eq 'COMBOBOX'
           db 85h
         else if class eq ''
           db 0
         else
           db class,0 ;maybe for class 1 byte only, so no literal
         end if
       else
         if ((class) and 1Fh) =10 | ((class) and 1Fh) =16 | ((class)-((class) and 80h))>18h | (class)<0
           .err unsupported classID = class
         end if
         db class
       end if
   end if }

macro dialog label,class,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize
 { local size,items
   align 1 shl REAL_RSRC_ALIGN_SHIFT
   label#.@offset dd style
   label#.@length = size - 1 + 1 shl REAL_RSRC_ALIGN_SHIFT
   label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSSHARED + NE_NSMOVE
   db items
   dw x,y,cx,cy
   dlgdefprop menu
   dlgdefprop class
   dlgdefprop title
   if (style) and DS_SETFONT
     if fontname eq
       db 8,'MS Sans Serif',0
     else
       db fontsize,fontname,0
     end if
   end if
   dialog_size equ size = $ - label#.@offset
   dialog_items equ items = dialog_items_counter
   dialog_items_counter = 0 }

macro dialogitem class,title,id,x,y,cx,cy,style,exstyle
 { dw x,y,cx,cy,id
   dd style or WS_CHILD
   dlgdefchild class
   dlgdefprop title
   db 0
   dialog_items_counter = dialog_items_counter + 1 }

macro enddialog
 { dialog_items
   dialog_size
   align 1 shl REAL_RSRC_ALIGN_SHIFT }

macro accelerator label,[fvirt,key,cmd]
 { common
    local size
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset:
    accel_count = 0
   forward
    accel_count = accel_count + 1
   common
    size = accel_count * 5
    label#.@length = size - 1 + 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@flags = NE_NSDPL + NE_NSSHARED + NE_NSMOVE
   forward
    accel_count = accel_count - 1
    if accel_count = 0
     db fvirt or 80h
    else
     db fvirt
    end if
    dw key,cmd }    


couple of fix in flag testing: such things:
Code:
what syntax should be
if (style) and DS_SETFONT ;if style macro param so and-operand related to whole expression
what syntax wrong
if style and DS_SETFONT ;if style macro param so and-operand related to its last member     
Post 04 Apr 2020, 23:21
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 05 Apr 2020, 12:14
https://yadi.sk/d/HTs1wxZvp6BmYw updated again
added 1 more resource:
Code:
macro versioninfo label,fileos,filetype,filesubtype,lang,cp,[name,value]
 { common
    local size,vivalue,visize
    align 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@offset dw size
    db visize,0
    label#.@length = size - 1 + 1 shl REAL_RSRC_ALIGN_SHIFT
    label#.@flags = NE_NSDISCARD + NE_NSDPL + NE_NSPRELOAD + NE_NSMOVE
    db 'VS_VERSION_INFO',0
    vivalue dd 0FEEF04BDh,00010000h
    local version,count,shift,char,filever,productver
    filever = 0
    productver = 0
   forward
    if name eq 'FileVersion' | name eq 'ProductVersion'
     virtual at 0
      db value
      count = $
      version = 0
      shift = 16
      repeat count
       load char from %-1
       if char='.'
        if shift mod 32
         shift = shift-16
        else
         shift = shift+32+16
        end if
       else
        version = (version and not (0FFFFh shl shift)) or ((version shr shift and 0FFFFh)*10+char-'0') shl shift
       end if
      end repeat
     end virtual
     if name eq 'FileVersion'
      filever = version
     else if name eq 'ProductVersion'
      productver = version
     end if
    end if
   common
    dq filever,productver
    dd 0,0,fileos,filetype+0,filesubtype+0,0,0
    visize = $ - vivalue
    local sfi_data,sfi_size
    sfi_data dd sfi_size
    db 'StringFileInfo',0
    align 4
    local str_data,str_size
    str_data dd str_size
    db '040904E4',0
   forward
    local vs_data,vs_size,value_data,value_size
    align 4
    vs_data dw vs_size,value_size
    db name,0
    align 4
    value_data db value,0
    value_size = $ - value_data
    vs_size = $ - vs_data
   common
    align 4
    str_size = $ - str_data
    sfi_size = $ - sfi_data
    local vfi_data,vfi_size,var_data,var_size
    vfi_data dd vfi_size
    db 'VarFileInfo',0
    var_data dw var_size,4
    db 'Translation',0
    dw lang,cp+0
    var_size = $ - var_data
    vfi_size = $ - vfi_data
    size = $ - label#.@offset }    


now win16 minipad closest to ideal (it is completely analog of minipad 32 or 64 in all sences, but unique abilities of win16 dosn`t catched yet - I mean use of RT_NAME_TABLE resource)

how looks like resource part of it:
Code:
  directory RT_MENU,menus,\
            RT_ICON,icons,\
            RT_GROUP_ICON,group_icons,\
            RT_NAME_TABLE,names_table,\
            RT_VERSION,versions

  resource menus,\
           IDR_MENU,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu

  resource icons,\
           1,LANG_NEUTRAL,icon_data

  resource group_icons,\
           IDR_ICON,LANG_NEUTRAL,main_icon

  resource names_table,\
           1,LANG_NEUTRAL,rsrc_names

  resource versions,\
           1,LANG_NEUTRAL,version

  menu main_menu,0
       menuitem '&File',0,MF_POPUP
                menuitem '&New',IDM_NEW
                menuseparator
                menuitem 'E&xit',IDM_EXIT,MF_END
       menuitem '&Help',0,MF_POPUP + MF_END
                menuitem '&About...',IDM_ABOUT,MF_END
  endmenu

  icon main_icon,icon_data,'minipad\logo.ico'

  nametable rsrc_names,RT_ICON,$8000 or 1,'APP_ICON',\
                       RT_MENU,$8000 or IDR_MENU,'APP_MENU'

  versioninfo version,VOS_DOS_WINDOWS16,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
              'FileDescription','MiniPad - example program',\
              'LegalCopyright','No rights reserved.',\
              'FileVersion','1.0',\
              'ProductVersion','1.0',\
              'OriginalFilename','MINIPAD.EXE'    
Post 05 Apr 2020, 12:14
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 06 Apr 2020, 01:50
https://yadi.sk/d/HTs1wxZvp6BmYw updated!!!!!
minipad atlast moved from projects to demos (in addition to completely reproduction of win32|64 analog behavior added use of resource RT_NAME_TABLE).
all windowses accept exes as valid (IDApro dislike smthing & messaging file structure as corrupted)
ToDo list: implement exports, fix IDA dislike of one of resources, maybe RT_NAME_TABLE deserve to be probed under PE.
Post 06 Apr 2020, 01:50
View user's profile Send private message Send e-mail Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 06 Apr 2020, 08:57
https://yadi.sk/d/HTs1wxZvp6BmYw updated
fix: on versions before setting on fastload flag will crash program, even without that flag IDA messaging about corruption.
Now fastload is fully functional.
Post 06 Apr 2020, 08:57
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 06 Apr 2020, 09:28
I tried your latest "Minipad" demos, but none of the versions work on my Windows 3.11 - they either cause an exception or even hang the entire system. I may investigate more later in a spare time.
Post 06 Apr 2020, 09:28
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 803
Location: Russian Federation, Sochi
ProMiNick 06 Apr 2020, 10:35
All versions before was with switched off NE_GANGL flag.
Try comment line
Code:
fastloadstart    


Or maybe one of resources unsupported in win3.1 (versioninfo was last added)

Is that helps? I thought I had VM with windows 3.1, but I hadn`t - there are DOS only with WINDOWS as folder, but without WINDOWS as subsystem. So I can`t test.

https://yadi.sk/d/HTs1wxZvp6BmYw updated again.
dialog example in projects: now creates dialog, but...
...no processing of DialogProc even initdialog not processed, however controls interactive but dialog is unclosable.
Post 06 Apr 2020, 10:35
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.