프로 세 스 와 스 레 드 API

windows api 의 정리 (프로 세 스 와 스 레 드)
    :
CreateProcess("C:\\windows\
otepad.exe",0,0,0,0,0,0,0,&si,&pi); WinExec("notepad",SW_SHOW);//exe ShellExcute(0,"open","notepad","c:\\a.txt","",SW_SHOW);
    :
CreateThread(0,0,startAddr,&Para,0,&tid);
CrateRemoteThread(hProc,0,0,startAddr,&Para,0,&tid);
_beginthread(startAddr,0,0);
_beginthreadex(0,0,startaddr,0,0,&tid);

    :
OpenProcess(PROCESS_ALL_ACCESS,0,pid);
    :
OpenThread(THREAD_ALL_ACCESS,0,&tid);
    :
CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS,0);
Process32First(hsnap,&pe32);
Process32Next(hsnap,&pe32);

    :
CreateToolhelp32SnapShot(TH32CS_SNAPTHREADED,0);
Thread32First(hsnap,&mdl32);
Thread32Next(hsnap,&mdl32);
    :
ExitProcess(0);
TerminateProcess(hProcess,0);

    :
ExitThread(5);
TerminateThread(5);
      :
CloseHandle(handle);

        (   )
GetCurrentProcess();   -1
        
GetCurrentThread();   -2
      ID
GetProcessId();
       ID
GetThreadId();
        
ReadProcessMemory(
hProcess,            //      
baseAddr,            //          ,       
Buf,                    //         ,            
len,                     //      
&size                  //       
);

 WriteProcessMemory(
hProcess,              //         , OpenProcess  
baseAddr,                //              ,      !
Buf,                     //           ,      ,              !     !
len,                      //       
&size                  //        
);
    
VirtualAlloc(0,size,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
      
VirtualAllocEx(hprocess,0,size,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
      
VirtualProtect(addr,Size,PAGE_EXECUTE_READWRITE,&lpflOldProtect );
VirtualProtectEx(hproc,addr,Size,PAGE_EXECUTE_READWRITE,&lpflOldProtect );

    :
VirtualFree(addr,size,MEM_RELEASE);
VirtualFreeEx(hProcess,addr,size,MEM_RELEASE);
       
SetPriorityclass(hproc,Normal);
GetPriority(hproc);

       :
SetThreadPriority(hthread,Normal);
GetThreadPriority(hthread);
SetThreadPriorityBoost(hproc,true);
GetThreadPriorityBoost(hproc,pBoost);
       :(WinNT/2K/XP<0x80000000)
getVersion();
       (      )
SuspendThread(hthread);
ResumeThread(hthread);
      
WaitForSingleObject(hthread,1000);
WaitForMultipleObject(num,handles,true,INFINITE);
       
GetExitCode(hthread,&code);
          
ZwQueryInformationThread(hthread,ThreadQuerySetWin32StartAddress,&Buf,4,NULL)


GetModuleFileName() :               DLL        ( '\0'  ),                。
DWORD WINAPI GetModuleFileName(
  _In_opt_  HMODULE hModule,   //     DLL    ,NULL                
  _Out_     LPTSTR lpFilename, //           
  _In_      DWORD nSize        //             
);
          :
OpenEvent(EVENT_ALL_ACCESS,false,Name);
CreateEvent(NULL,false,true,NULL);
WaitForSingleObject(hEvent,INFINITE);
SetEvent(hevent);
ReSetEvent(hevent);

          :
OpenMutex(MUTEX_ALL_ACCESS,false,name);
CreateMutex(NULL,false,NULL);
WaitForSingleObject(hmutex,INFINITE);
ReleaseMutex(hmutex);

좋은 웹페이지 즐겨찾기