読者です 読者をやめる 読者になる 読者になる

tmytのらくがき

個人の日記レベルです

新しいのリリースされてたのでカスタムしてみた。

X01T向け、HTCなどその他デバイス向けの2種類。
Universalは大体どんなデバイスでも動くと思います。今回はデバイス名決め打ちじゃないので。
X01TはSIMが刺さってないときにWifiとかSDとか使わせないためにドライバが変態的なのでUniversal版では動かないのです。困ったものだ。

Download: WifiInfoSetup_Universal.1.25.CAB
Download: WifiInfoSetup_X01T.1.25.CAB

以下パッチ

*** Wifi.cpp	Tue Jul 15 00:40:00 2008
--- WifiInfo/Wifi.cpp	Fri Jul 18 22:58:15 2008
***************
*** 17,22 ****
--- 17,23 ----
  #pragma comment(lib, "Ws2.lib")
  #include <iphlpapi.h>
  #pragma comment(lib, "Iphlpapi.lib")
+ #include <Pm.h>
  
  #include "wifi.h"
  #include "bt.h"
***************
*** 30,35 ****
--- 31,37 ----
  #define WIFI_LED_OFF_EVENT_NAME         _T("LedDrvOffEventWLAN")
  #define STOP_LED_BLINK_EVENT_NAME       _T("WifiInfoStopLedBlink")
  #define WIFI_TIMER_REMOVE_EVENT_NAME    _T("WifiIncoDisconnectTimerRemoveEvent")
+ #define WIFI_DEVICE_GUID                _T("{98C5250D-C29A-4985-AE5F-AFE5367E5006}\\")
  
  #define WIFI_DEVICE_NAME_LENGTH         MAX_PATH
  #define QUERY_BUFFER_SIZE               1024
***************
*** 52,58 ****
  static NDIS_802_11_POWER_MODE   g_ndisPowMode       = Ndis802_11PowerModeMax;
  static WIFI_POWER_MODE          g_wifiPowerMode     = WIFI_POWER_MODE_MAX_PSP;
  static TCHAR                    g_szIPAddress[32]   = _T(""),
!                                 g_szWifiDeviceName[WIFI_DEVICE_NAME_LENGTH] = _T("");
  
  BOOL                            g_bTurnWifiLedOn    = TRUE,
                                  g_bTurnBtOff        = TRUE,
--- 54,61 ----
  static NDIS_802_11_POWER_MODE   g_ndisPowMode       = Ndis802_11PowerModeMax;
  static WIFI_POWER_MODE          g_wifiPowerMode     = WIFI_POWER_MODE_MAX_PSP;
  static TCHAR                    g_szIPAddress[32]   = _T(""),
!                                 g_szWifiDeviceName[WIFI_DEVICE_NAME_LENGTH] = _T(""),
!                                 g_szWifiDeviceFullName[WIFI_DEVICE_NAME_LENGTH] = _T("");
  
  BOOL                            g_bTurnWifiLedOn    = TRUE,
                                  g_bTurnBtOff        = TRUE,
***************
*** 97,102 ****
--- 100,128 ----
  
      g_dwWifiStatusPrev = GetWifiStatus();
      RegisterNotification();
+ 
+ #ifdef UNIVERSAL
+ 	// アダプタ名が取得できるので。
+ 	HKEY hkey;
+ 	RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Comm\\", 0, KEY_ALL_ACCESS, &hkey);
+ 
+ 	wchar_t name[32];
+ 	DWORD n = 0, length = 31;
+ 	while (RegEnumKeyEx(hkey, n++, name, &length, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+ 	{
+ 		length = 31;
+ 		HKEY hsubkey;
+ 		DWORD data, sz = sizeof(DWORD);
+ 		RegOpenKeyEx(hkey, name, 0, KEY_ALL_ACCESS, &hsubkey);
+ 		if (RegQueryValueEx(hsubkey, L"Wireless", NULL, NULL, (LPBYTE)&data, &sz) == ERROR_SUCCESS) {
+ 			wcscat_s(g_szWifiDeviceFullName, WIFI_DEVICE_NAME_LENGTH, WIFI_DEVICE_GUID);
+ 			wcscat_s(g_szWifiDeviceFullName, WIFI_DEVICE_NAME_LENGTH, name);
+ 			break;
+ 		}
+ 	}
+ 
+ 	RegCloseKey(hkey);
+ #endif
  }
  
  // 終了
***************
*** 114,119 ****
--- 140,155 ----
  // 無線LAN ON
  VOID TurnWifiPowerOn()
  {
+ #ifdef X01T
+     SHELLEXECUTEINFO si = {sizeof(SHELLEXECUTEINFO), 0, NULL, NULL,
+          L"\\Windows\\tfwifi.exe", NULL, L"\\Windows", SW_SHOW,
+          0, NULL, NULL, NULL, 0, NULL, NULL};
+     ShellExecuteEx(&si);
+ #elif UNIVERSAL
+ 	// DevicePower D0 でON
+ 	DevicePowerNotify((PVOID)g_szWifiDeviceFullName, D0, POWER_NAME);
+ 	SetDevicePower((PVOID)g_szWifiDeviceFullName, POWER_NAME, D0);
+ #else
      HANDLE  hEvent = NULL;
  
      hEvent = CreateEvent(NULL, FALSE, FALSE, WIFI_POWON_EVENT_NAME);
***************
*** 125,136 ****
          CloseHandle(hEvent);
          hEvent = NULL;
      }
  }
  
  // 無線LAN OFF
  VOID TurnWifiPowerOff()
  {
!     HANDLE hEvent = NULL;
      hEvent = CreateEvent(NULL, FALSE, FALSE, WIFI_POWOFF_EVENT_NAME);
  
      if (hEvent != NULL) {
--- 161,183 ----
          CloseHandle(hEvent);
          hEvent = NULL;
      }
+ #endif
  }
  
  // 無線LAN OFF
  VOID TurnWifiPowerOff()
  {
! #ifdef X01T
!     SHELLEXECUTEINFO si = {sizeof(SHELLEXECUTEINFO), 0, NULL, NULL,
!          L"\\Windows\\tfwifi.exe", NULL, L"\\Windows", SW_SHOW,
!          0, NULL, NULL, NULL, 0, NULL, NULL};
!     ShellExecuteEx(&si);
! #elif UNIVERSAL
! 	// DevicePower D4 でOFF
! 	DevicePowerNotify((PVOID)g_szWifiDeviceFullName, D4, POWER_NAME);
! 	SetDevicePower((PVOID)g_szWifiDeviceFullName, POWER_NAME, D4);
! #else
! 	HANDLE hEvent = NULL;
      hEvent = CreateEvent(NULL, FALSE, FALSE, WIFI_POWOFF_EVENT_NAME);
  
      if (hEvent != NULL) {
***************
*** 138,143 ****
--- 185,191 ----
          CloseHandle(hEvent);
          hEvent = NULL;
      }
+ #endif
  }
  
  // 無線LAN LED ON/OFF