Hacking Wii disc dumper v1.0 released by nitrotux

linkinworm

Well-Known Member
Member
Joined
May 30, 2008
Messages
1,599
Trophies
1
Age
33
Location
Birmingham (England)
XP
1,982
Country
why is it that dumping takes the piss on all dumpers so far? i know it has to read the disk more closely them move that data to the sd card but come on, there must be some way to speed it up, could you not write some data to the cashe of the drive or something as a read ahead to speed shit up? sorry about this seeming nooby but i havnt really done much with the wiidrive, but i would really like the back up some games befor i turn 20
 

ProdigySim

Well-Known Member
Member
Joined
Nov 23, 2005
Messages
191
Trophies
0
XP
145
Country
United States
Does this app buffer data in memory or does it directly read the data from the disc out to the SD card?

If someone threaded this thing and put a big memory buffer in between the two it would probably speed up a bit.
 

djcraze

Well-Known Member
Member
Joined
Jun 19, 2008
Messages
159
Trophies
1
XP
409
Country
United States
Ok, so I thought that it would take 7 hours for the entire game.. But apparantly its for the 1500MB O_O.. so 7 * 5 is 35 hours to rip a Dual-Layer game.. Ehh I think i'll stick to my LG for now, however nice additions caitsith2
smile.gif
.
 

spliffdizzle

Active Member
Newcomer
Joined
May 2, 2008
Messages
36
Trophies
1
XP
237
Country
United States
QUOTE said:
QUOTE(drfsupercenter @ Jul 14 2008, 02:53 AM)
Maybe the guy who said it was 2MB short ran out of room on the SD card? LOL


I'm not sure. It's possible, but it would print a write error in that case.
I've also read that Wasabi users are having trouble reading certain parts of a GC/Wii disc.

Just to clarify (late to the party, I know), the SD card should not have ran out of space. I dumped, part 0.bin, moved it off to my PC, put the SD card back in and dumped part 1.bin, moved it to PC, put it back in and dumped part 2.bin. I also tried dumping just part 2.bin with a freshly formatted SD card, so no space problems there. Same error every time. If nitrotux wants the specific error displayed on screen, I'll get it for ya.

lecture.gif
And FYI, I have a CycloWiz with 3.6b installed, not a Wasabi...
 

nitrotux

Well-Known Member
OP
Newcomer
Joined
Jun 24, 2008
Messages
60
Trophies
0
XP
26
Country
United States
Ah.

I forgot to mention, you need to reboot the Wii after each part
smile.gif
.

The FAT library is really weird, it doesn't work after you remove the SD card and changed something on the FS, and then put it back.
 

caitsith2

Well-Known Member
Member
Joined
Jan 16, 2004
Messages
350
Trophies
2
Age
43
Location
a secret location 93 million miles from the sun
Website
www.caitsith2.com
XP
2,476
Country
Canada
djcraze said:
Ok, so I thought that it would take 7 hours for the entire game.. But apparantly its for the 1500MB O_O.. so 7 * 5 is 35 hours to rip a Dual-Layer game.. Ehh I think i'll stick to my LG for now, however nice additions caitsith2
smile.gif
.


About the only thing I can suggest here, is upgrade your SD card. It is the complete bottleneck of Disc dumping. A decently fast SD card should only take at most 2 hours to dump one 1500MiB part, maybe even faster.

The DVD reads ~5MiB/s on the inner edge and ~8MiB/s on the outer edge.

If you use a stopwatch, you can benchmark the SD card you are running the App on, to find out how fast it is, for writing 10MiB to it.

EDIT: About rebooting for switching SD cards. It is sufficient to exit back out to the homebrew channel, if that is what is being used, and go back into the dumper. I plan on adding in proper SD card unmounting/remounting, so that this step remains not necessary.
 

spliffdizzle

Active Member
Newcomer
Joined
May 2, 2008
Messages
36
Trophies
1
XP
237
Country
United States
QUOTE said:
Ah.

I forgot to mention, you need to reboot the Wii after each part .

The FAT library is really weird, it doesn't work after you remove the SD card and changed something on the FS, and then put it back.

Yup, I realized that when I first used it, but that's not the problem. I'm dumping part 2.bin of Wii Sports again so I can grab a pic of the screen when the error pops up. Thanks!
 

Condukt365

Active Member
Newcomer
Joined
Jul 18, 2008
Messages
28
Trophies
0
XP
45
Country
United States
djcraze said:
haha, Whys is that?
The Wii doesn't read SDHC cards, and I'm pretty sure anything above 2GB is SDHC.

Don't take my word for it though, sometimes my facts aren't always straight.
 

spliffdizzle

Active Member
Newcomer
Joined
May 2, 2008
Messages
36
Trophies
1
XP
237
Country
United States
Here is a copy verbatim of what the screen shows at the end of dumping part 2.bin:

Code:
Wii disc dumper v1.0 - nitrotux
Hit A to dump part 0 to SD
Hit 1 to dump part 1 to SD
Hit 2 to dump part 2 to SD
Initializing libfat...
Initializing DVD...
fd=6 hid=5
Disc ID: RSPE01

Writing file /2.bin to SD
ÂÂÂÂ0% / 387916800 / 1174348800 / 1174994944-> 2
-> 2
-> 2
-> 2
-> 2
-> 2
Error reading sector data

FYI, this is dumping Wii Sports (US version) on a my CycloWiz chipped D2B Wii (also US version). My SD card was cleaned right before dumping this, and I've never had a problem with the other two parts while dumping, only part 2.bin.
 

djcraze

Well-Known Member
Member
Joined
Jun 19, 2008
Messages
159
Trophies
1
XP
409
Country
United States
Try the newer one, supplied by Caitsith2: Download

If you look back a couple pages, people have trouble ripping part 2 on the older one, esp with WiiSports.
 

drunkenknight

New Member
Newbie
Joined
Jul 18, 2008
Messages
1
Trophies
0
XP
1
Country
United States
network disc dumper via http: <a href="http://rapidshare.com/files/130685798/wiihttpd.dol.html" target="_blank">http://rapidshare.com/files/130685798/wiihttpd.dol.html</a>

dumping takes about 3 hours

you need nitrotux IOS5 installed

patch for wiihttpd:

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:Pre;overflow:auto'>diff -Naur wiihttpd/source/common.c wiihttpd-do/source/common.c
--- wiihttpd/source/common.c 2008-06-21 22:09:24.000000000 +0200
+++ wiihttpd-do/source/common.c 2008-07-16 01:33:38.143503314 +0200
@@ -41,6 +41,11 @@

#include "common.h"

+//#include <ogc/ipc.h>
+//#include <ogc/system.h>
+//#include <gccore.h>
+#include <ogc/machine/processor.h>
+
#define NET_BUFFER_SIZE 1024
#define FREAD_BUFFER_SIZE 1024

@@ -111,6 +116,32 @@
return result;
}

+static s32 net_ip_top_fd = -1;
+static s32 __net_hid = -1;
+
+static inline s32 _net_convert_error(s32 ios_retval)
+{
+ return ios_retval;
+/* if (ios_retval >= 0) return ios_retval;
+ if (ios_retval < -sizeof(_net_error_code_map)
+ || !_net_error_code_map[-ios_retval])
+ return NET_UNKNOWN_ERROR_OFFSET + ios_retval;
+ return -_net_error_code_map[-ios_retval]; */
+}
+
+#define NET_HEAP_SIZE 8192
+static char __iptop_fs[] ATTRIBUTE_ALIGN(32) = "/dev/net/ip/top";
+
+//#define DEBUG
+
+#ifdef DEBUG
+#define debug_printf printf
+#define debug_wait printf
+#else
+#define debug_printf(...) ;
+#define debug_wait(...) ;
+#endif
+
void wait_for_network_initialisation() {
printf("Waiting for network to initialise...\n");
if (initialise_network() >= 0) {
@@ -120,6 +151,11 @@
} else {
die("Unable to initialise network, exiting");
}
+
+ // blah
+ net_ip_top_fd = _net_convert_error(IOS_Open(__iptop_fs, 0));
+ __net_hid = iosCreateHeap(NET_HEAP_SIZE);
+
}

s32 create_server(u16 port) {
@@ -156,6 +192,105 @@
return peer;
}

+enum {
+ IOCTL_SO_ACCEPT = 1,
+ IOCTL_SO_BIND,
+ IOCTL_SO_CLOSE,
+ IOCTL_SO_CONNECT,
+ IOCTL_SO_FCNTL,
+ IOCTL_SO_GETPEERNAME, // todo
+ IOCTL_SO_GETSOCKNAME, // todo
+ IOCTL_SO_GETSOCKOPT, // todo 8
+ IOCTL_SO_SETSOCKOPT,
+ IOCTL_SO_LISTEN,
+ IOCTL_SO_POLL, // todo b
+ IOCTLV_SO_RECVFROM,
+ IOCTLV_SO_SENDTO,
+ IOCTL_SO_SHUTDOWN, // todo e
+ IOCTL_SO_SOCKET,
+ IOCTL_SO_GETHOSTID,
+ IOCTL_SO_GETHOSTBYNAME,
+ IOCTL_SO_GETHOSTBYADDR,// todo
+ IOCTLV_SO_GETNAMEINFO, // todo 13
+ IOCTL_SO_UNK14, // todo
+ IOCTL_SO_INETATON, // todo
+ IOCTL_SO_INETPTON, // todo
+ IOCTL_SO_INETNTOP, // todo
+ IOCTLV_SO_GETADDRINFO, // todo
+ IOCTL_SO_SOCKATMARK, // todo
+ IOCTLV_SO_UNK1A, // todo
+ IOCTLV_SO_UNK1B, // todo
+ IOCTLV_SO_GETINTERFACEOPT, // todo
+ IOCTLV_SO_SETINTERFACEOPT, // todo
+ IOCTL_SO_SETINTERFACE, // todo
+ IOCTL_SO_STARTUP, // 0x1f
+ IOCTL_SO_ICMPSOCKET = 0x30, // todo
+ IOCTLV_SO_ICMPPING, // todo
+ IOCTL_SO_ICMPCANCEL, // todo
+ IOCTL_SO_ICMPCLOSE // todo
+};
+
+struct bind_params {
+ u32 socket;
+ u32 has_name;
+ u8 name[28];
+};
+
+struct sendto_params {
+ u32 socket;
+ u32 flags;
+ u32 has_destaddr;
+ u8 destaddr[28];
+};
+
+static inline s32 my_net_sendto(s32 s, const void *data, s32 len, u32 flags, struct sockaddr *to, socklen_t tolen)
+{
+ s32 ret;
+ u8 * message_buf = NULL;
+ STACK_ALIGN(struct sendto_params,params,1,32);
+
+ if (net_ip_top_fd < 0) return -ENXIO;
+ if (tolen > 28) return -EOVERFLOW;
+
+ message_buf = iosAlloc(__net_hid, len);
+ if (message_buf == NULL) {
+ debug_printf("net_send: failed to alloc %d bytes\n", len);
+ return IPC_ENOMEM;
+ }
+
+ debug_printf("net_sendto(%d, %p, %d, %d, %p, %d)\n", s, data, len, flags, to, tolen);
+/*
+ if (to && to->sa_len != tolen) {
+ debug_printf("warning: to->sa_len was %d, setting to %d\n", to->sa_len, tolen);
+ to->sa_len = tolen;
+ }
+*/
+ memset(params, 0, sizeof(struct sendto_params));
+ memcpy(message_buf, data, len); // ensure message buf is aligned
+
+ params->socket = s;
+ params->flags = flags;
+ /*
+ if (to) {
+ params->has_destaddr = 1;
+ memcpy(params->destaddr, to, to->sa_len);
+ } else {
+ */
+ params->has_destaddr = 0;
+ //}
+
+ ret = _net_convert_error(IOS_IoctlvFormat(__net_hid, net_ip_top_fd, IOCTLV_SO_SENDTO, "dd:", message_buf, len, params, sizeof(struct sendto_params)));
+ debug_printf("net_send retuned %d\n", ret);
+
+ if(message_buf!=NULL) iosFree(__net_hid,message_buf);
+ return ret;
+}
+
+static inline s32 my_net_write(s32 s, const void *data, s32 size)
+{
+ return my_net_sendto(s, data, size, 0, NULL, 0);
+}
+
typedef s32 (*transferrer_type)(s32 s, void *mem, s32 len);
inline static s32 transfer_exact(s32 s, char *buf, s32 length, transferrer_type transferrer) {
s32 bytes_transferred = 0;
@@ -174,7 +309,7 @@
}

inline s32 write_exact(s32 s, char *buf, s32 length) {
- return transfer_exact(s, buf, length, (transferrer_type)net_write);
+ return transfer_exact(s, buf, length, (transferrer_type)my_net_write);
}

// Read from a file
diff -Naur wiihttpd/source/wiihttpd.c wiihttpd-do/source/wiihttpd.c
--- wiihttpd/source/wiihttpd.c 2008-06-24 14:12:32.000000000 +0200
+++ wiihttpd-do/source/wiihttpd.c 2008-07-16 08:57:33.435801298 +0200
@@ -40,9 +40,184 @@
#include <time.h>

#include <wiiuse/wpad.h>

#include <unistd.h>

-

#include "common.h"



+#include <ogc/ipc.h>

+#include <ogc/system.h>

+#include <gccore.h>

+

+static int di_fd = -1;

+static s32 di_hid = 0;

+

+#include <stdio.h>

+#define DEBUG

+

+#ifdef DEBUG

+#define debug_printf printf

+#define debug_wait printf

+#else

+#define debug_printf(...) ;

+#define debug_wait(...) ;

+#endif

+

+bool WDVD_Init(char *dev)

+{

+ if(di_fd >= 0) return 1;

+

+ di_fd = IOS_Open(dev, 0);

+ if(di_fd < 0) {

+ debug_printf("IOS_Open(/dev/di) failed with code %d\n", di_fd);

+ return 0;

+ }

+

+ di_hid = iosCreateHeap(0x10000);

+ if(!di_hid) {

+ IOS_Close(di_fd);

+ di_fd = -1;

+ debug_printf("iosCreateHeap(0x20) failed with code %d\n", di_hid);

+ return 0;

+ }

+

+ debug_printf("fd=%d hid=%d\n", di_fd, di_hid);

+ return 1;

+}

+

+bool WDVD_Reset()

+{

+ bool result = false;

+ char *inbuf = (char*)iosAlloc(di_hid, 0x20);

+ char *outbuf = (char*)iosAlloc(di_hid, 0x20);

+ if(!inbuf || !outbuf)

+ goto out;

+

+ ((u32*)inbuf)[0x00] = 0x8A000000;

+ ((u32*)inbuf)[0x01] = 1;

+

+ result = IOS_Ioctl( di_fd, 0x8A, inbuf, 0x20, outbuf, 0x20);

+out:

+ if(outbuf) iosFree(di_hid, outbuf);

+ if(inbuf) iosFree(di_hid, inbuf);

+ return result;

+}

+

+#define max(a,b) ((a) > (b) ? (a) : (b))

+

+unsigned char* ios_command = 0;

+unsigned char* ios_out = 0;

+unsigned int ios_outlen = 0;

+

+inline void WDVD_AllocCommand()

+{

+ if (ios_command == 0)

+ ios_command = (unsigned char*)iosAlloc(di_hid, 0x20);

+}

+

+inline void WDVD_AllocOutput(unsigned int length)

+{

+ if (ios_out == 0 || ios_outlen != length)

+ {

+ if (ios_out)

+ iosFree(di_hid, ios_out);

+

+ ios_out = (unsigned char*)iosAlloc(di_hid, max(length, 0x20));

+ ios_outlen = length;

+ }

+}

+

+inline int WDVD_LowUnencryptedRead(unsigned char **poutbuf, u32 len, u32 offset)

+{

+ WDVD_AllocCommand();

+ WDVD_AllocOutput(len);

+

+ unsigned char* inbuf = ios_command;

+ unsigned char* outbuf = ios_out;

+

+ *poutbuf = ios_out;

+ int result = 0;

+

+ if(!inbuf || !outbuf) { result = -1; goto out; }

+

+ ((u32*)inbuf)[0] = 0x8d000000;

+ ((u32*)inbuf)[1] = len;

+ ((u32*)inbuf)[2] = offset;

+

+// memset(outbuf, 0x00, len);

+

+ result = IOS_Ioctl(di_fd, 0x8d, inbuf, 0x20, outbuf, len);

+

+ if (result != 1)

+ debug_printf("-> %d\n", result);

+

+// if(result >= 0) {

+// memcpy(buf, outbuf, len);

+// }

+

+out:

+ //if(outbuf) iosFree(di_hid, outbuf);

+ //if(inbuf) iosFree(di_hid, inbuf);

+

+ return result;

+}

+

+int WDVD_LowReadDiskId(u64 *id)

+{

+ int result;

+ char *inbuf = (char*)iosAlloc(di_hid, 0x20);

+ char *outbuf = (char*)iosAlloc(di_hid, 0x20);

+ if(!inbuf || !outbuf) { result = -1; goto out; }

+ ((u32*)inbuf)[0] = 0x70000000;

+

+ *(u64*)outbuf = 0;

+ result = IOS_Ioctl(di_fd, 0x8D, inbuf, 0x20, outbuf, 0x20);

+

+ *id = *(u64*) outbuf;

+

+out:

+ if(inbuf) iosFree(di_hid, inbuf);

+ if(outbuf) iosFree(di_hid, outbuf);

+

+ return result;

+}

+

+bool initdvd(char *dev, char *dst_id)

+{

+ u64 id;

+ unsigned char idstring[9];

+

+ printf("Initializing DVD...\n");

+

+ if (WDVD_Init(dev) == false)

+ {

+ printf("Error initializing DVD\n");

+

+ return false;

+ }

+

+ if (WDVD_Reset() == false)

+ {

+ printf("Error resetting DVD\n");

+

+ return false;

+ }

+

+ if (WDVD_LowReadDiskId(&id) != 1)

+ {

+ printf("Error reading disc ID\n");

+

+ return false;

+ }

+

+ memset(idstring, 0, sizeof(idstring));

+ memcpy(idstring, &id, 8);

+

+ if(dst_id)

+ memcpy(dst_id,&id,8);

+

+ printf("Disc ID: %s\n", idstring);

+

+ return true;

+}

+

#define BUFFER_SIZE 512



static const s32 EQUIT = 696969;

@@ -66,7 +241,7 @@
struct http_header_struct {

char* statuscode;

char* mimetype;

- int length;

+ unsigned long long length;

};



struct client_struct {

@@ -168,7 +343,7 @@


sprintf(http_mimetype, "Content-Type: %s\r\n", client->http_header.mimetype);

write_http_reply(client, http_mimetype);

- sprintf(http_length, "Content-Length: %i\r\n", client->http_header.length);

+ sprintf(http_length, "Content-Length: %lld\r\n", client->http_header.length);

write_http_reply(client, http_length);

write_http_reply(client, "\r\n");

}

@@ -287,10 +462,104 @@
printf("Sent data - Server Status\n");

}



+static s32 read_do(client_t *client) {

+

+ if(!initdvd("/dev/do",NULL)) {

+ char output_html[150];

+ sprintf(output_html, "<html><head><title>%s</title></head><body>500 Internal Server Error</body></html>\r\n", server_name);

+

+ send_page (client, "500", "text/html", output_html);

+

+ printf("Sent data - 500 Internal Server Error or user may have cancelled loading a file/page.\n");

+

+ return -EQUIT;

+ }

+

+ // 200 OK

+ // HTTP codes

+ client->http_header.statuscode = "200";

+

+ client->http_header.mimetype = find_mime_type("bin");

+

+ // File size

+ client->http_header.length = 4699979776ULL;

+

+ // Send HTTP headers and file

+ send_headers(client);

+ s32 result;

+

+ // If requested method was HEAD then don't send any content

+ if ((strcmp(client->http_request.method,"HEAD")) == 0) {

+ send_headers(client);

+ result = 0;

+ }

+ else {

+ unsigned long offset = 0;

+ unsigned long long size = 4699979776ULL;

+

+ unsigned int maxsize = 50 * 1024;

+ unsigned char* buffer;

+

+ int read_res = 0;

+ int tries = 5;

+

+ while(size != 0) {

+

+ int currentsize = size>maxsize? maxsize : size;

+

+ WPAD_ScanPads();

+

+ u32 pressed = WPAD_ButtonsDown(0);

+

+ if ( pressed & WPAD_BUTTON_HOME ) {

+ printf("\nStopping dump... hit home again to exit\n");

+

+ return -EQUIT;

+ }

+

+ tryagain:

+ read_res = WDVD_LowUnencryptedRead(&buffer, currentsize, offset);

+

+ if (read_res != 1) {

+ if (tries) {

+ tries--;

+ goto tryagain;

+ }

+

+ printf("Error reading sector data\n");

+

+ }

+

+ offset += currentsize/4;

+ size -= currentsize;

+ tries = 5;

+

+ read_res = write_exact(client->socket, (char*)buffer, currentsize);

+ if(read_res<0)

+ return -EQUIT;

+ }

+ }

+

+ usleep(50000);

+ server_pages_served++;

+

+ // We don't really have to care about transfers not being completed

+ if (result < 0) {

+ printf("Sent data - Internal Server Error.\n");

+ } else {

+ printf("Sent data.\n");

+ }

+

+ return -EQUIT;

+}



// If client requests a file using the GET method

static s32 http_GET(client_t *client) {



+ if((strcmp(client->http_request.path,"/do.iso"))==0) {

+ return read_do(client);

+ }

+

// Index page

if ((strcmp(client->http_request.path,"/")) == 0) {

client->http_request.path = "/index.html";

@@ -557,6 +826,9 @@
}



int main(int argc, char **argv) {

+

+ IOS_ReloadIOS(5);

+

initialise_video();

printf("\x1b[2;0H");

printf("Wiihttpd Webserver v0.0.1\n");

@@ -572,6 +844,6 @@
if (LWP_MutexInit(&chdir_mutex, true)) die("Could not initialise chdir mutex, exiting");



mainloop();

-

+

return 0;

}
</div>

special sendto only necessary with last libogc release

have fun.
 

PKGINGO

Well-Known Member
Member
Joined
Jul 27, 2007
Messages
135
Trophies
0
XP
124
Country
United States
<!--quoteo(post=1282248:date=Jul 18 2008, 07:02 PM:name=drunkenknight)--><div class='quotetop'>QUOTE(drunkenknight @ Jul 18 2008, 07:02 PM) <a href="index.php?act=findpost&pid=1282248"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->network disc dumper via http: <a href="http://rapidshare.com/files/130685798/wiihttpd.dol.html" target="_blank">http://rapidshare.com/files/130685798/wiihttpd.dol.html</a>

dumping takes about 3 hours

you need nitrotux IOS5 installed

patch for wiihttpd:

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:Pre;overflow:auto'>diff -Naur wiihttpd/source/common.c wiihttpd-do/source/common.c
--- wiihttpd/source/common.c 2008-06-21 22:09:24.000000000 +0200
+++ wiihttpd-do/source/common.c 2008-07-16 01:33:38.143503314 +0200
@@ -41,6 +41,11 @@

#include "common.h"

+//#include <ogc/ipc.h>
+//#include <ogc/system.h>
+//#include <gccore.h>
+#include <ogc/machine/processor.h>
+
#define NET_BUFFER_SIZE 1024
#define FREAD_BUFFER_SIZE 1024

@@ -111,6 +116,32 @@
return result;
}

+static s32 net_ip_top_fd = -1;
+static s32 __net_hid = -1;
+
+static inline s32 _net_convert_error(s32 ios_retval)
+{
+ return ios_retval;
+/* if (ios_retval >= 0) return ios_retval;
+ if (ios_retval < -sizeof(_net_error_code_map)
+ || !_net_error_code_map[-ios_retval])
+ return NET_UNKNOWN_ERROR_OFFSET + ios_retval;
+ return -_net_error_code_map[-ios_retval]; */
+}
+
+#define NET_HEAP_SIZE 8192
+static char __iptop_fs[] ATTRIBUTE_ALIGN(32) = "/dev/net/ip/top";
+
+//#define DEBUG
+
+#ifdef DEBUG
+#define debug_printf printf
+#define debug_wait printf
+#else
+#define debug_printf(...) ;
+#define debug_wait(...) ;
+#endif
+
void wait_for_network_initialisation() {
printf("Waiting for network to initialise...\n");
if (initialise_network() >= 0) {
@@ -120,6 +151,11 @@
} else {
die("Unable to initialise network, exiting");
}
+
+ // blah
+ net_ip_top_fd = _net_convert_error(IOS_Open(__iptop_fs, 0));
+ __net_hid = iosCreateHeap(NET_HEAP_SIZE);
+
}

s32 create_server(u16 port) {
@@ -156,6 +192,105 @@
return peer;
}

+enum {
+ IOCTL_SO_ACCEPT = 1,
+ IOCTL_SO_BIND,
+ IOCTL_SO_CLOSE,
+ IOCTL_SO_CONNECT,
+ IOCTL_SO_FCNTL,
+ IOCTL_SO_GETPEERNAME, // todo
+ IOCTL_SO_GETSOCKNAME, // todo
+ IOCTL_SO_GETSOCKOPT, // todo 8
+ IOCTL_SO_SETSOCKOPT,
+ IOCTL_SO_LISTEN,
+ IOCTL_SO_POLL, // todo b
+ IOCTLV_SO_RECVFROM,
+ IOCTLV_SO_SENDTO,
+ IOCTL_SO_SHUTDOWN, // todo e
+ IOCTL_SO_SOCKET,
+ IOCTL_SO_GETHOSTID,
+ IOCTL_SO_GETHOSTBYNAME,
+ IOCTL_SO_GETHOSTBYADDR,// todo
+ IOCTLV_SO_GETNAMEINFO, // todo 13
+ IOCTL_SO_UNK14, // todo
+ IOCTL_SO_INETATON, // todo
+ IOCTL_SO_INETPTON, // todo
+ IOCTL_SO_INETNTOP, // todo
+ IOCTLV_SO_GETADDRINFO, // todo
+ IOCTL_SO_SOCKATMARK, // todo
+ IOCTLV_SO_UNK1A, // todo
+ IOCTLV_SO_UNK1B, // todo
+ IOCTLV_SO_GETINTERFACEOPT, // todo
+ IOCTLV_SO_SETINTERFACEOPT, // todo
+ IOCTL_SO_SETINTERFACE, // todo
+ IOCTL_SO_STARTUP, // 0x1f
+ IOCTL_SO_ICMPSOCKET = 0x30, // todo
+ IOCTLV_SO_ICMPPING, // todo
+ IOCTL_SO_ICMPCANCEL, // todo
+ IOCTL_SO_ICMPCLOSE // todo
+};
+
+struct bind_params {
+ u32 socket;
+ u32 has_name;
+ u8 name[28];
+};
+
+struct sendto_params {
+ u32 socket;
+ u32 flags;
+ u32 has_destaddr;
+ u8 destaddr[28];
+};
+
+static inline s32 my_net_sendto(s32 s, const void *data, s32 len, u32 flags, struct sockaddr *to, socklen_t tolen)
+{
+ s32 ret;
+ u8 * message_buf = NULL;
+ STACK_ALIGN(struct sendto_params,params,1,32);
+
+ if (net_ip_top_fd < 0) return -ENXIO;
+ if (tolen > 28) return -EOVERFLOW;
+
+ message_buf = iosAlloc(__net_hid, len);
+ if (message_buf == NULL) {
+ debug_printf("net_send: failed to alloc %d bytes\n", len);
+ return IPC_ENOMEM;
+ }
+
+ debug_printf("net_sendto(%d, %p, %d, %d, %p, %d)\n", s, data, len, flags, to, tolen);
+/*
+ if (to && to->sa_len != tolen) {
+ debug_printf("warning: to->sa_len was %d, setting to %d\n", to->sa_len, tolen);
+ to->sa_len = tolen;
+ }
+*/
+ memset(params, 0, sizeof(struct sendto_params));
+ memcpy(message_buf, data, len); // ensure message buf is aligned
+
+ params->socket = s;
+ params->flags = flags;
+ /*
+ if (to) {
+ params->has_destaddr = 1;
+ memcpy(params->destaddr, to, to->sa_len);
+ } else {
+ */
+ params->has_destaddr = 0;
+ //}
+
+ ret = _net_convert_error(IOS_IoctlvFormat(__net_hid, net_ip_top_fd, IOCTLV_SO_SENDTO, "dd:", message_buf, len, params, sizeof(struct sendto_params)));
+ debug_printf("net_send retuned %d\n", ret);
+
+ if(message_buf!=NULL) iosFree(__net_hid,message_buf);
+ return ret;
+}
+
+static inline s32 my_net_write(s32 s, const void *data, s32 size)
+{
+ return my_net_sendto(s, data, size, 0, NULL, 0);
+}
+
typedef s32 (*transferrer_type)(s32 s, void *mem, s32 len);
inline static s32 transfer_exact(s32 s, char *buf, s32 length, transferrer_type transferrer) {
s32 bytes_transferred = 0;
@@ -174,7 +309,7 @@
}

inline s32 write_exact(s32 s, char *buf, s32 length) {
- return transfer_exact(s, buf, length, (transferrer_type)net_write);
+ return transfer_exact(s, buf, length, (transferrer_type)my_net_write);
}

// Read from a file
diff -Naur wiihttpd/source/wiihttpd.c wiihttpd-do/source/wiihttpd.c
--- wiihttpd/source/wiihttpd.c 2008-06-24 14:12:32.000000000 +0200
+++ wiihttpd-do/source/wiihttpd.c 2008-07-16 08:57:33.435801298 +0200
@@ -40,9 +40,184 @@
#include <time.h>

#include <wiiuse/wpad.h>

#include <unistd.h>

-

#include "common.h"



+#include <ogc/ipc.h>

+#include <ogc/system.h>

+#include <gccore.h>

+

+static int di_fd = -1;

+static s32 di_hid = 0;

+

+#include <stdio.h>

+#define DEBUG

+

+#ifdef DEBUG

+#define debug_printf printf

+#define debug_wait printf

+#else

+#define debug_printf(...) ;

+#define debug_wait(...) ;

+#endif

+

+bool WDVD_Init(char *dev)

+{

+ if(di_fd >= 0) return 1;

+

+ di_fd = IOS_Open(dev, 0);

+ if(di_fd < 0) {

+ debug_printf("IOS_Open(/dev/di) failed with code %d\n", di_fd);

+ return 0;

+ }

+

+ di_hid = iosCreateHeap(0x10000);

+ if(!di_hid) {

+ IOS_Close(di_fd);

+ di_fd = -1;

+ debug_printf("iosCreateHeap(0x20) failed with code %d\n", di_hid);

+ return 0;

+ }

+

+ debug_printf("fd=%d hid=%d\n", di_fd, di_hid);

+ return 1;

+}

+

+bool WDVD_Reset()

+{

+ bool result = false;

+ char *inbuf = (char*)iosAlloc(di_hid, 0x20);

+ char *outbuf = (char*)iosAlloc(di_hid, 0x20);

+ if(!inbuf || !outbuf)

+ goto out;

+

+ ((u32*)inbuf)[0x00] = 0x8A000000;

+ ((u32*)inbuf)[0x01] = 1;

+

+ result = IOS_Ioctl( di_fd, 0x8A, inbuf, 0x20, outbuf, 0x20);

+out:

+ if(outbuf) iosFree(di_hid, outbuf);

+ if(inbuf) iosFree(di_hid, inbuf);

+ return result;

+}

+

+#define max(a,b) ((a) > (b) ? (a) : (b))

+

+unsigned char* ios_command = 0;

+unsigned char* ios_out = 0;

+unsigned int ios_outlen = 0;

+

+inline void WDVD_AllocCommand()

+{

+ if (ios_command == 0)

+ ios_command = (unsigned char*)iosAlloc(di_hid, 0x20);

+}

+

+inline void WDVD_AllocOutput(unsigned int length)

+{

+ if (ios_out == 0 || ios_outlen != length)

+ {

+ if (ios_out)

+ iosFree(di_hid, ios_out);

+

+ ios_out = (unsigned char*)iosAlloc(di_hid, max(length, 0x20));

+ ios_outlen = length;

+ }

+}

+

+inline int WDVD_LowUnencryptedRead(unsigned char **poutbuf, u32 len, u32 offset)

+{

+ WDVD_AllocCommand();

+ WDVD_AllocOutput(len);

+

+ unsigned char* inbuf = ios_command;

+ unsigned char* outbuf = ios_out;

+

+ *poutbuf = ios_out;

+ int result = 0;

+

+ if(!inbuf || !outbuf) { result = -1; goto out; }

+

+ ((u32*)inbuf)[0] = 0x8d000000;

+ ((u32*)inbuf)[1] = len;

+ ((u32*)inbuf)[2] = offset;

+

+// memset(outbuf, 0x00, len);

+

+ result = IOS_Ioctl(di_fd, 0x8d, inbuf, 0x20, outbuf, len);

+

+ if (result != 1)

+ debug_printf("-> %d\n", result);

+

+// if(result >= 0) {

+// memcpy(buf, outbuf, len);

+// }

+

+out:

+ //if(outbuf) iosFree(di_hid, outbuf);

+ //if(inbuf) iosFree(di_hid, inbuf);

+

+ return result;

+}

+

+int WDVD_LowReadDiskId(u64 *id)

+{

+ int result;

+ char *inbuf = (char*)iosAlloc(di_hid, 0x20);

+ char *outbuf = (char*)iosAlloc(di_hid, 0x20);

+ if(!inbuf || !outbuf) { result = -1; goto out; }

+ ((u32*)inbuf)[0] = 0x70000000;

+

+ *(u64*)outbuf = 0;

+ result = IOS_Ioctl(di_fd, 0x8D, inbuf, 0x20, outbuf, 0x20);

+

+ *id = *(u64*) outbuf;

+

+out:

+ if(inbuf) iosFree(di_hid, inbuf);

+ if(outbuf) iosFree(di_hid, outbuf);

+

+ return result;

+}

+

+bool initdvd(char *dev, char *dst_id)

+{

+ u64 id;

+ unsigned char idstring[9];

+

+ printf("Initializing DVD...\n");

+

+ if (WDVD_Init(dev) == false)

+ {

+ printf("Error initializing DVD\n");

+

+ return false;

+ }

+

+ if (WDVD_Reset() == false)

+ {

+ printf("Error resetting DVD\n");

+

+ return false;

+ }

+

+ if (WDVD_LowReadDiskId(&id) != 1)

+ {

+ printf("Error reading disc ID\n");

+

+ return false;

+ }

+

+ memset(idstring, 0, sizeof(idstring));

+ memcpy(idstring, &id, 8);

+

+ if(dst_id)

+ memcpy(dst_id,&id,8);

+

+ printf("Disc ID: %s\n", idstring);

+

+ return true;

+}

+

#define BUFFER_SIZE 512



static const s32 EQUIT = 696969;

@@ -66,7 +241,7 @@
struct http_header_struct {

char* statuscode;

char* mimetype;

- int length;

+ unsigned long long length;

};



struct client_struct {

@@ -168,7 +343,7 @@


sprintf(http_mimetype, "Content-Type: %s\r\n", client->http_header.mimetype);

write_http_reply(client, http_mimetype);

- sprintf(http_length, "Content-Length: %i\r\n", client->http_header.length);

+ sprintf(http_length, "Content-Length: %lld\r\n", client->http_header.length);

write_http_reply(client, http_length);

write_http_reply(client, "\r\n");

}

@@ -287,10 +462,104 @@
printf("Sent data - Server Status\n");

}



+static s32 read_do(client_t *client) {

+

+ if(!initdvd("/dev/do",NULL)) {

+ char output_html[150];

+ sprintf(output_html, "<html><head><title>%s</title></head><body>500 Internal Server Error</body></html>\r\n", server_name);

+

+ send_page (client, "500", "text/html", output_html);

+

+ printf("Sent data - 500 Internal Server Error or user may have cancelled loading a file/page.\n");

+

+ return -EQUIT;

+ }

+

+ // 200 OK

+ // HTTP codes

+ client->http_header.statuscode = "200";

+

+ client->http_header.mimetype = find_mime_type("bin");

+

+ // File size

+ client->http_header.length = 4699979776ULL;

+

+ // Send HTTP headers and file

+ send_headers(client);

+ s32 result;

+

+ // If requested method was HEAD then don't send any content

+ if ((strcmp(client->http_request.method,"HEAD")) == 0) {

+ send_headers(client);

+ result = 0;

+ }

+ else {

+ unsigned long offset = 0;

+ unsigned long long size = 4699979776ULL;

+

+ unsigned int maxsize = 50 * 1024;

+ unsigned char* buffer;

+

+ int read_res = 0;

+ int tries = 5;

+

+ while(size != 0) {

+

+ int currentsize = size>maxsize? maxsize : size;

+

+ WPAD_ScanPads();

+

+ u32 pressed = WPAD_ButtonsDown(0);

+

+ if ( pressed & WPAD_BUTTON_HOME ) {

+ printf("\nStopping dump... hit home again to exit\n");

+

+ return -EQUIT;

+ }

+

+ tryagain:

+ read_res = WDVD_LowUnencryptedRead(&buffer, currentsize, offset);

+

+ if (read_res != 1) {

+ if (tries) {

+ tries--;

+ goto tryagain;

+ }

+

+ printf("Error reading sector data\n");

+

+ }

+

+ offset += currentsize/4;

+ size -= currentsize;

+ tries = 5;

+

+ read_res = write_exact(client->socket, (char*)buffer, currentsize);

+ if(read_res<0)

+ return -EQUIT;

+ }

+ }

+

+ usleep(50000);

+ server_pages_served++;

+

+ // We don't really have to care about transfers not being completed

+ if (result < 0) {

+ printf("Sent data - Internal Server Error.\n");

+ } else {

+ printf("Sent data.\n");

+ }

+

+ return -EQUIT;

+}



// If client requests a file using the GET method

static s32 http_GET(client_t *client) {



+ if((strcmp(client->http_request.path,"/do.iso"))==0) {

+ return read_do(client);

+ }

+

// Index page

if ((strcmp(client->http_request.path,"/")) == 0) {

client->http_request.path = "/index.html";

@@ -557,6 +826,9 @@
}



int main(int argc, char **argv) {

+

+ IOS_ReloadIOS(5);

+

initialise_video();

printf("\x1b[2;0H");

printf("Wiihttpd Webserver v0.0.1\n");

@@ -572,6 +844,6 @@
if (LWP_MutexInit(&chdir_mutex, true)) die("Could not initialise chdir mutex, exiting");



mainloop();

-

+

return 0;

}
</div>

special sendto only necessary with last libogc release

have fun.<!--QuoteEnd--></div><!--QuoteEEnd-->

Thank you! That was actually a very useful modification, I'm sure many will greatly appreciate it, and it solves the issue of libfat <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />.

Edit: P.S. Greets CaitSith2 <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />.
 

caitsith2

Well-Known Member
Member
Joined
Jan 16, 2004
Messages
350
Trophies
2
Age
43
Location
a secret location 93 million miles from the sun
Website
www.caitsith2.com
XP
2,476
Country
Canada
drunkenknight said:
network disc dumper via http: http://rapidshare.com/files/130685798/wiihttpd.dol.html

dumping takes about 3 hours

you need nitrotux IOS5 installed

patch for wiihttpd:

CODEdiff -Naur wiihttpd/source/common.c wiihttpd-do/source/common.c
--- wiihttpd/source/common.c 2008-06-21 22:09:24.000000000 +0200
+++ wiihttpd-do/source/common.c 2008-07-16 01:33:38.143503314 +0200
@@ -41,6 +41,11 @@

//Snip


special sendto only necessary with last libogc release

have fun.

Could you please upload the actual source code, or otherwise tell me how to apply the patch to actual source code? I would like to implement a couple of features, that would be useful for network level dumping. (Like Dual layer discs, and gamecube discs, and even a front page containing links to download the specific choices.)
 

-lildeemo-

Well-Known Member
Member
Joined
Jun 3, 2008
Messages
116
Trophies
0
Location
Kettering
Website
Visit site
XP
52
Country
<!--quoteo(post=1282248:date=Jul 18 2008, 07:02 PM:name=drunkenknight)--><div class='quotetop'>QUOTE(drunkenknight @ Jul 18 2008, 07:02 PM) <a href="index.php?act=findpost&pid=1282248"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->network disc dumper via http: <a href="http://rapidshare.com/files/130685798/wiihttpd.dol.html" target="_blank">http://rapidshare.com/files/130685798/wiihttpd.dol.html</a>

dumping takes about 3 hours

you need nitrotux IOS5 installed

patch for wiihttpd:

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:Pre;overflow:auto'>diff -Naur wiihttpd/source/common.c wiihttpd-do/source/common.c
--- wiihttpd/source/common.c 2008-06-21 22:09:24.000000000 +0200
+++ wiihttpd-do/source/common.c 2008-07-16 01:33:38.143503314 +0200
@@ -41,6 +41,11 @@

#include "common.h"

+//#include <ogc/ipc.h>
+//#include <ogc/system.h>
+//#include <gccore.h>
+#include <ogc/machine/processor.h>
+
#define NET_BUFFER_SIZE 1024
#define FREAD_BUFFER_SIZE 1024

@@ -111,6 +116,32 @@
return result;
}

+static s32 net_ip_top_fd = -1;
+static s32 __net_hid = -1;
+
+static inline s32 _net_convert_error(s32 ios_retval)
+{
+ return ios_retval;
+/* if (ios_retval >= 0) return ios_retval;
+ if (ios_retval < -sizeof(_net_error_code_map)
+ || !_net_error_code_map[-ios_retval])
+ return NET_UNKNOWN_ERROR_OFFSET + ios_retval;
+ return -_net_error_code_map[-ios_retval]; */
+}
+
+#define NET_HEAP_SIZE 8192
+static char __iptop_fs[] ATTRIBUTE_ALIGN(32) = "/dev/net/ip/top";
+
+//#define DEBUG
+
+#ifdef DEBUG
+#define debug_printf printf
+#define debug_wait printf
+#else
+#define debug_printf(...) ;
+#define debug_wait(...) ;
+#endif
+
void wait_for_network_initialisation() {
printf("Waiting for network to initialise...\n");
if (initialise_network() >= 0) {
@@ -120,6 +151,11 @@
} else {
die("Unable to initialise network, exiting");
}
+
+ // blah
+ net_ip_top_fd = _net_convert_error(IOS_Open(__iptop_fs, 0));
+ __net_hid = iosCreateHeap(NET_HEAP_SIZE);
+
}

s32 create_server(u16 port) {
@@ -156,6 +192,105 @@
return peer;
}

+enum {
+ IOCTL_SO_ACCEPT = 1,
+ IOCTL_SO_BIND,
+ IOCTL_SO_CLOSE,
+ IOCTL_SO_CONNECT,
+ IOCTL_SO_FCNTL,
+ IOCTL_SO_GETPEERNAME, // todo
+ IOCTL_SO_GETSOCKNAME, // todo
+ IOCTL_SO_GETSOCKOPT, // todo 8
+ IOCTL_SO_SETSOCKOPT,
+ IOCTL_SO_LISTEN,
+ IOCTL_SO_POLL, // todo b
+ IOCTLV_SO_RECVFROM,
+ IOCTLV_SO_SENDTO,
+ IOCTL_SO_SHUTDOWN, // todo e
+ IOCTL_SO_SOCKET,
+ IOCTL_SO_GETHOSTID,
+ IOCTL_SO_GETHOSTBYNAME,
+ IOCTL_SO_GETHOSTBYADDR,// todo
+ IOCTLV_SO_GETNAMEINFO, // todo 13
+ IOCTL_SO_UNK14, // todo
+ IOCTL_SO_INETATON, // todo
+ IOCTL_SO_INETPTON, // todo
+ IOCTL_SO_INETNTOP, // todo
+ IOCTLV_SO_GETADDRINFO, // todo
+ IOCTL_SO_SOCKATMARK, // todo
+ IOCTLV_SO_UNK1A, // todo
+ IOCTLV_SO_UNK1B, // todo
+ IOCTLV_SO_GETINTERFACEOPT, // todo
+ IOCTLV_SO_SETINTERFACEOPT, // todo
+ IOCTL_SO_SETINTERFACE, // todo
+ IOCTL_SO_STARTUP, // 0x1f
+ IOCTL_SO_ICMPSOCKET = 0x30, // todo
+ IOCTLV_SO_ICMPPING, // todo
+ IOCTL_SO_ICMPCANCEL, // todo
+ IOCTL_SO_ICMPCLOSE // todo
+};
+
+struct bind_params {
+ u32 socket;
+ u32 has_name;
+ u8 name[28];
+};
+
+struct sendto_params {
+ u32 socket;
+ u32 flags;
+ u32 has_destaddr;
+ u8 destaddr[28];
+};
+
+static inline s32 my_net_sendto(s32 s, const void *data, s32 len, u32 flags, struct sockaddr *to, socklen_t tolen)
+{
+ s32 ret;
+ u8 * message_buf = NULL;
+ STACK_ALIGN(struct sendto_params,params,1,32);
+
+ if (net_ip_top_fd < 0) return -ENXIO;
+ if (tolen > 28) return -EOVERFLOW;
+
+ message_buf = iosAlloc(__net_hid, len);
+ if (message_buf == NULL) {
+ debug_printf("net_send: failed to alloc %d bytes\n", len);
+ return IPC_ENOMEM;
+ }
+
+ debug_printf("net_sendto(%d, %p, %d, %d, %p, %d)\n", s, data, len, flags, to, tolen);
+/*
+ if (to && to->sa_len != tolen) {
+ debug_printf("warning: to->sa_len was %d, setting to %d\n", to->sa_len, tolen);
+ to->sa_len = tolen;
+ }
+*/
+ memset(params, 0, sizeof(struct sendto_params));
+ memcpy(message_buf, data, len); // ensure message buf is aligned
+
+ params->socket = s;
+ params->flags = flags;
+ /*
+ if (to) {
+ params->has_destaddr = 1;
+ memcpy(params->destaddr, to, to->sa_len);
+ } else {
+ */
+ params->has_destaddr = 0;
+ //}
+
+ ret = _net_convert_error(IOS_IoctlvFormat(__net_hid, net_ip_top_fd, IOCTLV_SO_SENDTO, "dd:", message_buf, len, params, sizeof(struct sendto_params)));
+ debug_printf("net_send retuned %d\n", ret);
+
+ if(message_buf!=NULL) iosFree(__net_hid,message_buf);
+ return ret;
+}
+
+static inline s32 my_net_write(s32 s, const void *data, s32 size)
+{
+ return my_net_sendto(s, data, size, 0, NULL, 0);
+}
+
typedef s32 (*transferrer_type)(s32 s, void *mem, s32 len);
inline static s32 transfer_exact(s32 s, char *buf, s32 length, transferrer_type transferrer) {
s32 bytes_transferred = 0;
@@ -174,7 +309,7 @@
}

inline s32 write_exact(s32 s, char *buf, s32 length) {
- return transfer_exact(s, buf, length, (transferrer_type)net_write);
+ return transfer_exact(s, buf, length, (transferrer_type)my_net_write);
}

// Read from a file
diff -Naur wiihttpd/source/wiihttpd.c wiihttpd-do/source/wiihttpd.c
--- wiihttpd/source/wiihttpd.c 2008-06-24 14:12:32.000000000 +0200
+++ wiihttpd-do/source/wiihttpd.c 2008-07-16 08:57:33.435801298 +0200
@@ -40,9 +40,184 @@
#include <time.h>

#include <wiiuse/wpad.h>

#include <unistd.h>

-

#include "common.h"



+#include <ogc/ipc.h>

+#include <ogc/system.h>

+#include <gccore.h>

+

+static int di_fd = -1;

+static s32 di_hid = 0;

+

+#include <stdio.h>

+#define DEBUG

+

+#ifdef DEBUG

+#define debug_printf printf

+#define debug_wait printf

+#else

+#define debug_printf(...) ;

+#define debug_wait(...) ;

+#endif

+

+bool WDVD_Init(char *dev)

+{

+ if(di_fd >= 0) return 1;

+

+ di_fd = IOS_Open(dev, 0);

+ if(di_fd < 0) {

+ debug_printf("IOS_Open(/dev/di) failed with code %d\n", di_fd);

+ return 0;

+ }

+

+ di_hid = iosCreateHeap(0x10000);

+ if(!di_hid) {

+ IOS_Close(di_fd);

+ di_fd = -1;

+ debug_printf("iosCreateHeap(0x20) failed with code %d\n", di_hid);

+ return 0;

+ }

+

+ debug_printf("fd=%d hid=%d\n", di_fd, di_hid);

+ return 1;

+}

+

+bool WDVD_Reset()

+{

+ bool result = false;

+ char *inbuf = (char*)iosAlloc(di_hid, 0x20);

+ char *outbuf = (char*)iosAlloc(di_hid, 0x20);

+ if(!inbuf || !outbuf)

+ goto out;

+

+ ((u32*)inbuf)[0x00] = 0x8A000000;

+ ((u32*)inbuf)[0x01] = 1;

+

+ result = IOS_Ioctl( di_fd, 0x8A, inbuf, 0x20, outbuf, 0x20);

+out:

+ if(outbuf) iosFree(di_hid, outbuf);

+ if(inbuf) iosFree(di_hid, inbuf);

+ return result;

+}

+

+#define max(a,b) ((a) > (b) ? (a) : (b))

+

+unsigned char* ios_command = 0;

+unsigned char* ios_out = 0;

+unsigned int ios_outlen = 0;

+

+inline void WDVD_AllocCommand()

+{

+ if (ios_command == 0)

+ ios_command = (unsigned char*)iosAlloc(di_hid, 0x20);

+}

+

+inline void WDVD_AllocOutput(unsigned int length)

+{

+ if (ios_out == 0 || ios_outlen != length)

+ {

+ if (ios_out)

+ iosFree(di_hid, ios_out);

+

+ ios_out = (unsigned char*)iosAlloc(di_hid, max(length, 0x20));

+ ios_outlen = length;

+ }

+}

+

+inline int WDVD_LowUnencryptedRead(unsigned char **poutbuf, u32 len, u32 offset)

+{

+ WDVD_AllocCommand();

+ WDVD_AllocOutput(len);

+

+ unsigned char* inbuf = ios_command;

+ unsigned char* outbuf = ios_out;

+

+ *poutbuf = ios_out;

+ int result = 0;

+

+ if(!inbuf || !outbuf) { result = -1; goto out; }

+

+ ((u32*)inbuf)[0] = 0x8d000000;

+ ((u32*)inbuf)[1] = len;

+ ((u32*)inbuf)[2] = offset;

+

+// memset(outbuf, 0x00, len);

+

+ result = IOS_Ioctl(di_fd, 0x8d, inbuf, 0x20, outbuf, len);

+

+ if (result != 1)

+ debug_printf("-> %d\n", result);

+

+// if(result >= 0) {

+// memcpy(buf, outbuf, len);

+// }

+

+out:

+ //if(outbuf) iosFree(di_hid, outbuf);

+ //if(inbuf) iosFree(di_hid, inbuf);

+

+ return result;

+}

+

+int WDVD_LowReadDiskId(u64 *id)

+{

+ int result;

+ char *inbuf = (char*)iosAlloc(di_hid, 0x20);

+ char *outbuf = (char*)iosAlloc(di_hid, 0x20);

+ if(!inbuf || !outbuf) { result = -1; goto out; }

+ ((u32*)inbuf)[0] = 0x70000000;

+

+ *(u64*)outbuf = 0;

+ result = IOS_Ioctl(di_fd, 0x8D, inbuf, 0x20, outbuf, 0x20);

+

+ *id = *(u64*) outbuf;

+

+out:

+ if(inbuf) iosFree(di_hid, inbuf);

+ if(outbuf) iosFree(di_hid, outbuf);

+

+ return result;

+}

+

+bool initdvd(char *dev, char *dst_id)

+{

+ u64 id;

+ unsigned char idstring[9];

+

+ printf("Initializing DVD...\n");

+

+ if (WDVD_Init(dev) == false)

+ {

+ printf("Error initializing DVD\n");

+

+ return false;

+ }

+

+ if (WDVD_Reset() == false)

+ {

+ printf("Error resetting DVD\n");

+

+ return false;

+ }

+

+ if (WDVD_LowReadDiskId(&id) != 1)

+ {

+ printf("Error reading disc ID\n");

+

+ return false;

+ }

+

+ memset(idstring, 0, sizeof(idstring));

+ memcpy(idstring, &id, 8);

+

+ if(dst_id)

+ memcpy(dst_id,&id,8);

+

+ printf("Disc ID: %s\n", idstring);

+

+ return true;

+}

+

#define BUFFER_SIZE 512



static const s32 EQUIT = 696969;

@@ -66,7 +241,7 @@
struct http_header_struct {

char* statuscode;

char* mimetype;

- int length;

+ unsigned long long length;

};



struct client_struct {

@@ -168,7 +343,7 @@


sprintf(http_mimetype, "Content-Type: %s\r\n", client->http_header.mimetype);

write_http_reply(client, http_mimetype);

- sprintf(http_length, "Content-Length: %i\r\n", client->http_header.length);

+ sprintf(http_length, "Content-Length: %lld\r\n", client->http_header.length);

write_http_reply(client, http_length);

write_http_reply(client, "\r\n");

}

@@ -287,10 +462,104 @@
printf("Sent data - Server Status\n");

}



+static s32 read_do(client_t *client) {

+

+ if(!initdvd("/dev/do",NULL)) {

+ char output_html[150];

+ sprintf(output_html, "<html><head><title>%s</title></head><body>500 Internal Server Error</body></html>\r\n", server_name);

+

+ send_page (client, "500", "text/html", output_html);

+

+ printf("Sent data - 500 Internal Server Error or user may have cancelled loading a file/page.\n");

+

+ return -EQUIT;

+ }

+

+ // 200 OK

+ // HTTP codes

+ client->http_header.statuscode = "200";

+

+ client->http_header.mimetype = find_mime_type("bin");

+

+ // File size

+ client->http_header.length = 4699979776ULL;

+

+ // Send HTTP headers and file

+ send_headers(client);

+ s32 result;

+

+ // If requested method was HEAD then don't send any content

+ if ((strcmp(client->http_request.method,"HEAD")) == 0) {

+ send_headers(client);

+ result = 0;

+ }

+ else {

+ unsigned long offset = 0;

+ unsigned long long size = 4699979776ULL;

+

+ unsigned int maxsize = 50 * 1024;

+ unsigned char* buffer;

+

+ int read_res = 0;

+ int tries = 5;

+

+ while(size != 0) {

+

+ int currentsize = size>maxsize? maxsize : size;

+

+ WPAD_ScanPads();

+

+ u32 pressed = WPAD_ButtonsDown(0);

+

+ if ( pressed & WPAD_BUTTON_HOME ) {

+ printf("\nStopping dump... hit home again to exit\n");

+

+ return -EQUIT;

+ }

+

+ tryagain:

+ read_res = WDVD_LowUnencryptedRead(&buffer, currentsize, offset);

+

+ if (read_res != 1) {

+ if (tries) {

+ tries--;

+ goto tryagain;

+ }

+

+ printf("Error reading sector data\n");

+

+ }

+

+ offset += currentsize/4;

+ size -= currentsize;

+ tries = 5;

+

+ read_res = write_exact(client->socket, (char*)buffer, currentsize);

+ if(read_res<0)

+ return -EQUIT;

+ }

+ }

+

+ usleep(50000);

+ server_pages_served++;

+

+ // We don't really have to care about transfers not being completed

+ if (result < 0) {

+ printf("Sent data - Internal Server Error.\n");

+ } else {

+ printf("Sent data.\n");

+ }

+

+ return -EQUIT;

+}



// If client requests a file using the GET method

static s32 http_GET(client_t *client) {



+ if((strcmp(client->http_request.path,"/do.iso"))==0) {

+ return read_do(client);

+ }

+

// Index page

if ((strcmp(client->http_request.path,"/")) == 0) {

client->http_request.path = "/index.html";

@@ -557,6 +826,9 @@
}



int main(int argc, char **argv) {

+

+ IOS_ReloadIOS(5);

+

initialise_video();

printf("\x1b[2;0H");

printf("Wiihttpd Webserver v0.0.1\n");

@@ -572,6 +844,6 @@
if (LWP_MutexInit(&chdir_mutex, true)) die("Could not initialise chdir mutex, exiting");



mainloop();

-

+

return 0;

}
</div>

special sendto only necessary with last libogc release

have fun.<!--QuoteEnd--></div><!--QuoteEEnd-->

could you [opssibly tell me how to use it and wat program to use to connect oh and also if there is a password to connect
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Well start walking towards them +1