COBRA Payload Integration in webMAN MOD for Disc Emulation: Technical Architecture Explained

webMAN MOD integrates the COBRA payload to translate ISO mounts into kernel-level virtual disc operations using sys_storage_ext_* syscalls, enabling seamless disc emulation on Cobra-based Custom Firmware (CFW).

The aldostools/webman-mod repository ships with a dedicated cobra/ directory containing the COBRA payload that is compiled into the final PRX plugin. This integration allows webMAN MOD to present ISO files as physical Blu-ray, DVD, or PlayStation discs to the PlayStation 3 system, but only when running on a Cobra-based CFW. Understanding this COBRA payload integration in webMAN MOD for disc emulation reveals how the plugin bridges user-space ISO selection with kernel-level storage extensions.

COBRA Detection and Initialization

At startup, webMAN MOD detects whether the underlying CFW supports COBRA by checking the Cobra version in main.c. This version check gates all COBRA-specific functionality behind compile-time and runtime guards.

static u16 cobra_version = 0;
static void sys_get_cobra_version(void);

If cobra_version returns non-zero, webMAN MOD registers its storage callbacks and enables the COBRA code paths wrapped in #ifdef COBRA_ONLY blocks. This design ensures the same binary remains compatible with both COBRA and non-COBRA systems.

The COBRA Storage API Architecture

The COBRA payload exposes a high-level API through cobra/cobra.h and implements kernel wrappers in cobra/cobra.c. These files define the CobraConfig structure and function prototypes that webMAN MOD uses to control disc emulation, region spoofing, and hardware settings.

Key functions in the COBRA storage API include:

  • cobra_mount_ps3_disc_image() – Mounts PlayStation 3 ISO files as virtual Blu-ray discs
  • cobra_send_fake_disc_insert_event() – Triggers XMB UI updates simulating physical disc insertion
  • cobra_get_disc_type() – Retrieves current disc type information for validation
  • cobra_map_game() – Maps games to virtual discs for disc-less launching

Mounting ISO Images as Virtual Discs

When a user selects an ISO through the web interface or network share, webMAN MOD builds an array of ISO file paths and invokes the appropriate COBRA mount routine. This logic resides in include/mount/mount_cobra.h.

/* mount_cobra.h – part of the mount routine */
char *cobra_iso_list[iso_parts];
char iso_list[iso_parts][path_len + 2];
...
cobra_iso_list[0] = (char *)iso_list[0];
...
cobra_mount_ps3_disc_image(cobra_iso_list, iso_parts);
sys_ppu_thread_usleep(2500);
cobra_send_fake_disc_insert_event();

The cobra_mount_ps3_disc_image() function in cobra/cobra.c forwards these file lists to the kernel through sys_storage_ext_mount_ps3_discfile:

/* cobra.c – PS3 disc mount wrapper */
int cobra_mount_ps3_disc_image(char *files[], unsigned int num)
{
    if (!files) return EINVAL;
    return sys_storage_ext_mount_ps3_discfile(num, files);
}

Simulating Disc Insertion and Ejection Events

After mounting the ISO, webMAN MOD must notify the XMB that a disc has been inserted. The COBRA payload provides cobra_send_fake_disc_insert_event() to trigger these UI updates without physical drive activity.

int cobra_send_fake_disc_insert_event(void)
{
    u64 param;
    unsigned int real_disctype, effective_disctype, iso_disctype;
    cobra_get_disc_type(&real_disctype, &effective_disctype, &iso_disctype);
    param = (u64)(ejected_realdisc) << 32ULL;
    sys_storage_ext_fake_storage_event(7, 0, BDVD_DRIVE);
    return sys_storage_ext_fake_storage_event(3, param, BDVD_DRIVE);
}

This function queries the current disc type, constructs the appropriate parameter, and invokes sys_storage_ext_fake_storage_event to simulate both the disc ejection (event 7) and insertion (event 3) sequences.

Configuration and Hardware Control

Beyond disc emulation, the COBRA payload integration enables runtime configuration through the CobraConfig structure defined in cobra/cobra.h. WebMAN MOD reads and writes this configuration via include/www/www_start.h to control:

  • Region spoofing settings
  • Fan speed management
  • PS2 netemu configuration
  • Disc-less boot parameters

Functions like cobra_read_config() and cobra_write_config() provide the interface between webMAN MOD's web interface and the kernel-level COBRA settings.

Summary

  • COBRA payload integration in webMAN MOD enables kernel-level disc emulation exclusively on Cobra-based CFW through the cobra/ directory compiled into the PRX.
  • Detection mechanism in main.c checks cobra_version at startup to gate COBRA-specific functionality behind #ifdef COBRA_ONLY blocks.
  • Storage API in cobra/cobra.c wraps sys_storage_ext_* syscalls to mount ISO files, simulate disc events, and manage virtual disc types.
  • Mount workflow in include/mount/mount_cobra.h builds ISO file lists and invokes cobra_mount_ps3_disc_image() followed by fake insert events.
  • Configuration interface through CobraConfig in cobra/cobra.h allows runtime control of region, fan speed, and emulation settings via include/www/www_start.h.

Frequently Asked Questions

How does webMAN MOD detect if COBRA is available on the system?

At initialization in main.c, webMAN MOD calls sys_get_cobra_version() to populate the static cobra_version variable. If this returns a non-zero value, the plugin enables all COBRA-specific code paths wrapped in #ifdef COBRA_ONLY preprocessor directives, ensuring compatibility with both COBRA and non-COBRA firmware.

What kernel syscalls does the COBRA payload use for disc emulation?

The COBRA payload in cobra/cobra.c utilizes the sys_storage_ext_* syscall family provided by Cobra CFW. Key syscalls include sys_storage_ext_mount_ps3_discfile() for mounting ISO images, sys_storage_ext_fake_storage_event() for simulating disc insert/eject events, and sys_storage_ext_get_disc_type() for retrieving virtual disc information.

Can webMAN MOD mount multi-part ISO files using COBRA?

Yes, webMAN MOD supports multi-part ISO files through the COBRA payload. In include/mount/mount_cobra.h, the code builds an array of file paths (cobra_iso_list) where each element points to a segment of the split ISO. This array is passed to cobra_mount_ps3_disc_image(), which forwards the complete file list to the kernel via sys_storage_ext_mount_ps3_discfile().

How does webMAN MOD simulate physical disc insertion without hardware?

After mounting an ISO, webMAN MOD calls cobra_send_fake_disc_insert_event() defined in cobra/cobra.c. This function first queries the current disc type using cobra_get_disc_type(), then invokes sys_storage_ext_fake_storage_event() twice—first with event type 7 (eject) and then with event type 3 (insert)—to trigger the XMB UI updates without any physical drive activity.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →