> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# hookfunction

> Bir target function değerini replacement function ile hook eder ve original target closure için cloned copy döndürür. İki arguments de functions olmalıdır. Function önce pending C function swaps değerlerini flush eder, target değerini function cloning ile cloning yapar, replacement closure veya onun mapped newcclosure target değerini hidden stack tracking içine ekler, target ve cloned original için FixCallstack çağırır, sonra target closure değerini C closure, Luau closure veya newcclosure-specific path üzerinden patch eder. Target henüz hook records içinde değilse cloned original restorefunction için orada saklanır. Returned function cloned original closure değeridir.

<div className="real-function-page">
  ```lua theme={null}
  hookfunction(target: function, replacement: function): function
  ```

  ## Aliaslar

  * `hookfunc`
  * `replaceclosure`
  * `detourfunction`
  * `detour_function`

  ## Argümanlar

  <ParamField path={"target"} type={"function"} required>
    Patch edilecek Function. Non-function vermek type error üretir.
  </ParamField>

  <ParamField path={"replacement"} type={"function"} required>
    Function değeri target içine install veya map edilen Function. Non-function vermek type error üretir.
  </ParamField>

  ## Dönüşler

  <ResponseField name={"original"} type={"function"}>
    Hook install edilmeden önce oluşturulan original target closure cloned copy değeri.
  </ResponseField>

  ## Örnek

  Patch a function closure and keep a cloned original.

  ```lua theme={null}
  local function target(value)
      return value + 1
  end

  local original
  original = hookfunction(target, function(value)
      return original(value) * 2
  end)
  ```
</div>
