#include #include #include #include "debug.h" #include "stringutils.h" void fill_ci(CONNMGR_CONNECTIONINFO *ci, GUID& guid, int prio) { memset(ci, 0, sizeof(CONNMGR_CONNECTIONINFO)); ci->cbSize= sizeof(CONNMGR_CONNECTIONINFO); ci->dwParams= CONNMGR_PARAM_GUIDDESTNET; ci->dwPriority= prio; ci->guidDestNet= guid; //ci->bDisabled= true; } void dump_ipaddr(CONNMGR_CONNECTION_IPADDR*ip) { for (unsigned i=0 ; icIPAddr ; i++) { printf("addr[%d]: %s\n", i, hexdump((BYTE*)(&ip->IPAddr[i]), sizeof(SOCKADDR_STORAGE)).c_str()); } } void dump_details(CONNMGR_CONNECTION_DETAILED_STATUS *p) { debug("v=%08lx p=%08lx t=%08lx s=%08lx f=%08lx sec=%08lx stat=%08lx q=%08lx\n", p->dwVer, p->dwParams, p->dwType, p->dwSubtype, p->dwFlags, p->dwSecure, p->dwConnectionStatus, p->dwSignalQuality); debug("dst=%s\n", GuidToString(&p->guidDestNet).c_str()); debug("src=%s\n", GuidToString(&p->guidSourceNet).c_str()); if (p->szDescription) debug("desc: %s\n", ToString(p->szDescription).c_str()); if (p->szAdapterName) debug("adap: %s\n", ToString(p->szAdapterName).c_str()); debug("last: %04d-%02d-%02d(%d) %02d:%02d:%02d.%03d\n", p->LastConnectTime.wYear, p->LastConnectTime.wMonth, p->LastConnectTime.wDay, p->LastConnectTime.wDayOfWeek, p->LastConnectTime.wHour, p->LastConnectTime.wMinute, p->LastConnectTime.wSecond, p->LastConnectTime.wMilliseconds); if (p->pIPAddr) dump_ipaddr(p->pIPAddr); } typedef HRESULT (WINAPI *PFN_ConnMgrQueryDetailedStatus)(CONNMGR_CONNECTION_DETAILED_STATUS *, DWORD *); PFN_ConnMgrQueryDetailedStatus myConnMgrQueryDetailedStatus; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { DebugSetLogfile("tstenumnet.log"); debug("start\n"); HMODULE hLib= LoadLibrary(_T("cellcore.dll")); myConnMgrQueryDetailedStatus= (PFN_ConnMgrQueryDetailedStatus )GetProcAddress(hLib, _T("ConnMgrQueryDetailedStatus")); debug("%08lx %08lx\n", hLib, myConnMgrQueryDetailedStatus); for (int i=0 ; 1 ; i++) { CONNMGR_DESTINATION_INFO di; memset(&di, 0, sizeof(di)); HRESULT hr= ConnMgrEnumDestinations(i, &di); if (hr) break; CONNMGR_CONNECTIONINFO ci; HANDLE hConn= NULL; DWORD status= 0; fill_ci(&ci, di.guid, CONNMGR_PRIORITY_USERINTERACTIVE); hr= ConnMgrEstablishConnectionSync(&ci, &hConn, 10000, &status); debug("%08lx %08lx %08lx %s %s\n", hr, status, hConn, GuidToString(&di.guid).c_str(), ToString(di.szDescription).c_str()); } DWORD size=0; HRESULT hr= myConnMgrQueryDetailedStatus(NULL, &size); debug("hr=%08lx, size=%08lx\n", hr, size); ByteVector bv(size); CONNMGR_CONNECTION_DETAILED_STATUS *s= (CONNMGR_CONNECTION_DETAILED_STATUS*)&bv[0]; hr= myConnMgrQueryDetailedStatus(s, &size); debug("hr=%08lx, size=%08lx\n", hr, size); for (CONNMGR_CONNECTION_DETAILED_STATUS *p= s ; p ; p= p->pNext) { dump_details(p); } debug("done\n"); return 0; }