AllocConsole

Posts 1–7 of 7 · Page 1 of 1
AllocConsole
Im trying to make a console to print text out, and the console dont show up.
here is the code im using
Code:
AllocConsole();
printf("initialized\n");
Im injecting said game with a dll.
Youre using Windows 7 x86?
Some windows update blocked AllocConsole in some cases. No idea why.
Quote Originally Posted by Nico View Post
Some windows update blocked AllocConsole in some cases. No idea why.
Windows does not block `AllocConsole()`.
Try this:
Code:
FreeConsole();

if (AllocConsole()) {
  freopen("CONIN$", "rb", stdin);
  freopen("CONOUT$", "wb", stdout);
  freopen("CONOUT$", "wb", stderr);

  // If you are using cout/cin/cerr uncomment the following
  //std::ios::sync_with_stdio();
}
Not working, here is my code
Code:
#include <windows.h>
#include "D3D.h"

#define DIP 0x12345678

void thread()
{
     init();
}

BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved )
{
	if( dwReason == DLL_PROCESS_ATTACH )
	{
		CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)thread, NULL, NULL, NULL);
	}
	return TRUE;
}
D3D.h
Code:
/* TO DO
1. ADD HOOK
2. ADD DIP
3. ADD ENDSCENE
*/

#include <windows.h>
#include <d3d9.h>
#include <iostream>
#pragma comment(lib, "d3d9.lib")

using namespace std;

D3DCOLOR RED = D3DCOLOR_ARGB(255, 255, 0, 0);
D3DCOLOR GREEN = D3DCOLOR_ARGB(255, 0, 255, 0);
D3DCOLOR BLUE = D3DCOLOR_ARGB(255, 0, 0, 255);

void init()
{
     FreeConsole();
     if (AllocConsole())
     {
     freopen("CONIN$", "rb", stdin);
     freopen("CONOUT$", "wb", stdout);
     freopen("CONOUT$", "wb", stderr);
     }
   printf("initialized\n");
}

void chams(float A, float R, float G, float B, IDirect3DDevice9 *pDevice)
{
    D3DMATERIAL9 pMaterial;
    ZeroMemory(&pMaterial, sizeof(D3DMATERIAL9));
	pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
	pMaterial.Ambient.a     =  (A/255);
    pMaterial.Ambient.r     =  (R/255);
    pMaterial.Ambient.g     =  (G/255);
    pMaterial.Ambient.b     =  (B/255);
	//Diffuse
	pMaterial.Diffuse.a     = (A/255);
    pMaterial.Diffuse.r     = (R/255);
    pMaterial.Diffuse.g     = (G/255);
    pMaterial.Diffuse.b     = (B/255);
	//Specular
	pMaterial.Specular.a = (A/255);
	pMaterial.Specular.r = (R/255);
    pMaterial.Specular.g = (G/255);
    pMaterial.Specular.b = (B/255);
    pDevice->SetMaterial(&pMaterial);
}

void hook()
{
}
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?