# buryarg.TWL

## Description

This command is for TWL ROMs. See `buryarg` for details on NITRO ROMs.

In TWL-SDK, an area for argument data is set up in the ROM image. By rewriting this section before startup, you can pass which parameters are possible to use as C language argc and argv format arguments. The ROM image file can be directly overwritten, so you can test the program under multiple conditions without having to recompile.

`buryarg.TWL` is a tool for writing argument data to the argument data area for the specified binary data. This tool is used with TWL ROMs (both NITRO/TWL hybrid ROMs and TWL-exclusive ROMs); use `buryarg` on NITRO ROMs.

Unlike `buryarg`, the `buryarg.TWL` command writes argument data to the ROM header region. With NITRO ROMs, if the argument data is not referenced, the region was not created. With TWL ROMs, on the other hand, `buryarg.TWL` can be used because the region exists regardless of whether it is referenced or not.

However, argument data embedded for TWL hybrid ROM builds cannot be loaded in NITRO mode.

## Using the Tool

### Start Command

`% buryarg.TWL [OPTION]... TWLSRLFILE [argument]...`

`TWLSRLFILE` is the original ROM file to overwrite. Normally, this is a .srl file. However, if you specify a .tlf file, it will be analyzed, and the operation will be done on the header binary.

If the `-r or --remain` options are specified, the original file will remain. By default, the original file will be modified. So if you don't want to change the original file, specify this option. The alias filename is the original filename plus `.argAdded`. When the output file is selected with `-o` option, the original file will not be changed, even when this option is not specified.

The -o and --output options take arguments. With this option, the output file is specified as in the following: `-o=dest.srl` or `-o dest.srl`. Do not specify the same file as the original file for the output file. Also, if "`-`" (minus) is specified as the output file, output goes to standard output.( Specify as: `-o-`. See `--stdout`, which is explained below.

`--stdout` is the same as specifying `-o-`. It outputs to standard output.

The `-f` and `--file` options take arguments. These options are for specifying a file as the data to replace. Specify as: `-f=rep.dat` or `-f rep.dat`.

If the `-q` or `--quiet` option is specified, quiet mode is used, and only error messages will be output.

If the `-v` or `--verbose` option is specified, detailed operation descriptions are displayed. Because output is made on the standard output, do not specify these options together when writing ROM data to the standard output.

The `-h` or `--help` options display simple instructions.

The `-d` or `--debug` options are for debugging. They dump the data that is to be replaced.

The `--version` option displays the command version.

### Argument Data Area

As stated earlier, the argument data region for TWL ROMs is located in the ROM header. By overwriting this region, different parameters can be passed to the ROM without having to recompile.

Caution: Be careful to avoid the following errors.

> - You specified the same file as the input file with the `-o` option.
> &rarr; This specification is not required if you want to overwrite the argument data. This is the default behavior.

> - You overwrote the argument data for the SRL file. Then started up from the TLF file.
> &rarr; When an application is started from a TLF file, the modules included in the TLF file will be read by the debugger, so even if the SRL file is overwritten, those changes will not be applied. If starting an application from a TLF file, be sure to specify the TLF file with `buryarg.TWL` and overwrite the necessary data.

> - You overwrote the argument data for the TLF file. Then started up the SRL file.
> &rarr; This is the opposite of the example above. Overwrite the argument data for the SRL file.

> - You tried to overwrite the argument data on a FINALROM build image.
> &rarr; Argument data can be written even for FINALROM build images. However, `OS_GetArgc()` will always return 0, and `OS_GetArgv()` will always return `NULL`.

> - You tried to overwrite the argument data on a NITRO mode ROM.
> &rarr; Only TWL ROMs can be overwritten with this command. For NITRO mode ROMs, use the `buryarg` command instead of `buryarg.TWL`.

### FINALROM and Argument Data

Argument data cannot be handled with a FINALROM. The `OS_GetArgc` function always returns 0, and the `OS_GetArgv` function always returns `NULL`. The reason that argument data cannot be handled for FINALROM builds is that a security hole may develop if a program depends on data that can be provided externally. Argument data is embedded as plain text without encryption or other encoding.

Argument data can be embedded even in the case of FINALROM builds, and the check routine inside programs remains as long as it is not deleted. Attention is required because this data and code is meaningless in the case of FINALROM builds. (For example, for a game with 30 stages, analysis is made of a check routine such as "STAGE = 50" may lead to the assumption that there may be a hidden stage.)

## Location

`$TwlSDK/tools/bin/buryarg.TWL.exe`

## See Also

`buryarg`
`OS_GetArgc`
`OS_GetArgv`
`OS_GetOpt*`

## Revision History

2008/07/08 Clarified that `buryarg` is used for NITRO.
2008/06/24 Added the fact that this mechanism cannot be used with TWL.
2005/08/30 Added the `OS_GetOpt*` function to See Also. Added `--stdout`.
2005/07/22 Support for NLF files.
2005/07/21 Initial version.

CONFIDENTIAL