/* This function creates a new mailbox and a rule to accompany * that mailbox. */ void FASTCALL CreateSortMailFrom( HWND hwnd ) { LPWINDINFO lpWindInfo; lpWindInfo = GetBlock( hwndTopic ); if( Amdb_GetTopicType( lpWindInfo->lpTopic ) != FTYPE_MAIL ) return; if( Adm_Dialog( hInst, hwnd, MAKEINTRESOURCE(IDDLG_SORTMAILFROM), SortMailFrom, 0L ) ) { MSGINFO msginfo; RULE rule; PTH pth; /* Get the current folder handle. */ Amdb_GetMsgInfo( lpWindInfo->lpMessage, &msginfo ); /* First create a new rule. */ memset( &rule, 0, sizeof(RULE) ); rule.wFlags = FILF_MOVE; rule.pData = lpWindInfo->lpTopic; rule.pMoveData = ptlDest; lstrcpy( rule.szFromText, szRuleAuthor ); if( CreateRule( &rule ) == NULL ) { fMessageBox( hwnd, 0, GS(IDS_STR1043), MB_OK|MB_ICONINFORMATION ); return; } /* If we move existing messages, then loop and move 'em. */ if( fMoveExisting ) { PTH FAR * lppth; int count; HCURSOR hOldCursor; INITIALISE_PTR(lppth); /* Busy, busy, bee */ hOldCursor = SetCursor( hWaitCursor ); /* First pass - count the number of messages. */ count = 0; for( pth = Amdb_GetFirstMsg( lpWindInfo->lpTopic, VM_VIEWCHRON ); pth; pth = Amdb_GetNextMsg( pth, VM_VIEWCHRON ) ) { MSGINFO msginfo2; Amdb_GetMsgInfo( pth, &msginfo2 ); // if( strcmp( msginfo2.szAuthor, szRuleAuthor ) == 0 || ( szRuleAuthor[ 0 ] == '@' && strstr( msginfo2.szAuthor, szRuleAuthor ) != NULL ) ) if( AddressRuleMatch( szRuleAuthor, msginfo2.szAuthor ) != -1 ) ++count; } /* Second pass, allocate a PTH array of count messages and collect * the pth handles to the array. */ if( count > 0 ) { if( fNewMemory( (PTH FAR *)&lppth, ( count + 1 ) * sizeof(PTH) ) ) { int index; index = 0; for( pth = Amdb_GetFirstMsg( lpWindInfo->lpTopic, VM_VIEWCHRON ); pth; pth = Amdb_GetNextMsg( pth, VM_VIEWCHRON ) ) { MSGINFO msginfo2; Amdb_GetMsgInfo( pth, &msginfo2 ); // if( strcmp( msginfo2.szAuthor, szRuleAuthor ) == 0 || ( szRuleAuthor[ 0 ] == '@' && strstr( msginfo2.szAuthor, szRuleAuthor ) != NULL ) ) if( AddressRuleMatch( szRuleAuthor, msginfo2.szAuthor ) != -1 ) { ASSERT( index < count ); lppth[ index++ ] = pth; } } ASSERT( index == count ); lppth[ index++ ] = NULL; DoCopyLocalRange( hwndTopic, lppth, count, ptlDest, TRUE, FALSE ); FreeMemory( (PTH FAR *)&lppth ); } } SetCursor( hOldCursor ); } } }
CPLErr GNMGenericNetwork::CreateMetadataLayer(GDALDataset * const pDS, int nVersion, size_t nFieldSize) { OGRLayer* pMetadataLayer = pDS->CreateLayer(GNM_SYSLAYER_META, NULL, wkbNone, NULL); if (NULL == pMetadataLayer) { CPLError( CE_Failure, CPLE_AppDefined, "Creation of '%s' layer failed", GNM_SYSLAYER_META ); return CE_Failure; } OGRFieldDefn oFieldKey(GNM_SYSFIELD_PARAMNAME, OFTString); oFieldKey.SetWidth(static_cast<int>(nFieldSize)); OGRFieldDefn oFieldValue(GNM_SYSFIELD_PARAMVALUE, OFTString); oFieldValue.SetWidth(static_cast<int>(nFieldSize)); if(pMetadataLayer->CreateField(&oFieldKey) != OGRERR_NONE || pMetadataLayer->CreateField(&oFieldValue) != OGRERR_NONE) { CPLError( CE_Failure, CPLE_AppDefined, "Creation of layer '%s' fields failed", GNM_SYSLAYER_META ); return CE_Failure; } OGRFeature *poFeature; // write name poFeature = OGRFeature::CreateFeature(pMetadataLayer->GetLayerDefn()); poFeature->SetField(GNM_SYSFIELD_PARAMNAME, GNM_MD_NAME); poFeature->SetField(GNM_SYSFIELD_PARAMVALUE, m_soName); if(pMetadataLayer->CreateFeature(poFeature) != OGRERR_NONE) { OGRFeature::DestroyFeature( poFeature ); CPLError( CE_Failure, CPLE_AppDefined, "Write GNM name failed"); return CE_Failure; } OGRFeature::DestroyFeature(poFeature); // write version poFeature = OGRFeature::CreateFeature(pMetadataLayer->GetLayerDefn()); poFeature->SetField(GNM_SYSFIELD_PARAMNAME, GNM_MD_VERSION); poFeature->SetField(GNM_SYSFIELD_PARAMVALUE, CPLSPrintf("%d", nVersion)); if(pMetadataLayer->CreateFeature(poFeature) != OGRERR_NONE) { OGRFeature::DestroyFeature( poFeature ); CPLError( CE_Failure, CPLE_AppDefined, "Write GNM version failed"); return CE_Failure; } OGRFeature::DestroyFeature(poFeature); // write description if(!sDescription.empty()) { poFeature = OGRFeature::CreateFeature(pMetadataLayer->GetLayerDefn()); poFeature->SetField(GNM_SYSFIELD_PARAMNAME, GNM_MD_DESCR); poFeature->SetField(GNM_SYSFIELD_PARAMVALUE, sDescription); if(pMetadataLayer->CreateFeature(poFeature) != OGRERR_NONE) { OGRFeature::DestroyFeature( poFeature ); CPLError( CE_Failure, CPLE_AppDefined, "Write GNM description failed"); return CE_Failure; } OGRFeature::DestroyFeature(poFeature); } // write srs if < 254 or create file if(!m_soSRS.empty()) { if(m_soSRS.size() >= nFieldSize) { // cppcheck-suppress knownConditionTrueFalse if(StoreNetworkSrs() != CE_None) return CE_Failure; } else { poFeature = OGRFeature::CreateFeature(pMetadataLayer->GetLayerDefn()); poFeature->SetField(GNM_SYSFIELD_PARAMNAME, GNM_MD_SRS); poFeature->SetField(GNM_SYSFIELD_PARAMVALUE, m_soSRS); if(pMetadataLayer->CreateFeature(poFeature) != OGRERR_NONE) { OGRFeature::DestroyFeature( poFeature ); CPLError( CE_Failure, CPLE_AppDefined, "Write GNM SRS failed"); return CE_Failure; } OGRFeature::DestroyFeature(poFeature); } } m_poMetadataLayer = pMetadataLayer; m_nVersion = nVersion; // create default rule return CreateRule("ALLOW CONNECTS ANY"); }
void FlushPolicy() { PPOLICY_RULE r; KIRQL irql; char buffer[MAX_PATH*2]; UCHAR i; BOOLEAN ValidRule; // cannot write to files while holding spinlock (irql != PASSIVE_LEVEL) // KeAcquireSpinLock(&NewPolicy.SpinLock, &irql); sprintf(buffer, "\r\n# %S Default Process Policy\r\n", ProcessToMonitor); WriteRule(buffer); sprintf(buffer, "policy_default: %s\r\n", DecodeAction(NewPolicy.DefaultPolicyAction)); WriteRule(buffer); if (! IS_OVERFLOW_PROTECTION_ON(NewPolicy)) WriteRule("protection_overflow: off"); if (! IS_USERLAND_PROTECTION_ON(NewPolicy)) WriteRule("protection_userland: off"); if (! IS_EXTENSION_PROTECTION_ON(NewPolicy)) WriteRule("protection_extension: off"); if (! IS_DEBUGGING_PROTECTION_ON(NewPolicy)) WriteRule("protection_debugging: off"); if (! IS_VDM_PROTECTION_ON(NewPolicy)) WriteRule("protection_dos16: off"); // KdPrint(("%s process\n", IsGuiThread ? "GUI" : "NON GUI")); for (i = 0; i < RULE_LASTONE; i++) { r = NewPolicy.RuleList[i]; if (r) { WritePolicyFile("\r\n\r\n# "); WritePolicyFile(RuleTypeData[i].Prefix); WritePolicyFile(" related operations\r\n\r\n"); } while (r) { if (i != RULE_SYSCALL) ValidRule = CreateRule(i, r, buffer); else ValidRule = CreateServiceRule(r, buffer); if (ValidRule == TRUE) WriteRule(buffer); r = (PPOLICY_RULE) r->Next; } } // KeReleaseSpinLock(&NewPolicy.SpinLock, irql); }