已得到某个进程aaa.exe打开的一个文件的句柄0x378想要关闭这个句柄 如何操作fileclose不行

解决方案 »

  1.   

    注射进目标进程的话直接CloseHandle($378);
      

  2.   

    否。可以用开远程线程的方式,执行CloseHandle。
      

  3.   

    找了几个代码  只要一执行  目标进程肯定关闭 这可不是我想要的结果我只要把它打开的文件的句柄关了就行program Project1;
    uses
      Windows;function Main(dwEntryPoint: Pointer): longword; stdcall;
    begin
    closehandle(thandle($5fc));
    ExitProcess(0);
    Result := 0;
    end;procedure Inject(ProcessHandle: longword; EntryPoint: pointer);
    var
    Module, NewModule: Pointer;
    Size, BytesWritten, TID: longword;
    begin
    Module := Pointer(GetModuleHandle(nil));
    Size := PImageOptionalHeader(Pointer(integer(Module) + PImageDosHeader(Module)._lfanew + SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage;
    VirtualFreeEx(ProcessHandle, Module, 0, MEM_RELEASE);
    NewModule := VirtualAllocEx(ProcessHandle, Module, Size, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
    WriteProcessMemory(ProcessHandle, NewModule, Module, Size, BytesWritten);
    CreateRemoteThread(ProcessHandle, nil, 0, EntryPoint, Module, 0, TID);
    end;var
    ProcessHandle, PID: longword;begin
    pid:=1412;
    ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, PID);//打开进程
    Inject(ProcessHandle, @Main);//插入代码
    CloseHandle(ProcessHandle);//关闭线程句柄
    end.
      

  4.   

    function Main(dwEntryPoint: Pointer): longword; stdcall;
    begin
    closehandle(thandle($5fc));
    ExitProcess(0);
    Result := 0;
    end;