Author Topic: Need larger window  (Read 9709 times)

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: Need larger window
« Reply #15 on: July 09, 2013, 11:20:02 PM »
This's a disasm of CreateWindowsEx in user32.dll
You need to look for the passed parameters in your program. I don't use OllyDbg much but
I know that previous version (1.x) of OllyDbg had a command line where you could simply type something like
Code: [Select]
bpx CreateWindowEx 
http://www.ollydbg.de/faq.htm

You said that using a Windows magnifier tool is cumbersome but you're having more troubles trying to find/modify the passed parameters for CreateWindowEx function.
You also may try ZoomIt utility from Sysinternals suite :
http://technet.microsoft.com/en-us/sysinternals/bb897434

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: Need larger window
« Reply #16 on: July 09, 2013, 11:45:20 PM »
Changing the size of the window could be as simple as finding the window handle and passing it in an appropriate MoveWindow call. And I think you should be able to do the same with child windows. In my tests WM_SETFONT did not behave as expected. Initially there was no visible change, then when I forced the window to redraw the font did change, but not to the font that I specified. I suspect that the font changed to the system font, but I did not investigate this. If the problem is the window style, you may be able to change it with SetWindowLongPtr (I use “may” because I can’t recall testing this with a window or a dialog). And you can get the current style with GetWindowLongPtr.

Code: [Select]
;==============================================================================
    include \masm32\include\masm32rt.inc
;==============================================================================
    .data
        hFont HFONT 0
        hDlg  HWND  0
    .code
;==============================================================================

;------------------------------------------------------------------
; This is a modification of the MakeFont procedure from the MASM32
; examples, with the height and width specifications replaced with
; a point size specification.
;------------------------------------------------------------------

MakeFont proc pointSize:dword,weight:dword,italic:dword,lpFontName:dword

    invoke GetDC, 0
    invoke GetDeviceCaps, eax, LOGPIXELSY
    mul   pointSize
    xor   edx, edx
    mov   ecx, 72
    div   ecx

    invoke CreateFont,eax,0,NULL,NULL,weight,italic,NULL,NULL,
                      DEFAULT_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,
                      PROOF_QUALITY,DEFAULT_PITCH or FF_DONTCARE,
                      lpFontName
    ret

MakeFont endp

;==============================================================================

;---------------------------------------------------------------------
; This procedure sizes the specified window so the client area is the
; specified width and height and optionally centers the window on the
; the screen.
;---------------------------------------------------------------------

SetClientSize proc hwnd:HWND,pixelWidth:DWORD,pixelHeight:DWORD,fCenter:DWORD

    LOCAL _x:DWORD, _y:DWORD, nWidth:DWORD, nHeight:DWORD
    LOCAL rcc:RECT, rcw:RECT

    invoke GetClientRect, hwnd, ADDR rcc
    invoke GetWindowRect, hwnd, ADDR rcw

    mov ecx, rcw.right
    sub ecx, rcw.left       ; ecx = window width - 1

    mov eax, pixelWidth
    dec eax                 ; eax = pixelWidth - 1
    mov edx, rcc.right      ; edx = client width - 1
    sub edx, eax            ; edx = difference
    sub ecx, edx            ; adjust width
    mov nWidth, ecx

    mov ecx, rcw.bottom
    sub ecx, rcw.top        ; ecx = window height - 1

    mov eax, pixelHeight
    dec eax                 ; eax = pixelHeight - 1
    mov edx, rcc.bottom     ; edx = client height - 1
    sub edx, eax            ; edx = difference
    sub ecx, edx            ; adjust height
    mov nHeight, ecx

    .IF fCenter
        invoke GetSystemMetrics, SM_CXSCREEN
        shr eax, 1
        mov edx, nWidth
        shr edx, 1
        sub eax, edx
        mov _x, eax
        invoke GetSystemMetrics, SM_CYSCREEN
        shr eax, 1
        mov edx, nHeight
        shr edx, 1
        sub eax, edx
        mov _y, eax
    .ELSE
        m2m _x, rcw.left
        m2m _y, rcw.top
    .ENDIF

    invoke MoveWindow, hwnd, _x, _y, nWidth, nHeight, TRUE

    ret

SetClientSize endp

;==============================================================================

EnumChildProc proc hwnd:HWND, lParam:LPARAM
    printf("%xh\n", hwnd)
    invoke SendMessage, hwnd, WM_SETFONT, hFont, FALSE
    return TRUE
EnumChildProc endp

;==============================================================================
start:
;==============================================================================
    ;----------------------------------------------------
    ; For a test dialog I used:
    ;
    ; \masm32\examples\dialogs_later\basic\basicdlg.exe
    ;----------------------------------------------------

    invoke MakeFont, 24, 800, 0, chr$("WingDings")

    invoke FindWindow, chr$("#32770"), chr$("Dialog Title")
    mov hDlg, eax
    printf("%xh\n\n",eax)

    invoke SetClientSize, hDlg, 500, 500, FALSE

    ;invoke SendMessage, hDlg, WM_SETFONT, hFont, TRUE

    invoke EnumChildWindows, hDlg, EnumChildProc, 0

    inkey

    invoke DeleteObject, hFont

    exit

;==============================================================================
end start




Well Microsoft, here’s another nice mess you’ve gotten us into.