예제 #1
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG msg;
    DWORD id;

#ifndef NDEBUG
    CreateConsole();
#endif

    hinst = hInstance;

    LoadConfig();

    MainWND_Create();

    CreateThread(&(SECURITY_ATTRIBUTES){sizeof(SECURITY_ATTRIBUTES), FALSE, 0}, 0, Magnifier, NULL, 0, &id);

    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    SaveConfig();

    return msg.wParam;
}
예제 #2
0
void ShowInfo(const char *str)
{
	if (_has_console) {
		fprintf(stderr, "%s\n", str);
	} else {
		bool old;
		ReleaseCapture();
		_left_button_clicked = _left_button_down = false;

		old = MyShowCursor(true);
		if (strlen(str) > 2048) {
			/* The minimum length of the help message is 2048. Other messages sent via
			 * ShowInfo are much shorter, or so long they need this way of displaying
			 * them anyway. */
			_help_msg = str;
			DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(101), NULL, HelpDialogFunc);
		} else {
#if defined(UNICODE)
			/* We need to put the text in a seperate buffer because the default
			 * buffer in MB_TO_WIDE might not be large enough (512 chars) */
			wchar_t help_msgW[8192];
#endif
			if (MessageBox(GetActiveWindow(), MB_TO_WIDE_BUFFER(str, help_msgW, lengthof(help_msgW)), _T("OpenTTD"), MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL) {
				CreateConsole();
			}
		}
		MyShowCursor(old);
	}
}
예제 #3
0
const char *VideoDriver_Dedicated::Start(const char * const *parm)
{
	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
	_dedicated_video_mem = (bpp == 0) ? NULL : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));

	_screen.width  = _screen.pitch = _cur_resolution.width;
	_screen.height = _cur_resolution.height;
	_screen.dst_ptr = _dedicated_video_mem;
	ScreenSizeChanged();
	BlitterFactoryBase::GetCurrentBlitter()->PostResize();

#if defined(WINCE)
	/* WinCE doesn't support console stuff */
#elif defined(WIN32)
	/* For win32 we need to allocate a console (debug mode does the same) */
	CreateConsole();
	CreateWindowsConsoleThread();
	SetConsoleTitle(_T("OpenTTD Dedicated Server"));
#endif

#ifdef __OS2__
	/* For OS/2 we also need to switch to console mode instead of PM mode */
	OS2_SwitchToConsoleMode();
#endif

	DEBUG(driver, 1, "Loading dedicated server");
	return NULL;
}
예제 #4
0
파일: win32.cpp 프로젝트: J0anJosep/OpenTTD
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	int argc;
	char *argv[64]; // max 64 command line arguments

	CrashLog::InitialiseCrashLog();

#if defined(UNICODE)
	/* Check if a win9x user started the win32 version */
	if (HasBit(GetVersion(), 31)) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
#endif

	/* Convert the command line to UTF-8. We need a dedicated buffer
	 * for this because argv[] points into this buffer and this needs to
	 * be available between subsequent calls to FS2OTTD(). */
	char *cmdline = stredup(FS2OTTD(GetCommandLine()));

#if defined(_DEBUG)
	CreateConsole();
#endif

	_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox

	/* setup random seed to something quite random */
	SetRandomSeed(GetTickCount());

	argc = ParseCommandLine(cmdline, argv, lengthof(argv));

	/* Make sure our arguments contain only valid UTF-8 characters. */
	for (int i = 0; i < argc; i++) ValidateString(argv[i]);

	openttd_main(argc, argv);
	free(cmdline);
	return 0;
}
예제 #5
0
파일: main.cpp 프로젝트: NGenesis/titanmods
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved){
	switch(dwReason){
		case DLL_PROCESS_ATTACH:
		{
			CreateConsole();
			SetConsoleCtrlHandler(TrapCtrlHandler, TRUE);
			
			char strExePath[MAX_PATH];
			GetModuleFileName(NULL, strExePath, MAX_PATH);
			String path = GetDirectoryOfFile(strExePath) + "\\achievements.xml";
			gAchievementList.LoadXML(path);
			Log(MSG_INFO, "%i Achievements loaded.", gAchievementList.mAll.Size());
			
			Log(MSG_INFO, "Running startup functions...");
			RunList::Instance().RunFunctions();

			Log(MSG_INFO, "Applying hooks...");
			HookList::Instance().ApplyHooks();

			Log(MSG_INFO, "Applying code changes...");
			WriteList::Instance().ApplyWrites();

			Log(MSG_INFO, "TitanROSE modifications loaded");
			return TRUE;
		}

		case DLL_PROCESS_DETACH:
			return TRUE;
	};

	return TRUE;
}
예제 #6
0
bool Context::Init(uint width, uint height)
{
	_width = width;
	_height = height;

#ifdef WIN32
	_instance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));

#ifndef FINAL
	if(!CreateConsole())
	{
		LogErrorL("Failed to create console window");
		return false;
	}
#endif

	WNDCLASSEX wc;

	memclr(&wc, sizeof(wc));

    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.lpfnWndProc   = WndProc;
    wc.hInstance     = _instance;
    wc.hIcon         = LoadIcon(nullptr, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(nullptr, IDC_ARROW);
    wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
    wc.lpszMenuName  = nullptr;
    wc.lpszClassName = "EngineClass";
    wc.hIconSm       = wc.hIcon;

    if(!RegisterClassEx(&wc))
    {
        LogErrorL("Failed to register class: %s", wc.lpszClassName);
        return false;
    }

	LPSTR window_title = "Engine";
    _window = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        wc.lpszClassName,
        window_title,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720,
        nullptr, nullptr, _instance, nullptr);

    if(_window == nullptr)
    {
        LogErrorL("Failed to create window: %s", window_title);
        return false;
    }

	LogSuccessL("Created window: %s", window_title);

    ShowWindow(_window, SW_SHOWNORMAL);
    UpdateWindow(_window);
#endif

	return true;
}
예제 #7
0
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
    MainLoop main;
    CreateConsole();
    main.Run();
    CloseWindow();
    return 0;
}
예제 #8
0
/* For the Windows platform, this is the start of the application. */
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
{
    wchar_t **argw = NULL;
    int	argc, i;

    /* Set this to the default value (windowed mode). */
    video_fullscreen = 0;

    /* We need this later. */
    hinstance = hInst;

    /* Set the application version ID string. */
    sprintf(emu_version, "%s v%s", EMU_NAME, EMU_VERSION);

#ifdef USE_CRASHDUMP
    /* Enable crash dump services. */
    InitCrashDump();
#endif

    /* First, set our (default) language. */
    set_language(0x0409);

    /* Create console window. */
    CreateConsole(1);

    /* Process the command line for options. */
    argc = ProcessCommandLine(&argw);

    /* Pre-initialize the system, this loads the config file. */
    if (! pc_init(argc, argw)) {
	/* Detach from console. */
	CreateConsole(0);
	return(1);
    }

    /* Cleanup: we may no longer need the console. */
    if (! force_debug)
	CreateConsole(0);

    /* Handle our GUI. */
    i = ui_init(nCmdShow);

    return(i);
}
예제 #9
0
int main(int argc, char *argv[])
{
#if _DEBUG
	CreateConsole(0);
#endif

	QApplication a(argc, argv);
	DivisionInfo w;
	w.show();
	return a.exec();
}
예제 #10
0
파일: main.cpp 프로젝트: EmanGalal/Phase-1
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR cmdLine, int cmdShow)
{
	CreateConsole();
	//Instance of the engine's core 
	InitSystem(hInstance, "Kai engine", 1280, 720);

	//Start the engine
	Run();
	system("pause");
	return 0;
}
예제 #11
0
파일: SinyMain.cpp 프로젝트: SinYocto/Siny
/**
 * AppInit()
 */
int AppInit(HINSTANCE hInst)
{
	CreateConsole();

	if(!InitD3D(hInst, windowed, screenWidth, screenHeight, multisampleType, multisampleQuality, HWnd, &D3D, &D3DDevice))
		return 0;

	if(!InitInput(hInst, HWnd, &DI, &DID_Keyboard, &DID_Mouse))
		return 0;

	return 1;
}
예제 #12
0
CReClass2015App::CReClass2015App()
{
	m_bHiColorIcons = TRUE;
	m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
	SetAppID("ReClass.2015.0.9.1.0");

	#ifdef _DEBUG
	CreateConsole();
	#endif

	FontWidth = 12;
	FontHeight = 12;
}
예제 #13
0
파일: Debug.cpp 프로젝트: NathanSaidas/Gem
		void Debug::Error(const char * aHeader, const char * aMessage, const char * aFilename)
		{
			CreateConsole();
			TimeStruct time = Time::GetTimeStruct();
			if (aHeader != nullptr)
			{
				printf("[%d:%d:%d][Error][%s]: %s\n", time.hours, time.minutes, time.seconds, aHeader, aMessage);
			}
			else
			{
				printf("[%d:%d:%d][Error]: %s\n", time.hours, time.minutes, time.seconds, aMessage);
			}
		}
예제 #14
0
파일: _video.c 프로젝트: Earlz/ancientstuff
void StartConsole(){
     //CONSOLE *tmp;
     //FirstConsole=malloc(sizeof(CONSOLE));
     LastConsole=malloc(sizeof(CONSOLE));

     FirstConsole=CreateConsole(USER_CONSOLE,0,"JouleCon",2);
     FirstConsole->prev=LastConsole;
     LastConsole->prev=FirstConsole;
     DebugCon=CreateConsole(REALTIME_CONSOLE,0,"JouleOS Debug",1); //realtime so that in an error we could see it
     SysControlCon=CreateConsole(USER_CONSOLE,0,"System Control Console",1);
     //FirstConsole=CreateConsole(USER_CONSOLE,0,"JouleCon",1);
     CurrentConsole=FirstConsole;
     ProcessConsole=FirstConsole;
     cls();
     SwitchConsole(CurrentConsole->next);
     SwitchConsole(CurrentConsole->next);
     SwitchConsole(CurrentConsole->next);

     //SwitchConsole(FirstConsole);
     //free(FirstConsole);
     JouleCon=FirstConsole;
     SwitchConsole(JouleCon);
}
예제 #15
0
BOOL APIENTRY DllMain( HMODULE hDllHandle, DWORD dwReason, LPVOID lpreserved )
{
	if(dwReason == DLL_PROCESS_ATTACH)
	{
		CoInitialize(nullptr);

		TOKEN_PRIVILEGES TPLEGES;	
		TPLEGES.PrivilegeCount=1;
		TPLEGES.Privileges->Luid.LowPart = 0x00000014;
		TPLEGES.Privileges->Luid.HighPart = 0x00000000;
		TPLEGES.Privileges->Attributes = 0x00000002;

		HANDLE htoken;
		OpenProcessToken(hDllHandle, TOKEN_ALL_ACCESS, &htoken);
		AdjustTokenPrivileges(htoken, 0, &TPLEGES, 0, 0, 0);

		INITCOMMONCONTROLSEX InitCtrls;
		InitCtrls.dwSize = sizeof(InitCtrls);
		InitCtrls.dwICC = ICC_WIN95_CLASSES;
		InitCommonControlsEx(&InitCtrls);

		g_hModule = hDllHandle;
		g_hModuleSrv = GetModuleHandleA( nullptr );
		g_uKey = *(ULONG*)0x007831CC;
		g_uIdofMulti = *(ULONG*)0x007831C8;

		DisableThreadLibraryCalls(hDllHandle);
		CreateConsole();

		Log(LOG_INFO, "--- vIrtuaL W0rld 0.6 by ---");
		Log(LOG_INFO, "Build: %s %s\n\n", __DATE__, __TIME__);

		Log(LOG_INFO, ">> Instance: ");
		Log(LOG_INFO, "DLL: %x  SRV: %x\n", g_hModule, g_hModuleSrv);
		
	
		g_prj.Inject();
		g_pLog.Inject();
		g_vGui.Inject();
		g_pWorldMng.Inject();
		g_pEvents.Inject();
		g_pTextCmd.Inject();
		g_pClient.Inject();
		g_pProperties.Inject();
		g_pUserMng.Inject();
		g_pPartyMng.Inject();
	}

	return TRUE;
}
예제 #16
0
int amx_termctl(int cmd,int value)
{
  switch (cmd) {
  case 0:
    return 1;           /* simple "is terminal support available" check */

  case 1: {
    CONSOLE *con;
    if ((con=ActiveConsole())!=NULL) {
      con->autowrap=(BOOL)value;
      return 1;
    } /* if */
    return 0;
  } /* case */

  case 2: {
    HWND hconsole=GetConsoleByIndex(value);
    while (hconsole==NULL) {
      CreateConsole(NULL,HWND_DESKTOP,DEFCOLUMNS,DEFWINLINES,DEFBUFFERLINES,DEFFONTHEIGHT,0);
      hconsole=GetConsoleByIndex(value);
    } /* while */
    return SetActiveConsole(hconsole);
  } /* case */

  case 3: {
    CONSOLE *con;
    if ((con=ActiveConsole())!=NULL) {
      con->boldfont=(BOOL)value;
      SetConsoleFont(con,con->cheight);
      return 1;
    } /* if */
    return 0;
  } /* case */

  case 4: {
    MSG msg;
    while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    } /* while */
    return (GetConsoleByIndex(value)!=NULL);
  } /* case */

  default:
    return 0;
  } /* switch */
}
예제 #17
0
int APIENTRY DllMain(HMODULE hModule, DWORD Reason, LPVOID Reserved)
{
    switch(Reason)
    {
    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hModule);
        CreateConsole();
        InstallHook();
        break;
    case DLL_PROCESS_DETACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
        break;
    }

    return TRUE;
}
예제 #18
0
파일: Log.cpp 프로젝트: FaceHunter/hAPI
bool Log::Init(const char* file, LogLevel logLevel)
{
	fileStream = fopen(file, "wb");

	if (fileStream == NULL)
	{
		return false;
	}

	enabled = true;

	CreateConsole("hAPI - Debug");
	ResizeConsole(80, 32766);

	Log::logLevel = logLevel;

	return true;
}
예제 #19
0
파일: Debug.cpp 프로젝트: NathanSaidas/Gem
		void Debug::LogFormat(const char * aHeader, const char * aFormat, ...)
		{
			CreateConsole();
			char tempbuffer[MAX_DEBUG_STRING_LENGTH];
			va_list args;
			va_start(args, aFormat);
			vsprintf_s(tempbuffer, MAX_DEBUG_STRING_LENGTH, aFormat, args);
			va_end(args);
			TimeStruct time = Time::GetTimeStruct();
			if (aHeader != nullptr)
			{
				printf("[%d:%d:%d][Log][%s]: %s\n", time.hours, time.minutes, time.seconds, aHeader, tempbuffer);
			}
			else
			{
				printf("[%d:%d:%d][Log]: %s\n", time.hours, time.minutes, time.seconds, tempbuffer);
			}
		}
예제 #20
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
#endif
{
	int argc;
	char *argv[64]; // max 64 command line arguments
	char *cmdline;

#if !defined(UNICODE)
	_codepage = GetACP(); // get system codepage as some kind of a default
#endif /* UNICODE */

	CrashLog::InitialiseCrashLog();

#if defined(UNICODE)

#if !defined(WINCE)
	/* Check if a win9x user started the win32 version */
	if (HasBit(GetVersion(), 31)) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
#endif

	/* For UNICODE we need to convert the commandline to char* _AND_
	 * save it because argv[] points into this buffer and thus needs to
	 * be available between subsequent calls to FS2OTTD() */
	char cmdlinebuf[MAX_PATH];
#endif /* UNICODE */

	cmdline = WIDE_TO_MB_BUFFER(GetCommandLine(), cmdlinebuf, lengthof(cmdlinebuf));

#if defined(_DEBUG)
	CreateConsole();
#endif

#if !defined(WINCE)
	_set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox
#endif

	/* setup random seed to something quite random */
	SetRandomSeed(GetTickCount());

	argc = ParseCommandLine(cmdline, argv, lengthof(argv));

	ttd_main(argc, argv);
	return 0;
}
예제 #21
0
파일: main.c 프로젝트: Keenuts/upv
int main()
{
    Console *c = CreateConsole();

    pid_t pid = fork();
    if(!pid)
    {
        c->displayLoop(c);
        return 0;
    }
    
    while(c->run)
    {
        char t = getchar();
        c->registerTyped(c, t);
    }

    FreeConsole(c);
}
예제 #22
0
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow)
{
	MSG msg;
 	MyRegisterClass(hInstance);
	if (!InitInstance (hInstance, SW_HIDE)) 
	{
		return FALSE;
	}
	CreateConsole();
	CDCurrentDirectory();
	SetEenvironment();
	ExecCmdline();
	ShowTrayIcon();
	while (GetMessage(&msg, NULL, 0, 0)) 
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	return 0;
}
예제 #23
0
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR lpCmdLine, int nCmdShow) {
    MSG msg;
    hInst = hInstance;
    SetEenvironment();
    
    MyRegisterClass(hInstance);
    if (!InitInstance (hInstance, SW_HIDE)) {
        return FALSE;
    }
    CreateConsole();
    
    ExecCmdline(L"默认", szPath, szCommand);
    ShowTrayIcon(szBalloon);
    
    while (GetMessage(&msg, NULL, 0, 0)) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
예제 #24
0
static CONSOLE *ActiveConsole(void)
{
  CONSOLE *con;

  for (con=consoleroot.next; con!=NULL && con->hwnd!=activeconsole; con=con->next)
    /* nothing */;
  if (con==NULL) {      /* active console "disappeared", switch to first console */
    /* create a console if there are none left */
    if (consoleroot.next==NULL)
      CreateConsole(NULL,HWND_DESKTOP,DEFCOLUMNS,DEFWINLINES,DEFBUFFERLINES,DEFFONTHEIGHT,0);
    con=consoleroot.next;
    activeconsole= (con!=NULL) ? con->hwnd : NULL;
  } /* if */
  /* if "con" still is NULL here, then the following holds:
   * 1. the "active console" (if there was one) disappeared
   * 2. there are no consoles left at all
   * 3. a new console could not be created
   */
  return con;
}
예제 #25
0
bool SystemClass::SystemInitialization()
{
	CreateConsole();

	cout << ">>Information Window Initialized" << endl;

	if (!WindowInitialization())
	{
		return false;
	}

	cout << ">>Window Initialized" << endl;

	mInput = new InputClass;
	if (!mInput)
	{
		return false;
	}
	
	mInput->Initialize();

	cout << ">>>>Input Controls Active" << endl;

	cout << ">>>>Timer Initalized" << endl;

	mGraphics = new GraphicsClass;
	if (!mGraphics)
	{
		return false;
	}

	if (!mGraphics->Initialize(WINDOW_WIDTH, WINDOW_HEIGHT, mHandle))
	{
		return false;
	}

	cout << ">>Graphics Fully Initialized" << endl;


	return true;
}
예제 #26
0
int WINAPI 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nShowCmd) {
    CreateConsole();
    WNDCLASS wc;
    wc.style            = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc      = WndProc;
    wc.cbClsExtra       = 0;
    wc.cbWndExtra       = 0;
    wc.hInstance        = hInstance;
    wc.hIcon            = LoadIcon(0, IDI_APPLICATION);
    wc.hCursor          = LoadCursor(0, IDC_ARROW);
    wc.hbrBackground    = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName     = 0;
    wc.lpszClassName    = L"SuperMotorn";
    if ( !RegisterClass(&wc) ) {
        MessageBox(0, L"Failed registering class", 0, 0);
        exit(-1);
    }
    window = CreateWindow(
        L"SuperMotorn",
        L"SuperMotorn",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        0,
        0,
        hInstance,
        0);
    if ( window == 0 ) {
        MessageBox(0, L"Failed creating window", 0, 0);
        exit(-1);
    }
    
    ShowWindow(window, nShowCmd);
    UpdateWindow(window);
    return Run();
}
예제 #27
0
파일: taskbar.c 프로젝트: overajog/goproxy
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG msg;
    hInst = hInstance;
    CDCurrentDirectory();
    SetEenvironment();
    ParseProxyList();
    MyRegisterClass(hInstance);
    if (!InitInstance (hInstance, SW_HIDE))
    {
        return FALSE;
    }
    CreateConsole();
    ExecCmdline();
    ShowTrayIcon(GetWindowsProxy(), NIM_ADD);
    TryDeleteUpdateFiles();
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
예제 #28
0
파일: main.cpp 프로젝트: NGenesis/titanmods
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved){
	switch(dwReason){
		case DLL_PROCESS_ATTACH:
		{
#ifdef DEBUG_MODE
			CreateConsole();
#endif
			SetConsoleCtrlHandler( TrapCtrlHandler, TRUE );
			LoadQuestIconScript("3DDATA\\CONTROL\\RES\\DATA1.RP");
			SetCheckSum(NewTitanCheckSum);

			RunList::Instance().RunFunctions();
			HookList::Instance().ApplyHooks();
			WriteList::Instance().ApplyWrites();

			Log(MSG_DEBUG, "TRUE");
			return TRUE;
		}
		case DLL_PROCESS_DETACH:
			return TRUE;
	};

	return TRUE;
}
예제 #29
0
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                                         )
{
        switch (ul_reason_for_call)
        {
        case DLL_PROCESS_ATTACH:
                DisableThreadLibraryCalls(hModule);
                CreateConsole();
                printf("[%s] Loaded.\n", __DLL_PSEUDO__);
                break;
        case DLL_THREAD_ATTACH:
                break;
        case DLL_THREAD_DETACH:
                break;
        case DLL_PROCESS_DETACH:
                printf("[%s] Unloaded.\n", __DLL_PSEUDO__);
                break;
        default:
                break;
        }
        return TRUE;
}
//
// The entrypoint.
//
// We create a console window that prints anything
// sent to stdout and then install our hooks.
// After that, we create an invisible window and
// sit in a message pumping loop until the user
// presses their Escape key.
//
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	if( false == CreateConsole( ) )
		return 1;

	if( false == InstallHooks() )
	{
		FreeConsole( );
		return 1;
	}

	//
	// Create a plain Win32 window we don't even show.
	// A wndproc needs to be running for our hooks not
	// to interfere with normal system operation.
	//

	const wchar_t class_name[] = L"whatever";
	WNDCLASSEX wc;
	MSG msg;

	wc.cbSize        = sizeof( WNDCLASSEX );
	wc.lpszClassName = class_name;
	wc.lpfnWndProc   = WndProc;
	wc.hInstance     = hInstance;
	wc.cbClsExtra    = NULL;
	wc.cbWndExtra    = NULL;
	wc.style         = NULL;
	wc.hIconSm       = NULL;
	wc.hIcon         = NULL;
	wc.hCursor       = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName  = NULL;

	if( NULL == RegisterClassEx( &wc ) )
	{
		wchar_t error[64];
		_snwprintf_s( error, sizeof error, L"Failed to register window class. Error code: %u", GetLastError( ) );
		MessageBox( NULL, error, L"Error", MB_ICONEXCLAMATION | MB_OK );
		return 1;
	}

	hwnd = CreateWindowEx( NULL, class_name, class_name, NULL,
		CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, NULL, NULL, hInstance, NULL);

	if( NULL == hwnd )
	{
		wchar_t error[64];
		_snwprintf_s( error, sizeof error, L"Failed to create window. Error code: %u", GetLastError( ) );
		MessageBox( NULL, error, L"Error", MB_ICONEXCLAMATION | MB_OK );
		return 1;
	}

	while( GetMessage( &msg, NULL, NULL, NULL ) > 0 )
	{
		TranslateMessage( &msg );
		DispatchMessage( &msg );
	}

	return msg.wParam;
}