So, I'm trying to get the contents of the server console.
Everything goes fine, it gets the pointers without any problem.
Thing is, it doesn't get the contents. Well okay, it does. But it doesn't set the right ones(??)
My tool (winspy) gets them really fucking easy and that's even more annoying
The output is:
And the second time I run it:
as you can see it gets the value i set to it.
Thing is, it doesn't change anything....
I know it's possible because WinSpy does it without any probs:
![[Image: 03qHEpTGBt.png]](http://i.nowfollow.nl/03qHEpTGBt.png)
I really need help with this, I don't know that much about the winapi but i couldn't find anything about it on the internet
EDIT: it even changes the content without any problem
WHY CAN'T I DO THAT?!
![[Image: mC2r5UJ74w.png]](http://i.nowfollow.nl/mC2r5UJ74w.png)
EDIT: Tried InternalGetWindowText. No difference
EDIT: Browsed trough winspy sourcecode, basically what I found. but what the **** is a HWND?
Everything goes fine, it gets the pointers without any problem.
Thing is, it doesn't get the contents. Well okay, it does. But it doesn't set the right ones(??)
My tool (winspy) gets them really fucking easy and that's even more annoying
Code:
namespace iw5test
{
class Program
{
static void Main(string[] args)
{
StringBuilder sbWinText = new StringBuilder(256);
StringBuilder lulz = new StringBuilder(256);
IntPtr form = FindWindow("IW5 WinConsole", null);
IntPtr txtbox = FindWindowEx(form, IntPtr.Zero, "Edit", null);
IntPtr console = FindWindowEx(form, txtbox, "Edit", null);
bool f = GetWindowText(console, sbWinText, 256);
bool a = GetWindowText(form, lulz, 256);
bool x = SetWindowText(console, "HAX!");
bool xxx = SetWindowText(txtbox, "sv_maxclients 1337");
Console.WriteLine("console get text operation = {0}\r\nconsole set text operation = {1}\r\ncommand set text operation = {2}\r\nform get text operation\r\n", f, x, xxx, a);
Console.WriteLine("CONSOLE TXT = {0}", sbWinText.ToString());
Console.WriteLine("FORM TXT = {0}", lulz.ToString());
Console.ReadLine();
}
[DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Ansi)]
public static extern bool GetWindowText(IntPtr hWnd, [OutAttribute()] StringBuilder strNewWindowName, Int32 maxCharCount);
[DllImport("user32.dll", EntryPoint = "SetWindowText", CharSet = CharSet.Ansi)]
public static extern bool SetWindowText(IntPtr hWnd, string lpString);
[DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Ansi)]
public static extern IntPtr FindWindow(string className, string windowName);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string lclassName, string windowTitle);
}
}The output is:
Code:
console get text operation = False
console set text operation = True
command set text operation = True
form get text operation= True
CONSOLE TXT =
FORM TXT = Call of Duty: Modern Warfare 3 Dedicated Server - PlayerManager EditionAnd the second time I run it:
Code:
console get text operation = True
console set text operation = True
command set text operation = True
form get text operation= True
CONSOLE TXT = HAX!
FORM TXT = Call of Duty: Modern Warfare 3 Dedicated Server - PlayerManager Edition
tionas you can see it gets the value i set to it.
Thing is, it doesn't change anything....
I know it's possible because WinSpy does it without any probs:
![[Image: 03qHEpTGBt.png]](http://i.nowfollow.nl/03qHEpTGBt.png)
I really need help with this, I don't know that much about the winapi but i couldn't find anything about it on the internet
EDIT: it even changes the content without any problem

WHY CAN'T I DO THAT?!
![[Image: mC2r5UJ74w.png]](http://i.nowfollow.nl/mC2r5UJ74w.png)
EDIT: Tried InternalGetWindowText. No difference

EDIT: Browsed trough winspy sourcecode, basically what I found. but what the **** is a HWND?
Code:
case IDC_SETCAPTION:
// Set the target's window caption to the contents of the edit box
hwndEdit1 = GetDlgItem(hwnd, IDC_CAPTION1);
hwndEdit2 = GetDlgItem(hwnd, IDC_CAPTION2);
// Show the combo box and hide the edit box
if(IsWindowVisible(hwndEdit1))
{
// Copy the contents of the edit box to the combo box
GetWindowText(hwndEdit1, szCaption, sizeof(szCaption) / sizeof(TCHAR));
SetWindowText(hwndEdit2, szCaption);
ShowWindow(hwndEdit2, SW_SHOW);
ShowWindow(hwndEdit1, SW_HIDE);
SetFocus(hwndEdit2);
}
hCtrl = (HWND)spy_hCurWnd;
// get the original text and add it to the combo list
GetWindowText(hCtrl, szCaption, sizeof(szCaption) / sizeof(TCHAR));
SendMessage(hwndEdit2, CB_ADDSTRING, 0, (LPARAM)szCaption);
// now see what the new caption is to be
GetWindowText(hwndEdit2, szCaption, sizeof(szCaption) / sizeof(TCHAR));
// set the text to the new string
if(hCtrl != 0 && IsWindow(hCtrl))
SendMessage(hCtrl, WM_SETTEXT, 0, (LPARAM)szCaption);
return TRUE;
}


