wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type, const wxString& url) const { if ( !m_windowInterface ) return wxHtmlParser::OpenURL(type, url); wxString myurl(url); wxHtmlOpeningStatus status; for (;;) { wxString myfullurl(myurl); // consider url as absolute path first wxURI current(myurl); myfullurl = current.BuildUnescapedURI(); // if not absolute then ... if( current.IsReference() ) { wxString basepath = GetFS()->GetPath(); wxURI base(basepath); // ... try to apply base path if valid ... if( !base.IsReference() ) { wxURI path(myfullurl); path.Resolve( base ); myfullurl = path.BuildUnescapedURI(); } else { // ... or force such addition if not included already if( !current.GetPath().Contains(base.GetPath()) ) { basepath += myurl; wxURI connected( basepath ); myfullurl = connected.BuildUnescapedURI(); } } } wxString redirect; status = m_windowInterface->OnHTMLOpeningURL(type, myfullurl, &redirect); if ( status != wxHTML_REDIRECT ) break; myurl = redirect; } if ( status == wxHTML_BLOCK ) return NULL; int flags = wxFS_READ; if (type == wxHTML_URL_IMAGE) flags |= wxFS_SEEKABLE; return GetFS()->OpenFile(myurl, flags); }
// The million dollar question here is: is NT_TIB.StackBase required // to be aligned? UINT WINAPI Dirtbox::ShimCallback(PVOID ShimContextPtr) { SHIM_CONTEXT ShimContext = *(PSHIM_CONTEXT)ShimContextPtr; free(ShimContextPtr); PNT_TIB OldNtTib = (PNT_TIB)__readfsdword(NT_TIB_SELF); PBYTE Tls; ETHREAD Ethread; KPCR Kpcr; Tls = (PBYTE)_alloca(ShimContext.TlsDataSize); memset(&Ethread, 0, sizeof(ETHREAD)); memset(&Kpcr, 0, sizeof(KPCR)); // Initialize Ethread structure Ethread.Tcb.TlsData = Tls; Ethread.UniqueThread = (PVOID)GetCurrentThreadId(); // Initialize subsystem independent part Kpcr.NtTib.ExceptionList = OldNtTib->ExceptionList; // Xbox XAPI assumes that the thread-local storage is located // at the stack base. (see beginning of function) Kpcr.NtTib.StackBase = &Tls[ShimContext.TlsDataSize]; Kpcr.NtTib.StackLimit = OldNtTib->StackLimit; Kpcr.NtTib.ArbitraryUserPointer = (PVOID)GetFS(); Kpcr.NtTib.Self = &Kpcr.NtTib; // Initialize Xbox subsystem part Kpcr.SelfPcr = &Kpcr; Kpcr.Prcb = &Kpcr.PrcbData; Kpcr.Irql = 0; Kpcr.Prcb->CurrentThread = (PKTHREAD)&Ethread; // Allocate LDT entry for new TIB and store selector in old TIB AllocateLdtEntry( (PWORD)&OldNtTib->ArbitraryUserPointer, (DWORD)&Kpcr, sizeof(KPCR) ); SwapTibs(); ShimContext.SystemRoutine(ShimContext.StartRoutine, ShimContext.StartContext); FatalPrint("ShimCallback: Should never get here."); return 0; }
// minimum cost of increasing the degree of vertices "b" by one int f(u32 b) { if (b == 0) return 0; if (memo[b] >= 0) return memo[b]; int best = INF; int nv = 0; int vs[MAXN]; for (u32 r = b; r; ClrFS(r)) { u32 x = GetFS(r); vs[nv++] = Ctz(x); } for (int i = 0; i < nv; ++i) for (int j = i + 1; j < nv; ++j) { u32 p = (1 << vs[i]) | (1 << vs[j]); int cur = g[vs[i]][vs[j]] + f(b & ~p); if (cur < best) best = cur; } return memo[b] = best; }