[Help] consoles.

Posts 1–7 of 7 · Page 1 of 1
[Help] consoles.
I was trying to allocate a console in a DLL using AllocConsole() and write to it using WriteConsole(), for some odd reason it prints question marks and some random letters. Could this be caused by the fact that I'm injecting the DLL into another process?

Lol, this is such a fail |:

code:

[PHP]
#include <windows.h>
#include <iostream>

void Say()
{

std::string Buf = "Test";
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
WriteConsole(handle,Buf.c_str(),Buf.length(),NULL, NULL);
}

bool __stdcall DllMain(HINSTANCE hinst,DWORD reason,void* reserved)
{
if(reason == DLL_PROCESS_ATTACH)
{
Say();
}
return true;
}
[/PHP]

Output:
[php]
?t ?? //something like that
[/php]


Why is it doing this to me?
Just do it like a badass, CreateWindow + a multiline textbox and you're good to go(also looks sexier)
Use WriteConsoleA? Or change your project settings to multibyte.
Change to Multibyte?

EDIT: Didn't see you mmbob T__T
Quote Originally Posted by Stephen View Post
Change to Multibyte?

EDIT: Didn't see you mmbob T__T
Ninja'd .



Actually, Void, I'd recommend you use the unicode version (std::wstring and WriteConsoleW). Windows NT is natively unicode so ASCII functions need to go through a conversion process which slows them down.
Quote Originally Posted by mmbob View Post
Ninja'd .



Actually, Void, I'd recommend you use the unicode version (std::wstring and WriteConsoleW). Windows NT is natively unicode so ASCII functions need to go through a conversion process which slows them down.
I'm more ninja than you.

Hmm, I was thinking of that but I had to leave quickly for school.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us