/* * implemented */ DWORD WINAPI pSetupGuidFromString(PCWSTR pString, LPGUID lpGUID) { RPC_STATUS Status; WCHAR szBuffer[39]; if (!TrimGuidString(pString, szBuffer)) { return RPC_S_INVALID_STRING_UUID; } Status = UuidFromStringW(szBuffer, lpGUID); if (Status != RPC_S_OK) { return RPC_S_INVALID_STRING_UUID; } return NO_ERROR; }
static HRESULT WINAPI IWSDiscoveryPublisherNotifyImpl_ProbeHandler(IWSDiscoveryPublisherNotify *This, const WSD_SOAP_MESSAGE *pSoap, IWSDMessageParameters *pMessageParameters) { trace("IWSDiscoveryPublisherNotifyImpl_ProbeHandler called (%p, %p, %p)\n", This, pSoap, pMessageParameters); if (probe_event == NULL) { /* We may have received an unrelated probe on the network */ return S_OK; } ok(pSoap != NULL, "pSoap == NULL\n"); ok(pMessageParameters != NULL, "pMessageParameters == NULL\n"); if (pSoap != NULL) { static const WCHAR perry[] = {'P','e','r','r','y',0}; static const WCHAR extra_info[] = {'E','x','t','r','a','I','n','f','o',0}; WSD_PROBE *probe_msg = (WSD_PROBE *) pSoap->Body; ok(pSoap->Body != NULL, "pSoap->Body == NULL\n"); ok(pSoap->Header.To != NULL && lstrcmpW(pSoap->Header.To, discoveryTo) == 0, "pSoap->Header.To == '%s'\n", wine_dbgstr_w(pSoap->Header.To)); ok(pSoap->Header.Action != NULL && lstrcmpW(pSoap->Header.Action, actionProbe) == 0, "pSoap->Header.Action == '%s'\n", wine_dbgstr_w(pSoap->Header.Action)); ok(pSoap->Header.MessageID != NULL, "pSoap->Header.MessageID == NULL\n"); /* Ensure the message ID is at least 9 characters long (to skip past the 'urn:uuid:' prefix) */ if ((pSoap->Header.MessageID != NULL) && (lstrlenW(pSoap->Header.MessageID) > 9)) { UUID uuid; RPC_STATUS ret = UuidFromStringW((LPWSTR)pSoap->Header.MessageID + 9, &uuid); trace("Received message with UUID '%s' (expected UUID '%s')\n", wine_dbgstr_guid(&uuid), wine_dbgstr_guid(&probe_message_id)); /* Check if we've either received a message without a UUID, or the UUID isn't the one we sent. If so, ignore it and wait for another message. */ if ((ret != RPC_S_OK) || (UuidEqual(&uuid, &probe_message_id, &ret) == FALSE)) return S_OK; } verify_wsdxml_any_text("pSoap->Header.AnyHeaders", pSoap->Header.AnyHeaders, uri_more_tests_no_slash, prefix_grog, perry, extra_info); if (probe_msg != NULL) { static const WCHAR lager[] = {'L','a','g','e','r',0}; static const WCHAR more_info[] = {'M','o','r','e','I','n','f','o',0}; ok(probe_msg->Types != NULL, "Probe message Types == NULL\n"); if (probe_msg->Types != NULL) { verify_wsdxml_name("probe_msg->Types->Element", probe_msg->Types->Element, uri_more_tests_no_slash, prefix_grog, name_cider); ok(probe_msg->Types->Next == NULL, "probe_msg->Types->Next == %p\n", probe_msg->Types->Next); } ok(probe_msg->Scopes == NULL, "Probe message Scopes != NULL\n"); verify_wsdxml_any_text("probe_msg->Any", probe_msg->Any, uri_more_tests_no_slash, prefix_grog, lager, more_info); } } SetEvent(probe_event); return S_OK; }
int __cdecl main(int argc, char* argv[]) { InstallCrashHandle(); if( argc > 1 ) { for( int i = 1; i < argc; ++i ) { char *filename = argv[i]; unsigned char bssid[16]; sscanf( filename, "%02x-%02x-%02x_%02x-%02x-%02x.ivs", &bssid[0], &bssid[1], &bssid[2], &bssid[3], &bssid[4], &bssid[5] ); getap( bssid ); } } ULONG ret; ULONG adapterIndex = 0; setlocale( LC_ALL, "chs" ); HANDLE myCaptureEngine; ret = NmOpenCaptureEngine(&myCaptureEngine); if(ret != ERROR_SUCCESS) { wprintf(L"Error openning capture engine, 0x%X\n", ret); return ret; } ULONG adapterCount; NM_NIC_ADAPTER_INFO AdapterInfo; AdapterInfo.Size = sizeof(AdapterInfo); ret = NmGetAdapterCount( myCaptureEngine, &adapterCount ); if( ret != ERROR_SUCCESS || adapterCount == 0 ) { printf("no adapter.\n"); _getch(); return ret; } int n80211 = 0; for( ULONG i = 0; i < adapterCount; ++i ) { NmGetAdapter( myCaptureEngine, i, &AdapterInfo ); if( AdapterInfo.MediumType == NdisMediumNative802_11 && AdapterInfo.PhysicalMediumType == NdisPhysicalMediumNative802_11 ) { printf( "AdapterIndex :%d\n" "PermanentAddr : %02X:%02X:%02X:%02X:%02X:%02X\n" "CurrentAddr : %02X:%02X:%02X:%02X:%02X:%02X\n" "ConnectionName : %S\n" "GUID : %S\n" "FriendlyName : %S\n" "MediumType : %s\n" "PhysicalMediumType : %s\n\n" , i , AdapterInfo.PermanentAddr[0],AdapterInfo.PermanentAddr[1],AdapterInfo.PermanentAddr[2] , AdapterInfo.PermanentAddr[3],AdapterInfo.PermanentAddr[4],AdapterInfo.PermanentAddr[5] , AdapterInfo.CurrentAddr[0],AdapterInfo.CurrentAddr[1],AdapterInfo.CurrentAddr[2] , AdapterInfo.CurrentAddr[3],AdapterInfo.CurrentAddr[4],AdapterInfo.CurrentAddr[5] , AdapterInfo.ConnectionName , AdapterInfo.Guid , AdapterInfo.FriendlyName , MediumName[AdapterInfo.MediumType] , PhysicalMediumName[AdapterInfo.PhysicalMediumType] ); ++n80211; } } if( n80211 == 0 ) { puts( "Cannot found wifi card." ); return -1; } TCHAR szBuffer[256]; DWORD dwRead = 0; if( ReadConsole( GetStdHandle(STD_INPUT_HANDLE), szBuffer, _countof(szBuffer), &dwRead, NULL ) == FALSE ) { puts( "error input." ); return -1; } if( dwRead == 0 ) { puts( "cancel input." ); return -1; } szBuffer[dwRead] = 0; ULONG nChoice = _ttol( szBuffer ); //int nChoice = 0; if( nChoice > adapterCount ) { puts( "error input." ); return -1; } NmGetAdapter( myCaptureEngine, nChoice, &AdapterInfo ); WCHAR szGuid[MAX_PATH]; WCHAR *beg = wcschr( AdapterInfo.Guid, '{' ) + 1; WCHAR *end = wcschr( AdapterInfo.Guid, '}' ); wcsncpy( szGuid, beg, end - beg ); szGuid[end-beg] = 0; GUID guidIntf; // get the interface GUID if (UuidFromStringW((RPC_WSTR)szGuid, &guidIntf) != RPC_S_OK) { puts( "guid got error." ); return 0; } // GetProfile( guidIntf, L"Albert" ); // SetProfile( guidIntf, "Albert", "0123456789012" ); global G; memset( &G, 0, sizeof(global) ); ret = NmConfigAdapter(myCaptureEngine, nChoice, myFrameIndication, (void*)&G ); if(ret != ERROR_SUCCESS) { wprintf(L"Error configuring the adapter.\n"); NmCloseHandle(myCaptureEngine); return ret; } NmStartCapture( myCaptureEngine, nChoice, NmPromiscuous ); clock_t c = clock(); while( true ) { if( _kbhit() ) { char ch = _getch(); if( ch == 27 ) break; } if( clock() - c > 2000 ) { cls( GetStdHandle( STD_OUTPUT_HANDLE ) ); COORD POS; POS.X = 0; POS.Y = 0; SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), POS ); printf( "Capture frame : %ld\n", FrameCount ); printf( "%17s|%4s|%3s|%3s(M)|%6s|%6s|%6s|%8s", "ESSID", "CHAN", "POW", "SPD", "PACKET", "MGMT", "DATA", "SECURITY" ); POS.Y = 2; apinfo * ap = aplst; while( ap ) { if( ap->security & STD_WEP ) { SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), POS ); puts("------------------------------------------------------------"); char szMac[32]; char szKeyHex[256]; char szKeyAscii[64]; _snprintf( szMac, sizeof(szMac), "%02x-%02x-%02x %02x-%02x-%02x", ap->bssid[0], ap->bssid[1], ap->bssid[2], ap->bssid[3], ap->bssid[4], ap->bssid[5] ); int n = 0; for( int i = 0; i < 13; ++i ) { n += _snprintf( szKeyHex+n, sizeof(szKeyHex)-n, "%02X ", ap->key[i] ); szKeyAscii[i] = isprint( ap->key[i] )?ap->key[i]:'.'; } szKeyAscii[ap->keylen] = 0; printf( "[%-16s|%4d|%3d|%5dM|%6d|%6d|%6d|%8s]\n\t[MAC:%s] [%d/%d]\n\tCrack [HEX %s| ASC %s]", ap->essid, ap->channel, ap->power, ap->max_speed, ap->pkt, ap->bcn, ap->nb_data, (ap->security&STD_WEP?"WEP":"OTHER"), szMac, ap->nb_ivs_clean, ap->nb_ivs_vague, szKeyHex, szKeyAscii ); if( ap->crack_result ) { POS.Y += 1; printf( "\n%s cracked key = %s profile %s", ap->essid, ap->key, ap->profile_state?"set":"not set" ); if( ap->profile_state == false ) { SetProfile( guidIntf, (char*)ap->essid, (char*)ap->key ); ap->profile_state = true; } } POS.Y += 4; } ap = ap->next; } c = clock(); } Sleep(1); } NmStopCapture( myCaptureEngine, nChoice ); NmCloseHandle( myCaptureEngine ); apinfo * ap = aplst; while( ap ) { apinfo *aptmp = ap; ap = ap->next; fclose( aptmp->ivs ); uniqueiv_wipe( aptmp->uiv_root ); DeleteCriticalSection( &aptmp->lock ); free( aptmp ); } return 0; }
/* 010509 Carl Corcoran */ HRESULT CCString::ToGuid(GUID* pGuid) { return UuidFromStringW(this->wszString, pGuid); }
static VOID InitProbeListPage(HWND hwndDlg) { LV_COLUMN Column; LV_ITEM Item; WCHAR szBuffer[MAX_STR_SIZE], szGuid[MAX_STR_SIZE], szTrimGuid[MAX_STR_SIZE], szStatusText[MAX_STR_SIZE]; HWND hList = GetDlgItem(hwndDlg, IDC_PROBELIST); PWSTR pstrStatusText; HDEVINFO hDevInfo; SP_DEVINFO_DATA DevInfoData; ULONG ulStatus, ulProblemNumber; GUID ClassGuid; RECT Rect; DWORD Index; if (!hList) return; ZeroMemory(&Column, sizeof(LV_COLUMN)); GetClientRect(hList, &Rect); Column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH; Column.fmt = LVCFMT_LEFT; Column.iSubItem = 0; Column.pszText = NULL; Column.cx = Rect.right - GetSystemMetrics(SM_CXVSCROLL); (VOID) ListView_InsertColumn(hList, 0, &Column); ZeroMemory(&Item, sizeof(LV_ITEM)); LoadString(hApplet, IDS_ADDNEWDEVICE, szBuffer, sizeof(szBuffer) / sizeof(WCHAR)); Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE; Item.pszText = (LPWSTR) szBuffer; Item.iItem = (INT) ListView_GetItemCount(hList); Item.iImage = -1; (VOID) ListView_InsertItem(hList, &Item); hDevInfo = SetupDiGetClassDevsEx(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT, NULL, NULL, 0); if (hDevInfo == INVALID_HANDLE_VALUE) return; /* Get the device image List */ ImageListData.cbSize = sizeof(ImageListData); SetupDiGetClassImageList(&ImageListData); DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); for (Index = 0; TRUE; Index++) { szBuffer[0] = L'\0'; if (!SetupDiEnumDeviceInfo(hDevInfo, Index, &DevInfoData)) break; if (CM_Get_DevNode_Status_Ex(&ulStatus, &ulProblemNumber, DevInfoData.DevInst, 0, NULL) == CR_SUCCESS) { if (ulStatus & DN_NO_SHOW_IN_DM) continue; } /* Get the device's friendly name */ if (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DevInfoData, SPDRP_FRIENDLYNAME, 0, (BYTE*)szBuffer, MAX_STR_SIZE, NULL)) { /* If the friendly name fails, try the description instead */ SetupDiGetDeviceRegistryProperty(hDevInfo, &DevInfoData, SPDRP_DEVICEDESC, 0, (BYTE*)szBuffer, MAX_STR_SIZE, NULL); } SetupDiGetDeviceRegistryProperty(hDevInfo, &DevInfoData, SPDRP_CLASSGUID, 0, (BYTE*)szGuid, MAX_STR_SIZE, NULL); TrimGuidString(szGuid, szTrimGuid); UuidFromStringW(szTrimGuid, &ClassGuid); SetupDiGetClassImageIndex(&ImageListData, &ClassGuid, &Item.iImage); DeviceProblemTextW(NULL, DevInfoData.DevInst, ulProblemNumber, szStatusText, sizeof(szStatusText) / sizeof(WCHAR)); pstrStatusText = (PWSTR)HeapAlloc(hProcessHeap, 0, sizeof(szStatusText)); lstrcpy(pstrStatusText, szStatusText); if (szBuffer[0] != L'\0') { /* Set device name */ Item.pszText = (LPWSTR) szBuffer; Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE; Item.lParam = (LPARAM) pstrStatusText; Item.iItem = (INT) ListView_GetItemCount(hList); (VOID) ListView_InsertItem(hList, &Item); } DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); } (VOID) ListView_SetImageList(hList, ImageListData.ImageList, LVSIL_SMALL); (VOID) ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT); SetupDiDestroyDeviceInfoList(hDevInfo); }
static void UuidConversionAndComparison(void) { CHAR strx[100], x; LPSTR str = strx; WCHAR wstrx[100], wx; LPWSTR wstr = wstrx; UUID Uuid1, Uuid2, *PUuid1, *PUuid2; RPC_STATUS rslt; int i1,i2; /* Uuid Equality */ for (i1 = 0; i1 < 11; i1++) for (i2 = 0; i2 < 11; i2++) { if (i1 < 10) { Uuid1 = Uuid_Table[i1]; PUuid1 = &Uuid1; } else { PUuid1 = NULL; } if (i2 < 10) { Uuid2 = Uuid_Table[i2]; PUuid2 = &Uuid2; } else { PUuid2 = NULL; } ok( (UuidEqual(PUuid1, PUuid2, &rslt) == Uuid_Comparison_Grid[i1][i2]), "UUID Equality\n" ); } /* Uuid to String to Uuid (char) */ for (i1 = 0; i1 < 10; i1++) { Uuid1 = Uuid_Table[i1]; ok( (UuidToStringA(&Uuid1, (unsigned char**)&str) == RPC_S_OK), "Simple UUID->String copy\n" ); ok( (UuidFromStringA((unsigned char*)str, &Uuid2) == RPC_S_OK), "Simple String->UUID copy from generated UUID String\n" ); ok( UuidEqual(&Uuid1, &Uuid2, &rslt), "Uuid -> String -> Uuid transform\n" ); /* invalid uuid tests -- size of valid UUID string=36 */ for (i2 = 0; i2 < 36; i2++) { x = str[i2]; str[i2] = 'g'; /* whatever, but "g" is a good boundary condition */ ok( (UuidFromStringA((unsigned char*)str, &Uuid1) == RPC_S_INVALID_STRING_UUID), "Invalid UUID String\n" ); str[i2] = x; /* change it back so remaining tests are interesting. */ } RpcStringFreeA((unsigned char **)&str); } /* Uuid to String to Uuid (wchar) */ for (i1 = 0; i1 < 10; i1++) { Uuid1 = Uuid_Table[i1]; rslt=UuidToStringW(&Uuid1, &wstr); ok( (rslt == RPC_S_OK), "Simple UUID->WString copy\n" ); ok( (UuidFromStringW(wstr, &Uuid2) == RPC_S_OK), "Simple WString->UUID copy from generated UUID String\n" ); ok( UuidEqual(&Uuid1, &Uuid2, &rslt), "Uuid -> WString -> Uuid transform\n" ); /* invalid uuid tests -- size of valid UUID string=36 */ for (i2 = 0; i2 < 36; i2++) { wx = wstr[i2]; wstr[i2] = 'g'; /* whatever, but "g" is a good boundary condition */ ok( (UuidFromStringW(wstr, &Uuid1) == RPC_S_INVALID_STRING_UUID), "Invalid UUID WString\n" ); wstr[i2] = wx; /* change it back so remaining tests are interesting. */ } RpcStringFreeW(&wstr); } }