VOID MrStopCore() { ASSERT(IsListEmpty(&g_core.mc_dcb_list)); if (g_core.mc_dev_list) MrFree(g_core.mc_dev_list); if (g_core.mc_reg.Buffer) MrFree(g_core.mc_reg.Buffer); /* stop and delete core deviceobj */ if (g_core.mc_devobj) MrDestroyDevice(g_core.mc_devobj, MOURE_SYMLNK); /* delete resource lock */ ExDeleteResourceLite(&g_core.mc_lock); }
int main(int argc, const char **argv) { int mj; if (Init(argc,argv) != 0) { MTX_ERROR("Initialization failed"); return -1; } /* Main loop: for all constituents of M ------------------------------------ */ for (mj = 0; mj < InfoM.NCf; mj++) { MatRep_t *rep_m; /* Generators for const. of M */ int nj; if (InfoM.Cf[mj].peakword < 0) { MESSAGE(0,("WARNING: No peak word word available for %s%s\n", InfoM.BaseName,Lat_CfName(&InfoM,mj))); } MESSAGE(0,("%s%s ",InfoM.BaseName,Lat_CfName(&InfoM,mj))); /* Read the generators for the <mj>-th contituent of M, and find the corresponding (=contragredient) constituent in N. ------------------------------------------------------------- */ rep_m = Lat_ReadCfGens(&InfoM,mj,InfoM.Cf[mj].peakword >= 0 ? LAT_RG_STD : 0); nj = FindConstituentInN(mj,rep_m); /* Calculate the P and Q matrix for this constituent ------------------------------------------------- */ if (nj >= 0) { MESSAGE(0,(" <--> %s%s\n",InfoN.BaseName, Lat_CfName(&InfoN,nj))); TKInfo.CfIndex[0][TKInfo.NCf] = mj; TKInfo.CfIndex[1][TKInfo.NCf] = nj; MakePQ(TKInfo.NCf,mj,nj); TKInfo.NCf++; } else MESSAGE(0,(" not found in %s\n",InfoN.BaseName)); /* Clean up -------- */ MrFree(rep_m); } CalcDim(); /* Calculate dimension */ TK_WriteInfo(&TKInfo,TkiName); /* Write .tki file */ if (App != NULL) AppFree(App); return 0; }
static int WriteAction() { MatRep_t *sub = NULL, *quot = NULL; MatRep_t **subp = SubName != NULL ? &sub : NULL; MatRep_t **quotp = QuotName != NULL ? " : NULL; if (Split(Span,Rep,subp,quotp) != 0) { MTX_ERROR("Split failed"); return -1; } if (SubName != NULL) { MrSave(sub,SubName); MrFree(sub); } if (QuotName != NULL) { MrSave(quot,QuotName); MrFree(quot); } return 0; }
NTSTATUS MrQueryString( IN PDEVICE_OBJECT d, IN DEVICE_REGISTRY_PROPERTY c, IN OUT PUNICODE_STRING n ) { PWCHAR data = NULL; ULONG len = 0; NTSTATUS status; data = MrAlloc(1024); if (NULL == data) { status = STATUS_INSUFFICIENT_RESOURCES; goto errorout; } RtlZeroMemory(n, sizeof(UNICODE_STRING)); status = IoGetDeviceProperty(d, c, 1024, data, &len); if (!NT_SUCCESS(status)) { goto errorout; } len = wcslen(data) * sizeof(WCHAR); if (0 == len) { goto errorout; } n->MaximumLength = (USHORT)len + sizeof(WCHAR); n->Buffer = MrAlloc(n->MaximumLength); if (NULL == n->Buffer) { status = STATUS_INSUFFICIENT_RESOURCES; goto errorout; } RtlCopyMemory(n->Buffer, data, len); n->Length = (USHORT)len; errorout: if (data) MrFree(data); return status; }
static int IsDual(int mj, MatRep_t *rep_m, int nj) { MatRep_t *rep_n; /* Generators of constituent of N */ int result; CfInfo *minfo = InfoM.Cf + mj; /* First check: Dimensions and splitting field must match ------------------------------------------------------ */ if (InfoN.Cf[nj].dim != minfo->dim || InfoN.Cf[nj].spl != minfo->spl) return 0; /* Read the (contragrediate) generators and compare ------------------------------------------------ */ MESSAGE(2,(" (%s%s)",InfoN.BaseName,Lat_CfName(&InfoN,nj))); rep_n = Lat_ReadCfGens(&InfoN,nj,LAT_RG_INVERT|LAT_RG_TRANSPOSE | (InfoN.Cf[nj].peakword >= 0 ? LAT_RG_STD : 0)); result = IsIsomorphic(rep_m,minfo,rep_n,Trans + TKInfo.NCf, minfo->peakword >= 0); MrFree(rep_n); return result; }
static int AddConstituent(MatRep_t *cf, CfInfo *info, int modno, int cfno) { int i, m; for (i = 0; i < NumCf; ++i) { int rc; rc = IsIsomorphic(CfList[i].Gen,CfList[i].Info,cf,NULL,0); if (rc < 0) return -1; if (rc) break; } if (i < NumCf) /* Constituent was already in the list */ { int m = CfList[i].Mult; MrFree(cf); CfList[i].CfMap[m][0] = modno; } else /* It's a new constituent */ { CfList[i].Gen = cf; CfList[i].Info = info; CfList[i].Wg = WgAlloc(cf); CfList[i].Mod = &ModList[modno].Info; CfList[i].Mult = 0; ++NumCf; } m = CfList[i].Mult; CfList[i].CfMap[m][0] = modno; CfList[i].CfMap[m][1] = cfno; CfList[i].Mult++; MESSAGE(1,("%s%s is constituent %d\n",ModList[modno].Info.BaseName, Lat_CfName(&ModList[modno].Info,cfno),i)); return i; }
static void MakePQ(int n, int mj, int nj) { MatRep_t *rep_m; Matrix_t *estar[MAXENDO], *endo[MAXENDO], *e, *ei; char fn[200]; int dim = InfoM.Cf[mj].dim; int spl = InfoM.Cf[mj].spl; int i; Matrix_t *p; MESSAGE(1,("Condensing %s%s x ",InfoM.BaseName,Lat_CfName(&InfoM,mj))); MESSAGE(1,("%s%s, [E:k]=%d\n",InfoN.BaseName,Lat_CfName(&InfoN,nj),spl)); /* Read the generators for the constituent of M and make the endomorphism ring. --------------------------------------------------------- */ rep_m = Lat_ReadCfGens(&InfoM,mj,InfoM.Cf[mj].peakword >= 0 ? LAT_RG_STD : 0); MESSAGE(2,("Calculating endomorphism ring\n")); MkEndo(rep_m,InfoM.Cf + mj,endo,MAXENDO); MrFree(rep_m); /* Calculate the Q matrix ---------------------- */ MESSAGE(2,("Calculating embedding of E\n")); MakeQ(n,spl,(const Matrix_t **)endo); /* Calculate the E* matrices Note: We should use the symmetry under i<-->k here! --------------------------------------------------- */ MESSAGE(2,("Calculating projection on E\n")); MESSAGE(2,(" E* matrices\n")); e = MatAlloc(FfOrder,spl,spl); for (i = 0; i < spl; ++i) { PTR pptr = MatGetPtr(e,i); int k; for (k = 0; k < spl; ++k) { FEL f; Matrix_t *x = MatDup(endo[i]); MatMul(x,endo[k]); f = MatTrace(x); FfInsert(pptr,k,f); MatFree(x); } } ei = MatInverse(e); MatFree(e); for (i = 0; i < spl; ++i) { int k; PTR p; estar[i] = MatAlloc(FfOrder,dim,dim); p = MatGetPtr(ei,i); for (k = 0; k < spl; ++k) MatAddMul(estar[i],endo[k],FfExtract(p,k)); } MatFree(ei); /* Transpose the E* matrices. This simplifies the calculation of tr(z E*) below. ----------------------------------------------- */ MESSAGE(2,(" Transposing E* matrices\n")); for (i = 0; i < spl; ++i) { Matrix_t *x = MatTransposed(estar[i]); MatFree(estar[i]); estar[i] = x; } /* Calculate the P matrix ---------------------- */ MESSAGE(2,(" P matrix\n")); p = MatAlloc(FfOrder,dim*dim,spl); for (i = 0; i < dim; ++i) { int j; for (j = 0; j < dim; ++j) { int r; PTR pptr = MatGetPtr(p,i*dim + j); Matrix_t *x = MatAlloc(FfOrder,dim,dim); MatCopyRegion(x,0,i,Trans[n],0,j,dim,1); for (r = 0; r < spl; ++r) { FEL f = MatProd(x,estar[r]); FfInsert(pptr,r,f); } MatFree(x); } } sprintf(fn,"%s.p.%d",TkiName,n+1); MESSAGE(2,("Writing %s\n",fn)); #if 0 if (InfoM.Cf[mj].peakword < 0) MatMulScalar(p,FF_ZERO); #endif MatSave(p,fn); /* Clean up -------- */ MatFree(p); for (i = 0; i < spl; ++i) MatFree(endo[i]); }
NTSTATUS MrUpdateHWs(ULONG s1, ULONG s2, PMR_DCB dcb) { PWCHAR s, p; ULONG b = 0, l, e, n; UNICODE_STRING t; NTSTATUS status = STATUS_SUCCESS; BOOLEAN changed = FALSE; e = g_core.mc_dev_bytes / sizeof(WCHAR); /* remove old tag */ if (s1 & MR_DEV_STATE_PERSIST) { while (s = MrLookupId(dcb)) { b = (ULONG)(s - g_core.mc_dev_list); l = wcslen(s); memset(s, 0, l * sizeof(WCHAR)); if (b + l + 1 < e) { memmove(s, s + l + 1, (e - b - l - 1) * sizeof(WCHAR)); memset(s + (e - b - l - 1), 0, (l + 1) * sizeof(WCHAR)); } changed = TRUE; } b = e - b - l; } /* add new tag */ if (s2 & MR_DEV_STATE_PERSIST) { n = dcb->md_did.Length / sizeof(WCHAR); if (p = MrStrStr(&dcb->md_did, L"&REV_", 5)) { if (p < dcb->md_did.Buffer + n) n = (ULONG)(p - dcb->md_did.Buffer); } if (p = MrStrStr(&dcb->md_did, L"&MI_", 4)) { if (p < dcb->md_did.Buffer + n) n = (ULONG)(p - dcb->md_did.Buffer); } if (p = MrStrStr(&dcb->md_did, L"&Col", 4)) { if (p < dcb->md_did.Buffer + n) n = (ULONG)(p - dcb->md_did.Buffer); } b = 0; while (b < g_core.mc_dev_bytes/sizeof(WCHAR)) { s = g_core.mc_dev_list + b; if (l = wcslen(s)) { b += l + 1; } else { break; } } if (e < b + n + 2) { s = MrAlloc((b + n + 0x100) * sizeof(WCHAR)); if (NULL == s) { status = STATUS_INSUFFICIENT_RESOURCES; goto errorout; } RtlCopyMemory(s, g_core.mc_dev_list, b*sizeof(WCHAR)); MrFree(g_core.mc_dev_list); g_core.mc_dev_list = s; e = b + n + 0x100; g_core.mc_dev_bytes = e * sizeof(WCHAR); } RtlCopyMemory(g_core.mc_dev_list + b, dcb->md_did.Buffer, n * sizeof(WCHAR)); b += n + 2; changed = TRUE; } if (changed) { /* set registry */ while (b >= 3) { if (g_core.mc_dev_list[b - 3] == 0 && g_core.mc_dev_list[b - 2] == 0 && g_core.mc_dev_list[b - 1] == 0 ) b = b - 1; else break; } status = MrSetRegValue(MOURE_DEVLIST, g_core.mc_dev_list, b * sizeof(WCHAR)); } errorout: return status; }
VOID MrCleanupString(PUNICODE_STRING n) { if (n && n->Buffer) { MrFree(n->Buffer); } }