Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-12-2023
DarkSton DarkSton is offline
Miembro
 
Registrado: jun 2017
Posts: 64
Poder: 7
DarkSton Va por buen camino
Unhappy eliminar handle

hola amigos estoy tratando de eliminar un handle tipo file

eh probado varia opciones y no me funciona
Responder Con Cita
  #2  
Antiguo 11-12-2023
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.275
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por DarkSton Ver Mensaje
estoy tratando de eliminar un handle tipo file
¿Te refieres a cerrar el ejecutable?
No he entendido muy bien lo que necesitas.


Cita:
Empezado por DarkSton Ver Mensaje
eh probado varia opciones y no me funciona
¿Te da algún error? ¿Qué código has utilizado?
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #3  
Antiguo 11-12-2023
DarkSton DarkSton is offline
Miembro
 
Registrado: jun 2017
Posts: 64
Poder: 7
DarkSton Va por buen camino
Eh buscado en Google y hay un código pero no funciona lo eh probado
Lo otro es que quiero eliminar de allí don de esta la imagen nada más
Código Delphi [-]
   Mostrar menu
Como finalizar uma Handle de um Processo.exe no DELPHI

Delphi
Thread
Olá pessoal,

Estou parado a dias tentando resolver esse problema que é finalizar uma Handle do type [Mutant] e o Nome: \\BaseNamedObjects\\NetCfgWriteLock , 
alguém para me ajudar nesse procedimento, preciso finalizar essa Handle sem que o processo.exe também termine.

Segue o exemplo dessa imagem;

http://3.bp.blogspot.com/-9d7z65gyNr...rer_mutant.png

Agradeço a quem me ajudar;
Eduardo
Eduardo

Curtir tópico
+ 0
RESPONDER
POSTS

19/07/2019

Eduardo
Alguém para me ajuda,,,,,,,,,
RESPONDER
Gostei
+ 0
19/07/2019

Eduardo
O que tem de errado nesse código que a Mutex do skype não finaliza
unit Unit1;
  
interface
  
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, PsAPI;
  
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  
var
  Form1: TForm1;
  
implementation
  
{$R *.dfm}
  
const
SystemHandleInformation       = $10;
STATUS_SUCCESS               = $00000000;
STATUS_BUFFER_OVERFLOW        = $80000005;
STATUS_INFO_LENGTH_MISMATCH   = $C0000004;
DefaulBUFFERSIZE              = $100000;
  
  
type
 OBJECT_INFORMATION_CLASS = (ObjectBasicInformation,ObjectNameInformation,ObjectTypeInformation,ObjectAllTypesInformation,Object  HandleInformation );
  
 SYSTEM_HANDLE=packed record
 uIdProcess:ULONG;
 ObjectType:UCHAR;
 Flags     :UCHAR;
 Handle    :Word;
 pObject   :Pointer;
 GrantedAccess:ACCESS_MASK;
 end;
  
 PSYSTEM_HANDLE      = ^SYSTEM_HANDLE;
 SYSTEM_HANDLE_ARRAY = Array[0..0] of SYSTEM_HANDLE;
 PSYSTEM_HANDLE_ARRAY= ^SYSTEM_HANDLE_ARRAY;
  
  SYSTEM_HANDLE_INFORMATION=packed record
 uCount:ULONG;
 Handles:SYSTEM_HANDLE_ARRAY;
 end;
 PSYSTEM_HANDLE_INFORMATION=^SYSTEM_HANDLE_INFORMATION;
  
 TNtQuerySystemInformation=function (SystemInformationClassWORD; SystemInformationointer; SystemInformationLengthWORD;  ReturnLength:PDWORD):THandle; stdcall;
 TNtQueryObject           =function (ObjectHandle:cardinal; ObjectInformationClass:OBJECT_INFORMATION_CLASS; ObjectInformationointer; Length:ULONG;ResultLength:PDWORD):THandle;stdcall;
  
 UNICODE_STRING=packed record
    Length       :Word;
    MaximumLength:Word;
    Buffer       :PWideChar;
 end;
  
 OBJECT_NAME_INFORMATION=UNICODE_STRING;
 POBJECT_NAME_INFORMATION=^OBJECT_NAME_INFORMATION;
  
Var
 NTQueryObject           :TNtQueryObject;
 NTQuerySystemInformation:TNTQuerySystemInformation;
  
function GetObjectInfo(hObject:cardinal; objInfoClass:OBJECT_INFORMATION_CLASS):LPWSTR;
var
 pObjectInfo:POBJECT_NAME_INFORMATION;
 HDummy     :THandle;
 dwSize     WORD;
begin
  Result:=nil;
  dwSize      := sizeof(OBJECT_NAME_INFORMATION);
  pObjectInfo := AllocMem(dwSize);
  HDummy      := NTQueryObject(hObject, objInfoClass, pObjectInfo,dwSize, @dwSize);
  
  if((HDummy = STATUS_BUFFER_OVERFLOW) or (HDummy = STATUS_INFO_LENGTH_MISMATCH)) then
    begin
   FreeMem(pObjectInfo);
   pObjectInfo := AllocMem(dwSize);
   HDummy      := NTQueryObject(hObject, objInfoClass, pObjectInfo,dwSize, @dwSize);
  end;
  
  if((HDummy >= STATUS_SUCCESS) and (pObjectInfo.Buffer <> nil)) then
  begin
   Result := AllocMem(pObjectInfo.Length + sizeof(WCHAR));
   CopyMemory(result, pObjectInfo.Buffer, pObjectInfo.Length);
  end;
  FreeMem(pObjectInfo);
end;
  
procedure TForm1.Button1Click(Sender: TObject);
var
 sDummy      : string;
 hProcess    : THandle;
 hObject     : THandle;
 ResultLength: DWORD;
 aBufferSize : DWORD;
 aIndex      : Integer;
 pHandleInfo : PSYSTEM_HANDLE_INFORMATION;
 HDummy      : THandle;
 lpwsName    : PWideChar;
 lpwsType    : PWideChar;
 lpszProcess : PAnsiChar;
begin
  try
    NTQueryObject            := GetProcAddress(GetModuleHandle('NTDLL.DLL'), 'NtQueryObject');
    NTQuerySystemInformation := GetProcAddress(GetModuleHandle('NTDLL.DLL'), 'NtQuerySystemInformation');
   if (@NTQuerySystemInformation<>nil) and (@NTQuerySystemInformation<>nil) then
    AbufferSize      := DefaulBUFFERSIZE;
  pHandleInfo      := AllocMem(AbufferSize);
  HDummy           := NTQuerySystemInformation(DWORD(SystemHandleInformation), pHandleInfo,AbufferSize, @ResultLength);  //Get the list of handles
  
  if(HDummy = STATUS_SUCCESS) then  //If no error continue
    begin
  
      for aIndex:=0 to pHandleInfo^.uCount-1 do   //iterate the list
      begin
    hProcess := OpenProcess(PROCESS_DUP_HANDLE or PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, FALSE, pHandleInfo.Handles[aIndex].uIdProcess);  //open the process to get aditional info
    if(hProcess <> INVALID_HANDLE_VALUE) then  //Check valid handle
    begin
     hObject := 0;
     if DuplicateHandle(hProcess, pHandleInfo.Handles[aIndex].Handle,GetCurrentProcess(), @hObject, STANDARD_RIGHTS_REQUIRED,FALSE, 0) then  //Get  a copy of the original handle
     begin
      lpwsName := GetObjectInfo(hObject, ObjectNameInformation); //Get the filename linked to the handle
      if (lpwsName <> nil)  then
      begin
       lpwsType    := GetObjectInfo(hObject, ObjectTypeInformation);
       lpszProcess := AllocMem(MAX_PATH);
  
       if GetModuleFileNameEx(hProcess, 0,lpszProcess, MAX_PATH)<>0 then  //get the name of the process
       begin
        sDummy:=ExtractFileName(lpszProcess);
        end
          else
            sDummy:= 'System Process';
            if lpwsName = '\\Sessions\\1\\BaseNamedObjects\\SkypeMutex' then
            begin
              ShowMessage('Found And Killed');
              CloseHandle(pHandleInfo.Handles[aIndex].Handle);
            end;
  
              FreeMem(lpwsName);
              FreeMem(lpwsType);
              FreeMem(lpszProcess);
      end;
      CloseHandle(hObject);
     end;
     CloseHandle(hProcess);
    end;
   end;
  end;
  finally
  FreeMem(pHandleInfo);
  end;
end;
  
end.
Esto es en mutan

Última edición por Neftali [Germán.Estévez] fecha: 11-12-2023 a las 12:32:14. Razón: Saltos de línea
Responder Con Cita
  #4  
Antiguo 11-12-2023
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.275
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
¿Te refieres a cerrar el ejecutable?
No he entendido muy bien lo que necesitas.
¿Te da algún error?
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #5  
Antiguo 11-12-2023
DarkSton DarkSton is offline
Miembro
 
Registrado: jun 2017
Posts: 64
Poder: 7
DarkSton Va por buen camino
Me refiero a la función de hacer clic derecho y close handle en la parte baja de la imagen donde dice files. E:/delphi7/panel GB retzu
Cerrar el ejecutable si sé.
Responder Con Cita
  #6  
Antiguo 11-12-2023
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.275
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Aquí tienes un hilo en el foro que utiliza la API de Windows CloseHandle, que creo que es la que necesitas:
https://www.clubdelphi.com/foros/showthread.php?t=48150

Si buscas encontrarás más, a ver si te sirve de algo.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #7  
Antiguo 11-12-2023
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Yo no comprendo muy bien la pregunta. Cerrar el Handle de un archivo es cerrar el archivo. Si el archivo es un ejecutable no se puede cerrar mientras el ejecutable se esté ejecutando.
Quizás lo que pretende DarkSton sea esconder el ejecutable de cualquier visor de procesos. Si esa es la pregunta, la cuestión no es fácil y pasa por estudiar varias estructuras del Kernel y programar un Driver ó inyectarse en el explorador de procesos para camuflar el archivo. De esto último hay algún ejemplo en CD.


Saludos.
Responder Con Cita
  #8  
Antiguo 16-12-2023
DarkSton DarkSton is offline
Miembro
 
Registrado: jun 2017
Posts: 64
Poder: 7
DarkSton Va por buen camino
dsculpen la molesta , lo que quiero es eliminar este archivo

es un archivo 0bytes lo cual no puedo eliminar
la unica forma de eliminar es asi
Responder Con Cita
  #9  
Antiguo 16-12-2023
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Si es un fichero temporal abierto por algún programa, tendrás que cerrar el programa que lo ha abierto.
Responder Con Cita
  #10  
Antiguo 16-12-2023
DarkSton DarkSton is offline
Miembro
 
Registrado: jun 2017
Posts: 64
Poder: 7
DarkSton Va por buen camino
lo que pasa que no quiero cerrar el ejecutable
Responder Con Cita
  #11  
Antiguo 16-12-2023
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.040
Poder: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Ya suponemos el motivo.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Handle de objetos juank1971 OOP 2 09-06-2012 19:10:54
TComponent y Handle ixMike OOP 5 12-10-2007 13:45:52
Handle disabled carlos_nielsen API de Windows 11 15-01-2007 02:23:23
ayuda comparar Handle JerS API de Windows 3 30-10-2006 20:19:01
Obtener Handle de un objeto senpiterno Varios 6 22-04-2004 15:21:40


La franja horaria es GMT +2. Ahora son las 19:37:00.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi