Credits: DrUnKeN ChEeTaH
\****************************/
add di endscene
add di DIP
and logger.h
cara menggunakannya...pastikan stride yg di pilih lalu tekan
delet...setelah berubah tulisan berwarna hijau lanjutkan ke loger
berikutnya...selamat mencoba....
\****************************/
- Code:
HRESULT
WINAPI hkSetStreamSource(LPDIRECT3DDEVICE9 pDevice,UINT
StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT
Stride)
{
__asm nop
if(StreamNumber == 0){
g_uiStride = Stride;
}
return oSetStreamSource(pDevice, StreamNumber, pStreamData, OffsetInBytes, Stride);
}
void Log(char* fmt, ...)
{
char buf[1024] = {0};
va_list va_alist;
ofstream output;
va_start(va_alist, fmt);
vsnprintf(buf, sizeof(buf), fmt, va_alist);
va_end(va_alist);
output.open("D3D9 Model Logger.txt", ios::app);
if(output.fail()) return;
output << buf << endl;
output.close();
}
void ModelRecLoggerMenu()
{
static int menuIndex = 0;
static int incrementBy = 1;
DrawString(10, 10, 0xFFFFFFFF, "In/Decrement By: %i", incrementBy);
for(int i = 0; i < 5; i++){
if(i == menuIndex){
DrawRectangle(8, 23+(i*15), 140, 18);
}
DrawString(10, 25+(i*15), model[i].isLogging==true?0xFF00FF00:0xFFFF0000, "%s", model[i].type);
if(i != LOGVALUES){
DrawString(100, 25+(i*15), model[i].isLogging==true?0xFF00FF00:0xFFFF0000, "%i", model[i].value);
}
}
if(GetAsyncKeyState(VK_UP)&1) menuIndex--;
if(GetAsyncKeyState(VK_DOWN)&1) menuIndex++;
if(GetAsyncKeyState(VK_LEFT)&1) model[menuIndex].value-=incrementBy;
if(GetAsyncKeyState(VK_RIGHT)&1) model[menuIndex].value+=incrementBy;
if(GetAsyncKeyState(VK_DELETE)&1)model[menuIndex].isLogging = !model[menuIndex].isLogging;
if(GetAsyncKeyState(VK_INSERT)&1)model[menuIndex].value = 0;
if(GetAsyncKeyState(VK_NEXT)&1){
incrementBy *= 10;
if(incrementBy > 1000){
incrementBy = 1;
}
}
if(GetAsyncKeyState(VK_END)&1){
for(int i = 0; i < 4; i++){
model[i].isLogging = false;
}
}
if(model[LOGVALUES].isLogging == true){
model[LOGVALUES].isLogging = false;
g_uiTimer = GetTickCount() + 2000;
Log("Stride: %i | NumVerts: %i | PrimCount: %i | StartIndex: %i",
model[STRIDE].isLogging == true ? model[STRIDE].value : -1,
model[NUMVERTS].isLogging == true ? model[NUMVERTS].value : -1,
model[PRIMCOUNT].isLogging == true ? model[PRIMCOUNT].value : -1,
model[STARTINDEX].isLogging == true ? model[STARTINDEX].value : -1);
}
if(menuIndex > 4) menuIndex = 0;
if(menuIndex < 0) menuIndex = 4;
if(model[menuIndex].value < 0) model[menuIndex].value = 0;
}
add di endscene
- Code:
//======================================= loger
if(g_pTexRed == NULL)
D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&red,
sizeof(red), &g_pTexRed);
if(g_pTexOrange == NULL)
D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&orange,
sizeof(orange), &g_pTexOrange);
if(g_pFont == NULL) D3DXCreateFont(pDevice, 20, 20, FW_BOLD, 10,
20, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, "Verdana", &g_pFont);
if(g_pLine == NULL) D3DXCreateLine(pDevice, &g_pLine);
pDevice->GetViewport(&g_ViewPort);
if(g_pFont != NULL && g_pLine != NULL){
ModelRecLoggerMenu();
if(g_uiTimer > GetTickCount()){
DrawString(g_ViewPort.Width/5,g_ViewPort.Height/5, 0xFF00FF00, "Values Saved");
}
add di DIP
- Code:
HRESULT hRet = oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
bool bIsLogging = false;
for(int i = 0; i < 4; i++){
if(model[i].isLogging == true){
bIsLogging = true;
break;
}
}
if(bIsLogging){
if((model[STRIDE].isLogging == true ?
model[STRIDE].value : g_uiStride) == g_uiStride
&&
(model[NUMVERTS].isLogging == true ?
model[NUMVERTS].value : NumVertices) == NumVertices
&&
(model[PRIMCOUNT].isLogging == true ? model[PRIMCOUNT].value : primCount) == primCount &&
(model[STARTINDEX].isLogging == true ? model[STARTINDEX].value : startIndex) == startIndex)
{
pDevice->SetRenderState( D3DRS_ZENABLE,false );
pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
pDevice->SetTexture( 0, g_pTexOrange );
oDrawIndexedPrimitive(pDevice, PrimType,
BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
pDevice->SetRenderState( D3DRS_ZENABLE, true );
pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
pDevice->SetTexture( 0, g_pTexRed );
}
}
and logger.h
- Code:
using namespace std;
#define HOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)hk##func)
#define STRIDE 0
#define NUMVERTS 1
#define PRIMCOUNT 2
#define STARTINDEX 3
#define LOGVALUES 4
#define ES 0
#define DIP 1
#define SSS 2
void Log(char* fmt, ...);
void ModelRecLoggerMenu();
struct ModelRecLogger_t
{
char* type;
int value;
bool isLogging;
};
ModelRecLogger_t model[5] = {
{"Stride:", 0, false},
{"NumVert:", 0, false},
{"PrimCount:", 0, false},
{"StartIndex:", 0, false},
{"LOG ALL VALUES", 0, false}
};
unsigned int g_uiTimer = NULL;
unsigned int g_uiStride = NULL;
LPD3DXFONT g_pFont = NULL;
LPD3DXLINE g_pLine = NULL;
D3DVIEWPORT9 g_ViewPort;
LPDIRECT3DTEXTURE9 g_pTexRed = NULL;
LPDIRECT3DTEXTURE9 g_pTexOrange = NULL;
const BYTE red[ 58 ] = {
0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00
};
const BYTE orange[ 58 ] = {
0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA5, 0xFF, 0x00
};
void DrawString(int x, int y, DWORD color, const char *fmt, ...)
{
RECT FontPos = { x, y, x + 120, y + 16 };
char buf[1024] = {'\0'};
va_list va_alist;
va_start(va_alist, fmt);
vsprintf(buf, fmt, va_alist);
va_end(va_alist);
g_pFont->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
}
//---DrawRectangle-----------------------------------------------------------------------------------------------------------------
void DrawRectangle(float x, float y, float w, int h)
{
D3DXVECTOR2 vLine1[2];
D3DXVECTOR2 vLine2[2];
D3DXVECTOR2 vLine3[2];
D3DXVECTOR2 vLine4[2];
vLine1[0].x = x;
vLine1[0].y = y;
vLine1[1].x = x;
vLine1[1].y = y+h;
vLine2[0].x = x+w;
vLine2[0].y = y;
vLine2[1].x = x+w;
vLine2[1].y = y+h;
vLine3[0].x = x;
vLine3[0].y = y;
vLine3[1].x = x+w;
vLine3[1].y = y;
vLine4[0].x = x;
vLine4[0].y = y+h;
vLine4[1].x = x+w;
vLine4[1].y = y+h;
g_pLine->SetWidth(2);
g_pLine->SetAntialias(false);
g_pLine->SetGLLines(false);
g_pLine->Begin();
g_pLine->Draw(vLine1, 2, 0xFF0000FF);
g_pLine->Draw(vLine2, 2, 0xFF0000FF);
g_pLine->Draw(vLine3, 2, 0xFF0000FF);
g_pLine->Draw(vLine4, 2, 0xFF0000FF);
g_pLine->End();
}
cara menggunakannya...pastikan stride yg di pilih lalu tekan
delet...setelah berubah tulisan berwarna hijau lanjutkan ke loger
berikutnya...selamat mencoba....