PID & Terminate

Тема в разделе "WASM.ASSEMBLER", создана пользователем BadLogin, 5 ноя 2008.

  1. BadLogin

    BadLogin Серёга =)

    Публикаций:
    0
    Регистрация:
    9 окт 2008
    Сообщения:
    82
    Адрес:
    Сайнт-Пи
    Подскажите кто, как завершить процесс на assembler'e

    на Си - определяем PID и вызываем функцию TerminateProcess. Вот а теперь аналог хочу реализовать на ассе ))

    Заранее спасибо )
     
  2. Partner

    Partner Павел

    Публикаций:
    0
    Регистрация:
    28 фев 2008
    Сообщения:
    917
    Адрес:
    Los Angeles
    Для TerminateProcess нужен handle, а не PID.
    На асме тоже можно вызвать TerminateProcess. Или вопрос как вызывать функции на асме ?
     
  3. Exp10der

    Exp10der Мастер дзена

    Публикаций:
    0
    Регистрация:
    27 авг 2007
    Сообщения:
    337
    Адрес:
    Красноярск
    BadLogin
    Я тебе подскажу по секрету, что даже можешь использовать push/call для этого... если нужно больше google - есть сила...
     
  4. BadLogin

    BadLogin Серёга =)

    Публикаций:
    0
    Регистрация:
    9 окт 2008
    Сообщения:
    82
    Адрес:
    Сайнт-Пи
    ага ... я просто не силён в асме =(((

    технологию push/call понял, но какие параметры нужно передавать (push) ??

    толком ничего конкретного не нашёл =((
     
  5. max7C4

    max7C4 New Member

    Публикаций:
    0
    Регистрация:
    17 мар 2008
    Сообщения:
    1.203
    Код (Text):
    1. The TerminateProcess function terminates the specified process and all of its threads.
    2.  
    3. BOOL TerminateProcess(
    4.  
    5.     HANDLE hProcess,    // handle to the process
    6.     UINT uExitCode  // exit code for the process  
    7.    );  
    8.  
    9.  
    10. Parameters
    11.  
    12. hProcess
    13.  
    14. Identifies the process to terminate.
    15. Windows NT: The handle must have PROCESS_TERMINATE access. For more information, see Process Objects.
    16.  
    17. uExitCode
    18.  
    19. Specifies the exit code for the process and for all threads terminated as a result of this call. Use the GetExitCodeProcess
    20.  function to retrieve the process's exit value. Use the GetExitCodeThread function to retrieve a thread's exit value. Return Values
    21.  
    22. If the function succeeds, the return value is nonzero.
    23. If the function fails, the return value is zero. To get extended error information, call GetLastError.
    если до сих пор не понятно, то так
    Код (Text):
    1. push 0
    2. push [Handle_of_Process]
    3. call [TerminateProcess] ; при использование некоторых компиляторов [] (MASM, TASM, etc) придется убрать
     
  6. BadLogin

    BadLogin Серёга =)

    Публикаций:
    0
    Регистрация:
    9 окт 2008
    Сообщения:
    82
    Адрес:
    Сайнт-Пи
    СПАСИБО!!!

    ай!
    на Си я открывал свой хендл, определял ПИД процесса и завершал его, а что ЗДЕСЬ еть хендл по русски в двух словах можно ...
     
  7. max7C4

    max7C4 New Member

    Публикаций:
    0
    Регистрация:
    17 мар 2008
    Сообщения:
    1.203
    Код (Text):
    1. he OpenProcess function returns a handle of an existing process object.
    2.  
    3. HANDLE OpenProcess(
    4.  
    5.     DWORD dwDesiredAccess,  // access flag
    6.     BOOL bInheritHandle,    // handle inheritance flag
    7.     DWORD dwProcessId   // process identifier
    8.    );  
    9.  
    10.  
    11. Parameters
    12.  
    13. dwDesiredAccess
    14.  
    15. Specifies the access to the process object. For operating systems that support security checking, this access is checked against any security descriptor for the target process. Any combination of the following access flags can be specified in addition to the STANDARD_RIGHTS_REQUIRED access flags:
    16.  
    17. Access  Description
    18. PROCESS_ALL_ACCESS  Specifies all possible access flags for the process object.
    19. PROCESS_CREATE_PROCESS  Used internally.
    20. PROCESS_CREATE_THREAD   Enables using the process handle in the CreateRemoteThread function to create a thread in the process.
    21. PROCESS_DUP_HANDLE  Enables using the process handle as either the source or target process in the DuplicateHandle function to duplicate a handle.
    22. PROCESS_QUERY_INFORMATION   Enables using the process handle in the GetExitCodeProcess and GetPriorityClass functions to read information from the process object.
    23. PROCESS_SET_INFORMATION Enables using the process handle in the SetPriorityClass function to set the priority class of the process.
    24. PROCESS_TERMINATE   Enables using the process handle in the TerminateProcess function to terminate the process.
    25. PROCESS_VM_OPERATION    Enables using the process handle in the VirtualProtectEx and WriteProcessMemory functions to modify the virtual memory of the process.
    26. PROCESS_VM_READ Enables using the process handle in the ReadProcessMemory function to read from the virtual memory of the process.
    27. PROCESS_VM_WRITE    Enables using the process handle in the WriteProcessMemory function to write to the virtual memory of the process.
    28. SYNCHRONIZE Windows NT only: Enables using the process handle in any of the wait functions to wait for the process to terminate.
    29.  
    30.  
    31. bInheritHandle
    32.  
    33. Specifies whether the returned handle can be inherited by a new process created by the current process. If TRUE, the handle is inheritable.
    34.  
    35. dwProcessId
    36.  
    37. Specifies the process identifier of the process to open.
    38.  
    39.  
    40.  
    41. Return Values
    42.  
    43. If the function succeeds, the return value is an open handle of the specified process.
    44. If the function fails, the return value is NULL. To get extended error information, call GetLastError.
    не в двух сложно.
    в общем открываешь процесс и терминируешь. вот так
    Код (Text):
    1. ;Process ID сам как нибудь получишь (надеюсь)
    2. push [PID]
    3. push 0
    4. push PROCESS_TERMINATE
    5. call [OpenProcess]
    6. test eax, eax
    7. jz .end
    8. push 0
    9. push eax
    10. call [TerminateProcess]
    11. .end
     
  8. wasm_test

    wasm_test wasm test user

    Публикаций:
    0
    Регистрация:
    24 ноя 2006
    Сообщения:
    5.582
    все что есть на си есть и здесь=) всё тот же самый набор апи и та же архитектура процессора. там хендл - дворд и тут хендл дворд.