My esp doesn't seem to be getting the right positions the world to screen works maybe it's the way I'm using ReadProcessMemory() also the offsets are correct to just used hazedumper
Code:
#include "Includes.h"
#include <thread>

HWND wnd;
HWND game;

HANDLE gHandle;
RECT rct;

DWORD moduleBase = 0;

LPDIRECT3D9 lp;
LPDIRECT3DDEVICE9 lpd;

int width = 0;
int height = 0;

struct Vector4
{
	float x, y, z, w;
};

struct Vector3
{
	float x, y, z;
};

struct Vector2
{
	float x, y;
};

struct viewmatrix
{
	float matrix[16];
};


struct Vector3 WorldToScreen(const struct Vector3 pos, struct viewmatrix matrix) {
	struct Vector3 out;
	float _x = matrix.matrix[0] * pos.x + matrix.matrix[1] * pos.y + matrix.matrix[2] * pos.z + matrix.matrix[3];
	float _y = matrix.matrix[4] * pos.x + matrix.matrix[5] * pos.y + matrix.matrix[6] * pos.z + matrix.matrix[7];
	out.z = matrix.matrix[12] * pos.x + matrix.matrix[13] * pos.y + matrix.matrix[14] * pos.z + matrix.matrix[15];

	_x *= 1.f / out.z;
	_y *= 1.f / out.z;

	out.x = width * .5f;
	out.y = height * .5f;

	out.x += 0.5f * _x * width + 0.5f;
	out.y -= 0.5f * _y * height + 0.5f;

	return out;
}

DWORD getbase(DWORD procID, const wchar_t* modname)
{
	DWORD mod = 0;
	HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procID);
	if (snap != INVALID_HANDLE_VALUE)
	{
		MODULEENTRY32 md;
		md.dwSize = sizeof(MODULEENTRY32);
		if (Module32First(snap, &md))
		{
			do
			{
				if (!wcscmp(md.szModule, modname))
				{
					mod = (DWORD)md.modBaseAddr;
					CloseHandle(snap);
				}
			} while (Module32Next(snap, &md));
		}
	}
	return mod;
	CloseHandle(snap);
}

void SetVars()
{
	game = FindWindowA(NULL, "Counter-Strike: Global Offensive - Direct3D 9");
	DWORD processID = 0;
	GetWindowThreadProcessId(game, &processID);
	gHandle = OpenProcess(PROCESS_ALL_ACCESS, false, processID);
	moduleBase = getbase(processID, L"client.dll");
	GetWindowRect(game, &rct);
	width = rct.right - rct.left;
	height = rct.bottom - rct.top;
}

void initd3d()
{
	lp = Direct3DCreate9(D3D_SDK_VERSION);

	D3DPRESENT_PARAMETERS p;
	ZeroMemory(&p, sizeof(D3DPRESENT_PARAMETERS));
	p.BackBufferWidth = rct.right - rct.left;
	p.BackBufferHeight = rct.bottom - rct.top;
	p.Windowed = true;
	p.hDeviceWindow = wnd;
	p.SwapEffect = D3DSWAPEFFECT_DISCARD;

	lp->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &p, &lpd);
}

void bkThread1()
{
	while (true)
	{
		GetWindowRect(game, &rct);
		width = rct.right - rct.left;
		height = rct.bottom - rct.top;
		InvalidateRect(wnd, &rct, true);
		MoveWindow(wnd, rct.left, rct.top, width, height, true);
	}
}

LPD3DXFONT baseFont;

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstace, LPSTR lpCmdLine, int nCmdShow)
{
	SetVars();
	WNDCLASSEX wndClass;
	ZeroMemory(&wndClass, sizeof(WNDCLASSEX));
	wndClass.cbSize = sizeof(WNDCLASSEX);
	wndClass.style = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc = WindowProc;
	wndClass.hInstance = hInstance;
	wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
	wndClass.hbrBackground = (HBRUSH)RGB(0, 0, 0);
	wndClass.lpszClassName = L"cl";
	RegisterClassEx(&wndClass);

	wnd = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_LAYERED, L"cl", L"Better Than Client", WS_OVERLAPPED, rct.left, rct.top, width, height, NULL, NULL, hInstance, NULL);
	SetLayeredWindowAttributes(wnd, RGB(255, 255, 255), 0, LWA_COLORKEY);
	ShowWindow(wnd, nCmdShow);

	initd3d();
	D3DXCreateFont(lpd, 20, 10, 1, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH, L"a Alloy ink", &baseFont);
	std::thread bk(bkThread1);

	MSG message;
	while (GetMessage(&message, NULL, 0, 0))
	{
		DispatchMessage(&message);
		TranslateMessage(&message);
	}
	return message.wParam;
}

void DrawLine(D3DCOLOR color, int x1, int y1, int x2, int y2, int Thickness)
{
	LPD3DXLINE line;
	D3DXCreateLine(lpd, &line);
	D3DXVECTOR2 points[2];
	points[0] = D3DXVECTOR2(x1, y1);
	points[1] = D3DXVECTOR2(x2, y2);
	
	line->SetWidth(Thickness);
	line->SetAntialias(false);
	line->Begin();
	line->Draw(points, 2, color);
	line->End();
	line->Release();
}

void HackEsp()
{
	DWORD entityList = 0;
	viewmatrix view;
	Vector3 position = {0,0,0};
	ReadProcessMemory(gHandle, (LPCVOID*)(moduleBase + dwEntityList), &entityList, sizeof(DWORD), 0);
	ReadProcessMemory(gHandle, (LPCVOID*)(moduleBase + dwViewMatrix), &view, sizeof(viewmatrix), 0);
	for (short int i = 0; i < 32; i++)
	{
		DWORD entity = 0;
		ReadProcessMemory(gHandle, (LPCVOID*)(entityList + (0x10 + i)), &entity, sizeof(entity), 0);
		ReadProcessMemory(gHandle, (LPCVOID*)(entity + m_vecOrigin), &position, sizeof(position), 0);
		position = WorldToScreen(position, view);
		if (position.z > 0.1f)
		{
			DrawLine(D3DCOLOR_ARGB(255, 50, 50, 255), rct.right / 2, rct.bottom, position.x, position.y, 2);
		}
	}
}

void DrawString(const char* text, int x, int y, D3DCOLOR color)
{
	RECT pos;
	pos.left = x;
	pos.top = y;

	baseFont->DrawTextA(0, text, strlen(text), &pos, DT_NOCLIP, color);
}

void HackPaint()
{
	lpd->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 255, 255, 255), 1.0f, 0);
	lpd->BeginScene();

	HackEsp();
	DrawString("Better Than You", 20, 20, D3DCOLOR_ARGB(255, 0, 0, 255));

	lpd->EndScene();
	lpd->Present(NULL, NULL, NULL, NULL);
}

LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
		break;
	case WM_PAINT:
		HackPaint();
		break;
	}
	return DefWindowProc(hWnd, message, wParam, lParam);
}