-
Notifications
You must be signed in to change notification settings - Fork 2
/
wConsole.h
44 lines (34 loc) · 989 Bytes
/
wConsole.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/// by ptr0x
__forceinline void WriteInConsole(const char *frmt_text, ...)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD nWritten;
char text[1024];
va_list pArgs;
va_start(pArgs, frmt_text);
vsprintf(text, frmt_text, pArgs);
va_end(pArgs);
WriteConsole(hConsole, text, strlen(text), &nWritten, NULL);
}
__forceinline void FixIOHandles()
{
/* Output fix */
int outParam = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
FILE *stdout_stream = _fdopen(outParam, "w");
*stdout = *stdout_stream;
/* Input fix */
int inParam = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT);
FILE *stdin_stream = _fdopen(inParam, "r");
*stdin = *stdin_stream;
}
__forceinline void CreateConsole()
{
AllocConsole();
FixIOHandles();
/*while(TRUE)
{
WORD cmd;
scanf("%x", &cmd);
execute_command(cmd);
}*/
}