Image Drawing libraries in C++
#1

Hi there, recently I have been working on a project related to SA:MP that won't be published but still I can say some of the main objectives...

One is actually get an working and efective anti-cheat, which I already made successfully.
The player doesn't even needs to "cheat", since he gets connected on the server, server will instantly know if he has any cheats or not.
Since I never used cheats for GTA SA I actually know only 2 of them and made it fully working against those two kind of hacks :3
Still there's one con, every player that connects to the server must have one file ( with ASI loader ) on their GTA SA Directory, else nothing would work, but if the player connects to the server without it, they will get automatically kicked...

Anyways my main point on creating this thread is that now i've made also an working way to detect all the keyboard keys on the client side and I also wanted to make one client sided "mouse cursor", since I already know how to detect the real mouse coordinates ( Position ), the only problem arising is that I don't actually know how to draw one image, so it would work as mouse...
Since I've been already searching I know that there's one way, by using DirectX SDK, I can make it draw one cursor the problem is that I'm not very familiar with that library and it looks actually hard, so I'm here to ask if anyone knows a good library that could draw '.png' or '.bmp' files...

If you know how to draw images with DirectX SDK I would actually be thankfully if you could give me an example of it

Thanks and conglurations if you have just read all that text

PS: On my "introduction", I've said that I only made my Anti-Cheat effective to two kinds of cheats ( s0... and vog... ), if you want actually to help me to get a better anti-cheat, you can by PM'ing me names of Cheats, so I could get how they work and update my anti-cheat...

Thanks again and Happy Holidays
Reply
#2

You need to hook Direct3D,I don't know exactly if you can hook via .asi(d3d9.dll is the only name that I saw in many projects - ENB,so..,etc),same thing I wanted to do few days ago,but now i have other problems

Here is an example: http://www.gtaforums.com/index.php?showtopic=237878
also, search on ****** about d3d hooking(click,click)
Reply
#3

Well yeah that's my problem with the Direct3D lib, I don't really know if I actually need to inject my code onto the d3d9.dll, does it has special functions or something? I gotta search that better :3

Edit:

While browsing around on GTA Forums I found this:

pawn Code:
typedef void (*Render2dStuffPtr)();

// Pointer to Render2dStuff function
Render2dStuffPtr fpRender2dStuff = (Render2dStuffPtr)0x0053E230;

// This function will be called by SA after hook is installed
void MyDrawFunction()
{
       // first draw SA's 2d stuff
       fpRender2dStuff();

       // draw own stuff here using d3d device or SA functions
}

// This function should typically be called in DllMain
void SetupMyDrawFunctionHook()
{
       DWORD oldProtect;
       DWORD *workAddress = (DWORD *)0x0053EB13; // Pointer to the call to Render2dStuff

       // change protection/permissions to allow modification to instructions
       VirtualProtect(workAddress, 4, PAGE_READWRITE, &oldProtect);

       // modify instruction with a pointer to our draw function
       *workAddress = (DWORD)&MyDrawFunction - (DWORD)(workAddress + 1);

       // restore original protection/permissions to allow code to be executed again
       VirtualProtect(workAddress, 4, oldProtect, NULL);
}
As you can see he hooks there everything without a problem , the thing is that it is made to render 2D objects, not sure how it is supposed to be done..
Reply
#4

its not that hard to do it with DirectX SDK

first, you gotta load the image as a texture using (D3DXCreateTextureFromFile)
then u can render it, by either using sprites or vertex buffer

anyways, here is a class i've written long tim ago, u can use it
Image.cpp
Image.h

usage is simple
Code:
CImage *pImage = new CImage(pDevice, "myimgfile.png");
pImage->SetParams(100.0f, 100.0f, 100.0f, 100.0f, 0xFFFFFFFF);

// On your render frame
pImage->Render();
Reply
#5

Thanks alot, tomorrow or maybe later I'll try it.

Once again thanks, Rep'ed
Reply
#6

Quote:
Originally Posted by SlashPT
View Post
Hi there, recently I have been working on a project related to SA:MP that won't be published but still I can say some of the main objectives...

One is actually get an working and efective anti-cheat, which I already made successfully.
The player doesn't even needs to "cheat", since he gets connected on the server, server will instantly know if he has any cheats or not.
Since I never used cheats for GTA SA I actually know only 2 of them and made it fully working against those two kind of hacks :3
Still there's one con, every player that connects to the server must have one file ( with ASI loader ) on their GTA SA Directory, else nothing would work, but if the player connects to the server without it, they will get automatically kicked...

Anyways my main point on creating this thread is that now i've made also an working way to detect all the keyboard keys on the client side and I also wanted to make one client sided "mouse cursor", since I already know how to detect the real mouse coordinates ( Position ), the only problem arising is that I don't actually know how to draw one image, so it would work as mouse...
Since I've been already searching I know that there's one way, by using DirectX SDK, I can make it draw one cursor the problem is that I'm not very familiar with that library and it looks actually hard, so I'm here to ask if anyone knows a good library that could draw '.png' or '.bmp' files...

If you know how to draw images with DirectX SDK I would actually be thankfully if you could give me an example of it

Thanks and conglurations if you have just read all that text

PS: On my "introduction", I've said that I only made my Anti-Cheat effective to two kinds of cheats ( s0... and vog... ), if you want actually to help me to get a better anti-cheat, you can by PM'ing me names of Cheats, so I could get how they work and update my anti-cheat...

Thanks again and Happy Holidays
Not only cheats, don't forget CLEO things...
Reply
#7

Quote:
Originally Posted by StreetGT
View Post
Not only cheats, don't forget CLEO things...
I already have that In mind and I already know what to do to solve that.

Thanks anyway for the tip...
Reply
#8

but any hacker could easily bypass the protection if you're creating a client sided anti-cheat :/
Reply
#9

Quote:
Originally Posted by Tony_Montana
View Post
but any hacker could easily bypass the protection if you're creating a client sided anti-cheat :/
Lets see if they do ^^ hehe
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)