diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index d114bf64b..0d42edcd8 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -779,12 +779,12 @@ int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings) /* - * User settings (at 0x3FE00 and 0x3FE00) + * User settings (at 0x3FE00 and 0x3FF00) */ fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FE00], 0); fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FF00], 1); - /* Config length */ + /* Wifi config length */ MMU.fw.data[0x2C] = 0x38; MMU.fw.data[0x2D] = 0x01; @@ -824,16 +824,20 @@ int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings) memcpy((MMU.fw.data + 0x146), FW_BBChannel, sizeof(FW_BBChannel)); memset((MMU.fw.data + 0x154), 0x10, 0xE); - /* WFC profile */ - memcpy((MMU.fw.data + 0x3FA40), FW_WFCProfile, sizeof(FW_WFCProfile)); + /* WFC profiles */ + memcpy((MMU.fw.data + 0x3FA40), &FW_WFCProfile1, sizeof(FW_WFCProfile)); + memcpy((MMU.fw.data + 0x3FB40), &FW_WFCProfile2, sizeof(FW_WFCProfile)); + memcpy((MMU.fw.data + 0x3FC40), &FW_WFCProfile3, sizeof(FW_WFCProfile)); + (*(u16*)(MMU.fw.data + 0x3FAFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FA00), 0xFE); + (*(u16*)(MMU.fw.data + 0x3FBFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FB00), 0xFE); + (*(u16*)(MMU.fw.data + 0x3FCFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FC00), 0xFE); + MMU.fw.data[0x162] = 0x19; memset((MMU.fw.data + 0x163), 0xFF, 0x9D); /* Wifi settings CRC16 */ - u16 wifi_crc16 = calc_CRC16(0, (MMU.fw.data + 0x2C), 0x138); - MMU.fw.data[0x2A] = (wifi_crc16 & 0xFF); - MMU.fw.data[0x2B] = (wifi_crc16 >> 8); + (*(u16*)(MMU.fw.data + 0x2A)) = calc_CRC16(0, (MMU.fw.data + 0x2C), 0x138); return TRUE ; } diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index 039c29178..699a9b39b 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -125,28 +125,70 @@ u8 FW_BBChannel[14] = { 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, /* channel 1- 6 */ 0xb6, 0xb6 /* channel 13-14 */ } ; -u8 FW_WFCProfile[0xC0] = { 'D','e','S','m','u','m','E',' ','S','o','f','t','A','P', - ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', /* ssid */ - 'D','e','S','m','u','m','E',' ','S','o','f','t','A','P', - ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', /* ssid */ - 'W','E','P','K','E','Y',' ','P','A','R','T',' ','1',' ',' ',' ', - 'W','E','P','K','E','Y',' ','P','A','R','T',' ','2',' ',' ',' ', - 'W','E','P','K','E','Y',' ','P','A','R','T',' ','3',' ',' ',' ', - 'W','E','P','K','E','Y',' ','P','A','R','T',' ','4',' ',' ',' ', - 127,0,0,1, /* IP address */ - 127,0,0,1, /* Gateway */ - 127,0,0,1, /* DNS 1 */ - 127,0,0,1, /* DNS 2 */ - 24, /* subnet/node seperating bit (n*'1' | (32-n)*'0' = subnet mask) */ - 0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0, - 0, /* WEP: disabled */ - 0, /* This entry is: normal (1= AOSS, FF = deleted)*/ - 0,0,0,0,0,0,0,0, - 'W','F','C',' ','U','S','E','R',' ','I','D',' ',' ',' ', /* user id */ - 0,0 /* CRC */ - } ; +/* Note : the values are inspired from what I found in a firmware image from my DS */ + +FW_WFCProfile FW_WFCProfile1 = {"DeSmuME Soft AP", + "", + "", + "", + "", + "", + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + 0, + "", + 0, + 0, + 0, + {0, 0, 0, 0, 0, 0, 0}, + 0, + {0xBA, 0xA0, 0x35, 0xE7, 0x01, 0xD0, 0x05, 0xAD, 0x39, 0x0F, 0x40, 0x1C, 0x2B, 0x2C}, + {0, 0} + } ; + +FW_WFCProfile FW_WFCProfile2 = {"", + "", + "", + "", + "", + "", + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + 0, + "", + 0, + 0, + 0xFF, + {0, 0, 0, 0, 0, 0, 0}, + 0, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0} + } ; + +FW_WFCProfile FW_WFCProfile3 = {"DeSmuME Soft AP 3", + "DeSmuME Soft AP 3", + "WEP KEY PART 1", + "WEP KEY PART 2", + "WEP KEY PART 3", + "WEP KEY PART 4", + {127, 0, 0, 1}, + {127, 0, 0, 1}, + {127, 0, 0, 1}, + {127, 0, 0, 1}, + 24, + "AOSS WEP KEY", + 0, + 0, + 0xFF, + {0, 0, 0, 0, 0, 0, 0}, + 0, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0} + } ; #ifdef EXPERIMENTAL_WIFI diff --git a/desmume/src/wifi.h b/desmume/src/wifi.h index b998c1c97..bab54f47f 100644 --- a/desmume/src/wifi.h +++ b/desmume/src/wifi.h @@ -448,6 +448,33 @@ void WIFI_usTrigger(wifimac_t *wifi) ; #endif +/* DS WFC profile data documented here : */ +/* http://dsdev.bigredpimp.com/2006/07/31/aoss-wfc-profile-data/ */ +/* Note : we use bytes to avoid endianness issues */ +typedef struct _FW_WFCProfile +{ + char SSID[32]; + char SSID_WEP64[32]; + char WEPKEY_PART1[16]; + char WEPKEY_PART2[16]; + char WEPKEY_PART3[16]; + char WEPKEY_PART4[16]; + u8 IP_ADDRESS[4]; + u8 GATEWAY[4]; + u8 PRIM_DNS[4]; + u8 SEC_DNS[4]; + u8 SUBNET_MASK; + u8 WEP64_KEY_AOSS[20]; + u8 UNK1; + u8 WEP_MODE; + u8 STATUS; + u8 UNK2[7]; + u8 UNK3; + u8 UNK4[14]; + u8 CRC16[2]; + +} FW_WFCProfile; + /* wifi data to be stored in firmware, when no firmware image was loaded */ extern u8 FW_Mac[6]; extern u8 FW_WIFIInit[32] ; @@ -455,6 +482,8 @@ extern u8 FW_BBInit[105] ; extern u8 FW_RFInit[36] ; extern u8 FW_RFChannel[6*14] ; extern u8 FW_BBChannel[14] ; -extern u8 FW_WFCProfile[0xC0] ; +extern FW_WFCProfile FW_WFCProfile1; +extern FW_WFCProfile FW_WFCProfile2; +extern FW_WFCProfile FW_WFCProfile3; #endif