GetWindowText() issue



Hi all,

Standard ANSI C Win32 application - no Unicode anywhere.
I want to retrieve the first 7 bytes of the current value of a
Combobox field on a window (all owned).
All values in the Combo Dropdown list are approx 20 bytes
in length.

So the code essentially is

TCHAR Buffer[8];

rc = GetWindowText(hWndCombo, Buffer, sizeof(Buffer));

Under Win9x:
rc = 8 (although it should be 7 according to the documentation as it should
not include the NULL character).

Under Windows XP SP2
rc = 16 and more importantly it is over-running the buffer.

I have tried calling GetWindowTextA() and I have also tried SendMessage(...,
WM_GETTEXT...) but under Windows XP it is ignoring the buffer size parameter
altogether.

I have confirmed that sizeof(Buffer) is correct, and I have even confirmed
sizeof(TCHAR) is 1 byte.

Can anyone reproduce this problem as it is frustrating the hell out of me.
Leslie.



.



Relevant Pages

  • [NT] Unchecked buffer in the Multiple UNC Provider Could Enable Code Execution
    ... The MUP receives commands containing UNC names from ... There is proper input checking in this first buffer. ... * Microsoft Windows NT 4.0 Workstation ... the vulnerability could only be exploited by a user who could ...
    (Securiteam)
  • Re: newbie: I/O with nasm
    ... BOOL ReadFile( ... BOOL WriteFile( ... Now, if Windows is what TK is looking for, we've got something to go on. ... Pointer to the buffer that receives the data read from the file. ...
    (alt.lang.asm)
  • New Secuity Vulnerabilities
    ... im Moshe BA from israel a.k.a Trancer and I would like to report 4-5 ... Windows 2003 Server has a built in Command Line Interreptor (I don't ... then the attacker has FULL access to the system. ... send(s, buffer, 5000, 0); ...
    (Vuln-Dev)
  • Re: Replacing fgets
    ... One more pointer is that if I use mmap it will solve my problem that is ... on SCO UNIX and on windows. ... char *buffer = 0; ... //Total Buffer Length ...
    (comp.lang.c)
  • Re: Replacing fgets
    ... One more pointer is that if I use mmap it will solve my problem that is ... on SCO UNIX and on windows. ... char *buffer = 0; ... //Total Buffer Length ...
    (comp.lang.c)