> ## 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.

# restorefunction

> 内部で function hook operation を呼び出して function を復元または置き換え、values は返しません。first argument は function である必要があります。function argument が 1 つの場合、function は the saved original function を検索します。entry が存在しない場合は "Function is not hooked" を発生させます。その後、hooked closure と stored original closure で function hook operation を呼び出し、Lua stack をクリアし、stored original が使われた場合は restored closure を hook records から削除します。second argument も function の場合、function は firstFunction をインストールする original function、secondFunction を patch する closure として扱います。この形式では、保存された hook records 値に対する missing-original check は行われません。保存された値は final remove check でのみ比較されます。 にのみ使われます。non-function second arguments は branch condition によって無視されます。restorefunc と restoreclosure は同じ function の aliases です。

<div className="real-function-page">
  ```lua theme={null}
  restorefunction(firstFunction: function, secondFunction?: function)
  ```

  ## エイリアス

  * `restorefunc`
  * `restoreclosure`

  ## 引数

  <ParamField path={"firstFunction"} type={"function"} required>
    1 つの argument では hook records から復元する hooked closure。function second argument がある場合は secondFunction にインストールする function。
  </ParamField>

  <ParamField path={"secondFunction"} type={"function"}>
    firstFunction で patch する optional closure。この branch は second argument が function の場合にのみ使われます。
  </ParamField>

  ## 例

  Restore a hooked closure to its original function.

  ```lua theme={null}
  local function target()
      return "original"
  end

  hookfunction(target, function()
      return "hooked"
  end)

  print(target())

  restorefunction(target)

  print(target())
  ```
</div>
