Fordi
Group: Members
Posts: 90
Joined: April 2004 |
|
Posted: Dec. 24 2004,01:14 |
|
Ok, it took a bit of doing, but I got cbagger01's last suggestion in.
Code Sample | Changes to linuxrc: ------LINE 529, inserting 27 lines: # last ditch - try to mount KNOPPIX ci file from /dev/hda if test -n "$FOUND_KNOPPIX" then else QEMU="" echo echo "${BLUE}Guess you're running from QEMU${NORMAL}" echo "${BLUE}Performing last-ditch effort to get KNOPPIX image${NORMAL}" # try to mount /dev/hda as a cloop echo "0" > /proc/sys/kernel/printk $INSMOD modules/cloop.o file=/dev/hda >/dev/null 2>&1 if mount -t iso9660 /dev/cloop /KNOPPIX >/dev/null 2>&1 then FOUND_KNOPPIX="/dev/hda" QEMU="TRUE" echo "${GREEN}Success!${NORMAL}" else # try one more time, this time directly trying to mount /dev/hda if mount -t iso9660 /dev/hda /KNOPPIX >/dev/null 2>&1 then FOUND_KNOPPIX="/dev/hda" QEMU="TRUE" echo "${GREEN}Success!${NORMAL}" else echo "${RED}Failed..." fi fi fi ------LINE 673, replacing 8 lines: rm -rf /etc/ftpusers /etc/passwd /etc/shadow /etc/shadow- /etc/group \ /etc/ppp /etc/isdn /etc/ssh /etc/ioctl.save \ /etc/inittab /etc/network /etc/sudoers \ /etc/init /etc/localtime /etc/dhcpc /etc/pnm2ppa.conf /etc/hosts 2>/dev/null cp -a /KNOPPIX/etc/ftpusers /KNOPPIX/etc/passwd /KNOPPIX/etc/shadow /KNOPPIX/etc/shadow- /KNOPPIX/etc/group \ /KNOPPIX/etc/ppp /KNOPPIX/etc/isdn /KNOPPIX/etc/ssh \ /KNOPPIX/etc/inittab /KNOPPIX/etc/network /KNOPPIX/etc/sudoers \ /KNOPPIX/sbin/init /KNOPPIX/etc/dhcpc /KNOPPIX/etc/hosts /etc/ 2>/dev/null ------LINE 689, inserting 10 lines # Hey, we're in QEMU! Let's get all cozy with the host, shall we? if test -n "$QEMU" then HNAME=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/sysname=/s/.*=//p' | /usr/bin/tail -1) HIP=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/sysip=/s/.*=//p' | /usr/bin/tail -1) echo echo "${BLUE}QEMU Host is ${MAGENTA}${HNAME}${BLUE} at IP ${MAGENTA}${HIP}${NORMAL}" echo "${HIP} ${HNAME}" >> /etc/hosts echo "${HIP} syshost" >>/etc/hosts fi |
Code Sample | Listing of rq.c #include <winsock.h> #include <shellapi.h> int doit(); int doit(char* res) { WSADATA wsaData; if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) { return 255; } int i=0; char ac[80]; char ip[16]; if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) { printf("Error %d when getting local host name\r\n", WSAGetLastError()); return 1; } struct hostent *phe = gethostbyname(ac); if (phe == 0) { printf("Yow! Bad host lookup!\r\n"); return 1; }
struct in_addr addr; memcpy(&addr, phe->h_addr_list[i], sizeof(struct in_addr)); sprintf(res, "sysname=%s sysip=%s", ac, inet_ntoa(addr)); WSACleanup(); return 0; } int main(int argc, char *argv[]) { char hostip[95]; char* temp; int retval = doit(hostip); temp=malloc(1024); sprintf(temp, "-kernel isolinux/linux24 -initrd isolinux/minirt24.gz -hda KNOPPIX/KNOPPIX -L qemu -append \"sb=0x220,5,1,5 vga=789 %s\"", &hostip[0]); ShellExecute(NULL, NULL, "qemu/qemu.exe", temp, NULL, SW_SHOW); free(temp); return retval; } |
compile that thusly (using mingw):
Code Sample | gcc -O2 rq.c -o rq.exe -lshell32 -lwsock32 strip rq.exe upx -9 rq.exe |
It should come out to 3584 bytes.
Code Sample | listing of autorun.inf [autorun] open=rq.exe |
Ok, now that I've posted all that, what it does: It allows QEMU to communicate with the host PC via either it's known hostname ("punquin" in my case) or by "syshost". You see the append line has also changed to include a definition of the emulated SB card. I haven't tested this (I'm doing my tests from my work (WinXP) computer via rdesktop, and while textmode works fine, using a mouse is a highly wonky). Still, seeing as the SB card isn't working at all without that line, it can't hurt to throw it in.
|