Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$loadlib ..\Includes\SRL\plugins\libremoteinput}
- type
- TRemoteInput = record
- FImage: TExternalImage;
- EIOS: Pointer;
- PID: Int32;
- end;
- procedure TRemoteInput.Setup;
- const
- RS_EXECUTABLE = {$IFDEF WINDOWS}'JagexLauncher.exe'{$ELSE}'java'{$ENDIF};
- begin
- {$IFNDEF SIMBAHEADLESS}
- if (Self.PID = 0) then
- Self.PID := GetSimbaTargetPID();
- {$ENDIF}
- try
- if (Self.PID = 0) then
- begin
- if (ShowQuestionDialog('SRL', 'Automatically try to find a RS client?') = False) then
- raise 'No RS clients found';
- RIInject(RS_EXECUTABLE, Self.PID);
- end else
- RIInject(Self.PID);
- Self.EIOS := EIOS_PairClient(Self.PID);
- if (Self.EIOS <> nil) then
- Target.SetEIOS('..\Includes\SRL\plugins\libremoteinput', ToString(Self.PID));
- except
- WriteLn(GetExceptionMessage());
- end;
- end;
- function TRemoteInput.IsSetup: Boolean;
- begin
- Result := (Self.PID > 0);
- end;
- property TRemoteInput.Image: TExternalImage;
- begin
- if (Self.FImage = nil) then
- begin
- EIOS_SetGraphicsDebugging(Self.EIOS, True);
- Self.FImage := TExternalImage.Create();
- Self.FImage.SetMemory(PColorBGRA(EIOS_GetDebugImageBuffer(Self.EIOS)), Target.Width, Target.Height);
- (*
- Self.Image.SetPersistentMemory(
- PtrUInt(EIOS_GetDebugImageBuffer(Self.EIOS)),
- Target.Width, Target.Height
- );
- *)
- Self.FImage.BeginUpdate();
- Self.FImage.Clear();
- Self.FImage.EndUpdate();
- end;
- Result := Self.FImage;
- end;
- function EIOS_GetClientPIDs: TIntegerArray;
- var
- I: Int32;
- begin
- for I := 0 to EIOS_GetClients(True) - 1 do
- Result += EIOS_GetClientPID(I);
- end;
- //function EIOS_PairClient(Pid: Int32): Pointer; override;
- //begin
- // Result := inherited();
- // if (Result = nil) then
- // raise 'Failed to pair client';
- //end;
- procedure RIInject(PID: Int32); override;
- var
- PIDs: TIntegerArray;
- begin
- inherited();
- if (not SleepUntil(Length(PIDs := EIOS_GetClientPIDs()) > 0, 100, 1000) and (Pids.Contains(Pid))) then
- raise 'Failed to inject into pid ' + ToString(pid);
- end;
- procedure RIInject(ProcessName: String; out PID: Int32); overload;
- var
- PIDs: TIntegerArray;
- begin
- RIInject(ProcessName);
- if (not SleepUntil(Length(PIDs := EIOS_GetClientPIDs()) > 0, 100, 1000)) then
- raise 'Failed to inject into "' + ProcessName + '"';
- PID := PIDs[0];
- end;
- var RI: TRemoteInput;
- begin
- RI.Setup();
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement