lelejau 0 Light Poster

so which file I need to include? I need to use this type LPD3DXFONT.
when I include only d3dx9.h I get no errors, but I need both d3d.h and d3dx9.h ... but they seem not to like each other lol

and if I include d3d after d3dx9, the compiler still thinks that I didnt include the d3d and keep throwing me errors about undeclared identifiers.

I want to do whats here: http://www.toymaker.info/Games/html/text.html

lelejau 0 Light Poster

Just after I include D3DX9.H I get tons of errors... like these:

Error	12	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1987	1	Aura2
Error	13	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1987	1	Aura2
Error	14	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1987	1	Aura2
Error	15	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1988	1	Aura2
Error	16	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1988	1	Aura2
Error	17	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1988	1	Aura2
Error	18	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1989	1	Aura2
Error	19	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1989	1	Aura2
Error	20	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1989	1	Aura2
Error	21	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk (summer 2004)\include\d3dx9math.inl	1990	1	Aura2
Error	22	error C2039: 'm' : is not a member of 'D3DXMATRIX'	c:\program files\microsoft directx 9.0 sdk …
lelejau 0 Light Poster

would be nice if you mark the thread as solved and rate my post =p

lelejau 0 Light Poster

Just increment the prime counter here:

if (isPrime){
 
            cout << i << endl;
        }

and then just printf() it. (in the end of the function).
Your code didnt work because you deleted all the braces, making the code display a number between 10 and 20 all the time, but only incrementing the prime conter when the number is prime indeed, thats why you have a 3 number after the 20.

lelejau 0 Light Poster

I have this code to take a screenshot of my app window:

BOOL TakeScreenshot()
{
	struct tagPOINT Point;
	struct _SYSTEMTIME SystemTime;
	HWND handle = (HWND)WINDOW_HANDLE;
	if(handle)
	{
		CreateDirectoryA("Capture",0);
		RECT r;
		GetClientRect(handle,&r);

		Point.x = r.left;
		Point.y = r.top;
		
		ClientToScreen(handle,&Point);
		OffsetRect(&r,Point.x,Point.y);

		HDC cr = CreateDCA("DISPLAY",0,0,0);
		HDC cr1 = CreateCompatibleDC(cr);
		HBITMAP ho = CreateCompatibleBitmap(cr,r.right - r.left,r.bottom - r.top);
		HGDIOBJ s = SelectObject(cr1,ho);
		GetLocalTime(&SystemTime);
		

		BitBlt(cr1,0,0,r.right,r.bottom,cr,r.left,r.top,0xCC0020);
		SelectObject(cr1,s);
		DeleteDC(cr1);
		DeleteDC(cr);

		BITMAP bmpScreen;
		GetObject(ho,sizeof(BITMAP),&bmpScreen);
		
		BITMAPFILEHEADER   bmfHeader; 
		BITMAPINFOHEADER bi;

		bi.biSize			= sizeof(BITMAPINFOHEADER);    
		bi.biWidth			= bmpScreen.bmWidth;    
		bi.biHeight			= bmpScreen.bmHeight;  
		bi.biPlanes			= 1;    
		bi.biBitCount		= 32;    
		bi.biCompression	= BI_RGB;    
		bi.biSizeImage		= 0;  
		bi.biXPelsPerMeter	= 0;    
		bi.biYPelsPerMeter	= 0;    
		bi.biClrUsed		= 0;    
		bi.biClrImportant	= 0;

		DWORD dwBmpSize = ((bmpScreen.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmpScreen.bmHeight;
		HANDLE hDIB = GlobalAlloc(GHND,dwBmpSize); 
		char *lpbitmap = (char *)GlobalLock(hDIB);

		GetDIBits(GetDC(handle),ho,0,(UINT)bmpScreen.bmHeight,lpbitmap,(BITMAPINFO*)&bi,DIB_RGB_COLORS);
		HANDLE hFile = CreateFileA("Capture\\image.bmp",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);   
		DWORD dwSizeofDIB = dwBmpSize + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
		bmfHeader.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER); 
		bmfHeader.bfSize = dwSizeofDIB; 
		bmfHeader.bfType = 0x4D42; //BM
		DWORD dwBytesWritten = 0;
		WriteFile(hFile, (LPSTR)&bmfHeader, sizeof(BITMAPFILEHEADER), &dwBytesWritten, NULL);
		WriteFile(hFile, (LPSTR)&bi, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
		WriteFile(hFile, (LPSTR)lpbitmap, dwBmpSize, &dwBytesWritten, NULL);
		GlobalUnlock(hDIB);    
		GlobalFree(hDIB);
		CloseHandle(hFile);
	}
	return TRUE;
}

But I'd like to write in the top of the image some informations, like, the time the screenshot was taken, etc.. how can I do that?
I already have the struct defined, but dont know what to do with it...

lelejau 0 Light Poster

Narue, forgive me, I dont know how to quote posts lol

well, because fopen has more then one argument to open a file, maybe it is more advanced then ifstream? I never used ifstream, so if you can tell me the differences it would be nice. wouldnt ifstream be some C method when fopen is c++?

lelejau 0 Light Poster

which DX SDK should I download then? because I already have downloaded the latest it this declaration was missing.
I am reinstalling the latest DX SDK and now downloading this update:

http://www.microsoft.com/download/en/confirmation.aspx?id=21416

there is no such d3d.h file here in my "C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\" directory.

I guess its working now. thank you

lelejau 0 Light Poster

fopen is simpler?

lelejau 0 Light Poster

why dont you use fopen instead?

lelejau 0 Light Poster

No, because now it says something like: can not include d3d.h, missing file...

and I already tried to include the DX SDK includes folder into the aditional include folder into my project settings but that didnt solve it.

lelejau 0 Light Poster

I have already downloaded the latest DX SDK (June 2010) and still, this error remains.


error C2065: 'IID_IDirect3D3' : undeclared identifier

I already included the headers below but it seems not to work, what am I missing?

#include <d3d9.h>
#include <ddraw.h>

lelejau 0 Light Poster

Hello.
I have some function named:

Function Decrypt(pBuffer :TBytes) : TBytes ;

and I hooked winsock recv method, and I have this function:

function R_CallBack(a1:Integer; var buffer;a2,a3:Integer):cardinal;stdcall;
var DecryptedBuffer:TBytes;
begin
DecryptedBuffer:=Decrypt(buffer);
Result:=1;
end;

but I'm getting an error..

Incompatible types: 'procedure, untyped pointer or untyped parameter' and 'TBytes'
What should I do? :S

lelejau 0 Light Poster

Hello, I have this code:

void GetProcId(char* ProcName)
	{
		PROCESSENTRY32   pe32;
		HANDLE         hSnapshot = NULL;

		pe32.dwSize = sizeof( PROCESSENTRY32 );
		hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

		if( Process32First( hSnapshot, &pe32 ) )
		{
			do{
				if( _stricmp( pe32.szExeFile, ProcName ) == 0 )
					break;
			}while( Process32Next( hSnapshot, &pe32 ) );
		}

		if( hSnapshot != INVALID_HANDLE_VALUE )
			CloseHandle( hSnapshot );

		ProcId = pe32.th32ProcessID;
	}

But I keep getting:

argument of type "WCHAR *" is incompatible with parameter of type "const char *
'_stricmp' : cannot convert parameter 1 from 'WCHAR [260]' to 'const char *'

I dont know what to do anymore, I'm researching this kind of code for over 2h!

lelejau 0 Light Poster

Solved.
RegisterClassA(&wc);

:P Thanks;

lelejau 0 Light Poster
WNDCLASSEX wc;
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style=0;
	wc.cbClsExtra = 0;
	wc.lpfnWndProc = (WNDPROC)0x414820;
	wc.cbWndExtra = 0;
	wc.hInstance=hInst;
	HICON icon = LoadIconA(hInst,(LPCSTR)111);
	wc.hIcon = icon;
	wc.hIconSm = icon;
	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = TEXT("Window");
	RegisterClassEx(&wc);

I'm using VS 2010, but it works fine with C++ 6.0 or DevC++. But I dont want to use them.

lelejau 0 Light Poster

LPCSTR Name = "Window";

Just this.

lelejau 0 Light Poster

I have this code:

HWND handle = CreateWindowExA(0,name,name,
		WS_POPUP+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_SYSMENU+WS_CAPTION,
		0x13D,0x86, // x y
		0x320,0x258, // width height
		0,0,hInst,0);

But my window's name only contains one letter oO My final window name is "W"...

what am I doing wrong?

lelejau 0 Light Poster

Hello. How can I protect my application against Memory Editors?

Like, Cheat Engine, Debuggers, etc.

lelejau 0 Light Poster

Hello. How can I protect my application against Memory Editors?

Like, Cheat Engine, Debuggers, etc.

lelejau 0 Light Poster

Hi. In C++ ie we can do this:


code.cpp

#include vars.h


main()
{
if var1 == 1 { printf("ok"); }
return true; }

The point is not the code itself, but that #include.

I'd like to have a *.cs file containing some numeric variables.
But not a Class, just a normal text file containing variables like const int var1 = 1;

How can I do that?

lelejau 0 Light Poster

*bump*.

I dont know how to translate it to delphi. Any1 can help me?

lelejau 0 Light Poster

I understand it, but I want to translate this code to Delphi. I know more delphi than C++, I could do more things with this code in delphi.

lelejau 0 Light Poster

I do know what it does, just dont know how it works.

This functions prints a message inside the chat of a game.

lelejau 0 Light Poster

Hello, I have this C++ code, I dunno how it works..

Anyway, I'd like to have it translated to Delphi.

If anyone can help me out, I'd be glad.

typedef void (*t_ChatPrint)		( char * );
t_ChatPrint	ChatPrint		= (t_ChatPrint)0x0054E410;
void ChatPrintf( const char *format, ... )
{
	va_list	ap;
	char	szBuffer[512] = "";

	va_start( ap, format );
	_vsnprintf_s( szBuffer, 512, 511, format, ap );
	va_end( ap );

	ChatPrint( szBuffer );
}

We use it like this:

ChatPrintf("Hello my %s.","friend");

Thanks in advance.

lelejau 0 Light Poster

Hello, I have this code:

.data
xd db "jjjj",0
      .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

LibMain proc instance:DWORD,reason:DWORD,unused:DWORD 

    .if reason == DLL_PROCESS_ATTACH

push dword ptr ds:[ xd]
call Teste
      mov eax, TRUE                 ; return TRUE so DLL will start

    .elseif reason == DLL_PROCESS_DETACH

    .elseif reason == DLL_THREAD_ATTACH

    .elseif reason == DLL_THREAD_DETACH

    .endif

    ret

LibMain endp

Teste proc T
        invoke MessageBox, NULL, addr T, addr T, MB_OK
        ret 

Teste endp

But, the messagebox, after the "jjj" text, there is some weird characters.
How to fix it?

lelejau 0 Light Poster

I changed the control to pulic in form1 design, and I did what I wanted to. I just cant see why doing this is not recomended.

lelejau 0 Light Poster

I already did it.. Thanks.

lelejau 0 Light Poster

I already tried that, and it didn't worked :B
But, I'll mark this Thread as Solved. Thanks for your help, and if you can show me how to do it from myClass I would be bery happy. =]

lelejau 0 Light Poster

Even if it isn't recomended, could you show me how to do it? Just for knoledge.
And, why its not recomended?

lelejau 0 Light Poster

I could see the sub that updates the textbox is inside the form1.
Is it possible to transfer it to myClass?

lelejau 0 Light Poster

This is just an example that I can modify later to do my stuff. There are several checks in myClass and listBox needs to be updated (from myClass).

lelejau 0 Light Poster

No, that is not what I meant. My class should update the listbox, not multiply two values..

lelejau 0 Light Poster

I think this cant help me, because there is no other form. I am using a Tab Control.
And I want to create a class to update a listbox, but using invoke because I'm running in a diffrent Thread.

There is a Form1.cs which have all the form codes.
Then, I created another *.cs file. MyClass.cs that have the Update() procedure with a string argument.
The Update have to update Form1 listBox with the argument passed.

If it isn't too much work for you to do, I'd be glad if you can help me to do, exactly, this.
Thanks.

lelejau 0 Light Poster

There isnt a Form2.
There is a button that, OnClick will start the thred.
That button will create a new instance of my Class (separated from the MainForm class) and execute some procedure.
e.g

public void ThreadSub()
{
	MyClass cl = new MyClass();
	cl.Start("Thread started!");
}
public void OnClickButton()
{
	Thread s = new Thread(new ThreadStart(ThreadSub));
	s.Start();
}

Lets assume I have a listBox in the Main form(there is only ONE form!) named lBox.
Then, the code from the Start() procedure, should insert the Thread Started! text into it.
Using Invoke, because I'm this will be executed inside a diffrent thread. More clear now?

lelejau 0 Light Poster

I have use Threads. I'll use it in a exe i'm making, and the exe will be multi threading...

lelejau 0 Light Poster

I have this function in the main form:

public void Check()
{
	UpBox myClass = new UpBox();
	myClass.UpdateBox(listBox1,"Hello");
}
public void Initial()
{
	Thread thread = new Thread(new ThreadStart(Check));
	thread.Start();
}
class UpBox
{
	private delegate void Box(ListBox list, string text);
	public void Box2(ListBox list,string text)
	{
		list.Items.Add(text);
	}
	public void UpdateBox(ListBox list, string text)
	{
		this.Invoke(new Box(Box2),list,text);
	}
}

Now, as I'm inside a thread, I'd have to use Invoke method to insert items in a ListBox.Invoke doesnt work.
Anyone can give me a hand here?
This Class is in a separated *.cs file.

Thx.

lelejau 0 Light Poster

I got these erros:

invalid conversion from `unsigned int (*)(HWND__*, const CHAR*, const CHAR*, UINT)' to `void*'

invalid conversion from `unsigned int (**)(HWND__*, const CHAR*, const CHAR*, UINT)' to `void**'
both in line 27.

Actually, i'm trying to hook MessageBox. Here is my code:

#include "windows.h"

typedef bool __stdcall (*ApiHookFPtr)(char* ModName, char* ApiName, void* FuncAddr, void* HookedApi, void** MainApi, int codigo);
typedef bool __stdcall (*ApiUnHookFPtr)(char* ModName, char* ApiName, void* FuncAddr, void* HookedApi, void** MainApi, int codigo);

unsigned int __stdcall (*MessageBox_Next)(HWND handle, LPCSTR a,LPCSTR b,UINT x);


unsigned int __stdcall MessageBox_CallBack(HWND handle, LPCSTR a,LPCSTR b,UINT x) 
{
    if(MessageBox_Next)
    {
    return MessageBox_Next(handle, a,b, x);
    }else{
    return 0;
    }

}

int main() {
  HMODULE dll_hdl = LoadLibrary("Project2.dll");
  
  ApiHookFPtr ApiHook = reinterpret_cast<ApiHookFPtr>(GetProcAddress(dll_hdl,"ApiHook"));
  ApiUnHookFPtr ApiUnHook = reinterpret_cast<ApiUnHookFPtr>(GetProcAddress(dll_hdl,"ApiUnHook"));

  //use the functions.
  ApiHook("user32.dll","MessageBoxA",NULL,&MessageBox_CallBack,&MessageBox_Next,585);
  
  MessageBoxA( 0,"jj","jjj",MB_OK);
  
  system("pause");
  return 1;
  FreeLibrary(dll_hdl);
}

Well, I fixed it like this:

ApiHook("user32.dll","MessageBoxA",NULL,(void*)&MessageBox_CallBack,(void**)&MessageBox_Next,585);

The callback function:

unsigned int __stdcall MessageBox_CallBack(HWND handle, LPCSTR a,LPCSTR b,UINT x) 
{
    if(MessageBox_Next)
    {
        return 0;
    }else{
    return 0;
    }

}

After hooking, I call MessageBox. It shouldnt appear, but the messagebox still works. What am I doing wrong?

lelejau 0 Light Poster

The second code you gave me works. Now, how should I use it?

Like in this link that I posted:

http://pastebin.com/PLKcKKhn

lelejau 0 Light Poster

Here is the DLL code compiled.

http://pastebin.com/7WdcETBv

To use it, in Delphi we do:

http://pastebin.com/PLKcKKhn


Idk a lot of C++, so what do I have to do to call this functions?

lelejau 0 Light Poster

Well, thats an idea. thanks for the answer, I'll try and post the results later.

lelejau 0 Light Poster

No, I'm not a hacker lol. Its just for a game. I have it done in Delphi, using that MagicApiHook component. But I'd like to upgrade to C++, but I cant find any kind of component like MagicApiHook to C++.

I have a few codes here, but none of then works as they should.

lelejau 0 Light Poster

how can I hook the LoadLibraryA API? I am googling a lot but I can't find any piece of code that helps me doing what I want to.

I just want to intercept it and display in a message box what is the name of the DLL that the program is trying to load.

is there a way I can do that?

Thanks.

Example: I would do it in a DLL. Then, inject this dll in my test app and then use an injector to inject a dll. The DLL must intercept that and display the dll name.