Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dogbait module #534

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions iop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SUBDIRS = \
sound \
startup \
system \
system2x6 \
tcpip \
usb

Expand Down
12 changes: 12 additions & 0 deletions iop/system2x6/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

SUBDIRS = dogbait

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/Rules.make
16 changes: 16 additions & 0 deletions iop/system2x6/dogbait/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2009, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.

IOP_BIN = dogbait.irx
IOP_SRC_DIR = src/
IOP_OBJS = main.o imports.o

include $(PS2SDKSRC)/Defs.make
include $(PS2SDKSRC)/iop/Rules.bin.make
include $(PS2SDKSRC)/iop/Rules.make
include $(PS2SDKSRC)/iop/Rules.release
28 changes: 28 additions & 0 deletions iop/system2x6/dogbait/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Dogbait

This module provides a thread to trick the namco arcade system 246/256 watchdog, to avoit it from shutting down the machine if security dongle is not connected for some time.

it's main purpose is to prevent the watchdog from shutting down the system. while keeping a safe access to security dongle

## How to use this module in your program

Use `SifLoadStartModule` or `LoadModuleBuffer` directly.

due to the purpose of this module, checking if the module loaded successfully and stayed resident on IOP is important

like this:
```c
int ret, id;
id = LoadModuleBuffer(dogbait_irx, size_dogbait_irx, 0, NULL, &ret);
if (id<0 || ret == 1) we_have_an_error();
```

If the module fails to load, please let know the user that the machine will shutdown in a few minutes.

Of course, if your app does not involve access to any memory card/security dongle, then loading the following modules in order and keeping a security dongle plugged will also satisfy the watchdog
```
rom0:SIO2MAN
rom0:MCMAN
rom0:LED
rom0:DAEMON
```
17 changes: 17 additions & 0 deletions iop/system2x6/dogbait/src/imports.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
thbase_IMPORTS_start
I_CreateThread
I_StartThread
I_DelayThread
thbase_IMPORTS_end

stdio_IMPORTS_start
I_printf
stdio_IMPORTS_end

intrman_IMPORTS_start
I_CpuEnableIntr
intrman_IMPORTS_end

cdvdman_IMPORTS_start
I_sceCdApplySCmd
cdvdman_IMPORTS_end
26 changes: 26 additions & 0 deletions iop/system2x6/dogbait/src/irx_imports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2009, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
#
# Defines all IRX imports.
*/

#ifndef IOP_IRX_IMPORTS_H
#define IOP_IRX_IMPORTS_H

#include <irx.h>

/* Please keep these in alphabetical order! */

#include <intrman.h>
#include <loadcore.h>
#include <cdvdman.h>
#include <stdio.h>
#include <thbase.h>

#endif /* IOP_IRX_IMPORTS_H */
54 changes: 54 additions & 0 deletions iop/system2x6/dogbait/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "irx_imports.h"

#define MODNAME "dogbait"
#define MAJOR 1
#define MINOR 0

#ifdef DEBUG
#define DPRINTF(fmt, x...) printf(MODNAME ": " fmt, ##x)
#else
#define DPRINTF(x...)
#endif

IRX_ID(MODNAME, MAJOR, MINOR);
char rdata[16];
char wdata[1] = {0x42};

//the loop waiting was made to mirror what rom0:DAEMON did
void bait(void*)
{
int x;
printf("DOGBAIT v%d.%d by El_isra\n", MAJOR, MINOR);
do {
#ifdef DEBUG
x =
#endif
//thanks uyjulian for the idea. arcade CDVDMAN has the blue led control export stubbed so directly calling the CMD was the only choice
sceCdApplySCmd(0x03, wdata, sizeof(wdata), rdata);
DPRINTF("sceCdApplySCmd(0x03, %x) ret %d\n", wdata[0], x);
x = 0x3c;
while (0 < x) {
DelayThread(1000000);
x = x + -1;
}
} while(1);
}

int _start(int argc, char** argv)
{
int x;
iop_thread_t T;
CpuEnableIntr();
T.attr = 0x2000000;
T.thread = bait;
T.priority = 0x7e;
T.stacksize = 0x800;
T.option = 0;
x = CreateThread(&T);
if (x > 0) {
DPRINTF("Starting Thread\n");
StartThread(x,0);
return MODULE_RESIDENT_END;
} else {DPRINTF("CreateThread: %d\n", x);}
return MODULE_NO_RESIDENT_END;
}