//提升权限
void DebugPrivilege()
{
HANDLE hToken = NULL;
//打开当前进程的访问令牌
int hRet = OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken);
if( hRet)
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
//取得描述权限的LUID
LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//调整访问令牌的权限
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(tp),NULL,NULL);
CloseHandle(hToken);
}
}
void InpouringDll()//注入
{
WCHAR *DllName = _T("C:\\Users\\yjip\\Documents\\Visual Studio 2008\\Projects\\tetst\\Debug\\TestDLL.dll");
DWORD ProcessID = GetProcessIdByName(L"notepad.exe");//得到进程ID//explorer
DebugPrivilege();
void DebugPrivilege()
{
HANDLE hToken = NULL;
//打开当前进程的访问令牌
int hRet = OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken);
if( hRet)
{
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
//取得描述权限的LUID
LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&tp.Privileges[0].Luid);
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//调整访问令牌的权限
AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(tp),NULL,NULL);
CloseHandle(hToken);
}
}
void InpouringDll()//注入
{
WCHAR *DllName = _T("C:\\Users\\yjip\\Documents\\Visual Studio 2008\\Projects\\tetst\\Debug\\TestDLL.dll");
DWORD ProcessID = GetProcessIdByName(L"notepad.exe");//得到进程ID//explorer
DebugPrivilege();