From c2a2445897af17adb56a32dcf111312763a575d4 Mon Sep 17 00:00:00 2001
From: Toni Uhlig <matzeton@googlemail.com>
Date: Mon, 2 Jul 2018 01:06:39 +0200
Subject: initial commit

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
---
 csgo_wh/.gitignore               |   2 +
 csgo_wh/Makefile                 |  26 +++++++
 csgo_wh/csgo_dll.cbp             |  79 +++++++++++++++++++++
 csgo_wh/csgo_dll.depend          | 144 +++++++++++++++++++++++++++++++++++++++
 csgo_wh/csgo_dll.layout          |  69 +++++++++++++++++++
 csgo_wh/include/D9DW.h           |  45 ++++++++++++
 csgo_wh/include/D9DW_Config.h    |  14 ++++
 csgo_wh/include/D9DW_Rectangle.h |  35 ++++++++++
 csgo_wh/include/D9DW_Text.h      |  36 ++++++++++
 csgo_wh/include/DLLMain.h        |  36 ++++++++++
 csgo_wh/include/Game.h           |  83 ++++++++++++++++++++++
 csgo_wh/include/Hook.h           |  20 ++++++
 csgo_wh/src/D9DW.cpp             | 119 ++++++++++++++++++++++++++++++++
 csgo_wh/src/D9DW_Rectangle.cpp   |  36 ++++++++++
 csgo_wh/src/D9DW_Text.cpp        |  44 ++++++++++++
 csgo_wh/src/DLLMain.cpp          |  78 +++++++++++++++++++++
 csgo_wh/src/Game.cpp             | 100 +++++++++++++++++++++++++++
 csgo_wh/src/Hook.cpp             |  72 ++++++++++++++++++++
 18 files changed, 1038 insertions(+)
 create mode 100755 csgo_wh/.gitignore
 create mode 100644 csgo_wh/Makefile
 create mode 100755 csgo_wh/csgo_dll.cbp
 create mode 100755 csgo_wh/csgo_dll.depend
 create mode 100755 csgo_wh/csgo_dll.layout
 create mode 100755 csgo_wh/include/D9DW.h
 create mode 100755 csgo_wh/include/D9DW_Config.h
 create mode 100755 csgo_wh/include/D9DW_Rectangle.h
 create mode 100755 csgo_wh/include/D9DW_Text.h
 create mode 100755 csgo_wh/include/DLLMain.h
 create mode 100755 csgo_wh/include/Game.h
 create mode 100755 csgo_wh/include/Hook.h
 create mode 100755 csgo_wh/src/D9DW.cpp
 create mode 100755 csgo_wh/src/D9DW_Rectangle.cpp
 create mode 100755 csgo_wh/src/D9DW_Text.cpp
 create mode 100755 csgo_wh/src/DLLMain.cpp
 create mode 100755 csgo_wh/src/Game.cpp
 create mode 100755 csgo_wh/src/Hook.cpp

(limited to 'csgo_wh')

diff --git a/csgo_wh/.gitignore b/csgo_wh/.gitignore
new file mode 100755
index 0000000..4c7473d
--- /dev/null
+++ b/csgo_wh/.gitignore
@@ -0,0 +1,2 @@
+/bin
+/obj
diff --git a/csgo_wh/Makefile b/csgo_wh/Makefile
new file mode 100644
index 0000000..4713e60
--- /dev/null
+++ b/csgo_wh/Makefile
@@ -0,0 +1,26 @@
+CC = i686-w64-mingw32-gcc
+CXX = i686-w64-mingw32-g++
+CFLAGS := -Iinclude -Os -s -Wall -fvisibility=hidden -ffunction-sections -fdata-sections -ffast-math -fomit-frame-pointer -fexpensive-optimizations -Wl,--gc-sections -m32 -static -static-libgcc -static-libstdc++
+LDFLAGS :=
+
+TARGETS := csgo_wh
+
+CSGOWH_SRC := D9DW.cpp D9DW_Rectangle.cpp D9DW_Text.cpp DLLMain.cpp Game.cpp Hook.cpp
+
+
+all: $(TARGETS)
+
+%.o: %.cpp
+	@echo 'Building file: $<'
+	@echo 'Invoking: GCC C++ Compiler'
+	$(CXX) $(CFLAGS) -D_GNU_SOURCE=1 -DPSAPI_VERSION=1 -std=c++11 $(CFLAGS) -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o $@ $<
+	@echo 'Finished building: $<'
+	@echo ' '
+
+
+csgo_wh: $(patsubst %.cpp,src/%.o,$(CSGOWH_SRC))
+	@echo 'Building target: $@'
+	@echo 'Invoking: GCC C Linker'
+	$(CXX) $(CFLAGS) $(LDFLAGS)  -shared -o $@.dll $^ -lpsapi -luser32 -ld3d9 -ld3dx9
+	@echo 'Finished building target: $@'
+	@echo ' '
diff --git a/csgo_wh/csgo_dll.cbp b/csgo_wh/csgo_dll.cbp
new file mode 100755
index 0000000..54afd2d
--- /dev/null
+++ b/csgo_wh/csgo_dll.cbp
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="csgo_dll" />
+		<Option pch_mode="2" />
+		<Option compiler="gcc" />
+		<Build>
+			<Target title="Debug">
+				<Option output="bin/csgo_dll" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Debug/" />
+				<Option type="3" />
+				<Option compiler="gcc" />
+				<Option createDefFile="1" />
+				<Option createStaticLib="1" />
+				<Compiler>
+					<Add option="-std=c++0x" />
+					<Add option="-Wall" />
+					<Add option="-g" />
+					<Add option="-Wno-comment" />
+					<Add option="-DBUILD_DLL" />
+					<Add option="-DENABLE_DEBUG=1" />
+					<Add directory="include" />
+				</Compiler>
+				<Linker>
+					<Add library="user32" />
+				</Linker>
+			</Target>
+			<Target title="Release">
+				<Option output="bin/csgo_dll" prefix_auto="1" extension_auto="1" />
+				<Option object_output="obj/Release/" />
+				<Option type="3" />
+				<Option compiler="gcc" />
+				<Option createDefFile="1" />
+				<Option createStaticLib="1" />
+				<Compiler>
+					<Add option="-std=c++0x" />
+					<Add option="-DBUILD_DLL" />
+					<Add directory="include" />
+				</Compiler>
+				<Linker>
+					<Add library="user32" />
+				</Linker>
+			</Target>
+		</Build>
+		<Compiler>
+			<Add option="-Wno-unknown-pragmas" />
+			<Add directory="C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/include" />
+		</Compiler>
+		<Linker>
+			<Add option="-static -static-libgcc" />
+			<Add library="C:\MinGW\lib\libpsapi.a" />
+			<Add library="C:\MinGW\lib\libkernel32.a" />
+			<Add library="d3d9" />
+			<Add library="d3dx9" />
+			<Add directory="C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/lib" />
+			<Add directory="C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x86" />
+		</Linker>
+		<Unit filename="include/D9DW.h" />
+		<Unit filename="include/D9DW_Config.h" />
+		<Unit filename="include/D9DW_Rectangle.h" />
+		<Unit filename="include/D9DW_Text.h" />
+		<Unit filename="include/DLLMain.h" />
+		<Unit filename="include/Game.h" />
+		<Unit filename="include/Hook.h" />
+		<Unit filename="src/D9DW.cpp" />
+		<Unit filename="src/D9DW_Rectangle.cpp" />
+		<Unit filename="src/D9DW_Text.cpp" />
+		<Unit filename="src/DLLMain.cpp" />
+		<Unit filename="src/Game.cpp" />
+		<Unit filename="src/Hook.cpp" />
+		<Extensions>
+			<code_completion />
+			<envvars />
+			<debugger />
+			<lib_finder disable_auto="1" />
+		</Extensions>
+	</Project>
+</CodeBlocks_project_file>
diff --git a/csgo_wh/csgo_dll.depend b/csgo_wh/csgo_dll.depend
new file mode 100755
index 0000000..c61fa30
--- /dev/null
+++ b/csgo_wh/csgo_dll.depend
@@ -0,0 +1,144 @@
+# depslib dependency file v1.0
+1440503366 source:c:\users\dev0\src\cheats\csgo_dll\src\d9dw.cpp
+	"DLLMain.h"
+	<cstdio>
+	<d3d9.h>
+	<d3dx9.h>
+	<stdarg.h>
+	<windows.h>
+	<psapi.h>
+	<commctrl.h>
+	"D9DW.h"
+
+1429447254 c:\users\dev0\src\cheats\csgo_dll\include\dllmain.h
+	<windows.h>
+	"D9DW.h"
+
+1430964629 c:\users\dev0\src\cheats\csgo_dll\include\d9dw.h
+	<d3d9.h>
+	<d3dx9.h>
+	<d3d9types.h>
+	<stdbool.h>
+	"Game.h"
+	"D9DW_Config.h"
+	"D9DW_Text.h"
+	"D9DW_Rectangle.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d9.h
+	<stdlib.h>
+	<objbase.h>
+	<windows.h>
+	"d3d9types.h"
+	"d3d9caps.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d9types.h
+	<float.h>
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3d9caps.h
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9.h
+	<limits.h>
+	"d3d9.h"
+	"d3dx9math.h"
+	"d3dx9core.h"
+	"d3dx9xof.h"
+	"d3dx9mesh.h"
+	"d3dx9shader.h"
+	"d3dx9effect.h"
+	"d3dx9tex.h"
+	"d3dx9shape.h"
+	"d3dx9anim.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9math.h
+	"d3dx9.h"
+	<math.h>
+	"d3dx9math.inl"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9math.inl
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9core.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9xof.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9mesh.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9shader.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9effect.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9tex.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9shape.h
+	"d3dx9.h"
+
+1274308617 c:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx9anim.h
+
+1430961159 c:\users\dev0\src\cheats\csgo_dll\include\game.h
+	<cstdio>
+	<windows.h>
+	<psapi.h>
+
+1429114787 c:\users\dev0\src\cheats\csgo_dll\include\d9dw_config.h
+
+1430964099 c:\users\dev0\src\cheats\csgo_dll\include\d9dw_text.h
+	<d3d9.h>
+	<d3dx9.h>
+	<stdbool.h>
+
+1430959528 c:\users\dev0\src\cheats\csgo_dll\include\d9dw_rectangle.h
+	<d3d9.h>
+	<d3dx9.h>
+	<stdbool.h>
+	"D9DW_Config.h"
+
+1429386171 source:c:\users\dev0\src\cheats\csgo_dll\src\d9dw_rectangle.cpp
+	"DLLMain.h"
+	"D9DW_Rectangle.h"
+	<cstdio>
+	<d3d9.h>
+	<d3dx9.h>
+
+1430964276 source:c:\users\dev0\src\cheats\csgo_dll\src\d9dw_text.cpp
+	"DLLMain.h"
+	<cstdio>
+	<d3d9.h>
+	<d3dx9.h>
+	"D9DW_Text.h"
+
+1440503387 source:c:\users\dev0\src\cheats\csgo_dll\src\dllmain.cpp
+	"DLLMain.h"
+	<cstdio>
+	<d3d9.h>
+	<stdarg.h>
+	<windows.h>
+	<psapi.h>
+	<commctrl.h>
+	"Hook.h"
+	"D9DW.h"
+	"Game.h"
+
+1440502246 c:\users\dev0\src\cheats\csgo_dll\include\hook.h
+
+1430960427 source:c:\users\dev0\src\cheats\csgo_dll\src\game.cpp
+	<cstdio>
+	<stdlib.h>
+	<math.h>
+	"Game.h"
+
+1430039163 source:c:\users\dev0\src\cheats\csgo_dll\src\hook.cpp
+	<cstdio>
+	<d3d9.h>
+	<d3dx9.h>
+	<stdarg.h>
+	<windows.h>
+	<psapi.h>
+	<commctrl.h>
+	"Hook.h"
+	"Game.h"
+
diff --git a/csgo_wh/csgo_dll.layout b/csgo_wh/csgo_dll.layout
new file mode 100755
index 0000000..08f7f4a
--- /dev/null
+++ b/csgo_wh/csgo_dll.layout
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_layout_file>
+	<ActiveTarget name="Debug" />
+	<File name="include\D9DW.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="568" topLine="9" />
+		</Cursor>
+	</File>
+	<File name="include\D9DW_Config.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="0" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="include\D9DW_Rectangle.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="525" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="include\D9DW_Text.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="248" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="include\DLLMain.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="375" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="include\Game.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="522" topLine="20" />
+		</Cursor>
+	</File>
+	<File name="include\Hook.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="396" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="src\D9DW.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="2252" topLine="72" />
+		</Cursor>
+	</File>
+	<File name="src\D9DW_Rectangle.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="640" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="src\D9DW_Text.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="268" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="src\DLLMain.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="1315" topLine="42" />
+		</Cursor>
+	</File>
+	<File name="src\Game.cpp" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="2089" topLine="0" />
+		</Cursor>
+	</File>
+	<File name="src\Hook.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+		<Cursor>
+			<Cursor1 position="1239" topLine="36" />
+		</Cursor>
+	</File>
+</CodeBlocks_layout_file>
diff --git a/csgo_wh/include/D9DW.h b/csgo_wh/include/D9DW.h
new file mode 100755
index 0000000..0ce2a44
--- /dev/null
+++ b/csgo_wh/include/D9DW.h
@@ -0,0 +1,45 @@
+#ifndef DDRW_HPP_INCLUDED
+#define DDRW_HPP_INCLUDED
+
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <d3d9types.h>
+#include <stdbool.h>
+
+#include "Game.h"
+#include "D9DW_Config.h"
+#include "D9DW_Text.h"
+#include "D9DW_Rectangle.h"
+
+
+#define MENU_DISABLE    0x1
+#define MENU_ESP        0x2
+
+
+class D9DW
+{
+
+private:
+    IDirect3DDevice9* pDevice;
+
+    void drawESP(UINT32 idx, ENTITY *ent, FLOAT pos[3]);
+
+    void doESP(Game *game);
+
+    void __stdcall doMenu(Game *game, int startx, int starty, int heightpad);
+
+public:
+    D9DW_Text pTxt;
+    D9DW_Rectangle pRec;
+
+    void Create(IDirect3DDevice9 *pDev);
+
+    void Release(void);
+
+    void __stdcall Render(Game* game, bool bActive);
+
+    HRESULT checkDxDevice(void);
+
+};
+
+#endif // DDRW_HPP_INCLUDED
diff --git a/csgo_wh/include/D9DW_Config.h b/csgo_wh/include/D9DW_Config.h
new file mode 100755
index 0000000..bbf65f4
--- /dev/null
+++ b/csgo_wh/include/D9DW_Config.h
@@ -0,0 +1,14 @@
+#ifndef DDRW_CONFIG_H_INCLUDED
+#define DDRW_CONFIG_H_INCLUDED
+
+#ifdef __cplusplus
+
+#define C_API extern "C"
+
+#else
+
+#define C_API
+
+#endif
+
+#endif // DDRW_CONFIG_H_INCLUDED
diff --git a/csgo_wh/include/D9DW_Rectangle.h b/csgo_wh/include/D9DW_Rectangle.h
new file mode 100755
index 0000000..57dea3e
--- /dev/null
+++ b/csgo_wh/include/D9DW_Rectangle.h
@@ -0,0 +1,35 @@
+#ifndef DDRW_RECTANGLE_H_INCLUDED
+#define DDRW_RECTANGLE_H_INCLUDED
+
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <stdbool.h>
+#include "D9DW_Config.h"
+
+
+class D9DW_Rectangle
+{
+private:
+
+    ID3DXLine* gLine;
+    IDirect3DDevice9* pDev;
+
+    inline void clearoutArea(int x, int y, int width, int height, UINT32 rgb_alpha);
+
+public:
+    HRESULT Create(IDirect3DDevice9* pDevice)
+    {
+        pDev = pDevice;
+        return D3DXCreateLine(pDev, &gLine);
+    }
+
+    void Release(void)
+    {
+        gLine->Release();
+    }
+
+    void Draw(int x , int y, int width, int height, UINT32 rgb_alpha, bool doFill);
+
+};
+
+#endif // DDRW_RECTANGLE_H_INCLUDED
diff --git a/csgo_wh/include/D9DW_Text.h b/csgo_wh/include/D9DW_Text.h
new file mode 100755
index 0000000..00f7815
--- /dev/null
+++ b/csgo_wh/include/D9DW_Text.h
@@ -0,0 +1,36 @@
+#ifndef D9DW_TEXT_H_INCLUDED
+#define D9DW_TEXT_H_INCLUDED
+
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <stdbool.h>
+
+
+class D9DW_Text
+{
+
+private:
+    static bool bInit;
+    static ID3DXFont* m_pFont;
+
+public:
+    bool isInitialized(void) {
+        return this->bInit;
+    }
+
+    void Create(IDirect3DDevice9* pDev);
+
+    void Release(void);
+
+    void DrawText(int x, int y, UINT32 rgb_alpha, const char *s_text, va_list p_va);
+
+    void DrawText(int x, int y, UINT32 rgb_alpha, const char *s_text, ...)
+    {
+        va_list va;
+        va_start(va, s_text);
+        this->DrawText(x, y, rgb_alpha, s_text, va);
+        va_end(va);
+    }
+};
+
+#endif // D9DW_TEXT_H_INCLUDED
diff --git a/csgo_wh/include/DLLMain.h b/csgo_wh/include/DLLMain.h
new file mode 100755
index 0000000..a11f94a
--- /dev/null
+++ b/csgo_wh/include/DLLMain.h
@@ -0,0 +1,36 @@
+#ifndef __MAIN_H__
+#define __MAIN_H__
+
+#include <windows.h>
+#include "D9DW.h"
+
+#define VERSION "0.3a"
+#define COPYRIGHT "CS:GO_HACK (C) by lnslbrty"
+#define CINTERFACE 1
+
+#ifdef BUILD_DLL
+#define DLL_EXPORT __declspec(dllexport)
+#else
+#define DLL_EXPORT __declspec(dllimport)
+#endif
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+__declspec(dllexport) BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
+
+#ifdef ENABLE_DEBUG
+#define DBG(fmt, ...) D9DW::DbgMessageBox(256, fmt, __VA_ARGS__)
+void DbgMessageBox(size_t sz_len, const char *fmt, ...);
+#else
+#define DBG(fmt, ...)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __MAIN_H__
diff --git a/csgo_wh/include/Game.h b/csgo_wh/include/Game.h
new file mode 100755
index 0000000..554ae9f
--- /dev/null
+++ b/csgo_wh/include/Game.h
@@ -0,0 +1,83 @@
+#ifndef GAME_H_INCLUDED
+#define GAME_H_INCLUDED
+
+#include <cstdio>
+#include <windows.h>
+#include <psapi.h>
+
+#define OFF_ENTITIES 0x49EE2E4
+#define OFF_LOCALPLAYER 0xA4CA5C
+
+#define MAXPLAYER 32
+#define ENTLOOP   0x10
+#define ENTPOS    0x134
+#define ENTAIMX   0xC0
+#define ENTAIMY   0x438
+#define ENTVANGL  0x158C
+#define ENTTEAM   0xF0
+#define PLYFOV    0x159C
+
+#define TEAM_COUNTER 0x3
+#define TEAM_TERROR  0x2
+
+
+#ifdef ENABLE_DEBUG
+#define DEBUG_VAR Game::pLogFile
+#define DEBUG_FILE "./log.txt"
+#define DEBUG_INIT DEBUG_VAR = fopen(DEBUG_FILE,"a+");
+#define DEBUG_FLUSH fflush(DEBUG_VAR);
+#define DEBUG_CLOSE fclose(DEBUG_VAR);
+#define DEBUG_LOG(msg, ...) fprintf(DEBUG_VAR, "[%s:%d] ", __FILE__, __LINE__); fprintf(DEBUG_VAR, msg, __VA_ARGS__); fprintf(DEBUG_VAR, "%s", "\r\n"); DEBUG_FLUSH;
+#define WDEBUG_LOG(msg, ...) fwprintf(DEBUG_VAR, L"[%hs:%d] ", __FILE__, __LINE__); fwprintf(DEBUG_VAR, msg, __VA_ARGS__);
+#else
+#define DEBUG_VAR
+#define DEBUG_FILE
+#define DEBUG_INIT
+#define DEBUG_LOG(msg, ...)
+#define WDEBUG_LOG(msg, ...)
+#define DEBUG_FLUSH
+#define DEBUG_CLOSE
+#endif // ENABLE_DEBUG
+
+
+typedef struct _entitiy
+{
+    PVOID p_adr;
+    FLOAT p_pos[3];
+    FLOAT p_aim[2];
+    BYTE p_team;
+} ENTITY;
+
+class Game
+{
+
+private:
+    bool init = false;
+
+public:
+    HMODULE h_clientDLL, h_shaderapiDLL;
+    MODULEINFO m_client, m_shaderapi;
+    UINT32 dwWidth;
+    UINT32 dwHeight;
+    UINT32 dwFov;
+    UINT32 dwPlayerCount = 0;
+    ENTITY *g_localPlayer;
+    ENTITY g_entities[MAXPLAYER];
+
+#ifdef ENABLE_DEBUG
+    static FILE* pLogFile;
+#endif
+
+    bool Init(void);
+
+    bool Reset(void);
+
+    bool ReadEntities(void);
+
+    void ReadCVars(void);
+
+    static FLOAT calcVecDist(float v1[3], float v2[3]);
+
+};
+
+#endif // GAME_H_INCLUDED
diff --git a/csgo_wh/include/Hook.h b/csgo_wh/include/Hook.h
new file mode 100755
index 0000000..53ee3b3
--- /dev/null
+++ b/csgo_wh/include/Hook.h
@@ -0,0 +1,20 @@
+#ifndef HOOK_H_INCLUDED
+#define HOOK_H_INCLUDED
+
+#define ENDSCENE_OFFSET 0x2179F
+
+typedef __int32 (__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
+
+class Hook
+{
+public:
+
+    static bool hookEndScene(EndScene_t pHookFunc, EndScene_t *pEndScene, bool unhook);
+
+    static BYTE* Detour(BYTE *src, const BYTE *dst);
+
+    static void UnDetour(BYTE *src);
+
+};
+
+#endif // HOOK_H_INCLUDED
diff --git a/csgo_wh/src/D9DW.cpp b/csgo_wh/src/D9DW.cpp
new file mode 100755
index 0000000..4efd7be
--- /dev/null
+++ b/csgo_wh/src/D9DW.cpp
@@ -0,0 +1,119 @@
+#include "DLLMain.h"
+
+#include <cstdio>
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <stdarg.h>
+#include <windows.h>
+#include <psapi.h>
+#include <commctrl.h>
+
+#include "D9DW.h"
+
+#define MENUCOLOR_DEFAULT  D3DCOLOR_ARGB(0xAA, 0x77, 0x00, 0x77)
+#define MENUCOLOR_ACTIVE   D3DCOLOR_ARGB(0xAA, 0x11, 0xAA, 0x00)
+#define MENUCOLOR_INACTIVE D3DCOLOR_ARGB(0xAA, 0xAA, 0x11, 0x00)
+
+
+typedef void (__stdcall *keyPressed_t)(D9DW *, Game *, bool);
+struct st_menuEntry
+{
+    bool active;
+    char *name;
+    int id;
+    keyPressed_t callback;
+};
+typedef struct st_menuEntry st_menuEntry;
+
+
+void __stdcall showDebugCB(D9DW *cPtr, Game *game, bool active)
+{
+    UINT32 i;
+    cPtr->pTxt.DrawText(450, 1 , MENUCOLOR_DEFAULT, "%u x %u / %u", game->dwWidth, game->dwHeight, game->dwFov);
+    for (i = 0; i < game->dwPlayerCount; i++)
+    {
+        cPtr->pTxt.DrawText(450, 20+(i*15), MENUCOLOR_DEFAULT, "[%u] [%8.2f,%8.2f,%8.2f]", i, game->g_entities[i].p_pos[0], game->g_entities[i].p_pos[1], game->g_entities[i].p_pos[2]);
+    }
+}
+
+
+static st_menuEntry menuEntries[] = { { false, (char*) "toggle esp", VK_F2, NULL }, { false, (char*) "toggle debug", VK_F3, showDebugCB } };
+static const int bMenuKey = VK_F1;
+static bool bMenu = false;
+
+
+void __stdcall D9DW::doMenu(Game *game, int startx, int starty, int heightpad)
+{
+    size_t idx;
+
+    if (GetKeyState(bMenuKey) &1)
+    {
+        bMenu = !bMenu;
+    }
+    if (bMenu)
+    {
+        this->pTxt.DrawText(startx, starty, MENUCOLOR_INACTIVE, "disable menu");
+    }
+    for (idx = 0; idx < sizeof(menuEntries)/sizeof(menuEntries[0]); idx++)
+    {
+        if (GetKeyState(menuEntries[idx].id) &1)
+        {
+            menuEntries[idx].active = !menuEntries[idx].active;
+            if (menuEntries[idx].callback) menuEntries[idx].callback(this, game, menuEntries[idx].active);
+        }
+        if (bMenu)
+        {
+            DEBUG_LOG("%u: %s", idx, menuEntries[idx].name);
+            this->pTxt.DrawText(startx, starty + ((idx+1)*heightpad), (menuEntries[idx].active ? MENUCOLOR_ACTIVE : MENUCOLOR_INACTIVE), "[%d] - %s", menuEntries[idx].id, menuEntries[idx].name);
+        }
+    }
+}
+
+void __stdcall D9DW::Render(Game* game, bool bActive)
+{
+    if (bActive)
+    {
+        //this->doMenu(game, 5, 300, 12);
+        this->pTxt.DrawText(2, 1 , MENUCOLOR_DEFAULT, "%s %s - [F1 MENU] - %d Player", COPYRIGHT, VERSION, game->dwPlayerCount);
+    }
+    else
+    {
+        this->pTxt.DrawText(2, 1 , MENUCOLOR_DEFAULT, "%s %s - WAITING FOR GAME ...", COPYRIGHT, VERSION, game->dwPlayerCount);
+    }
+}
+
+void D9DW::Create(IDirect3DDevice9 *pDev)
+{
+    this->pDevice = pDev;
+    this->pTxt.Create(pDev);
+    this->pRec.Create(pDev);
+}
+
+void D9DW::Release(void)
+{
+    this->pTxt.Release();
+    this->pRec.Release();
+}
+
+HRESULT D9DW::checkDxDevice(void)
+{
+    return ( D9DW::pDevice->TestCooperativeLevel() );
+}
+
+void D9DW::drawESP(UINT32 idx, ENTITY *ent, FLOAT pos[3])
+{
+}
+
+void D9DW::doESP(Game *game)
+{
+    UINT32 i;
+    FLOAT pos[3];
+
+    for (i = 0; i < game->dwPlayerCount; i++)
+    {
+        pos[0] = game->g_entities[i].p_pos[0] - game->g_localPlayer->p_pos[0];
+        pos[1] = game->g_entities[i].p_pos[1] - game->g_localPlayer->p_pos[1];;
+        pos[2] = game->g_entities[i].p_pos[2] - game->g_localPlayer->p_pos[2];;
+        this->drawESP(i, &game->g_entities[i], pos);
+    }
+}
diff --git a/csgo_wh/src/D9DW_Rectangle.cpp b/csgo_wh/src/D9DW_Rectangle.cpp
new file mode 100755
index 0000000..f9f267d
--- /dev/null
+++ b/csgo_wh/src/D9DW_Rectangle.cpp
@@ -0,0 +1,36 @@
+#include "DLLMain.h"
+#include "D9DW_Rectangle.h"
+
+#include <cstdio>
+#include <d3d9.h>
+#include <d3dx9.h>
+
+
+inline void D9DW_Rectangle::clearoutArea(int x, int y, int width, int height, UINT32 rgb_alpha)
+{
+    D3DRECT rect;
+    rect.x1 = x;
+    rect.x2 = x + width;
+    rect.y1 = y;
+    rect.y2 = y + height;
+    this->pDev->Clear(1, &rect, D3DCLEAR_TARGET, rgb_alpha, 0.0f, 0);
+}
+
+void D9DW_Rectangle::Draw(int x , int y, int width, int height, UINT32 rgb_alpha, bool doFill)
+{
+    D3DXVECTOR2 points[8];
+    points[0] = D3DXVECTOR2(x, y);
+    points[1] = D3DXVECTOR2(x + width, y);
+    points[2] = D3DXVECTOR2(x + width, y);
+    points[3] = D3DXVECTOR2(x + width, y + height);
+    points[4] = D3DXVECTOR2(x + width, y + height);
+    points[5] = D3DXVECTOR2(x, y + height);
+    points[6] = D3DXVECTOR2(x, y + height);
+    points[7] = D3DXVECTOR2(x, y);
+    this->gLine->SetPattern(0xffffffff);
+    this->gLine->SetPatternScale(2.0f);
+    this->gLine->Begin();
+    this->gLine->Draw(points, 8, rgb_alpha);
+    this->gLine->End();
+    D9DW_Rectangle::clearoutArea(x+3, y+3, width-6, height-6, 0x770077AA);
+}
diff --git a/csgo_wh/src/D9DW_Text.cpp b/csgo_wh/src/D9DW_Text.cpp
new file mode 100755
index 0000000..9b2e833
--- /dev/null
+++ b/csgo_wh/src/D9DW_Text.cpp
@@ -0,0 +1,44 @@
+#include "DLLMain.h"
+
+#include <cstdio>
+#include <d3d9.h>
+#include <d3dx9.h>
+
+#include "D9DW_Text.h"
+
+bool D9DW_Text::bInit = false;
+ID3DXFont* D9DW_Text::m_pFont = NULL;
+
+
+void D9DW_Text::Create(IDirect3DDevice9* pDev)
+{
+    if (!bInit)
+    {
+        D3DXCreateFont(pDev, 15, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &m_pFont);
+        bInit = true;
+    }
+}
+
+void D9DW_Text::Release(void)
+{
+    if (bInit)
+    {
+        bInit = false;
+        m_pFont->Release();
+        m_pFont = NULL;
+    }
+}
+
+void D9DW_Text::DrawText(int x, int y, UINT32 rgb_alpha, const char *s_text, va_list p_va)
+{
+    if (!bInit) return;
+    RECT rct;
+    rct.left=x;
+    rct.top=y;
+    rct.right=rct.left+350;
+    rct.bottom=rct.top+350;
+    char logbuf[100] = {0};
+    memset(&logbuf[0], '\0', 100);
+    _vsnprintf(logbuf, sizeof(logbuf), s_text, p_va);
+    m_pFont->DrawTextA(NULL, logbuf, sizeof(logbuf), &rct, 0, rgb_alpha);
+}
diff --git a/csgo_wh/src/DLLMain.cpp b/csgo_wh/src/DLLMain.cpp
new file mode 100755
index 0000000..b9d12cb
--- /dev/null
+++ b/csgo_wh/src/DLLMain.cpp
@@ -0,0 +1,78 @@
+#include "DLLMain.h"
+
+#include <cstdio>
+#include <d3d9.h>
+#include <stdarg.h>
+#include <windows.h>
+#include <psapi.h>
+#include <commctrl.h>
+
+#include "Hook.h"
+#include "D9DW.h"
+#include "Game.h"
+
+#define DXD9DEVICE_OFFSET 0x198298 + 0x44
+
+
+typedef __int32 (__stdcall* EndScene_t)(LPDIRECT3DDEVICE9);
+
+static LPDIRECT3DDEVICE9 pDevice = NULL;
+static bool bActive = true;
+static EndScene_t pEndScene = NULL;
+static D9DW ddraw;
+//static Game game;
+
+
+__int32 __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice_t)
+{
+    asm volatile ("nop; nop; nop");
+    int retOrigEndScene = D3D_OK;
+    if(pDevice == NULL)
+    {
+        pDevice = pDevice_t;
+        //DEBUG_LOG("D3D9 Device (%X): %p", (UINT32)((UINT32) game.m_shaderapi.lpBaseOfDll + DXD9DEVICE_OFFSET), pDevice);
+        DEBUG_LOG("EndScene Arg: %p", pDevice_t);
+        DEBUG_FLUSH;
+        ddraw.Create(pDevice);
+    }
+    else
+    {
+        HRESULT c_ret = ddraw.checkDxDevice();
+        if (c_ret == D3D_OK)
+        {
+            //game.ReadCVars();
+            ddraw.Render(/* &game */ NULL, /* game.ReadEntities() */ false);
+        }
+        else pEndScene = NULL;
+        retOrigEndScene = (pEndScene != NULL ? pEndScene(pDevice_t) : D3D_OK);
+    }
+    asm volatile ("nop; nop; nop");
+    return retOrigEndScene;
+}
+
+DWORD WINAPI MainThread(void *arg)
+{
+    //game.Init();
+    Hook::hookEndScene(hkEndScene, &pEndScene, false);
+    while ( bActive )
+    {
+        Sleep(500);
+        if ( GetForegroundWindow() != FindWindow( 0, "Counter-Strike: Global Offensive" ) )
+        {
+            pDevice = NULL;
+            ddraw.Release();
+        }
+    }
+    return 0;
+}
+
+__declspec(dllexport) BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    if (fdwReason == DLL_PROCESS_ATTACH)
+    {
+        DWORD dwThreadId;
+        DisableThreadLibraryCalls(hinstDLL);
+        CreateThread(NULL, 0, MainThread, NULL, 0, &dwThreadId);
+    }
+    return TRUE; // succesful
+}
diff --git a/csgo_wh/src/Game.cpp b/csgo_wh/src/Game.cpp
new file mode 100755
index 0000000..379fd48
--- /dev/null
+++ b/csgo_wh/src/Game.cpp
@@ -0,0 +1,100 @@
+#include <cstdio>
+#include <stdlib.h>
+#include <math.h>
+
+#include "Game.h"
+
+
+#ifdef ENABLE_DEBUG
+FILE* Game::pLogFile = NULL;
+#endif
+
+
+bool Game::Init(void)
+{
+    DEBUG_INIT;
+    this->init = true;
+    if ( (h_clientDLL = GetModuleHandle("client.dll")) == NULL ) return false;
+    if ( (h_shaderapiDLL = GetModuleHandle("shaderapidx9.dll")) == NULL ) return false;
+    memset(&this->m_client, '\0', sizeof(MODULEINFO));
+    memset(&this->m_shaderapi, '\0', sizeof(MODULEINFO));
+    if (GetModuleInformation(GetCurrentProcess(), h_clientDLL, &this->m_client, sizeof(MODULEINFO)) == TRUE)
+    {
+        DEBUG_LOG("MODINFO(client.dll): 0x%p (%lu)", this->m_client.lpBaseOfDll, this->m_client.SizeOfImage);
+    }
+    else return false;
+    if (GetModuleInformation(GetCurrentProcess(), h_shaderapiDLL, &this->m_shaderapi, sizeof(MODULEINFO)) == TRUE)
+    {
+        DEBUG_LOG("MODINFO(shaderapidx9.dll): 0x%p (%lu)", this->m_shaderapi.lpBaseOfDll, this->m_shaderapi.SizeOfImage);
+    }
+    else return false;
+    return ( true );
+}
+
+bool Game::Reset(void)
+{
+    this->init = false;
+    DEBUG_CLOSE;
+    return (this->Init());
+}
+
+bool Game::ReadEntities(void)
+{
+    UINT32 i;
+    PVOID pLocalPlayer;
+    BYTE bLocalPlayerTeam;
+    bool bLocalPlayerFound = false;
+
+    if (this->init != true) return false;
+    memset(&g_entities, '\0', sizeof(ENTITY)*MAXPLAYER);
+    memset(&g_localPlayer, '\0', sizeof(ENTITY));
+    pLocalPlayer = (PVOID) *(UINT32*)( (UINT32) this->m_client.lpBaseOfDll + (UINT32) OFF_LOCALPLAYER );
+    if ( pLocalPlayer == NULL ) return false;
+    bLocalPlayerTeam = *(BYTE*)( (UINT32) pLocalPlayer + ENTTEAM);
+    if ( bLocalPlayerTeam != TEAM_COUNTER && bLocalPlayerTeam != TEAM_TERROR ) return false;
+    dwPlayerCount = 0;
+    for (i = 0; i < MAXPLAYER; i++)
+    {
+
+        g_entities[i].p_adr = (PVOID) *(UINT32*)( (UINT32) this->m_client.lpBaseOfDll + (UINT32) OFF_ENTITIES + (UINT32) (ENTLOOP * i) );
+        if (g_entities[i].p_adr == NULL)
+        {
+            break;
+        }
+        dwPlayerCount++;
+    }
+    for (i = 0; i < dwPlayerCount; i++)
+    {
+        if (g_entities[i].p_adr != NULL)
+        {
+            g_entities[i].p_pos[0] = *(FLOAT *) ( (UINT32) g_entities[i].p_adr + (UINT32) ENTPOS );
+            g_entities[i].p_pos[1] = *(FLOAT *) ( (UINT32) g_entities[i].p_adr + (UINT32) ENTPOS + 0x4 );
+            g_entities[i].p_pos[2] = *(FLOAT *) ( (UINT32) g_entities[i].p_adr + (UINT32) ENTPOS + 0x8 );
+
+            g_entities[i].p_aim[0] = *(FLOAT *) ( (UINT32) g_entities[i].p_adr + (UINT32) ENTAIMX );
+            g_entities[i].p_aim[1] = *(FLOAT *) ( (UINT32) g_entities[i].p_adr + (UINT32) ENTAIMY );
+            g_entities[i].p_team = *(BYTE *) ( (UINT32) g_entities[i].p_adr + (UINT32) ENTTEAM );
+
+            if (!bLocalPlayerFound && pLocalPlayer == g_entities[i].p_adr)
+            {
+                g_localPlayer = &g_entities[i];
+                bLocalPlayerFound = true;
+            }
+        }
+        else break;
+    }
+
+    return bLocalPlayerFound;
+}
+
+void Game::ReadCVars(void)
+{
+    //dwWidth = *(UINT32*)( (UINT32) this->m_client.lpBaseOfDll + (UINT32) OFF_RESOLUTION );
+    //dwHeight = *(UINT32*)( (UINT32) this->m_client.lpBaseOfDll + (UINT32) OFF_RESOLUTION + 0x4 );
+    //dwFov = *(UINT32*)( (UINT32) this->m_client.lpBaseOfDll + (UINT32) OFF_FOV );
+}
+
+FLOAT Game::calcVecDist(float v1[3], float v2[3])
+{
+    return sqrtf( powf(v1[0] - v2[0], 2.0f) + powf(v1[1] - v2[1], 2.0f) + powf(v1[2] - v2[2], 2.0f) );
+}
diff --git a/csgo_wh/src/Hook.cpp b/csgo_wh/src/Hook.cpp
new file mode 100755
index 0000000..61dc1ca
--- /dev/null
+++ b/csgo_wh/src/Hook.cpp
@@ -0,0 +1,72 @@
+#include <cstdio>
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <stdarg.h>
+#include <windows.h>
+#include <psapi.h>
+#include <commctrl.h>
+
+#include "Hook.h"
+#include "Game.h"
+
+
+bool Hook::hookEndScene(EndScene_t pHookFunc, EndScene_t *pEndScene, bool unhook)
+{
+    HMODULE hm_ddrw = GetModuleHandleA("d3d9.dll");
+    MODULEINFO md_ddrw;
+    LPVOID p_fEndScene;
+
+
+    memset(&md_ddrw, '\0', sizeof(md_ddrw));
+    if (hm_ddrw != NULL && GetModuleInformation(GetCurrentProcess(), hm_ddrw, &md_ddrw, sizeof(md_ddrw)) == TRUE)
+    {
+        DEBUG_LOG("MODINFO(d3d9.dll): 0x%p (%lu)", md_ddrw.lpBaseOfDll, md_ddrw.SizeOfImage);
+        if ( (p_fEndScene = (LPVOID)( (PBYTE)md_ddrw.lpBaseOfDll + ENDSCENE_OFFSET )) != NULL )
+        {
+            DEBUG_LOG("ENDSCENE: 0x%p | HOOK: 0x%p | REL_OFF: %lu", p_fEndScene, pHookFunc, (DWORD)( (DWORD)pHookFunc - (DWORD)p_fEndScene));
+            if (!unhook)
+            {
+                *pEndScene = (EndScene_t) Hook::Detour((PBYTE)p_fEndScene,(PBYTE)pHookFunc);
+            }
+            else
+            {
+                Hook::UnDetour((PBYTE)p_fEndScene);
+            }
+        }
+        else return false;
+    }
+    else return false;
+    return true;
+}
+
+BYTE* Hook::Detour(BYTE *src, const BYTE *dst)
+{
+    BYTE *jmp = (BYTE *) calloc(1, 0x5);
+    DWORD dwback;
+    VirtualProtect(src - 0x5, 0x7, PAGE_READWRITE, &dwback); // important for changing opcodes in the code section
+    jmp[0] = 0xE9; // far jump (32bit offset signed)
+    *(DWORD*)(jmp+1) = (DWORD)(dst - src);
+    memcpy(src - 0x5, jmp, 0x5);
+    src[0] = 0xEB; // short jump (8bit offset signed)
+    src[1] = 0xF9; // two complement -> -0x7
+    VirtualProtect(src - 0x5, 0x7, dwback, &dwback);
+    free(jmp);
+    return (src + 0x2); // return the REAL function addr -> MOV EDI,EDI = 2 bytes
+}
+
+void Hook::UnDetour(BYTE *src)
+{
+    BYTE *jmp = (BYTE *) calloc(1, 0x5);
+    DWORD dwback;
+    VirtualProtect(src - 0x5, 0x7, PAGE_READWRITE, &dwback);
+    src[0] = 0x8B; // MOV opcode
+    src[1] = 0xFF; // operand0: EDI, operand1: EDI
+    jmp[0] = 0x90; // overwrite JMP with NOP-sled
+    jmp[1] = 0x90;
+    jmp[2] = 0x90;
+    jmp[3] = 0x90;
+    jmp[4] = 0x90;
+    memcpy(src - 0x5, jmp, 0x5);
+    VirtualProtect(src - 0x5, 0x7, dwback, &dwback);
+    free(jmp);
+}
-- 
cgit v1.2.3