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

#21
The Workshop / Re: LogBuddy debugging aid, im...
Last post by NoCforMe - April 02, 2025, 03:41:22 PM
Quote from: guga on April 02, 2025, 03:16:38 PMOne question. Is really necessary to call the functions of the dll using GetProcAdress ? Can we do it directly without the needs to initialize all of them ?
Ex:
call 'LogBuddy.LogBuddyStart' OurWinTitle

which should be the equivalent in masm for
invoke LogBuddyStart OFFSET OurWinTitle

I don't know any other way of calling functions in a DLL. This is my first experience writing a DLL, so I'm certainly no expert.

But I don't see how else you could do it: you can't just call by name as you would a linked-in function, because how would the linker resolve it?

Any enlightenment here would be appreciated.

BTW, if you want the MASM source, let me know.
#22
The Workshop / Re: LogBuddy debugging aid, im...
Last post by guga - April 02, 2025, 03:16:38 PM
Hi NoCForme, i ported it to RosAsm.

I´m giving a test. Seems to be working as expected. Attached a simple test file (RosAsm source embedded in the exe)

RosAsm port of the main functions and structures:
[LB_DLLname: B$ "LogBuddy.dll", 0]
[LB_StartProcName: B$ "LogBuddyStart", 0]
[LB_FinishProcName: B$ "LogBuddyFinish", 0]
[LB_LogMsgProcName: B$ "LogBuddyLogMsg", 0]
[LB_DumpMemProcName: B$ "LogBuddyDumpMem", 0]
[LB_AddTextProcName: B$ "LogBuddyAddText", 0]
[LB_AddSepProcName: B$ "LogBuddyAddSeparator", 0]
[LB_WriteFileProcName: B$ "LogBuddyWriteToFile", 0]
[LB_ClearLogProcName: B$ "LogBuddyClearLog", 0]
[LB_LogVarProcName: B$ "LogBuddyLogVar", 0]
[LB_PutTimeProcName: B$ "LogBuddyPutTime", 0]
[LB_ShowStructProcName: B$ "LogBuddyShowStruct", 0]

[DLLinitFlag: B$ &FALSE]
[LB_DLLfailMsg: B$ "Failed to load LogBuddy.dll", 0]

[LB_StartProcAddr: D$ 0]
[LB_FinishProcAddr: D$ 0]
[LB_LogMsgProcAddr: D$ 0]
[LB_DumpMemProcAddr: D$ 0]
[LB_AddTextProcAddr: D$ 0]
[LB_AddSepProcAddr: D$ 0]
[LB_WriteFileProcAddr: D$ 0]
[LB_ClearLogProcAddr: D$ 0]
[LB_LogVarProcAddr: D$ 0]
[LB_PutTimeProcAddr: D$ 0]
[LB_ShowStructProcAddr: D$ 0]


; Variable types for LogBuddyLogVar():
[LB_varInt 1]        ; signed integer
[LB_varUint 2]       ; unsigned integer
[LB_varString 3]     ; string displayed with quotes around it
[LB_varHex 4]        ; unsigned hex value
[LB_varHex32 5]      ; unsigned full 32-bit hex value (8 digits)

; Message inclusion/exclusion modes:
[LB_msgsAll 0]       ; all messages
[LB_msgsSingle 1]    ; just the one message
[LB_msgsInclList 2]  ; a list of messages
[LB_msgsExclList 3]  ; exclude a list of messages
[LB_msgsInclClass 4] ; one or more classes of messages
[LB_msgsExclClass 5] ; exclude one or more classes of messages

; Message inclusion/exclusion classes:
[LB_CursorMsgs 1]
[LB_MouseMsgs 2]
[LB_NCmsgs 4]
[LB_SizeMoveMsgs 8]
[LB_KBmsgs 010]      ; 10H becomes 010
[LB_ctlcolorMsgs 020] ; 20H becomes 020

[msgMode:
  msgMode.msgModeType: D$ 0
  msgMode.msgModeValue: D$ 0]

;==========================
; Structure display stuff:
;==========================

[LB_STRUCT_ELEMENT:
  LB_STRUCT_ELEMENT.namePtr: D$ 0
  LB_STRUCT_ELEMENT.etype: D$ 0]

[LB_structTypeD1 1]    ; DWORD, unsigned decimal
[LB_structTypeD2 2]    ; DWORD, unsigned hex
[LB_structTypeD3 3]    ; DWORD, signed
[LB_structTypeW1 4]    ; WORD, unsigned decimal
[LB_structTypeW2 5]    ; WORD, unsigned hex
[LB_structTypeW3 6]    ; WORD, signed
[LB_structTypeB1 7]    ; BYTE, unsigned decimal
[LB_structTypeB2 8]    ; BYTE, unsigned hex
[LBA_structTypeB3 9]   ; BYTE, signed
[LB_structTypeS1 10]   ; pointer to an ASCIIZ string
[LB_structTypeS2 11]   ; fixed-length ASCII string *
[LB_structTypeAB1 12]  ; byte array, unsigned decimal *
[LB_structTypeAB2 13]  ; byte array, unsigned hex *
[LB_structTypeAB3 14]  ; byte array, signed *
[LB_structTypeAW1 15]  ; word array, unsigned decimal *
[LB_structTypeAW2 16]  ; word array, unsigned hex *
[LB_structTypeAW3 17]  ; word array, signed *
[LB_structTypeAD1 18]  ; DWORD array, unsigned decimal *
[LB_structTypeAD2 19]  ; DWORD array, unsigned hex *
[LB_structTypeAD3 20]  ; DWORD array, signed *
[LB_structTypeV1 21]   ; DWORD symbolic value field **
[LB_structTypeV2 22]   ; WORD symbolic value field **
[LB_structTypeV3 23]   ; BYTE symbolic value field **
[LB_structTypeF1 24]   ; DWORD bit-flag field **
[LB_structTypeStruct 25] ; nested structure ***


;==========================================================
; Log Buddy Structure Definitions
;==========================================================

[Sz_LB_RECT_sName: B$ "RECT", 0]
[Sz_LB_RECT.left_eName: B$ "left", 0]
[Sz_LB_RECT.top_eName: B$ "top", 0]
[Sz_LB_RECT.right_eName: B$ "right", 0]
[Sz_LB_RECT.bottom_eName: B$ "bottom", 0]

[LB_RECT:
  LB_RECT.sname:D$ Sz_LB_RECT_sName
  LB_RECT.left: D$ Sz_LB_RECT.left_eName, LB_structTypeD1
  LB_RECT.top: D$ Sz_LB_RECT.top_eName, LB_structTypeD1
  LB_RECT.right: D$ Sz_LB_RECT.right_eName, LB_structTypeD1
  LB_RECT.bottom: D$ Sz_LB_RECT.bottom_eName, LB_structTypeD1
  D$ 0]  ; Terminator

; Strings for LB_PAINTSTRUCT
[Sz_LB_PAINTSTRUCT_sName: B$ "PAINTSTRUCT", 0]
[Sz_LB_PAINTSTRUCT_hDC_eName: B$ "hDC", 0]
[Sz_LB_PAINTSTRUCT_fErase_eName: B$ "fErase", 0]
[Sz_LB_PAINTSTRUCT_rcPaint_eName: B$ "rcPaint", 0]
[Sz_LB_PAINTSTRUCT_fRestore_eName: B$ "fRestore", 0]
[Sz_LB_PAINTSTRUCT_fIncUpdate_eName: B$ "fIncUpdate", 0]
[Sz_LB_PAINTSTRUCT_rgbReserved_eName: B$ "rgbReserved", 0]

[LB_PAINTSTRUCT:
  LB_PAINTSTRUCT.sname: D$ Sz_LB_PAINTSTRUCT_sName
  LB_PAINTSTRUCT.hDC: D$ Sz_LB_PAINTSTRUCT_hDC_eName, D$ LB_structTypeD2
  LB_PAINTSTRUCT.fErase: D$ Sz_LB_PAINTSTRUCT_fErase_eName, D$ LB_structTypeD3
  LB_PAINTSTRUCT.rcPaint: D$ Sz_LB_PAINTSTRUCT_rcPaint_eName, D$ LB_structTypeStruct, D$ LB_RECT
  LB_PAINTSTRUCT.fRestore: D$ Sz_LB_PAINTSTRUCT_fRestore_eName, D$ LB_structTypeD3
  LB_PAINTSTRUCT.fIncUpdate: D$ Sz_LB_PAINTSTRUCT_fIncUpdate_eName, D$ LB_structTypeD3
  LB_PAINTSTRUCT.rgbReserved: D$ Sz_LB_PAINTSTRUCT_rgbReserved_eName, D$ (LB_structTypeAB1 or (32 shl 16))
  D$ 0]  ; Terminator

; Strings for LB_BITMAP
[Sz_LB_BITMAP_sName: B$ "BITMAP", 0]
[Sz_LB_BITMAP_bmType_eName: B$ "bmType", 0]
[Sz_LB_BITMAP_bmWidth_eName: B$ "bmWidth", 0]
[Sz_LB_BITMAP_bmHeight_eName: B$ "bmHeight", 0]
[Sz_LB_BITMAP_bmWidthBytes_eName: B$ "bmWidthBytes", 0]
[Sz_LB_BITMAP_bmPlanes_eName: B$ "bmPlanes", 0]
[Sz_LB_BITMAP_bmBitsPixel_eName: B$ "bmBitsPixel", 0]
[Sz_LB_BITMAP_bmBits_eName: B$ "bmBits", 0]

[LB_BITMAP:
  LB_BITMAP.sname: D$ Sz_LB_BITMAP_sName
  LB_BITMAP.bmType: D$ Sz_LB_BITMAP_bmType_eName, D$ LB_structTypeD1
  LB_BITMAP.bmWidth: D$ Sz_LB_BITMAP_bmWidth_eName, D$ LB_structTypeD1
  LB_BITMAP.bmHeight: D$ Sz_LB_BITMAP_bmHeight_eName, D$ LB_structTypeD1
  LB_BITMAP.bmWidthBytes: D$ Sz_LB_BITMAP_bmWidthBytes_eName, D$ LB_structTypeD1
  LB_BITMAP.bmPlanes: D$ Sz_LB_BITMAP_bmPlanes_eName, D$ LB_structTypeW1
  LB_BITMAP.bmBitsPixel: D$ Sz_LB_BITMAP_bmBitsPixel_eName, D$ LB_structTypeW1
  LB_BITMAP.bmBits: D$ Sz_LB_BITMAP_bmBits_eName, D$ LB_structTypeD2
  D$ 0]  ; Terminator

; Strings for LB_LOGFONT
[Sz_LB_LOGFONT_sName: B$ "LOGFONT", 0]
[Sz_LB_LOGFONT_lfHeight_eName: B$ "lfHeight", 0]
[Sz_LB_LOGFONT_lfWidth_eName: B$ "lfWidth", 0]
[Sz_LB_LOGFONT_lfEscapement_eName: B$ "lfEscapement", 0]
[Sz_LB_LOGFONT_lfOrientation_eName: B$ "lfOrientation", 0]
[Sz_LB_LOGFONT_lfWeight_eName: B$ "lfWeight", 0]
[Sz_LB_LOGFONT_lfItalic_eName: B$ "lfItalic", 0]
[Sz_LB_LOGFONT_lfUnderline_eName: B$ "lfUnderline", 0]
[Sz_LB_LOGFONT_lfStrikeOut_eName: B$ "lfStrikeOut", 0]
[Sz_LB_LOGFONT_lfCharSet_eName: B$ "lfCharSet", 0]
[Sz_LB_LOGFONT_lfOutPrecision_eName: B$ "lfOutPrecision", 0]
[Sz_LB_LOGFONT_lfClipPrecision_eName: B$ "lfClipPrecision", 0]
[Sz_LB_LOGFONT_lfQuality_eName: B$ "lfQuality", 0]
[Sz_LB_LOGFONT_lfPitchAndFamily_eName: B$ "lfPitchAndFamily", 0]
[Sz_LB_LOGFONT_lfFaceName_eName: B$ "lfFaceName", 0]

[LB_LOGFONT:
  LB_LOGFONT.sname: D$ Sz_LB_LOGFONT_sName
  LB_LOGFONT.lfHeight: D$ Sz_LB_LOGFONT_lfHeight_eName, D$ LB_structTypeD3
  LB_LOGFONT.lfWidth: D$ Sz_LB_LOGFONT_lfWidth_eName, D$ LB_structTypeD1
  LB_LOGFONT.lfEscapement: D$ Sz_LB_LOGFONT_lfEscapement_eName, D$ LB_structTypeD1
  LB_LOGFONT.lfOrientation: D$ Sz_LB_LOGFONT_lfOrientation_eName, D$ LB_structTypeD1
  LB_LOGFONT.lfWeight: D$ Sz_LB_LOGFONT_lfWeight_eName, D$ LB_structTypeV1, D$ LB_LFweightTable
  LB_LOGFONT.lfItalic: D$ Sz_LB_LOGFONT_lfItalic_eName, D$ LB_structTypeB1
  LB_LOGFONT.lfUnderline: D$ Sz_LB_LOGFONT_lfUnderline_eName, D$ LB_structTypeB1
  LB_LOGFONT.lfStrikeOut: D$ Sz_LB_LOGFONT_lfStrikeOut_eName, D$ LB_structTypeB1
  LB_LOGFONT.lfCharSet: D$ Sz_LB_LOGFONT_lfCharSet_eName, D$ LB_structTypeV3, D$ LB_LFcharsetTable
  LB_LOGFONT.lfOutPrecision: D$ Sz_LB_LOGFONT_lfOutPrecision_eName, D$ LB_structTypeV3, D$ LB_LBoutPrecisTable
  LB_LOGFONT.lfClipPrecision: D$ Sz_LB_LOGFONT_lfClipPrecision_eName, D$ LB_structTypeV3, D$ LB_LFclipPrecisTable
  LB_LOGFONT.lfQuality: D$ Sz_LB_LOGFONT_lfQuality_eName, D$ LB_structTypeV3, D$ LB_LFqualityTable
  LB_LOGFONT.lfPitchAndFamily: D$ Sz_LB_LOGFONT_lfPitchAndFamily_eName, D$ LB_structTypeB1
  LB_LOGFONT.lfFaceName: D$ Sz_LB_LOGFONT_lfFaceName_eName, D$ (LB_structTypeS2 or (&LF_FACESIZE shl 16))
  D$ 0]  ; Terminator

;=================================================
; Code-to-text tables for symbolic value display (using pointers):
;=================================================

; Strings for LB_LFweightTable
[Txt_FW_DONTCARE: B$ "FW_DONTCARE", 0]
[Txt_FW_THIN: B$ "FW_THIN", 0]
[Txt_FW_EXTRALIGHT: B$ "FW_EXTRALIGHT", 0]
[Txt_FW_LIGHT: B$ "FW_LIGHT", 0]
[Txt_FW_NORMAL: B$ "FW_NORMAL", 0]
[Txt_FW_MEDIUM: B$ "FW_MEDIUM", 0]
[Txt_FW_SEMIBOLD: B$ "FW_SEMIBOLD", 0]
[Txt_FW_BOLD: B$ "FW_BOLD", 0]
[Txt_FW_EXTRABOLD: B$ "FW_EXTRABOLD", 0]
[Txt_FW_HEAVY: B$ "FW_HEAVY", 0]

[LB_LFweightTable:
  D$ Txt_FW_DONTCARE, D$ &FW_DONTCARE
  D$ Txt_FW_THIN, D$ &FW_THIN
  D$ Txt_FW_EXTRALIGHT, D$ &FW_EXTRALIGHT
  D$ Txt_FW_LIGHT, D$ &FW_LIGHT
  D$ Txt_FW_NORMAL, D$ &FW_NORMAL
  D$ Txt_FW_MEDIUM, D$ &FW_MEDIUM
  D$ Txt_FW_SEMIBOLD, D$ &FW_SEMIBOLD
  D$ Txt_FW_BOLD, D$ &FW_BOLD
  D$ Txt_FW_EXTRABOLD, D$ &FW_EXTRABOLD
  D$ Txt_FW_HEAVY, D$ &FW_HEAVY
  D$ 0]  ; Terminator

; Strings for LB_LFcharsetTable
[Txt_ANSI_CHARSET: B$ "ANSI_CHARSET", 0]
[Txt_BALTIC_CHARSET: B$ "BALTIC_CHARSET", 0]
[Txt_CHINESEBIG5_CHARSET: B$ "CHINESEBIG5_CHARSET", 0]
[Txt_DEFAULT_CHARSET: B$ "DEFAULT_CHARSET", 0]
[Txt_EASTEUROPE_CHARSET: B$ "EASTEUROPE_CHARSET", 0]
[Txt_GB2312_CHARSET: B$ "GB2312_CHARSET", 0]
[Txt_GREEK_CHARSET: B$ "GREEK_CHARSET", 0]
[Txt_HANGUL_CHARSET: B$ "HANGUL_CHARSET", 0]
[Txt_MAC_CHARSET: B$ "MAC_CHARSET", 0]
[Txt_OEM_CHARSET: B$ "OEM_CHARSET", 0]
[Txt_RUSSIAN_CHARSET: B$ "RUSSIAN_CHARSET", 0]
[Txt_SHIFTJIS_CHARSET: B$ "SHIFTJIS_CHARSET", 0]
[Txt_SYMBOL_CHARSET: B$ "SYMBOL_CHARSET", 0]
[Txt_TURKISH_CHARSET: B$ "TURKISH_CHARSET", 0]
[Txt_VIETNAMESE_CHARSET: B$ "VIETNAMESE_CHARSET", 0]
[Txt_JOHAB_CHARSET: B$ "JOHAB_CHARSET", 0]
[Txt_ARABIC_CHARSET: B$ "ARABIC_CHARSET", 0]
[Txt_HEBREW_CHARSET: B$ "HEBREW_CHARSET", 0]
[Txt_THAI_CHARSET: B$ "THAI_CHARSET", 0]

[LB_LFcharsetTable:
  D$ Txt_ANSI_CHARSET, D$ &ANSI_CHARSET
  D$ Txt_BALTIC_CHARSET, D$ &BALTIC_CHARSET
  D$ Txt_CHINESEBIG5_CHARSET, D$ &CHINESEBIG5_CHARSET
  D$ Txt_DEFAULT_CHARSET, D$ &DEFAULT_CHARSET
  D$ Txt_EASTEUROPE_CHARSET, D$ &EASTEUROPE_CHARSET
  D$ Txt_GB2312_CHARSET, D$ &GB2312_CHARSET
  D$ Txt_GREEK_CHARSET, D$ &GREEK_CHARSET
  D$ Txt_HANGUL_CHARSET, D$ &HANGUL_CHARSET
  D$ Txt_MAC_CHARSET, D$ &MAC_CHARSET
  D$ Txt_OEM_CHARSET, D$ &OEM_CHARSET
  D$ Txt_RUSSIAN_CHARSET, D$ &RUSSIAN_CHARSET
  D$ Txt_SHIFTJIS_CHARSET, D$ &SHIFTJIS_CHARSET
  D$ Txt_SYMBOL_CHARSET, D$ &SYMBOL_CHARSET
  D$ Txt_TURKISH_CHARSET, D$ &TURKISH_CHARSET
  D$ Txt_VIETNAMESE_CHARSET, D$ &VIETNAMESE_CHARSET
  D$ Txt_JOHAB_CHARSET, D$ &JOHAB_CHARSET
  D$ Txt_ARABIC_CHARSET, D$ &ARABIC_CHARSET
  D$ Txt_HEBREW_CHARSET, D$ &HEBREW_CHARSET
  D$ Txt_THAI_CHARSET, D$ &THAI_CHARSET
  D$ 0]  ; Terminator

; Strings for LB_LBoutPrecisTable
[Txt_OUT_DEFAULT_PRECIS: B$ "OUT_DEFAULT_PRECIS", 0]
[Txt_OUT_DEVICE_PRECIS: B$ "OUT_DEVICE_PRECIS", 0]
[Txt_OUT_OUTLINE_PRECIS: B$ "OUT_OUTLINE_PRECIS", 0]
[Txt_OUT_PS_ONLY_PRECIS: B$ "OUT_PS_ONLY_PRECIS", 0]
[Txt_OUT_RASTER_PRECIS: B$ "OUT_RASTER_PRECIS", 0]
[Txt_OUT_STRING_PRECIS: B$ "OUT_STRING_PRECIS", 0]
[Txt_OUT_STROKE_PRECIS: B$ "OUT_STROKE_PRECIS", 0]
[Txt_OUT_TT_ONLY_PRECIS: B$ "OUT_TT_ONLY_PRECIS", 0]
[Txt_OUT_TT_PRECIS: B$ "OUT_TT_PRECIS", 0]

[LB_LBoutPrecisTable:
  D$ Txt_OUT_DEFAULT_PRECIS, D$ &OUT_DEFAULT_PRECIS
  D$ Txt_OUT_DEVICE_PRECIS, D$ &OUT_DEVICE_PRECIS
  D$ Txt_OUT_OUTLINE_PRECIS, D$ &OUT_OUTLINE_PRECIS
  D$ Txt_OUT_PS_ONLY_PRECIS, D$ &OUT_PS_ONLY_PRECIS
  D$ Txt_OUT_RASTER_PRECIS, D$ &OUT_RASTER_PRECIS
  D$ Txt_OUT_STRING_PRECIS, D$ &OUT_STRING_PRECIS
  D$ Txt_OUT_STROKE_PRECIS, D$ &OUT_STROKE_PRECIS
  D$ Txt_OUT_TT_ONLY_PRECIS, D$ &OUT_TT_ONLY_PRECIS
  D$ Txt_OUT_TT_PRECIS, D$ &OUT_TT_PRECIS
  D$ 0]  ; Terminator

; Strings for LB_LFclipPrecisTable
[Txt_CLIP_DEFAULT_PRECIS: B$ "CLIP_DEFAULT_PRECIS", 0]
[Txt_CLIP_DFA_DISABLE: B$ "CLIP_DFA_DISABLE", 0]
[Txt_CLIP_EMBEDDED: B$ "CLIP_EMBEDDED", 0]
[Txt_CLIP_LH_ANGLES: B$ "CLIP_LH_ANGLES", 0]
[Txt_CLIP_STROKE_PRECIS: B$ "CLIP_STROKE_PRECIS", 0]

[LB_LFclipPrecisTable:
  D$ Txt_CLIP_DEFAULT_PRECIS, D$ &CLIP_DEFAULT_PRECIS
  D$ Txt_CLIP_DFA_DISABLE, D$ &CLIP_DFA_DISABLE
  D$ Txt_CLIP_EMBEDDED, D$ &CLIP_EMBEDDED
  D$ Txt_CLIP_LH_ANGLES, D$ &CLIP_LH_ANGLES
  D$ Txt_CLIP_STROKE_PRECIS, D$ &CLIP_STROKE_PRECIS
  D$ 0]  ; Terminator

; Strings for LB_LFqualityTable
[Txt_ANTIALIASED_QUALITY: B$ "ANTIALIASED_QUALITY", 0]
[Txt_CLEARTYPE_QUALITY: B$ "CLEARTYPE_QUALITY", 0]
[Txt_DEFAULT_QUALITY: B$ "DEFAULT_QUALITY", 0]
[Txt_DRAFT_QUALITY: B$ "DRAFT_QUALITY", 0]
[Txt_NONANTIALIASED_QUALITY: B$ "NONANTIALIASED_QUALITY", 0]
[Txt_PROOF_QUALITY: B$ "PROOF_QUALITY", 0]

[LB_LFqualityTable:
  D$ Txt_ANTIALIASED_QUALITY, D$ &ANTIALIASED_QUALITY
  D$ Txt_CLEARTYPE_QUALITY, D$ &CLEARTYPE_QUALITY
  D$ Txt_DEFAULT_QUALITY, D$ &DEFAULT_QUALITY
  D$ Txt_DRAFT_QUALITY, D$ &DRAFT_QUALITY
  D$ Txt_NONANTIALIASED_QUALITY, D$ &NONANTIALIASED_QUALITY
  D$ Txt_PROOF_QUALITY, D$ &PROOF_QUALITY
  D$ 0]  ; Terminator

Proc LogBuddyInit:
    Local @libHandle

    Call 'Kernel32.LoadLibraryA' LB_DLLname
    test eax eax | jz @fail
    mov D@libHandle eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_StartProcName
    test eax eax | jz @fail
    mov D$LB_StartProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_FinishProcName
    test eax eax | jz @fail
    mov D$LB_FinishProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_LogMsgProcName
    test eax eax | jz @fail
    mov D$LB_LogMsgProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_DumpMemProcName
    test eax eax | jz @fail
    mov D$LB_DumpMemProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_AddTextProcName
    test eax eax | jz @fail
    mov D$LB_AddTextProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_AddSepProcName
    test eax eax | jz @fail
    mov D$LB_AddSepProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_WriteFileProcName
    test eax eax | jz @fail
    mov D$LB_WriteFileProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_ClearLogProcName
    test eax eax | jz @fail
    mov D$LB_ClearLogProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_LogVarProcName
    test eax eax | jz @fail
    mov D$LB_LogVarProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_PutTimeProcName
    test eax eax | jz @fail
    mov D$LB_PutTimeProcAddr eax

    Call 'Kernel32.GetProcAddress' D@libHandle, LB_ShowStructProcName
    test eax eax | jz @fail
    mov D$LB_ShowStructProcAddr eax

    ; Success!
    mov eax &TRUE
    mov B$DLLinitFlag al
    ExitP

@fail:
    call 'user32.MessageBoxA' &NULL, LB_DLLfailMsg, &NULL, &MB_OK
    xor eax eax

EndP

Proc LogBuddyStart:
    Arguments @winTitle

    If B$DLLinitFlag = &TRUE
        call D$LB_StartProcAddr D@winTitle
    End_If

EndP

Proc LogBuddyFinish:

    If B$DLLinitFlag = &TRUE
        call D$LB_FinishProcAddr
    End_If

EndP

Proc LogBuddyLogMsg:
    Arguments @hWin, @msg, @wParam, @lParam, @modePtr

    If B$DLLinitFlag = &TRUE
        call D$LB_LogMsgProcAddr D@hWin, D@msg, D@wParam, D@lParam, D@modePtr
    End_If

EndP

Proc LogBuddyDumpMem:
    Arguments @memStart, @memLength, @namePtr

    If B$DLLinitFlag = &TRUE
        call D$LB_DumpMemProcAddr D@memStart, D@memLength, D@namePtr
    End_If

EndP

Proc LogBuddyAddText:
    Arguments @textPtr

    If B$DLLinitFlag = &TRUE
        call D$LB_AddTextProcAddr D@textPtr
    End_If

EndP

Proc LogBuddyAddSeparator:

    If B$DLLinitFlag = &TRUE
        call D$LB_AddSepProcAddr
    End_If

EndP

Proc LogBuddyWriteToFile:
    Arguments @filenamePtr

    If B$DLLinitFlag = &TRUE
        call D$LB_WriteFileProcAddr D@filenamePtr
    End_If

EndP

Proc LogBuddyClearLog:

    If B$DLLinitFlag = &TRUE
        call D$LB_ClearLogProcAddr
    End_If

EndP

Proc LogBuddyLogVar:
    Arguments @varnamePtr, @var, @varType

    If B$DLLinitFlag = &TRUE
        call D$LB_LogVarProcAddr D@varnamePtr, D@var, D@varType
    End_If

EndP

Proc LogBuddyPutTime:

    If B$DLLinitFlag = &TRUE
        call D$LB_PutTimeProcAddr
    End_If

EndP

Proc LogBuddyShowStruct:
    Arguments @templatePtr, @structPtr

    If B$DLLinitFlag = &TRUE
        call D$LB_ShowStructProcAddr D@templatePtr, D@structPtr
    End_If

EndP

Main Function
(...)

Main:

    ; Initialize LogBuddy:
    call LogBuddyInit
    ; Start LogBuddy rolling:
    call LogBuddyStart OurWinTitle

    ; Show a memory dump of a memory dialog template:
    call LogBuddyDumpMem DLG_BuddyTest, 150, OurWinTitle
    ; obtenir le handle du programme
    ; ------------------------------
    call 'Kernel32.GetModuleHandleA' &NULL
    mov D$wc.hInstance eax
(...)

___________________________________________________________________________________________

Proc MainWinProc:
    Arguments @hWnd @Message @wParam @lParam
    Local @hFont

    pushad

    .If D@Message = &WM_CLOSE

         call 'User32.PostQuitMessage' &NULL

    .Else_If D@Message = &WM_PAINT

         call 'User32.BeginPaint' D@hWnd ps
         call 'GDI32.CreateFontA' 24 16 &NULL &NULL 400 &NULL &NULL &NULL &OEM_CHARSET,
                                  &OUT_DEFAULT_PRECIS &CLIP_DEFAULT_PRECIS,
                                  &DEFAULT_QUALITY &DEFAULT_PITCH+&FF_SCRIPT,
                                  FontName
         call 'GDI32.SelectObject' D$ps.hdc eax
         mov D@hFont eax

         call 'GDI32.SetTextColor' D$ps.hdc {RGB 0,255,255}

         call 'GDI32.SetBkColor' D$ps.hdc {RGB 200,0,0}

         call 'GDI32.TextOutA' D$ps.hdc D$hitTxt_X D$hitTxt_Y TxtString D$TxtStringLen

         call 'GDI32.SelectObject' D$ps.hdc D@hFont

         call 'User32.EndPaint' D@hWnd ps

    .Else
         call LogBuddyLogMsg D@hWnd, D@Message, D@wParam, D@lParam, LB_msgsAll
         popad
         call 'User32.DefWindowProcA' D@hWnd D@Message D@wParam D@lParam
         ExitP

    .End_If

    popad
    mov eax &NULL
EndP



One question. Is really necessary to call the functions of the dll using GetProcAdress ? Can we do it directly without the needs to initialize all of them ?
Ex:
call 'LogBuddy.LogBuddyStart' OurWinTitle

which should be the equivalent in masm for
invoke LogBuddyStart OFFSET OurWinTitle
#23
The Laboratory / Re: SIMD_BinaryScan (Instring ...
Last post by guga - April 02, 2025, 12:03:32 PM
Finished the backwards algo. I´ll clean-up the code and put the comments on it and post here both (The normal version updated and this one). I tested both and they seems to work without errors (as far i saw). I loaded a big text (Around 6.5 Mb) from Project Guttenberg called: "The Project Gutenberg EBook of The Adventures of Sherlock Holmes by Sir Arthur Conan Doyle (#15 in our series by Sir Arthur Conan Doyle)" and starting scanning it. The test consists in loading the text in memory and creating patterns starting from 1 Byte that are incremented on each loop. So, on the 1st iteration, it take 38 bytes from the start, used it as a pattern and scan it on the big text. On the next iteration, it adds 1 byte to the older pos and then search 38 bytes as a pattern on the big text and it continues incrementing and scanning until it reaches the end of the 6.5 Mb file. I only limited the size of the pattern to a maximum of 38 bytes in order to see it the algo will crash even considering that the pattern position is being incremented at each loop, and therefore we could reach some unaligned and aligned text to perform the scans, depending of position of the newly created pattern on each loop. Fortunately, it always found the patterns created and never bypassed the limits of SSE registers in any of it´s internal functions.

So it processed something around 6.5Mb * 6.5Mb (42.5 Tb) of information. On my tests it took a bit more than one hour to perform the whole thing. So, not counting the limitation of my CPU, the speed of this thing (in theory) can reach something around 11.74 Gb/sec.

The tests i did was like this:

[MyTxt: D$ 0] ; Pointer to the contents of Big.txt
[MyTxtSize: D$ 0] ; Size of Big.txt
[GugaDymmyCnt: D$ 0]

    call 'FastCRT.ReadOpenedFile' &NULL, {B$ "big.txt", 0}, MyTxt, MyTxtSize, 0
    mov eax D$MyTxtSize | mov D$GugaDymmyCnt eax
    mov edi D$MyTxt
    Do
        call SIMD_BinaryScan_Back D$MyTxt, D$MyTxtSize, edi, 38
        If eax = 0
            mov eax eax ; If debugger paused here, it means we found an error. Fortunately, it never reached this point, meaning it always found the patterns it was searching for :)
        End_If
        inc edi
        dec D$GugaDymmyCnt ; dummy counter to estimate when this thing will stop.
        lea eax D$edi+38
    Loop_Until B$eax = 0
    call 'KERNEL32.ExitProcess' 0

Once i finish the comments i´ll upload it here.

One question. The reversed functions uses as an input the starting address of the text (The same as in the regular version), and internally it points it to the end to it starts scanning backwards.I made this only to maintain some correspondence with the normal version. But, i´m considering adding a flag where the user can input to start the scanning from the end of the string to the start.

For example:
[MyTxt: B$ "I say, Berg, my dear fellow," said Rostov, "when you get a letter
from home and meet one of your own people whom you want to talk
everything over with, and I happen to be there, I'll go at once, to be
out of your way! Do go somewhere, anywhere... to the devil!" he
exclaimed, and immediately seizing him by the shoulder and looking
amiably into his face, evidently wishing to soften the rudeness of his
words, he added, "Don't be hurt, my dear fellow; you know I speak from
my heart as to an old acquaintance.", 0]

[MyTxtSize: D$ 509]

[MyPattern: B$ "wishing", 0]
[MYpatternSize: D$ 7]

[SCAN_FROM_END 0]
[SCAN_FROM_START 1]

call SIMD_BinaryScan_Back MyTxt, D$MyTxtSize, MyPattern, D$MYpatternSize, SCAN_FROM_START
It will scan the string "wishing" from the start "I say,..." to the end

Or


call SIMD_BinaryScan_Back MyTxt, D$MyTxtSize, MyPattern, D$MYpatternSize, SCAN_FROM_END
It will scan the string "wishing" from the end of the text " an old acquaintance." to the start.

Later i´ll rename those flags, this was just a idea. Does a flag to do this is better, or i keep the algo without it scanning as default always from start to the end ?
#24
The Workshop / Re: LogBuddy debugging aid, im...
Last post by guga - April 02, 2025, 11:41:20 AM
Great idea  :thumbsup:  :thumbsup:  :thumbsup:

#25
The Workshop / Re: LogBuddy debugging aid, im...
Last post by NoCforMe - April 02, 2025, 10:38:30 AM
BTW, I wanted to point out (specifically to JJ) that I've finally embraced macros in this project!

Turned out that using macros was the only reasonable way to simplify making those structure templates. It's all in the manual, but here's one of them, for the LOGFONT structure:

LB_LOGFONT    LABEL DWORD
  @LB_structHeader "LOGFONT"
  @LB_structElement "lfHeight", $LB_structTypeD3
  @LB_structElement "lfWidth", $LB_structTypeD1
  @LB_structElement "lfEscapement", $LB_structTypeD1
  @LB_structElement "lfOrientation", $LB_structTypeD1
  @LB_structElement "lfWeight", $LB_structTypeV1
    DD LB_LFweightTable
  @LB_structElement "lfItalic", $LB_structTypeB1
  @LB_structElement "lfUnderline", $LB_structTypeB1
  @LB_structElement "lfStrikeOut", $LB_structTypeB1
  @LB_structElement "lfCharSet", $LB_structTypeV3
    DD LB_LFcharsetTable
  @LB_structElement "lfOutPrecision", $LB_structTypeV3
    DD LB_LBoutPrecisTable
  @LB_structElement "lfClipPrecision", $LB_structTypeV3
    DD LB_LFclipPrecisTable
  @LB_structElement "lfQuality", $LB_structTypeV3
    DD LB_LFqualityTable
  @LB_structElement "lfPitchAndFamily", $LB_structTypeB1
  @LB_structElement "lfFaceName", $LB_structTypeS2 OR (LF_FACESIZE SHL 16)
    DD 0

The macros make this much simpler by being able to bounce back and forth between putting data in the .const and .data segments.

(Those insertions in the list, like DD LB_LFqualityTable, are the code-to-text lists that show symbolic constants instead of raw numbers.)
#26
The Workshop / LogBuddy debugging aid, improv...
Last post by NoCforMe - April 02, 2025, 10:12:31 AM
I wanted to post the progress I've made with my LogBuddy debugging aid. It'd be nice if anyone wanted to take it out for a spin and report back with their take on it.

This is not a full-blown debugger, but it is a very handy aid that's pretty easy to get up and running. You only need to include 2 files in the debugee program (an include file and a small assembler stub), and have the DLL accessible.

It lets you
  • view individual variables
  • dump selected memory areas
  • capture selected window messages (WM_xxxx
  • measure timings

And the newest thing: it can now show the contents of an entire structure. I'm really happy about this latest feature: I've long thought about how to do this, and I came up with a scheme that's pretty easy to use. Once you have the logger installed and started up, to view a structure all you need to put in your code is
INVOKE LogBuddyShowStruct, <ptr. to template>, <ptr. to structure>The "template" takes a bit to set up, but that only needs to be done once (and it's all explained in the manual, attached here).

It can even handle nested structures, i.e., a structure within a structure. (It can only do one level of nesting, but that's all you need in most cases.)

It also has a facility to show values as Win32 symbolic constant names instead of just raw numbers.

You cannot view this attachment.

So check it out, and let me know what you think.
#27
Windows API / Re: Buffer alignment
Last post by NoCforMe - April 02, 2025, 10:00:27 AM
"daydreamer": what the hell does this have to do with buffer alignment?
And what's with that blond girl picture? Not you, we know ...
#28
The Orphanage / Re: 4x4 avatar version
Last post by zedd151 - April 02, 2025, 06:55:50 AM
Quote from: sinsi on April 02, 2025, 06:39:31 AMHave you considered different ways of painting
..
You are basically creating them every WM_PAINT anyway.
Yeah, I know. But I wanted to keep the code fairly simple. Maybe another time.
No issues with the painting as it is, btw.  :smiley:

Bob Ross style (under 30 minutes and easy) painting.  :azn:
#29
The Orphanage / Re: 4x4 avatar version
Last post by sinsi - April 02, 2025, 06:39:31 AM
Have you considered different ways of painting?

Make 16 bitmaps, store the handles in an array for easy access. You are basically creating them every WM_PAINT anyway.

Draw the background and grid either once as a bitmap or in WM_PAINT then all you need to do is draw the numbers each paint.

#30
The Orphanage / Re: 4x4 avatar version
Last post by zedd151 - April 02, 2025, 01:50:08 AM
Quote from: FORTRANS on April 01, 2025, 11:05:10 PMAnd note that, for me to get working code, it took quite some time and effort.

Of course I probably did a lot of rewriting to get an acceptable
program to play with.

And I tried all sorts of excursions along the way.
That is all part of the fun when trying new things in assembly for the first time.    :thumbsup: