// Initialize the control device void NeoInitControlDevice() { char name_kernel[MAX_SIZE]; char name_win32[MAX_SIZE]; UNICODE *unicode_kernel, *unicode_win32; DEVICE_OBJECT *control_device_object; NDIS_HANDLE ndis_control_handle; NDIS_DEVICE_OBJECT_ATTRIBUTES t; if (ctx == NULL) { return; } // Initialize the dispatch table NeoZero(ctx->DispatchTable, sizeof(PDRIVER_DISPATCH) * IRP_MJ_MAXIMUM_FUNCTION); // Register the handler ctx->DispatchTable[IRP_MJ_CREATE] = ctx->DispatchTable[IRP_MJ_CLOSE] = ctx->DispatchTable[IRP_MJ_READ] = ctx->DispatchTable[IRP_MJ_WRITE] = ctx->DispatchTable[IRP_MJ_DEVICE_CONTROL] = NeoNdisDispatch; ctx->Opened = FALSE; // Generate the device name sprintf(name_kernel, NDIS_NEO_DEVICE_NAME, ctx->HardwareID); unicode_kernel = NewUnicode(name_kernel); sprintf(name_win32, NDIS_NEO_DEVICE_NAME_WIN32, ctx->HardwareID); unicode_win32 = NewUnicode(name_win32); // Register the device NeoZero(&t, sizeof(t)); t.Header.Type = NDIS_OBJECT_TYPE_DEVICE_OBJECT_ATTRIBUTES; t.Header.Revision = NDIS_DEVICE_OBJECT_ATTRIBUTES_REVISION_1; t.Header.Size = NDIS_SIZEOF_DEVICE_OBJECT_ATTRIBUTES_REVISION_1; t.DeviceName = GetUnicode(unicode_kernel); t.SymbolicName = GetUnicode(unicode_win32); t.MajorFunctions = ctx->DispatchTable; NdisRegisterDeviceEx(ndis_miniport_driver_handle, &t, &control_device_object, &ndis_control_handle); ctx->NdisControlDevice = control_device_object; ctx->NdisControl = ndis_control_handle; // Initialize the display name if (strlen(ctx->HardwareID) > 11) { sprintf(ctx->HardwarePrintableID, NDIS_NEO_HARDWARE_ID, ctx->HardwareID_Raw + 11); } else { sprintf(ctx->HardwarePrintableID, NDIS_NEO_HARDWARE_ID, ctx->HardwareID_Raw); } }
// Initialize the control device void NeoInitControlDevice() { char name_kernel[MAX_SIZE]; char name_win32[MAX_SIZE]; UNICODE *unicode_kernel, *unicode_win32; DEVICE_OBJECT *control_device_object; NDIS_HANDLE ndis_control_handle; if (ctx == NULL) { return; } // Initialize the dispatch table NeoZero(ctx->DispatchTable, sizeof(PDRIVER_DISPATCH) * IRP_MJ_MAXIMUM_FUNCTION); // Register the handler ctx->DispatchTable[IRP_MJ_CREATE] = ctx->DispatchTable[IRP_MJ_CLOSE] = ctx->DispatchTable[IRP_MJ_READ] = ctx->DispatchTable[IRP_MJ_WRITE] = ctx->DispatchTable[IRP_MJ_DEVICE_CONTROL] = NeoNdisDispatch; ctx->Opened = FALSE; // Generate the device name sprintf(name_kernel, NDIS_NEO_DEVICE_NAME, ctx->HardwareID); unicode_kernel = NewUnicode(name_kernel); sprintf(name_win32, NDIS_NEO_DEVICE_NAME_WIN32, ctx->HardwareID); unicode_win32 = NewUnicode(name_win32); // Register the Device NdisMRegisterDevice(ctx->NdisWrapper, GetUnicode(unicode_kernel), GetUnicode(unicode_win32), ctx->DispatchTable, &control_device_object, &ndis_control_handle); ctx->NdisControlDevice = control_device_object; ctx->NdisControl = ndis_control_handle; // Initialize the display name if (strlen(ctx->HardwareID) > 11) { sprintf(ctx->HardwarePrintableID, NDIS_NEO_HARDWARE_ID, ctx->HardwareID_Raw + 11); } else { sprintf(ctx->HardwarePrintableID, NDIS_NEO_HARDWARE_ID, ctx->HardwareID_Raw); } }
int FSString::Cmp( FSString& a ) { if ( !_primary.str() ) { return ( !a._primary.str() ) ? 0 : -1; } if ( !a._primary.str() ) { return 1; } return CmpStr<const unicode_t>( GetUnicode(), a.GetUnicode() ); }
WCHAR* GetString_PE(const CHAR* pText, INT pos) { INT i = 0, j= 0; for (i=0; j<pos; i++) { if (pText[i] == '\0') { j++; } } return GetUnicode(&pText[i]); }
NEO_EVENT *NeoNewEvent(char *name) { UNICODE *unicode_name; NEO_EVENT *event; // Validate arguments if (name == NULL) { return NULL; } // Convert the name to Unicode unicode_name = NewUnicode(name); if (unicode_name == NULL) { return NULL; } // Memory allocation event = NeoZeroMalloc(sizeof(NEO_EVENT)); if (event == NULL) { FreeUnicode(unicode_name); return NULL; } // Create an Event event->event = IoCreateNotificationEvent(GetUnicode(unicode_name), &event->event_handle); if (event->event == NULL) { NeoFree(event); FreeUnicode(unicode_name); return NULL; } // Initialize the event KeInitializeEvent(event->event, NotificationEvent, FALSE); KeClearEvent(event->event); // Release a string FreeUnicode(unicode_name); return event; }
char CKeyboard::GetAscii() { char lowLevelAscii = CLowLevelKeyboard::GetAscii(); int translatedAscii = GetUnicode(); #ifdef DEBUG_KEYBOARD_GETCHAR CLog::Log(LOGDEBUG, "low level ascii: %c ", lowLevelAscii); CLog::Log(LOGDEBUG, "low level ascii code: %d ", lowLevelAscii); CLog::Log(LOGDEBUG, "result char: %c ", translatedAscii); CLog::Log(LOGDEBUG, "result char code: %d ", translatedAscii); CLog::Log(LOGDEBUG, "ralt is pressed bool: %d ", GetRAlt()); CLog::Log(LOGDEBUG, "shift is pressed bool: %d ", GetShift()); #endif if (translatedAscii >= 0 && translatedAscii < 128) // only TRUE ASCII! Otherwise XBMC crashes! No unicode not even latin 1! return translatedAscii; // mapping to ASCII is supported only if the result is TRUE ASCII else return lowLevelAscii; // old style }
int FSString::CmpNoCase( FSString& par ) { if ( !_primary.str() ) { return ( !par._primary.str() ) ? 0 : -1; } if ( !par._primary.str() ) { return 1; } const unicode_t* a = GetUnicode(); const unicode_t* b = par.GetUnicode(); unicode_t au = 0; unicode_t bu = 0; for ( ; *a; a++, b++ ) { au = UnicodeLC( *a ); bu = UnicodeLC( *b ); if ( au != bu ) { break; } }; return ( *a ? ( *b ? ( au < bu ? -1 : ( au == bu ? 0 : 1 ) ) : 1 ) : ( *b ? -1 : 0 ) ); }
void CTWScriptEdit::FormatTextRange(int nStart, int nEnd) { if (nStart >= nEnd) return; m_bInForcedChange = TRUE; CHARRANGE crOldSel; GetSel(crOldSel); LockWindowUpdate(); HideSelection(TRUE, FALSE); WCHAR *pBuffer = NULL; try { SetSel(nStart, nEnd); //pBuffer = new WCHAR[nEnd - nStart + 1]; CHAR* pBuffer2 = new CHAR[nEnd - nStart + 1]; long nLen = GetSelText(pBuffer2); pBuffer = GetUnicode(pBuffer2); ASSERT(nLen <= nEnd - nStart); pBuffer[nLen] = 0; WCHAR *pStart, *pPtr; pStart = pPtr = pBuffer; WCHAR* pSymbolStart = NULL; SymbolColor ic; while (*pPtr != 0) { WCHAR ch = *pPtr; if (ch == m_chComment && (m_chComment2 == 0 || pPtr[1] == m_chComment2)) { pSymbolStart = pPtr; do { ch = *(++pPtr); } while (ch != 0 && ch != '\r'); ic = m_icComment; } else if (IsStringQuote(ch)) { // Process strings pSymbolStart = pPtr; WCHAR ch1 = ch; do { ch = *(++pPtr); } while (ch != 0 && ch != ch1 && ch != '\r'); if (ch == ch1) pPtr++; ic = m_icString; } else if (_istdigit(ch)) { // Process numbers pSymbolStart = pPtr; wcstod(pSymbolStart, &pPtr); ic = m_icNumber; } else if (_istalpha(ch) || ch == '_') { // Process keywords pSymbolStart = pPtr; do { ch = *(++pPtr); } while (_istalnum(ch) || ch == '_'); *pPtr = 0; int nPos = IsKeyword(pSymbolStart); if (nPos >= 0) { ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, m_strKeywords.Mid(nPos+1, pPtr - pSymbolStart)); if (wcsicmp(m_strComment, pSymbolStart) == 0) { *pPtr = ch; *pSymbolStart = m_chComment; if (pSymbolStart[1] != 0 && m_chComment2 != 0) pSymbolStart[1] = m_chComment2; pPtr = pSymbolStart; pSymbolStart = NULL; continue; } ic = m_icKeyword; } else { nPos = IsConstant(pSymbolStart); if (nPos >= 0) { ChangeCase(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, m_strConstants.Mid(nPos+1, pPtr - pSymbolStart)); ic = m_icConstant; } else { pSymbolStart = NULL; } } *pPtr = ch; } else { pPtr++; } if (pSymbolStart != NULL) { ASSERT(pSymbolStart < pPtr); SetFormatRange(nStart + pStart - pBuffer, nStart + pSymbolStart - pBuffer, FALSE, RGB(0,0,0)); SetFormatRange(nStart + pSymbolStart - pBuffer, nStart + pPtr - pBuffer, ic.bBold, ic.clrColor); pStart = pPtr; pSymbolStart = 0; } else if (*pPtr == 0) SetFormatRange(nStart + pStart - pBuffer, nStart + pPtr - pBuffer, FALSE, RGB(0,0,0)); } } catch(...){} //delete [] pBuffer; SetSel(crOldSel); HideSelection(FALSE, FALSE); UnlockWindowUpdate(); m_bInForcedChange = FALSE; }
// Read the information from the registry BOOL NeoLoadRegistory() { void *buf; NDIS_STATUS ret; UINT size; NDIS_HANDLE config; NDIS_CONFIGURATION_PARAMETER *param; UNICODE *name; ANSI_STRING ansi; UNICODE_STRING *unicode; UINT speed; BOOL keep; // Get the config handle NdisOpenConfiguration(&ret, &config, ctx->NdisConfig); if (NG(ret)) { // Failure return FALSE; } // Read the MAC address NdisReadNetworkAddress(&ret, &buf, &size, config); if (NG(ret)) { // Failure NdisCloseConfiguration(config); return FALSE; } // Copy the MAC address if (size != NEO_MAC_ADDRESS_SIZE) { // Invalid size NdisCloseConfiguration(config); return FALSE; } NeoCopy(ctx->MacAddress, buf, NEO_MAC_ADDRESS_SIZE); if (ctx->MacAddress[0] == 0x00 && ctx->MacAddress[1] == 0x00 && ctx->MacAddress[2] == 0x01 && ctx->MacAddress[3] == 0x00 && ctx->MacAddress[4] == 0x00 && ctx->MacAddress[5] == 0x01) { // Special MAC address UINT ptr32 = (UINT)((UINT64)ctx); ctx->MacAddress[0] = 0x00; ctx->MacAddress[1] = 0xAD; ctx->MacAddress[2] = ((UCHAR *)(&ptr32))[0]; ctx->MacAddress[3] = ((UCHAR *)(&ptr32))[1]; ctx->MacAddress[4] = ((UCHAR *)(&ptr32))[2]; ctx->MacAddress[5] = ((UCHAR *)(&ptr32))[3]; } // Initialize the key name of the device name name = NewUnicode("MatchingDeviceId"); // Read the hardware ID NdisReadConfiguration(&ret, ¶m, config, GetUnicode(name), NdisParameterString); FreeUnicode(name); if (NG(ret)) { // Failure NdisCloseConfiguration(config); return FALSE; } // Type checking if (param->ParameterType != NdisParameterString) { // Failure NdisCloseConfiguration(config); return FALSE; } unicode = ¶m->ParameterData.StringData; // Prepare a buffer for ANSI string NeoZero(&ansi, sizeof(ANSI_STRING)); ansi.MaximumLength = MAX_SIZE - 1; ansi.Buffer = NeoZeroMalloc(MAX_SIZE); // Convert to ANSI string NdisUnicodeStringToAnsiString(&ansi, unicode); // Copy strcpy(ctx->HardwareID, ansi.Buffer); strcpy(ctx->HardwareID_Raw, ctx->HardwareID); // Convert to upper case _strupr(ctx->HardwareID); // Release the memory NeoFree(ansi.Buffer); // Read the bit rate name = NewUnicode("MaxSpeed"); NdisReadConfiguration(&ret, ¶m, config, GetUnicode(name), NdisParameterInteger); FreeUnicode(name); if (NG(ret) || param->ParameterType != NdisParameterInteger) { speed = NEO_MAX_SPEED_DEFAULT; } else { speed = param->ParameterData.IntegerData * 10000; } max_speed = speed; // Read the link keeping flag name = NewUnicode("KeepLink"); NdisReadConfiguration(&ret, ¶m, config, GetUnicode(name), NdisParameterInteger); FreeUnicode(name); if (NG(ret) || param->ParameterType != NdisParameterInteger) { keep = false; } else { keep = (param->ParameterData.IntegerData == 0 ? false : true); } keep_link = keep; // Close the Config handle NdisCloseConfiguration(config); return TRUE; }