在本进程中删除别的进程的.DLL
void CCEQQDlg::OnButton1() {
// TODO: Add your control notification handler code here
DWORD pid;
HANDLE handle;
PROCESSENTRY32 p32;
p32.dwSize=sizeof(PROCESSENTRY32);
handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
bool bol=Process32First(handle,&p32);
while(bol)
{
if(strcmp(p32.szExeFile,"QQGame.exe")==0)
{
pid=p32.th32ProcessID;
HANDLE ph=::OpenProcess(PROCESS_ALL_ACCESS,false,pid);
HANDLE hmodule;
MODULEENTRY32 m32;
m32.dwSize=sizeof(MODULEENTRY32);
hmodule=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pid);
bool bolm=Module32First(hmodule,&m32);
while(bolm)
{
if(strcmp(m32.szModule,"TenSLX.dll")==0)
{
//找到要删除的"TenSLX.dll"了。如何编程删除它
HANDLE lipai;
LUID luid;
TOKEN_PRIVILEGES tkp;
BOOL bol=::OpenProcessToken(ph,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,&lipai);
if(bol==false)
{
MessageBox("获得令牌失败");
return;
}
bol=::LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&luid);
if(bol==false)
{
MessageBox("获得令牌失败1");
return;
}
tkp.PrivilegeCount=1;
tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
tkp.Privileges[0].Luid=luid;
bol=AdjustTokenPrivileges(lipai,false,&tkp,sizeof(tkp),NULL,NULL);
if(bol==false)
{
MessageBox("获得令牌失败2");
return;
}
MessageBox("提升权限成功");
HMODULE hmodule=::LoadLibrary("kernel32.dll");
LPVOID free1;
free1=GetProcAddress(hmodule,"FreeLibrary");
DWORD id;
HANDLE hThread=CreateRemoteThread(ph,NULL,0,
(LPTHREAD_START_ROUTINE)free1,(HMODULE)m32.modBaseAddr,0,&id);
WaitForSingleObject(hThread, INFINITE);
MessageBox("删除DLL成功");
//SetHook(m32.szModule);
}
bolm=Module32Next(hmodule,&m32);
}
}
bol=Process32Next(handle,&p32);
}
CloseHandle(handle);
}
程序执行没有报错,就是删除不了TenSLX.dll不知道错在哪里了