我想向哥哥们求教一个问题,不知道您是否能帮我问题是:怎么样才能打系统进程(System 权限的)用C++写
我写了好长时间可是没有什么结果,只能打开用户(带有Administrator权限)进程这在里我先谢谢你们了 

解决方案 »

  1.   

    调用如下函数后再打开..//提升进程访问权限 
    void EnableDebugPriv() 
    {
        HANDLE hToken;
        LUID sedebugnameValue;
        TOKEN_PRIVILEGES tkp;    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
            return;    if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue))
    {
            CloseHandle(hToken);
            return;
        }    tkp.PrivilegeCount = 1;
        tkp.Privileges[0].Luid = sedebugnameValue;
        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;    if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL))
            CloseHandle(hToken);
    }
      

  2.   

    是呀,我也是这样做的,可是当我用OpenProcess()时,总是打不开
      

  3.   

    先提高自已的权限,然后用AdjustTokenPrivileges(第二参数选TURE)去掉它权限。
      

  4.   

    好果不行的话,你可以操作这个SYSTEM的所有线程,一样的效果。
      

  5.   

    边OpenProcess()都打不开,怎么操作呀
      

  6.   


    OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS_P, &hToken)看看这第二个参数看看行不行,
    你最好把你那一节源码拿来看看,
      

  7.   

    这是我的全部代码~!
    我用的VC6.0  Windows 2003 Server求求哥哥们帮高度一下
    怎么才能打开(或结束)带有System权限的进程// Shuai file.cpp : Defines the entry point for the console application.
    //#include "stdafx.h"
    #include <windows.h>
    #include <iostream.h>int AddPrivilege() 

    HANDLE hToken; 
    TOKEN_PRIVILEGES tp; 
    LUID Luid; // if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
    // if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY|TOKEN_ALL_ACCESS,&hToken))  
    if (!OpenProcessToken(GetCurrentProcess(),0x0028,&hToken))

    printf("OpenProcessToken error.\n"); 
    return 1; 

    if (!LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&Luid))
    // if (!LookupPrivilegeValue(NULL,0x0028,&Luid))
    // if (!LookupPrivilegeValue(NULL,SE_SYSTEM_PROFILE_NAME,&Luid)) //SE_DEBUG_NAME
    // if(!LookupPrivilegeValue(NULL,SE_SYSTEM_ENVIRONMENT_NAME,&Luid))   

    printf("LookupPrivilegeValue error.\n"); 
    return 1; 
    }  tp.PrivilegeCount = 1; 
    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 
    // tp.Privileges[0].Luid = Luid;  if (!AdjustTokenPrivileges(hToken,TRUE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,NULL))
    // if (!AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(TOKEN_PRIVILEGES),NULL,NULL)) { 
    printf("AdjustTokenPrivileges error.\n"); 
    return 1; 
    }   if   (   GetLastError()   !=   NO_ERROR   )   
                      {     
                              printf("AdjustTokenPrivileges   Error!\n");   
                              //return(FALSE);   
                      }   // UpdateToSystem(); 
    return 0; 

    //SE_DEBUG_NAME
    int main(int argc, char* argv[])
    {
    printf("Hello World!\n");
    // AddPrivilege();
    int pid;
    while(1)
    {
    scanf("%d",&pid);
    HANDLE hProc=OpenProcess(TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,FALSE,pid);
    // HANDLE hProc=OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_ALL_ACCESS,FALSE,pid);
    if(hProc)
    {
    printf("成功");
    }
                    else
                    {
                            printf("失败"); continue;
                    }
    // HeapLock(hProc);
    // HeapDestroy(hProc);
    // HeapFree(hProc,0,NULL);
    TerminateProcess(hProc,1);
    // HeapSize(hProc,HEAP_NO_SERIALIZE,NULL);
    }
    return 0;
    }
      

  8.   

    按下面的方法做,我已经在你的代码上测试过了,可以成功~:
    添加如下函数://提升进程访问权限 
    void EnableDebugPriv() 
    {
        HANDLE hToken;
        LUID sedebugnameValue;
        TOKEN_PRIVILEGES tkp;    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
            return;    if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &sedebugnameValue))
    {
            CloseHandle(hToken);
            return;
        }    tkp.PrivilegeCount = 1;
        tkp.Privileges[0].Luid = sedebugnameValue;
        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;    if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL))
            CloseHandle(hToken);
    }
    在main函数里面调用它~:int   main(int   argc,   char*   argv[]) 

    printf("Hello   World!\n"); 
    // AddPrivilege(); 
    EnableDebugPriv();
    ...