Repository navigation
Conversation
A script proc-ptr variable is three pointer-sized slots (ProcNo, Self, Ptr), and the runtime treats Self/Ptr as a native method only when ProcNo = 0 (CM_PV in TPSExec.RunLine). The btProcPtr result of an invoked function was written as a bare TMethod, which put Code into ProcNo, so calling the returned procedure from the script failed with "Out of Proc Range". Repro: register a Delphi function that returns a TMethod (Data = nil, Code = a plain procedure) as "function GetCB : TCB;" with TCB = procedure(var x : Integer; var y : Integer), then in the script "CB := GetCB; CB(X, Y);". Before: runtime error "Out of Proc Range" on the call, Win32 and Win64 (Delphi 13, InvokeCall path). After: the Delphi procedure runs and writes X and Y back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A script proc-ptr variable is three pointer-sized slots
(ProcNo, Self, Ptr), and the runtime treatsSelf/Ptras a native method only whenProcNo = 0(theCM_PVcase inTPSExec.RunLine). InInvokeCall.incthebtProcPtrresult of an invoked function is written as a bareTMethod, which putsCodeintoProcNo. Calling the returned procedure from the script then fails with "Out of Proc Range".Repro
Script:
Change
The result is written in the proc-ptr layout:
ProcNo := 0, thenSelf := Data,Ptr := Code, i.e. the same layout the runtime builds for a native method elsewhere.Testing
Delphi 13 (InvokeCall path, the default since Delphi 10.1), Win32 and Win64, current master:
Out of Proc Rangeon theCB(X, Y)line.X = 600,Y = 800.