---
title: hook_param
description: Retrieve the parameter value for a named hook parameter
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

### Behaviour

<Tabs>
<TabItem label="C">
* Look up the value for a named parameter specified in `read_ptr`
* Write the parameter's value to `write_ptr`
</TabItem>

<TabItem label="JavaScript">
* Retrieve the value of a parameter associated with the specified key.
* Returns the value associated with the key, or an error code if the retrieval fails.
</TabItem>
</Tabs>

### Definition

<Tabs>
<TabItem label="C">
```c
int64_t hook_param (
    uint32_t write_ptr,
    uint32_t write_len,
    uint32_t read_ptr,
    uint32_t read_len
);
```
</TabItem>

<TabItem label="JavaScript">
```javascript
function hook_param(key: ByteArray | HexString): ErrorCode | ByteArray
```
</TabItem>
</Tabs>



### Example

<Tabs>
<TabItem label="C">
```c
uint8_t pname[] = {0xCAU, 0xFEU};
uint8_t pvalue[32];
int64_t value_len = 
    hook_param(pvalue, 32, pname, 2);
```
</TabItem>

<TabItem label="JavaScript">
```javascript
const pname = [0xCA, 0xFE]
const pvalue = hook_param(pname)
```
</TabItem>
</Tabs>



### Parameters

<Tabs>
<TabItem label="C">
| Name       | Type      | Description                                                                              |
| ---------- | --------- | ---------------------------------------------------------------------------------------- |
| write_ptr | uint32_t | Pointer to a buffer of a suitable size to store the output. Should be at least 32 bytes. |
| write_len | uint32_t | Length of the output buffer.                                                             |
| read_ptr  | uint32_t | Pointer to a buffer containing the parameter's name                                      |
| read_len  | uint32_t | Length of the parameter's name                                                           |


</TabItem>

<TabItem label="JavaScript">


| Name | Type                   | Description                                        |
| ---- | ---------------------- | -------------------------------------------------- |
| key  | ByteArray or HexString | The key for which to retrieve the parameter value. |
</TabItem>
</Tabs>



### Return Code

<Tabs>
<TabItem label="C">
| Type     | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| int64_t | <p>The number of bytes written<br /><br />If negative, an error:<br /><code>OUT_OF_BOUNDS</code><br />- pointers/lengths specified outside of hook memory.<br /><br /><code>DOESNT_EXIST</code><br />- The specified paramater doesn't exist or is null<br /><br /><code>TOO_SMALL</code><br />- The parameter name can't be null<br /><br /><code>TOO_BIG</code><br />- The parameter name is greater than 32 bytes</p> |


</TabItem>

<TabItem label="JavaScript">


| Type                   | Description                                                                         |
| ---------------------- | ----------------------------------------------------------------------------------- |
| ByteArray or ErrorCode | Returns the value associated with the key, or an error code if the retrieval fails. |
</TabItem>
</Tabs>

