├── MyLib ├── pch.h ├── pch.cpp ├── D3DMenu.h ├── D3DMenu1.h ├── Misc.cpp ├── MyLib.cpp ├── aobscan.h ├── DxManager.h ├── GameESP.cpp ├── aobscan.cpp ├── DxManager.cpp ├── MemoryManager.h ├── ProcManager.cpp ├── MemoryManager.cpp ├── WRand.h ├── Misc.h ├── MyLib.vcxproj.user ├── ProcManager.h ├── WRand.cpp ├── instdrv.h ├── MyLib.vcxproj.filters ├── GameESP.h ├── D3DMenu1.cpp ├── D3DMenu.cpp ├── instdrv.cpp └── MyLib.vcxproj ├── img ├── 11.png └── 22.png ├── .gitmodules ├── README.md ├── pubg.sln └── .gitignore /MyLib/pch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/pch.h -------------------------------------------------------------------------------- /img/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/img/11.png -------------------------------------------------------------------------------- /img/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/img/22.png -------------------------------------------------------------------------------- /MyLib/pch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/pch.cpp -------------------------------------------------------------------------------- /MyLib/D3DMenu.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/D3DMenu.h -------------------------------------------------------------------------------- /MyLib/D3DMenu1.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/D3DMenu1.h -------------------------------------------------------------------------------- /MyLib/Misc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/Misc.cpp -------------------------------------------------------------------------------- /MyLib/MyLib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/MyLib.cpp -------------------------------------------------------------------------------- /MyLib/aobscan.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/aobscan.h -------------------------------------------------------------------------------- /MyLib/DxManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/DxManager.h -------------------------------------------------------------------------------- /MyLib/GameESP.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/GameESP.cpp -------------------------------------------------------------------------------- /MyLib/aobscan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/aobscan.cpp -------------------------------------------------------------------------------- /MyLib/DxManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/DxManager.cpp -------------------------------------------------------------------------------- /MyLib/MemoryManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/MemoryManager.h -------------------------------------------------------------------------------- /MyLib/ProcManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/ProcManager.cpp -------------------------------------------------------------------------------- /MyLib/MemoryManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ohroy/pubg-hack/HEAD/MyLib/MemoryManager.cpp -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "pubg-driver"] 2 | path = pubg-driver 3 | url = git://github.com/rozbo/pubg-driver.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pubg-mobile-esp 2 | 刺激战场腾讯模拟器方框透视+磁性自瞄 3 | 4 | ## thanks 5 | this project is based on [https://github.com/w1nds/pubg-mobile-esp](https://github.com/w1nds/pubg-mobile-esp) 6 | 7 | 8 | ## 效果图 9 | 10 | ![](./img/22.png) 11 | ![](./img/11.png) 12 | 13 | -------------------------------------------------------------------------------- /MyLib/WRand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class WRand 7 | { 8 | public: 9 | WRand(); 10 | ~WRand(); 11 | 12 | std::string Generate(int iLong, BOOL bUpLow, BOOL bNum, BOOL bNumOnly); 13 | char GetChar(int Flag); 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /MyLib/Misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define MYPRINT 3 | #include 4 | 5 | //MyOutputDebugStringA("%d,%s",123,"hello"); 6 | void MyOutputDebugStringA(const char * lpcszOutputString, ...); 7 | //MyOutputDebugStringW(L"%d,%s",456,L"world!"); 8 | void MyOutputDebugStringW(const wchar_t * szOutputString, ...); 9 | -------------------------------------------------------------------------------- /MyLib/MyLib.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Auto 5 | WindowsLocalDebugger 6 | 7 | -------------------------------------------------------------------------------- /MyLib/ProcManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ProcManager 6 | { 7 | public: 8 | ProcManager(); 9 | ~ProcManager(); 10 | static int GetProcessIdByName(LPCTSTR szProcess); 11 | static BOOL EnableDebugPriv(); 12 | static DWORD_PTR GetModuleBase(DWORD dwPid, LPCTSTR szModName); 13 | static int GetProcessThreadNumByID(DWORD dwPID); 14 | static int GetAowProcId(); 15 | }; 16 | -------------------------------------------------------------------------------- /MyLib/WRand.cpp: -------------------------------------------------------------------------------- 1 | #include "WRand.h" 2 | #include 3 | 4 | 5 | WRand::WRand() 6 | { 7 | srand((unsigned)time(NULL)); 8 | } 9 | 10 | 11 | WRand::~WRand() 12 | { 13 | } 14 | char WRand::GetChar(int Flag) 15 | { 16 | char m_sArray[] = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"); 17 | char m_sArrayNum[] = ("1234567890"); 18 | char s; 19 | switch (Flag) 20 | { 21 | case 10: 22 | { 23 | int k = rand(); 24 | k = k % 10; 25 | s = m_sArrayNum[k]; 26 | } 27 | break; 28 | case 26: 29 | { 30 | int k = rand(); 31 | k = k % 26; 32 | s = m_sArray[k]; 33 | } 34 | break; 35 | case 52: 36 | { 37 | int k = rand(); 38 | k = k % 52; 39 | s = m_sArray[k]; 40 | } 41 | break; 42 | case 62: 43 | { 44 | int k = rand(); 45 | k = k % 62; 46 | s = m_sArray[k]; 47 | } 48 | break; 49 | default: 50 | { 51 | int k = rand(); 52 | k = k % 26; 53 | s = m_sArray[k]; 54 | } 55 | break; 56 | } 57 | 58 | return s; 59 | } 60 | std::string WRand::Generate(int iLong, BOOL bUpLow, BOOL bNum, BOOL bNumOnly) 61 | { 62 | srand((unsigned)time(NULL)); 63 | int iFlag = 26; 64 | std::string str; 65 | if (bUpLow == TRUE) 66 | iFlag = 52; 67 | if (bNum == TRUE) 68 | iFlag = 62; 69 | if (bNumOnly == TRUE) 70 | iFlag = 10; 71 | 72 | for (int i = 0; i < iLong; i++) 73 | { 74 | str += GetChar(iFlag); 75 | } 76 | return str; 77 | } -------------------------------------------------------------------------------- /pubg.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2036 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyLib", "MyLib\MyLib.vcxproj", "{602B808C-39C3-4B6A-98AC-A89120CF337F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Debug|x64.ActiveCfg = Debug|x64 17 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Debug|x64.Build.0 = Debug|x64 18 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Debug|x86.Build.0 = Debug|Win32 20 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Release|x64.ActiveCfg = Release|x64 21 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Release|x64.Build.0 = Release|x64 22 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Release|x86.ActiveCfg = Release|Win32 23 | {602B808C-39C3-4B6A-98AC-A89120CF337F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {BE729871-C3EC-488A-9D3C-E2A257A6ADEE} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /MyLib/instdrv.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * (C) COPYRIGHT AUTHORS, 2015 - 2017, portions (C) Mark Russinovich, FileMon 4 | * 5 | * TITLE: INSTDRV.H 6 | * 7 | * VERSION: 1.10 8 | * 9 | * DATE: 17 Apr 2017 10 | * 11 | * Common header file for the program SCM usage. 12 | * 13 | * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 14 | * ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED 15 | * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 16 | * PARTICULAR PURPOSE. 17 | * 18 | *******************************************************************************/ 19 | #pragma once 20 | #include 21 | #include 22 | 23 | BOOL scmInstallDriver( 24 | _In_ SC_HANDLE SchSCManager, 25 | _In_ LPCTSTR DriverName, 26 | _In_opt_ LPCTSTR ServiceExe 27 | ); 28 | 29 | BOOL scmStartDriver( 30 | _In_ SC_HANDLE SchSCManager, 31 | _In_ LPCTSTR DriverName 32 | ); 33 | 34 | BOOL scmOpenDevice( 35 | _In_ LPCTSTR DriverName, 36 | _Inout_opt_ PHANDLE lphDevice 37 | ); 38 | 39 | BOOL scmStopDriver( 40 | _In_ SC_HANDLE SchSCManager, 41 | _In_ LPCTSTR DriverName 42 | ); 43 | 44 | BOOL scmRemoveDriver( 45 | _In_ SC_HANDLE SchSCManager, 46 | _In_ LPCTSTR DriverName 47 | ); 48 | 49 | BOOL scmUnloadDeviceDriver( 50 | _In_ LPCTSTR Name 51 | ); 52 | 53 | BOOL scmLoadDeviceDriver( 54 | _In_ LPCTSTR Name, 55 | _In_opt_ LPCTSTR Path, 56 | _Inout_ PHANDLE lphDevice 57 | ); 58 | -------------------------------------------------------------------------------- /MyLib/MyLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 头文件 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 头文件 29 | 30 | 31 | 头文件 32 | 33 | 34 | 头文件 35 | 36 | 37 | 头文件 38 | 39 | 40 | 头文件 41 | 42 | 43 | 头文件 44 | 45 | 46 | 头文件 47 | 48 | 49 | 50 | 51 | 源文件 52 | 53 | 54 | 源文件 55 | 56 | 57 | 源文件 58 | 59 | 60 | 源文件 61 | 62 | 63 | 源文件 64 | 65 | 66 | 源文件 67 | 68 | 69 | 源文件 70 | 71 | 72 | 源文件 73 | 74 | 75 | 源文件 76 | 77 | 78 | 源文件 79 | 80 | 81 | 源文件 82 | 83 | 84 | -------------------------------------------------------------------------------- /MyLib/GameESP.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "D3DMenu.h" 4 | #include "ProcManager.h" 5 | #include "MemoryManager.h" 6 | 7 | extern DxManager *pDxm; 8 | extern D3DMenu* pMenu; 9 | extern MemoryManager *pMM; 10 | extern DWORD dwGamePid; 11 | extern DWORD dwJuzhenAddr; 12 | 13 | void ESPWork(); 14 | DWORD WINAPI ThreadUpdateData(LPVOID p); 15 | DWORD WINAPI ThreadUpdateData2(LPVOID p); 16 | DWORD WINAPI ThreadUpdateData3(LPVOID p); 17 | 18 | struct FRotator 19 | { 20 | float Pitch; 21 | float Yaw; 22 | float Roll; 23 | 24 | FRotator() 25 | { 26 | } 27 | FRotator(float flPitch, float flYaw, float flRoll) 28 | { 29 | Pitch = flPitch; 30 | Yaw = flYaw; 31 | Roll = flRoll; 32 | } 33 | 34 | 35 | double Length() 36 | { 37 | return sqrt(Pitch * Pitch + Yaw * Yaw + Roll * Roll); 38 | } 39 | 40 | FRotator Clamp() 41 | { 42 | if (Pitch > 180) 43 | Pitch -= 360; 44 | else if (Pitch < -180) 45 | Pitch += 360; 46 | if (Yaw > 180) 47 | Yaw -= 360; 48 | else if (Yaw < -180) 49 | Yaw += 360; 50 | if (Pitch < -89) 51 | Pitch = -89; 52 | if (Pitch > 89) 53 | Pitch = 89; 54 | while (Yaw < -180.0f) 55 | Yaw += 360.0f; 56 | while (Yaw > 180.0f) 57 | Yaw -= 360.0f; 58 | Roll = 0; 59 | return *this; 60 | } 61 | 62 | FRotator operator-(FRotator angB) 63 | { 64 | 65 | return FRotator(Pitch - angB.Pitch, Yaw - angB.Yaw, Roll - angB.Roll); 66 | } 67 | 68 | FRotator operator+(FRotator angB) 69 | { 70 | 71 | return FRotator(Pitch + angB.Pitch, Yaw + angB.Yaw, Roll + angB.Roll); 72 | } 73 | }; 74 | 75 | 76 | //Vector3 77 | class Vector3 78 | { 79 | public: 80 | Vector3() : x(0.f), y(0.f), z(0.f) 81 | { 82 | 83 | } 84 | 85 | Vector3(float _x, float _y, float _z) : x(_x), y(_y), z(_z) 86 | { 87 | 88 | } 89 | ~Vector3() 90 | { 91 | 92 | } 93 | 94 | float x; 95 | float y; 96 | float z; 97 | 98 | inline float Dot(Vector3 v) 99 | { 100 | return x * v.x + y * v.y + z * v.z; 101 | } 102 | 103 | inline float Distance(Vector3 v) 104 | { 105 | return float(sqrtf(powf(v.x - x, 2.0) + powf(v.y - y, 2.0) + powf(v.z - z, 2.0))); 106 | } 107 | inline float Length() { 108 | return sqrt(x*x + y * y + z * z); 109 | } 110 | 111 | FRotator ToFRotator() 112 | { 113 | FRotator rot; 114 | float RADPI = (float)(180 / M_PI); 115 | rot.Yaw = (float)(atan2(y, x) * RADPI); 116 | rot.Pitch = (float)atan2(z, sqrt((x * x) + (y * y))) * RADPI; 117 | rot.Roll = 0; 118 | 119 | return rot; 120 | } 121 | 122 | 123 | Vector3 operator+(Vector3 v) 124 | { 125 | return Vector3(x + v.x, y + v.y, z + v.z); 126 | } 127 | 128 | Vector3 operator-(Vector3 v) 129 | { 130 | return Vector3(x - v.x, y - v.y, z - v.z); 131 | } 132 | Vector3 operator/(float Scale) { 133 | const float RScale = 1.f / Scale; 134 | return Vector3(x * RScale, y * RScale, z * RScale); 135 | } 136 | //Vector3& Vector3::operator*=(const Vector3& v) { 137 | // x *= v.x; 138 | // y *= v.y; 139 | // z *= v.z; 140 | // return *this; 141 | //} 142 | 143 | }; 144 | -------------------------------------------------------------------------------- /MyLib/D3DMenu1.cpp: -------------------------------------------------------------------------------- 1 | #include "D3DMenu.h" 2 | 3 | void D3DMenu::AddItem(char *txt, int *var, char **opt, int maxval, int typ) 4 | { 5 | if (noitems >= (maxitems - 3)) return; 6 | MENU[noitems]->typ = typ; 7 | MENU[noitems]->txt = txt; 8 | MENU[noitems]->opt = opt; 9 | MENU[noitems]->var = var; 10 | MENU[noitems]->maxval = maxval; 11 | noitems++; 12 | totheight = (noitems*height) + titleheight; 13 | } 14 | 15 | void D3DMenu::AddGroup(char *txt, int *var, char **opt, int maxval) 16 | { 17 | AddItem(txt, var, opt, maxval, MENUGROUP); 18 | } 19 | 20 | void D3DMenu::AddGroup1(char *txt, int *var, char **opt, int maxval) 21 | { 22 | AddItem(txt, var, opt, maxval, MENUGROUP1); 23 | } 24 | 25 | 26 | void D3DMenu::AddText(char *txt, char *opt) 27 | { 28 | AddItem(txt, 0, (char **)opt, 0, MENUTEXT); 29 | } 30 | 31 | void D3DMenu::Show(DxManager *pDxm) 32 | { 33 | int i, val, cy; 34 | DWORD color; 35 | 36 | if (!visible) 37 | return; 38 | 39 | cy = y; 40 | if (title) { 41 | pDxm->DrawString((float)(x + totwidth / 4), (float)cy - 3, col_title, title); 42 | cy += titleheight; 43 | } 44 | for (i = 0; i < noitems; i++) { 45 | if (MENU[i]->typ == MENUTEXT) 46 | { 47 | pDxm->DrawString((float)x, (float)cy, col_on, MENU[i]->txt); 48 | if (MENU[i]->opt) 49 | { 50 | pDxm->DrawString((float)(x + ofs), (float)cy, col_on, (char *)MENU[i]->opt); 51 | } 52 | } 53 | else 54 | { 55 | val = (MENU[i]->var) ? (*MENU[i]->var) : 0; 56 | if (i == cur) 57 | color = col_current; 58 | else if (MENU[i]->typ == MENUGROUP) 59 | color = col_group; 60 | else if (MENU[i]->typ == MENUGROUP1) 61 | color = (val) ? col_on : col_off; 62 | else 63 | color = (val) ? col_on : col_off; 64 | pDxm->DrawString((float)x, (float)cy, color, MENU[i]->txt); 65 | if (MENU[i]->opt) 66 | { 67 | pDxm->DrawString((float)(x + ofs), (float)cy, color, (char *)MENU[i]->opt[val]); 68 | } 69 | } 70 | cy += height; 71 | } 72 | } 73 | 74 | void D3DMenu::Nav(void) 75 | { 76 | if (GetAsyncKeyState(VK_HOME) & 1) visible = (!visible); 77 | 78 | if (!visible) return; 79 | 80 | if (visible) 81 | { 82 | if (GetAsyncKeyState(VK_CONTROL)) 83 | { 84 | if (GetAsyncKeyState(VK_UP) & 1) y -= 10; 85 | if (GetAsyncKeyState(VK_DOWN) & 1) y += 10; 86 | if (GetAsyncKeyState(VK_LEFT) & 1) x -= 10; 87 | if (GetAsyncKeyState(VK_RIGHT) & 1) x += 10; 88 | } 89 | else 90 | { 91 | if (GetAsyncKeyState(VK_UP) & 1) { 92 | do { 93 | cur--; 94 | if (cur < 0) cur = noitems - 1; 95 | } while (MENU[cur]->typ == MENUTEXT); 96 | } 97 | else if (GetAsyncKeyState(VK_DOWN) & 1) { 98 | do { 99 | cur++; 100 | if (cur == noitems) cur = 0; 101 | } while (MENU[cur]->typ == MENUTEXT); 102 | } 103 | else if (MENU[cur]->var) { 104 | int dir = 0; 105 | if (GetAsyncKeyState(VK_LEFT) & 1 && *MENU[cur]->var > 0) 106 | dir = -1; 107 | if (GetAsyncKeyState(VK_RIGHT) & 1 && *MENU[cur]->var < (MENU[cur]->maxval - 1)) 108 | dir = 1; 109 | if (dir) { 110 | *MENU[cur]->var += dir; 111 | if (MENU[cur]->typ == MENUGROUP) noitems = 0; 112 | if (MENU[cur]->typ == MENUGROUP1) noitems = 0; 113 | } 114 | } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /MyLib/D3DMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "D3DMenu.h" 2 | 3 | void D3DMenu::AddItem(char *txt, int *var, char **opt, int maxval, int typ) 4 | { 5 | if (noitems >= (maxitems - 3)) return; 6 | MENU[noitems]->typ = typ; 7 | MENU[noitems]->txt = txt; 8 | MENU[noitems]->opt = opt; 9 | MENU[noitems]->var = var; 10 | MENU[noitems]->maxval = maxval; 11 | noitems++; 12 | totheight = (noitems*height) + titleheight; 13 | } 14 | 15 | void D3DMenu::AddGroup(char *txt, int *var, char **opt, int maxval) 16 | { 17 | AddItem(txt, var, opt, maxval, MENUGROUP); 18 | } 19 | 20 | void D3DMenu::AddGroup1(char *txt, int *var, char **opt, int maxval) 21 | { 22 | AddItem(txt, var, opt, maxval, MENUGROUP1); 23 | } 24 | 25 | 26 | void D3DMenu::AddText(char *txt, char *opt) 27 | { 28 | AddItem(txt, 0, (char **)opt, 0, MENUTEXT); 29 | } 30 | 31 | void D3DMenu::Show() 32 | { 33 | int i, val, cy; 34 | DWORD color; 35 | 36 | if (!visible) 37 | return; 38 | 39 | cy = y; 40 | if (title) { 41 | dxm->DrawString((float)(x + totwidth / 4), (float)cy - 3, col_title, dxm->pFontMenu,title); 42 | cy += titleheight; 43 | } 44 | for (i = 0; i < noitems; i++) { 45 | if (MENU[i]->typ == MENUTEXT) 46 | { 47 | dxm->DrawString((float)x, (float)cy, col_on, dxm->pFontMenu,MENU[i]->txt); 48 | if (MENU[i]->opt) 49 | { 50 | dxm->DrawString((float)(x + ofs), (float)cy, col_on, dxm->pFontMenu,(char *)MENU[i]->opt); 51 | } 52 | } 53 | else 54 | { 55 | val = (MENU[i]->var) ? (*MENU[i]->var) : 0; 56 | if (i == cur) 57 | color = col_current; 58 | else if (MENU[i]->typ == MENUGROUP) 59 | color = col_group; 60 | else if (MENU[i]->typ == MENUGROUP1) 61 | color = (val) ? col_on : col_off; 62 | else 63 | color = (val) ? col_on : col_off; 64 | dxm->DrawString((float)x, (float)cy, color, dxm->pFontMenu,MENU[i]->txt); 65 | if (MENU[i]->opt) 66 | { 67 | dxm->DrawString((float)(x + ofs), (float)cy, color, dxm->pFontMenu, (char *)MENU[i]->opt[val]); 68 | } 69 | } 70 | cy += height; 71 | } 72 | } 73 | 74 | void D3DMenu::Nav(void) 75 | { 76 | if (GetAsyncKeyState(VK_HOME) & 1) visible = (!visible); 77 | 78 | if (!visible) return; 79 | 80 | if (visible) 81 | { 82 | if (GetAsyncKeyState(VK_CONTROL)) 83 | { 84 | if (GetAsyncKeyState(VK_UP) & 1) y -= 10; 85 | if (GetAsyncKeyState(VK_DOWN) & 1) y += 10; 86 | if (GetAsyncKeyState(VK_LEFT) & 1) x -= 10; 87 | if (GetAsyncKeyState(VK_RIGHT) & 1) x += 10; 88 | } 89 | else 90 | { 91 | if (GetAsyncKeyState(VK_UP) & 1) { 92 | do { 93 | cur--; 94 | if (cur < 0) cur = noitems - 1; 95 | } while (MENU[cur]->typ == MENUTEXT); 96 | } 97 | else if (GetAsyncKeyState(VK_DOWN) & 1) { 98 | do { 99 | cur++; 100 | if (cur == noitems) cur = 0; 101 | } while (MENU[cur]->typ == MENUTEXT); 102 | } 103 | else if (MENU[cur]->var) { 104 | int dir = 0; 105 | if (GetAsyncKeyState(VK_LEFT) & 1 && *MENU[cur]->var > 0) 106 | dir = -1; 107 | if (GetAsyncKeyState(VK_RIGHT) & 1 && *MENU[cur]->var < (MENU[cur]->maxval - 1)) 108 | dir = 1; 109 | if (dir) { 110 | *MENU[cur]->var += dir; 111 | if (MENU[cur]->typ == MENUGROUP) noitems = 0; 112 | if (MENU[cur]->typ == MENUGROUP1) noitems = 0; 113 | } 114 | } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.opendb 7 | *.db 8 | *.userosscache 9 | *.sln.docstates 10 | *.VC.db 11 | # User-specific files (MonoDevelop/Xamarin Studio) 12 | *.userprefs 13 | 14 | # Build results 15 | [Dd]ebug/ 16 | [Dd]ebugPublic/ 17 | [Rr]elease/ 18 | [Rr]eleases/ 19 | x64/ 20 | x86/ 21 | build/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | 26 | # Visual Studio 2015 cache/options directory 27 | .vs/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | # DNX 43 | project.lock.json 44 | artifacts/ 45 | 46 | *_i.c 47 | *_p.c 48 | *_i.h 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tmp 60 | *.tmp_proj 61 | *.log 62 | *.vspscc 63 | *.vssscc 64 | .builds 65 | *.pidb 66 | *.svclog 67 | *.scc 68 | 69 | # Chutzpah Test files 70 | _Chutzpah* 71 | 72 | # Visual C++ cache files 73 | ipch/ 74 | *.aps 75 | *.ncb 76 | *.opensdf 77 | *.sdf 78 | *.cachefile 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | *.vspx 84 | 85 | # TFS 2012 Local Workspace 86 | $tf/ 87 | 88 | # Guidance Automation Toolkit 89 | *.gpState 90 | 91 | # ReSharper is a .NET coding add-in 92 | _ReSharper*/ 93 | *.[Rr]e[Ss]harper 94 | *.DotSettings.user 95 | 96 | # JustCode is a .NET coding add-in 97 | .JustCode 98 | 99 | # TeamCity is a build add-in 100 | _TeamCity* 101 | 102 | # DotCover is a Code Coverage Tool 103 | *.dotCover 104 | 105 | # NCrunch 106 | _NCrunch_* 107 | .*crunch*.local.xml 108 | 109 | # MightyMoose 110 | *.mm.* 111 | AutoTest.Net/ 112 | 113 | # Web workbench (sass) 114 | .sass-cache/ 115 | 116 | # Installshield output folder 117 | [Ee]xpress/ 118 | 119 | # DocProject is a documentation generator add-in 120 | DocProject/buildhelp/ 121 | DocProject/Help/*.HxT 122 | DocProject/Help/*.HxC 123 | DocProject/Help/*.hhc 124 | DocProject/Help/*.hhk 125 | DocProject/Help/*.hhp 126 | DocProject/Help/Html2 127 | DocProject/Help/html 128 | 129 | # Click-Once directory 130 | publish/ 131 | 132 | # Publish Web Output 133 | *.[Pp]ublish.xml 134 | *.azurePubxml 135 | ## TODO: Comment the next line if you want to checkin your 136 | ## web deploy settings but do note that will include unencrypted 137 | ## passwords 138 | #*.pubxml 139 | 140 | *.publishproj 141 | 142 | # NuGet Packages 143 | *.nupkg 144 | # The packages folder can be ignored because of Package Restore 145 | **/packages/* 146 | # except build/, which is used as an MSBuild target. 147 | !**/packages/build/ 148 | # Uncomment if necessary however generally it will be regenerated when needed 149 | #!**/packages/repositories.config 150 | 151 | # Windows Azure Build Output 152 | csx/ 153 | *.build.csdef 154 | 155 | # Windows Store app package directory 156 | AppPackages/ 157 | 158 | # Visual Studio cache files 159 | # files ending in .cache can be ignored 160 | *.[Cc]ache 161 | # but keep track of directories ending in .cache 162 | !*.[Cc]ache/ 163 | 164 | # Others 165 | ClientBin/ 166 | [Ss]tyle[Cc]op.* 167 | ~$* 168 | *~ 169 | *.dbmdl 170 | *.dbproj.schemaview 171 | *.pfx 172 | *.publishsettings 173 | node_modules/ 174 | orleans.codegen.cs 175 | 176 | # RIA/Silverlight projects 177 | Generated_Code/ 178 | 179 | # Backup & report files from converting an old project file 180 | # to a newer Visual Studio version. Backup files are not needed, 181 | # because we have git ;-) 182 | _UpgradeReport_Files/ 183 | Backup*/ 184 | UpgradeLog*.XML 185 | UpgradeLog*.htm 186 | 187 | # SQL Server files 188 | *.mdf 189 | *.ldf 190 | 191 | # Business Intelligence projects 192 | *.rdl.data 193 | *.bim.layout 194 | *.bim_*.settings 195 | 196 | # Microsoft Fakes 197 | FakesAssemblies/ 198 | 199 | # Node.js Tools for Visual Studio 200 | .ntvs_analysis.dat 201 | 202 | # Visual Studio 6 build log 203 | *.plg 204 | 205 | # Visual Studio 6 workspace options file 206 | *.opt 207 | 208 | # LightSwitch generated files 209 | GeneratedArtifacts/ 210 | _Pvt_Extensions/ 211 | ModelManifest.xml 212 | -------------------------------------------------------------------------------- /MyLib/instdrv.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "instdrv.h" 3 | #include 4 | /* 5 | * scmInstallDriver 6 | * 7 | * Purpose: 8 | * 9 | * Create SCM service entry describing kernel driver. 10 | * 11 | */ 12 | BOOL scmInstallDriver( 13 | _In_ SC_HANDLE SchSCManager, 14 | _In_ LPCTSTR DriverName, 15 | _In_opt_ LPCTSTR ServiceExe 16 | ) 17 | { 18 | SC_HANDLE schService=NULL; 19 | for (int i = 0; i < 3 && (NULL == schService); i++) 20 | { 21 | schService = CreateService(SchSCManager, // SCManager database 22 | DriverName, // name of service 23 | DriverName, // name to display 24 | SC_MANAGER_ALL_ACCESS, // desired access 25 | SERVICE_KERNEL_DRIVER, // service type 26 | SERVICE_DEMAND_START, // start type 27 | SERVICE_ERROR_IGNORE, // error control type 28 | ServiceExe, // service's binary 29 | NULL, // no load ordering group 30 | NULL, // no tag identifier 31 | NULL, // no dependencies 32 | NULL, // LocalSystem account 33 | NULL // no password 34 | ); 35 | if (schService == NULL) { 36 | printf("s1%s\n", DriverName); 37 | char szOut[100] = { 0 }; 38 | wsprintfA(szOut, "%x weeor:%d", (DWORD_PTR)SchSCManager, GetLastError()); 39 | OutputDebugStringA(szOut); 40 | } 41 | else 42 | { 43 | break; 44 | } 45 | } 46 | 47 | CloseServiceHandle(schService); 48 | return TRUE; 49 | } 50 | 51 | /* 52 | * scmStartDriver 53 | * 54 | * Purpose: 55 | * 56 | * Start service, resulting in SCM drvier load. 57 | * 58 | */ 59 | BOOL scmStartDriver( 60 | _In_ SC_HANDLE SchSCManager, 61 | _In_ LPCTSTR DriverName 62 | ) 63 | { 64 | SC_HANDLE schService; 65 | BOOL ret; 66 | 67 | schService = OpenService(SchSCManager, 68 | DriverName, 69 | SC_MANAGER_ALL_ACCESS 70 | ); 71 | if (schService == NULL) 72 | { 73 | return FALSE; 74 | } 75 | 76 | 77 | ret = StartService(schService, 0, NULL); 78 | if(!ret) 79 | { 80 | DWORD errcode = GetLastError();//== ERROR_SERVICE_ALREADY_RUNNING; 81 | if(errcode!= ERROR_SERVICE_ALREADY_RUNNING) 82 | { 83 | printf_s("start service error:%d", errcode); 84 | ret = true; 85 | } 86 | 87 | } 88 | 89 | 90 | CloseServiceHandle(schService); 91 | 92 | return ret; 93 | } 94 | 95 | /* 96 | * scmOpenDevice 97 | * 98 | * Purpose: 99 | * 100 | * Open driver device by symbolic link. 101 | * 102 | */ 103 | BOOL scmOpenDevice( 104 | _In_ LPCTSTR DriverName, 105 | _Inout_opt_ PHANDLE lphDevice 106 | ) 107 | { 108 | TCHAR completeDeviceName[64]; 109 | HANDLE hDevice; 110 | 111 | RtlSecureZeroMemory(completeDeviceName, sizeof(completeDeviceName)); 112 | wsprintf(completeDeviceName, TEXT("\\\\.\\%s"), DriverName); 113 | 114 | hDevice = CreateFile(completeDeviceName, 115 | GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0 116 | ); 117 | if (hDevice == INVALID_HANDLE_VALUE) 118 | { 119 | DWORD errcode = GetLastError(); 120 | printf_s("open driver error:%d", errcode); 121 | return FALSE; 122 | } 123 | 124 | 125 | if (lphDevice) { 126 | *lphDevice = hDevice; 127 | } 128 | else { 129 | CloseHandle(hDevice); 130 | } 131 | 132 | return TRUE; 133 | } 134 | 135 | /* 136 | * scmStopDriver 137 | * 138 | * Purpose: 139 | * 140 | * Command SCM to stop service, resulting in driver unload. 141 | * 142 | */ 143 | BOOL scmStopDriver( 144 | _In_ SC_HANDLE SchSCManager, 145 | _In_ LPCTSTR DriverName 146 | ) 147 | { 148 | BOOL ret; 149 | INT iRetryCount; 150 | SC_HANDLE schService; 151 | SERVICE_STATUS serviceStatus; 152 | 153 | ret = FALSE; 154 | schService = OpenService(SchSCManager, DriverName, SC_MANAGER_ALL_ACCESS); 155 | if (schService == NULL) { 156 | return ret; 157 | } 158 | 159 | iRetryCount = 5; 160 | do { 161 | SetLastError(0); 162 | ret = ControlService(schService, SERVICE_CONTROL_STOP, &serviceStatus); 163 | if (ret != FALSE) 164 | break; 165 | 166 | if (GetLastError() != ERROR_DEPENDENT_SERVICES_RUNNING) 167 | break; 168 | Sleep(1000); 169 | iRetryCount--; 170 | } while (iRetryCount); 171 | CloseServiceHandle(schService); 172 | 173 | return ret; 174 | } 175 | 176 | /* 177 | * scmRemoveDriver 178 | * 179 | * Purpose: 180 | * 181 | * Remove service entry from SCM database. 182 | * 183 | */ 184 | BOOL scmRemoveDriver( 185 | _In_ SC_HANDLE SchSCManager, 186 | _In_ LPCTSTR DriverName 187 | ) 188 | { 189 | SC_HANDLE schService; 190 | BOOL bResult = FALSE; 191 | 192 | schService = OpenService(SchSCManager, DriverName, SC_MANAGER_ALL_ACCESS); 193 | if (schService) { 194 | bResult = DeleteService(schService); 195 | CloseServiceHandle(schService); 196 | } 197 | return bResult; 198 | } 199 | 200 | /* 201 | * scmUnloadDeviceDriver 202 | * 203 | * Purpose: 204 | * 205 | * Combines scmStopDriver and scmRemoveDriver. 206 | * 207 | */ 208 | BOOL scmUnloadDeviceDriver( 209 | _In_ LPCTSTR Name 210 | ) 211 | { 212 | SC_HANDLE schSCManager; 213 | BOOL bResult = FALSE; 214 | 215 | if (Name == NULL) { 216 | return bResult; 217 | } 218 | schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 219 | if (schSCManager) { 220 | scmStopDriver(schSCManager, Name); 221 | bResult = scmRemoveDriver(schSCManager, Name); 222 | CloseServiceHandle(schSCManager); 223 | } 224 | return bResult; 225 | } 226 | 227 | /* 228 | * scmLoadDeviceDriver 229 | * 230 | * Purpose: 231 | * 232 | * Unload if already exists, Create, Load and Open driver instance. 233 | * 234 | */ 235 | BOOL scmLoadDeviceDriver( 236 | _In_ LPCTSTR Name, 237 | _In_opt_ LPCTSTR Path, 238 | _Inout_ PHANDLE lphDevice 239 | ) 240 | { 241 | SC_HANDLE schSCManager; 242 | BOOL bResult = FALSE; 243 | 244 | if (Name == NULL) { 245 | return bResult; 246 | } 247 | 248 | schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 249 | if (schSCManager) { 250 | scmRemoveDriver(schSCManager, Name); 251 | scmUnloadDeviceDriver(Name); 252 | scmInstallDriver(schSCManager, Name, Path); 253 | scmStartDriver(schSCManager, Name); 254 | bResult = scmOpenDevice(Name, lphDevice); 255 | CloseServiceHandle(schSCManager); 256 | 257 | } 258 | 259 | return bResult; 260 | } 261 | -------------------------------------------------------------------------------- /MyLib/MyLib.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {602B808C-39C3-4B6A-98AC-A89120CF337F} 24 | Win32Proj 25 | MyLib 26 | 10.0.17763.0 27 | pubg 28 | 29 | 30 | 31 | Application 32 | true 33 | v141 34 | Unicode 35 | false 36 | 37 | 38 | Application 39 | false 40 | v141 41 | true 42 | Unicode 43 | 44 | 45 | Application 46 | true 47 | v141 48 | Unicode 49 | 50 | 51 | Application 52 | false 53 | v141 54 | true 55 | Unicode 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | true 77 | $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(DXSDK_DIR)Lib\x86 78 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include 79 | 80 | 81 | true 82 | D:\sdks\Microsoft DirectX SDK (June 2010)\Include;$(IncludePath) 83 | 84 | 85 | false 86 | $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(DXSDK_DIR)Lib\x86 87 | pubg 88 | $(VC_IncludePath);$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include 89 | 90 | 91 | false 92 | 93 | 94 | 95 | NotUsing 96 | Level3 97 | Disabled 98 | true 99 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 100 | true 101 | pch.h 102 | false 103 | MultiThreadedDebug 104 | 105 | 106 | Console 107 | true 108 | RequireAdministrator 109 | 110 | 111 | 112 | 113 | Use 114 | Level3 115 | Disabled 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | pch.h 120 | 121 | 122 | Console 123 | true 124 | 125 | 126 | 127 | 128 | NotUsing 129 | Level3 130 | Disabled 131 | true 132 | false 133 | true 134 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | pch.h 137 | false 138 | false 139 | MultiThreadedDLL 140 | Disabled 141 | 142 | 143 | Console 144 | true 145 | true 146 | false 147 | 148 | 149 | 150 | 151 | NotUsing 152 | Level3 153 | MaxSpeed 154 | true 155 | true 156 | true 157 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 158 | true 159 | pch.h 160 | 161 | 162 | Console 163 | true 164 | true 165 | true 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | Create 191 | Create 192 | Create 193 | Create 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | --------------------------------------------------------------------------------