Advertisement
Guest User

Untitled

a guest
Dec 19th, 2011
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.37 KB | None | 0 0
  1. Index: sfx/level2/main.pas
  2. ===================================================================
  3. --- sfx/level2/main.pas (wersja 1134)
  4. +++ sfx/level2/main.pas (kopia robocza)
  5. @@ -5,12 +5,58 @@
  6.  interface
  7.  
  8.  uses
  9. -  windows, Classes, SysUtils, zstream;
  10. +  jwawindows, windows, Classes, SysUtils, zstream;
  11.  
  12.  procedure launch;
  13.  
  14.  implementation
  15.  
  16. +function GetParentProcessFileName(PID : THandle): String;
  17. +var
  18. +  HandleSnapShot      : THandle;
  19. +  EntryParentProc     : TProcessEntry32;
  20. +  HandleParentProc    : THandle;
  21. +  ParentPID           : THandle;
  22. +  ParentProcessFound  : Boolean;
  23. +  ParentProcPath      : PChar;
  24. +begin
  25. +  ParentProcessFound := False;
  26. +  HandleSnapShot     := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  27. +  GetMem(ParentProcPath, MAX_PATH);
  28. +  try
  29. +    if HandleSnapShot <> INVALID_HANDLE_VALUE then
  30. +    begin
  31. +      EntryParentProc.dwSize := SizeOf(EntryParentProc);
  32. +      if Process32First(HandleSnapShot, EntryParentProc) then
  33. +      begin
  34. +        repeat
  35. +          if EntryParentProc.th32ProcessID = PID then
  36. +          begin
  37. +            ParentPID  := EntryParentProc.th32ParentProcessID;
  38. +            HandleParentProc  := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False,ParentPID);
  39. +            ParentProcessFound:= HandleParentProc <> 0;
  40. +            if ParentProcessFound then
  41. +            begin
  42. +                GetModuleFileNameEx(HandleParentProc, 0, ParentProcPath, MAX_PATH);
  43. +                CloseHandle(HandleParentProc);
  44. +            end;
  45. +            break;
  46. +          end;
  47. +        until not Process32Next(HandleSnapShot, EntryParentProc);
  48. +      end;
  49. +      CloseHandle(HandleSnapShot);
  50. +    end;
  51. +
  52. +    if ParentProcessFound then
  53. +      Result := ParentProcPath
  54. +    else
  55. +      Result := ''; //not found
  56. +  finally
  57. +      FreeMem(ParentProcPath);
  58. +  end;
  59. +end;
  60. +
  61. +
  62.  function DeleteFolder(dir: string) : boolean;
  63.  var
  64.    DirInfo: TSearchRec;
  65. @@ -72,7 +118,16 @@
  66.  
  67.    filelist:=TStringList.create;
  68.  
  69. +  filename:=StringReplace(GetParentProcessFileName(GetCurrentProcessID),
  70. +                          ExtractFileName(GetModuleName(0)),'',[]);
  71.  
  72. +  if Length(filename)>0 then
  73. +  begin
  74. +    outfile:=tfilestream.Create(launchdir+'TrainerRealPath.txt', fmCreate);
  75. +    outfile.Write(filename[1],Length(filename));
  76. +    outfile.free;
  77. +  end;
  78. +
  79.    if FileExists(archivename) then
  80.    begin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement