<!--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
re;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" />.