The MASM Forum

General => The Campus => Topic started by: Magnum on June 30, 2013, 05:21:37 AM

Title: Need larger window
Post by: Magnum on June 30, 2013, 05:21:37 AM
I have a very old program that has a fixed size window.

Because of declining vision, I need a larger window.

It doesn't use CreateWindow, what would it use instead ?

Thanks.



Title: Re: Need larger window
Post by: dedndave on June 30, 2013, 05:25:45 AM
there are a few CreateDialog functions
possibly the dialog is in resource - try res hacker
Title: Re: Need larger window
Post by: Magnum on June 30, 2013, 07:11:00 AM
I found this.

extrn CreateDialogIndirectParamA:dword ; Create   a modeless dialog box from
         ; a dialog box template   in memory
Title: Re: Need larger window
Post by: Zen on June 30, 2013, 07:29:18 AM
This is kind of silly,...but, you can invoke GetDesktopWindow (http://msdn.microsoft.com/en-us/library/windows/desktop/ms633504(v=vs.85).aspx). Then, with that handle you can obtain the Device Context: GetDC (http://msdn.microsoft.com/en-us/library/windows/desktop/dd144871(v=vs.85).aspx).
Then,...and this is the fun part,...you can display some data using a huge font.
Here is a link to MSDN GDI Functions: Windows GDI (http://msdn.microsoft.com/en-us/library/windows/desktop/dd145203(v=vs.85).aspx). Microsoft tells you that these functions are obsolete and, not to use them in new programs,...but, they work great,...and, are especially annoying if your legacy app was written in MFC.
Title: Re: Need larger window
Post by: Magnum on June 30, 2013, 07:51:21 AM
I don't call your posts silly.  :biggrin:

Is this the right thing that needs some larger sizes and if so which one do I need to change.

Andy


CONTROL "1", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 0, 9, 8, 9
   CONTROL "00:00:00", 1018, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 11, 7, 42, 12 , 0x00020000
   CONTROL "START", 1019, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 7, 33, 13
   CONTROL "2", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 0, 25, 8, 9
   CONTROL "00:00:00", 1020, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 11, 23, 42, 12 , 0x00020000
   CONTROL "START", 1021, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 23, 33, 13
   CONTROL "3", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 0, 41, 8, 9
   CONTROL "00:00:00", 1022, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 11, 39, 42, 12 , 0x00020000
   CONTROL "START", 1023, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 39, 33, 13
   CONTROL "4", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 0, 57, 8, 9
   CONTROL "00:00:00", 1024, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 11, 55, 42, 12 , 0x00020000
   CONTROL "START", 1025, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 55, 33, 13
   CONTROL "5", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 0, 74, 8, 9
   CONTROL "00:00:00", 1026, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 11, 72, 42, 12 , 0x00020000
   CONTROL "START", 1027, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 53, 72, 33, 13
   CONTROL "6", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 93, 9, 8, 9
   CONTROL "00:00:00", 1028, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 104, 7, 42, 12 , 0x00020000
   CONTROL "START", 1029, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 146, 7, 33, 13
   CONTROL "7", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 93, 25, 8, 9
   CONTROL "00:00:00", 1030, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 104, 23, 42, 12 , 0x00020000
   CONTROL "START", 1031, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 146, 23, 33, 13
   CONTROL "8", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 93, 41, 8, 9
   CONTROL "00:00:00", 1032, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 104, 39, 42, 12 , 0x00020000
   CONTROL "START", 1033, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 146, 39, 33, 13
   CONTROL "9", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 93, 57, 8, 9
   CONTROL "00:00:00", 1034, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 104, 55, 42, 12 , 0x00020000
   CONTROL "START", 1035, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 146, 55, 33, 13
   CONTROL "10", -1, STATIC, SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 93, 74, 8, 9
   CONTROL "00:00:00", 1036, STATIC, SS_CENTER | SS_NOTIFY | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 104, 72, 42, 12 , 0x00020000
   CONTROL "START", 1037, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 146, 72, 33, 13

Title: Re: Need larger window
Post by: Zen on June 30, 2013, 07:58:32 AM
MAGNUM,
I didn't mean that your question was silly,...I mean't that my suggestion was silly (because. normally you wouldn't want to overwrite the display on the Desktop).
It will, however, work. And, it will work with any available window.
Probably the best solution would be to invoke: CreateWindowEx (http://msdn.microsoft.com/en-us/library/windows/desktop/ms632680(v=vs.85).aspx), and then display data in a HUGE font. This can then be destroyed immediately
Title: Re: Need larger window
Post by: Magnum on June 30, 2013, 08:07:14 AM
I don't have the source, so that's why I am looking to change some instructions in the .exe to have it display a larger window.

The program displays a set of 10 timers that I use a lot for brewing tea, conspiracy theories, etc.  :t

The window is 286 pixels wide but I can't find that to make it larger.

I read up DIALOGEX and WM_INITDIALOG and how they use CreateWindowEx.

Andy
Title: Re: Need larger window
Post by: sinsi on June 30, 2013, 10:30:59 AM
Doesn't Windows have a zoom/magnifier tool?
Title: Re: Need larger window
Post by: Magnum on June 30, 2013, 12:01:14 PM
It does but it's a little cumbersome.

I found another timer that's larger.



Title: Re: Need larger window
Post by: TWell on June 30, 2013, 05:31:54 PM
If you mean to modify old exe, just use ResourceHacker or another dialog editor to change dialog font size bigger.
With poide.exe it's possible too.
Title: Re: Need larger window
Post by: Magnum on July 01, 2013, 08:49:26 AM
I need the window larger, not a larger font.

Andy

Unless making the font larger would make the window larger.

Title: Re: Need larger window
Post by: japheth on July 01, 2013, 04:45:15 PM
Quote from: Magnum on July 01, 2013, 08:49:26 AM
Unless making the font larger would make the window larger.

It will. However, there's no guarantee that you can change the font size in the dialog template - the font parameters are an optional part of the dialog resource ( DS_SETFONT flag must be set ).

Title: Re: Need larger window
Post by: xandaz on July 01, 2013, 09:35:59 PM
  Maybe if you were to step into a CreateWindowEx call, you'd realise there's a more manual way of doing it. Just a thought of course. I never did it.
Title: Re: Need larger window
Post by: Magnum on July 09, 2013, 10:51:45 AM
I found the CreateWindowEx call using IDA but I can't find out how to get to it using Ollydbg.

If I can get to it, it should be simple to give it larger width and height values.

Andy
Title: Re: Need larger window
Post by: Magnum on July 09, 2013, 11:11:12 AM
I found this, but no where can I find where any of the parameters are passed.

??



CPU Disasm
Address   Hex dump          Command                                  Comments
7E42E4A9  /$  8BFF          MOV EDI,EDI                              ; HWND USER32.CreateWindowExA(ExtStyle,ClassName,WindowName,Style,X,Y,Width,Height,hParent,hMenu,hInst,lParam)
7E42E4AB  |.  55            PUSH EBP
7E42E4AC  |.  8BEC          MOV EBP,ESP
7E42E4AE  |.  68 01000040   PUSH 40000001                            ; /Arg13 = 40000001
7E42E4B3  |.  FF75 34       PUSH DWORD PTR SS:[ARG.12]               ; |Arg12 => [ARG.12]
7E42E4B6  |.  FF75 30       PUSH DWORD PTR SS:[ARG.11]               ; |Arg11 => [ARG.11]
7E42E4B9  |.  FF75 2C       PUSH DWORD PTR SS:[ARG.10]               ; |Arg10 => [ARG.10]
7E42E4BC  |.  FF75 28       PUSH DWORD PTR SS:[ARG.9]                ; |Arg9 => [ARG.9]
7E42E4BF  |.  FF75 24       PUSH DWORD PTR SS:[ARG.8]                ; |Arg8 => [ARG.8]
7E42E4C2  |.  FF75 20       PUSH DWORD PTR SS:[ARG.7]                ; |Arg7 => [ARG.7]
7E42E4C5  |.  FF75 1C       PUSH DWORD PTR SS:[ARG.6]                ; |Arg6 => [ARG.6]
7E42E4C8  |.  FF75 18       PUSH DWORD PTR SS:[ARG.5]                ; |Arg5 => [ARG.5]
7E42E4CB  |.  FF75 14       PUSH DWORD PTR SS:[ARG.4]                ; |Arg4 => [ARG.4]
7E42E4CE  |.  FF75 10       PUSH DWORD PTR SS:[ARG.3]                ; |Arg3 => [ARG.3]
7E42E4D1  |.  FF75 0C       PUSH DWORD PTR SS:[ARG.2]                ; |Arg2 => [ARG.2]
7E42E4D4  |.  FF75 08       PUSH DWORD PTR SS:[ARG.1]                ; |Arg1 => [ARG.1]
7E42E4D7  |.  E8 B5FEFFFF   CALL 7E42E391                            ; \USER32.7E42E391
Title: Re: Need larger window
Post by: GoneFishing 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
bpx CreateWindowEx 
http://www.ollydbg.de/faq.htm (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 (http://technet.microsoft.com/en-us/sysinternals/bb897434)
Title: Re: Need larger window
Post by: MichaelW 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.


;==============================================================================
    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