News:

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

Main Menu

Recent posts

#41
16 bit DOS Programming / Re: Problem With Reading Keybo...
Last post by NoCforMe - April 23, 2025, 05:00:26 AM
I'd say, as a first guess, that this has nothing at all to do with the assembler, and everything to do with the state of the keyboard port (or the interrupt controller) when you're reading them.

Not sure what exactly you're doing by reading the interrupt controller (port 20h) before looking for a keystroke: what's the logic here? Are you first looking for a pending interrupt, as if a key had been pressed? That might be the problem, or at least part of it.
#42
16 bit DOS Programming / Problem With Reading Keyboard ...
Last post by jejump - April 23, 2025, 01:11:22 AM

Hey folks,

I'm assembling a small TSR for DOS (MS-DOS is v6.22) and my TSR code works flawlessly ONLY IF I assemble my source (MASM 6.11) and then install by typing the name of the .com file.  If I simply boot (warm or cold), skip the assembly process, and just install the .com as it was last assembled, the code works up to the point where I check the keyboard port.  It's like the keyboard reading code isn't being observed properly.  Here's some of the pertinent code in question:


CA_Wait:                   ; Wait Loop
call    KBS_Service
test    BYTE PTR CS:[New_08 + 4], 1
jnz     Return
mov     DX, 379h
in      AL, DX
and     AL, 60h
jz      CA_Wait    ; Loop


KBS_Service:
pushf
push    AX
push    DX
push    ES
in      AL, 20h
test    AL, 2
jz      KBS_End
in      AL, 60h
cmp     AL, 1
jne     Esc_Key_No
or      BYTE PTR CS:[New_08 + 4], 1
Esc_Key_No:
mov     AX,0040h
mov     ES, AX
mov     AL, ES:[001Ch]
mov     ES:[001Ah], AL
mov     AL,20h                  ;Clear interrupt controller
out     20h,AL
out     0Ah,AL
and     ES:[0017h], 0F0h
KBS_End:
pop     ES
pop     DX
pop     AX
popf
ret


Basically, the wait loop is waiting on either signals from the parallel port, or the Esc key from the keyboard to exit the loop.  Just before this wait loop is entered, the keyboard interrupt mask is applied on port 21h, bit 1, so that no keyboard interrupt is processed.  It gets re-enabled later on.  Like I said, this works great as long as I assemble just before installing--as if the assembler running is somehow creating a more cohesive/conducive environment for this code.  Anyone have thoughts on this behavior?  Hopefully I've made it clear what's going on.  Thanks for the help!


John
#43
The Campus / Re: Windows 11?
Last post by rsala - April 22, 2025, 09:20:43 PM
Hi Wayne,

Thanks a lot for your post! Yes, you are right, the problem is the BlackWidth parameter. My good friend Héctor A. Medina, who is the ECPendulum author, is already working on it! :thumbsup:
#44
RosAsm / A more robust IsChild function
Last post by guga - April 22, 2025, 09:19:52 PM
Hi guys, i made a more robust IsChild function. In fact this is the core that exists in User32.dll but tweaked to ensure a more wide scenario (multiple desktops, for example).

References:
ReactOS IsChild
ReactOS GetThreadDesktopWnd


;;
    IsChild
    Determines whether a specified window is a child or descendant of another window.

    Arguments:
        hWndParent (in): Handle to the potential parent window.
        hWnd (in): Handle to the window to test.

    Return Value:
        If hWnd is a child or descendant of hWndParent, returns TRUE (1).
        Otherwise, returns FALSE (0), including cases where:
            - hWnd or hWndParent is invalid (not a window).
            - The thread's desktop or default desktop window is inaccessible.
            - hWnd is not a child window (lacks WS_CHILD style or has WS_POPUP).
            - The parent chain ends without reaching hWndParent.

    Remarks:
        -   This function traverses the parent chain of hWnd using GetParent until it finds
            hWndParent or reaches a non-child window or NULL.
        -   A child window must have the WS_CHILD style and not have the WS_POPUP style.
        -   The function performs validation checks:
        -   Verifies hWnd and hWndParent are valid windows using IsWindow.
        -   Ensures the thread has a valid desktop using GetThreadDesktop.
        -   Ensures the default desktop window is accessible using GetDesktopWindow.
        -   These desktop checks are conservative, ensuring the window hierarchy is valid
            in the thread's context, though GetDesktopWindow is typically sufficient for
            user-mode applications.
        -   The function preserves ECX and EDX registers, as Windows API calls may modify
            these volatile registers.
        -   Used by GetWindowPosEx to determine if a window is a child for coordinate
            calculations.

 Usage Example:
   [WINPOS:
    WINPOS.cx: D$ 0
    WINPOS.cy: D$ 0
    WINPOS.width: D$ 0
    WINPOS.height: D$ 0]

   ; Check if a dialog control is a child of its parent dialog
   call 'USER32.GetDlgItem' D@hDlg, 156  ; Get control handle
   mov ebx eax                          ; Save control handle
   call 'USER32.GetAncestor' ebx, &GA_PARENT  ; Get parent dialog
   call IsChild eax, ebx
   If eax = &TRUE
       ; Control is a child, use client coordinates in GetWindowPosEx
       call GetWindowPosEx ebx, WINPOS
   End_If

    Author: Gustavo Trigueiros (aka: Beyond2000!/Guga)
    Build Date: May 2012 (v1.0), Updated April 2025 (v1.1)
    Notes:
        -   Adapted from system-level code, replacing GetThreadDesktopWnd with standard
            GetDesktopWindow for user-mode compatibility.
        -   Added GetThreadDesktop for additional thread desktop validation, inspired by
            original system-level implementation.
        -   Corrected style check to use bitwise OR (WS_POPUP | WS_CHILD) for reliable
            child window detection.
;;

Proc IsChild:
    Arguments @hWndParent, @hWnd
    Local @CurrentWnd, @Style
    Uses ecx, edx

    ; Validate input windows
    call 'USER32.IsWindow' D@hWndParent
    On eax = 0, ExitP
    call 'USER32.IsWindow' D@hWnd
    On eax = 0, ExitP

    ; Validate thread's desktop
    call 'kernel32.GetCurrentThreadId'
    call 'user32.GetThreadDesktop' eax
    On eax = 0, ExitP

    ; Validate default desktop window
    call 'USER32.GetDesktopWindow'
    On eax = 0, ExitP

    ; Initialize CurrentWnd = hWnd
    mov eax D@hWnd | mov D@CurrentWnd eax
    ; Traverse parent chain
    .While D@CurrentWnd <> 0
        ; Get window style
        call 'USER32.GetWindowLongA' D@CurrentWnd, &GWL_STYLE

        ; Check if window is a child: (style & (WS_POPUP | WS_CHILD)) == WS_CHILD
        and eax (&WS_POPUP+&WS_CHILD)   ; Bitwise OR for mask
        .If eax = &WS_CHILD
             ;  Get parent window
            Call 'USER32.GetParent' D@CurrentWnd
            mov D@CurrentWnd eax
            ; Check if parent is NULL
            On eax = 0, ExitP
            ; Check if parent matches hWndParent
            If eax = D@hWndParent
                mov eax &TRUE
                ExitP
            End_If
        .Else
            ; Not a child window, stop traversal
            xor eax eax
            ExitP
        .End_If

    .End_While

    ; Default return FALSE
    xor eax eax

EndP
#45
Miscellaneous Projects / Re: PDB Dumper (Ported to C)
Last post by guga - April 22, 2025, 06:56:43 PM
Excellent. Tks, Timo.
#46
Miscellaneous Projects / Re: PDB Dumper (Ported to C)
Last post by TimoVJL - April 22, 2025, 06:49:14 PM
This site give some info too
https://github.com/microsoft/microsoft-pdb/tree/master/cvdump

EDIT: once having fun with low level
#47
Miscellaneous Projects / Re: PDB Dumper (Ported to C)
Last post by guga - April 22, 2025, 04:51:34 PM
And here is the Source code.

Btw...soon i´ll update the RosAsm version (It is working better and with the correct results than the C one)
#48
Miscellaneous Projects / PDB Dumper (Ported to C)
Last post by guga - April 22, 2025, 04:51:03 PM
Hi everyone,

Years ago I started a small program for RosAsm that scans pdb files RosAsm PDB Dumper. Since I'm updating RosAsm, I decided to test it and see how it would work in a new interface and adapted the code to C. The interface is reasonable, but since it's in C and I have no experience with it, I quickly translated it from RosAsm to C to see how it would work. Here's the little program and the source code in C.

#49
The Orphanage / Re: Ramblings...
Last post by sinsi - April 22, 2025, 04:39:45 PM
CS_BYTEALIGNCLIENT
0x1000
Aligns the window's client area on a byte boundary (in the x direction).
This style affects the width of the window and its horizontal placement on the display.

CS_BYTEALIGNWINDOW
0x2000
Aligns the window on a byte boundary (in the x direction).
This style affects the width of the window and its horizontal placement on the display.
I see those class flags still used today  :badgrin:
#50
RosAsm / RichEdit control with images a...
Last post by guga - April 22, 2025, 07:29:06 AM
Years ago, i gave a try enabling images on a RTF control, and also make it work with hyperlinks. I found this old project and made a small update on it.

It inserts the image existent inside a rtf. The only problem (yet), is that it does not delete it if we load it again. Anyway, here´s the test files with embedded sources. For Ansi and Unicode version of richEdit.