在调试模式下,我得到了这个:
Severity Code Description Project File Line
Error C2660 'DrawTextA': function does not take 4 arguments Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 41
Severity Code Description Project File Line
Error C2065 'i': undeclared identifier Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 53
Severity Code Description Project File Line
Error IntelliSense: argument of type "const char *" is incompatible with parameter of type "HDC" Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 41
Severity Code Description Project File Line
Error IntelliSense: argument of type "int" is incompatible with parameter of type "LPCSTR" Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 41
Severity Code Description Project File Line
Error IntelliSense: argument of type "D3DCOLOR" is incompatible with parameter of type "LPRECT" Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 41
Severity Code Description Project File Line
Error IntelliSense: too few arguments in function call Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 41
Severity Code Description Project File Line
Error C2065 'i': undeclared identifier Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 53
Severity Code Description Project File Line
Error C2228 left of '.name' must have class/struct/union Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 53
Severity Code Description Project File Line
Error C2228 left of '.c_str' must have class/struct/union Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 53
Severity Code Description Project File Line
Error C2660 'DrawTextA': function does not take 4 arguments Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 53
Severity Code Description Project File Line
Error IntelliSense: identifier "i" is undefined Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 53
Severity Code Description Project File Line
Error IntelliSense: argument of type "int" is incompatible with parameter of type "LPCSTR" Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 53
Severity Code Description Project File Line
Error IntelliSense: argument of type "D3DCOLOR" is incompatible with parameter of type "LPRECT" Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 53
Severity Code Description Project File Line
Error IntelliSense: too few arguments in function call Win32Project6 c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp 53
Hacks.cpp的CODe
#include "Hacks.h"
int MenuIndex;
D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);
D3DCOLOR fontGreen = D3DCOLOR_ARGB(255, 0, 255, 0);
D3DCOLOR fontBlue = D3DCOLOR_ARGB(255, 0, 0, 255);
D3DCOLOR fontWhite = D3DCOLOR_ARGB(255, 255, 255, 255);
D3DCOLOR fontBlack = D3DCOLOR_ARGB(255, 0, 0, 0);
void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont)
{
D3DXCreateFont(d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
choiceFont.c_str(), &Font);
}
void Hacks::InitializeMenuItems()
{
hack[WALLHACK].name = "WallHack and chams";
hack[CUSTOM_CROSSHAIR].name = "Show custom crosshair";
hack[NO_RECOIL].name = "No Recoil";
hack[UNLIM_AMMO].name = "Unlimited equipment";
hack[AUTO_FIRE].name = "Auto Fire";
hack[HIDE_MENU].name = "Hide menu [INSERT]";
hack[HIDE_MENU].on = false;
}
void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color)
{
RECT rct = { x - 120, y + 120, y + 15 };
Font->DrawTextA(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Color);
}
void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice)
{
if (!hack[HIDE_MENU].on)
{
DrawFilledRectangle(55, 20, 200, 50, fontBlue, d3dDevice);
DrawBorderBox(55, 20, 200, 50, 4, fontBlack, d3dDevice);
DrawTextA("GAME", 190, 30, fontWhite);
DrawFilledRectangle(30, 55, 250, (62 * MAX_MENU_ITEMS), fontBlue, d3dDevice);
DrawBorderBox(30, 55, 250, (62 * MAX_MENU_ITEMS), 6, fontBlack, d3dDevice);
int y = 40;
for (int i = 0; i < MAX_MENU_ITEMS; i++)
{
DrawFilledRectangle(45, 30 + y, 220, 40, hack[i].on ? fontGreen : fontRed, d3dDevice);
DrawBorderBox(45, 30 + y, 220, 40, 4, fontBlack, d3dDevice);
}
DrawTextA(hack[i].name.c_str(), 170, 39 + y, fontBlack);
y + 50;
}
}
void Hacks::DrawFilledRectangle(int x, int y, int width, int height, D3DCOLOR color, IDirect3DDevice9 *d3dDevice)
{
}
void Hacks::DrawBorderBox(int x, int y, int width, int height, int thickness, D3DCOLOR color, IDirect3DDevice9 *d3dDevice)
{
}
void Hacks::KeyboardInput()
{
}
CODE for Hacks.h
#include "d3d9.h"
#include <ctime>
#include <iostream>
#define D3DHOOK_TEXTURES
#define MAX_MENU_ITEMS 6
#define WALLHACK 0
#define CUSTOM_CROSSHAIR 1
#define NO_RECOIL 2
#define UNLIM_AMMO 3
#define AUTO_FIRE 4
#define HIDE_MENU 5
/*DEFINITION FOR OUT CHAMS*/
class Hacks
{
public:
int m_Stride;
void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont);
void Hacks::InitializeMenuItems();
void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color);
void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice);
void Hacks::DrawFilledRectangle(int x, int y, int width, int height,D3DCOLOR color, IDirect3DDevice9 *d3dDevice);
void Hacks::DrawBorderBox(int x, int y, int width, int height, int thickness, D3DCOLOR color, IDirect3DDevice9 *d3dDevice);
void Hacks::KeyboardInput();
LPDIRECT3DTEXTURE9 texRed;
LPDIRECT3DTEXTURE9 textGreen;
LPDIRECT3DTEXTURE9 textBlue;
LPDIRECT3DTEXTURE9 textWhite;
D3DVIEWPORT9 ViewPort;
LPD3DXFONT Font;
struct d3dMenuHack
{
bool on;
std::string name;
};
d3dMenuHack hack[MAX_MENU_ITEMS];
};
是的,我将它设置为多字节字符集,当我从教程的创建者复制代码时,它工作得很好,但问题是它们完全相同的代码100%相同但只有一个工作和其他没有,设置设置为win 32,调试和发布都会产生错误。
这是教程代码:
#include "hacks.h";
/*--------------CHEAT RELATED VARS-------------------*/
int MenuIndex = 0;
// Create a colour for the text
D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);
D3DCOLOR fontGreen = D3DCOLOR_ARGB(255, 0, 255, 0);
D3DCOLOR fontBlue = D3DCOLOR_ARGB(255, 0, 42, 255);
D3DCOLOR fontWhite = D3DCOLOR_ARGB(255, 255, 255, 255);
D3DCOLOR fontBlack = D3DCOLOR_ARGB(255, 0, 0, 0);
/*---------------------------------------------------*/
void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont)
{
D3DXCreateFont( d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
choiceFont.c_str(), &m_font );
}
void Hacks::InitializeMenuItems()
{
hack[WALLHACK].name = " WallHack and chams";
hack[CUSTOM_CROSSHAIR].name = " Show custom crosshair";
hack[NO_RECOIL].name = " No Recoil";
hack[UNLIM_AMMO].name = " Unlimited equipment";
hack[AUTO_FIRE].name = "All guns Automatic";
hack[HIDE_MENU].name = " Hide hack [INSERT]";
//make the hack visible by default
hack[HIDE_MENU].on = false; //shows hack by default
}
void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice)
{
if(!hack[HIDE_MENU].on)
{
//Add game name here, and put border around it
DrawFilledRect( 55, 20, 200, 50, fontBlue, d3dDevice );
DrawBorderBox(55, 20, 200, 50, 4, fontBlack, d3dDevice );
Draw_Text("COD 4 MP hack", 190, 30, fontWhite);
//draw back of our hack, transparent black
DrawFilledRect( 30, 55, 250, (62*MAX_MENU_ITEMS),fontBlue, d3dDevice );
//draw hack border
DrawBorderBox(30, 55, 250, (62*MAX_MENU_ITEMS), 6/*was 6*/, fontBlack, d3dDevice );
//Reset our time and update the text again in 2 secs
int y = 40;
for(int i = 0; i < MAX_MENU_ITEMS; i ++)
{
//Draw each box's back colour, this will be based on whether the hack is on e.g.
//red means off and green means on
DrawFilledRect( 45, 30+y, 220, 40, hack[i].on ? fontGreen : fontRed, d3dDevice );
//draw box Around Each hack item If the item is highlighted it will show with a white border
DrawBorderBox(45, 30+y, 220, 40, 4, fontBlack, d3dDevice );
//draw White border to show the user which hack item is currently selected
if(MenuIndex == i)
{
DrawBorderBox(41, 26+y, 228, 48, 4, fontWhite, d3dDevice );
}
//Ternary at its finest, if the hack is on we display the text colour in green
//otherwise its green
//Draw_Text(hack[i].KeyAssigned.c_str(), 160 , 32+y, fontWhite);
Draw_Text(hack[i].name.c_str(), 170 , 39+y, fontBlack);
//Draw_Text(hack[i].state. c_str(), 355 , 32+y, hack[i].on ? fontGreen : fontRed);
//used to position the next item below by 30 height units
y+= 50;
}
Draw_Text("Select using arrow keys", 170, ((62*MAX_MENU_ITEMS)+7), fontWhite);
Draw_Text("Turn ON/OFF [END] key", 170, ((62*MAX_MENU_ITEMS)+27), fontWhite);
}
}
void Hacks::DrawBorderBox( int x, int y, int w, int h, int thickness, D3DCOLOR Colour, IDirect3DDevice9 *pDevice)
{
//Top horiz line
DrawFilledRect( x, y, w, thickness, Colour, pDevice );
//Left vertical line
DrawFilledRect( x, y, thickness, h, Colour, pDevice );
//right vertical line
DrawFilledRect( (x + w), y, thickness, h, Colour, pDevice );
//bottom horiz line
DrawFilledRect( x, y + h, w+thickness, thickness, Colour, pDevice );
}
//We receive the 2-D Coordinates the colour and the device we want to use to draw those colours with
void Hacks::DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
{
//We create our rectangle to draw on screen
D3DRECT BarRect = { x, y, x + w, y + h };
//We clear that portion of the screen and display our rectangle
dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}
void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Colour)
{
// Create a rectangle to indicate where on the screen it should be drawn
RECT rct = {x- 120, y, x+ 120, y + 15};
// Draw some text
m_font->DrawText(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Colour );
}
void Hacks::KeyboardInput()
{
if(GetAsyncKeyState(VK_UP)&1)
{
if(MenuIndex > 0)
{
MenuIndex--;
}
}
if(GetAsyncKeyState(VK_DOWN)&1)
{
if(MenuIndex < MAX_MENU_ITEMS-1)
{
MenuIndex++;
}
}
if(GetAsyncKeyState(VK_END)&1)
{
hack[MenuIndex].on = !hack[MenuIndex].on;
if(MenuIndex == NO_RECOIL)
{
//this is where we write memory, these are nop values
}
if(MenuIndex == UNLIM_AMMO)
{
//this is where we write memory
}
}
if(GetAsyncKeyState(VK_INSERT)&1)
{
//TEXT DOESNT CHANGE as the hack is either hidden or not
//and if its hidden you cant tell the user to turn hack on(at least we wont)
hack[HIDE_MENU].on = !hack[HIDE_MENU].on;
}
}
这很奇怪,在视频中他使用了DrawTextA,youtube;逃跑黑客。
但是如果我使用Draw_Text它也会出错
答案 0 :(得分:0)
DrawTextA接受5个参数,而您只传入4个。
INT DrawText(
[in] LPD3DXSPRITE pSprite,
[in] LPCTSTR pString,
[in] INT Count,
[in] LPRECT pRect,
[in] DWORD Format,
[in] D3DCOLOR Color
);
pSprite变量可以为NULL,如果您查看要粘贴的源代码,他会将NULL作为每个函数调用中的第一个参数。只需在其他4个参数前放置一个NULL,它将进行编译。