⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc.hxx

📁 Windows CE 6.0 Server 源码
💻 HXX
📖 第 1 页 / 共 2 页
字号:
	ROUTER_LIST			*pRouteFrom;
	ROUTER_LIST			*pRouteLocal;

	HMODULE				hLibLPCRT;
	CeGenerateGUID_t	CeGenerateGUID;

	static int FindInRouteList (ROUTER_LIST *pList, GUID *pGUID, WCHAR **ppFormatName) {
		while (pList) {
			if (pList->fGUID && (pList->guid == *pGUID)) {
				*ppFormatName = pList->szFormatName;
				return TRUE;
			}
			pList = pList->pNext;
		}

		return FALSE;
	}

	static int FindInRouteList (ROUTER_LIST *pList, WCHAR *uri, WCHAR **ppFormatName) {
		while (pList) {
			if (! pList->fGUID) {
				int fFound = FALSE;
				if (pList->fWildCard) {
					if (wcsnicmp (uri, pList->uri, pList->cUriLen) == 0)
						fFound = TRUE;
				} else if (0 == wcsicmp (uri, pList->uri))
					fFound = TRUE;

				if (fFound) {
					*ppFormatName = pList->szFormatName;
					return TRUE;
				}
			}
			pList = pList->pNext;
		}

		return FALSE;
	}

	// performs reverse lookup of FindInRouteList
	static int FindGuidInRouteList (ROUTER_LIST *pList, WCHAR *szFormatName, GUID **ppGUID) {
		while (pList) {
			if (pList->fGUID && (0 == wcsicmp (szFormatName, pList->szFormatName))) {
				*ppGUID = &pList->guid;
				return TRUE;
			}
			pList = pList->pNext;
		}

		return FALSE;
	}

	static int FindUriInRouteList(ROUTER_LIST *pList, WCHAR *szFormatName, WCHAR **ppUri) {
		while (pList) {
			if ((! pList->fGUID) && (0 == wcsicmp (szFormatName, pList->szFormatName))) {
				*ppUri = pList->uri;
				return TRUE;
			}
			pList = pList->pNext;
		}

		return FALSE;
	}

	int RouteTo (GUID *pGUID, WCHAR **ppFormatName) {
		return FindInRouteList (pRouteTo, pGUID, ppFormatName);
	}

	int RouteFrom (GUID *pGUID, WCHAR **ppFormatName) {
		return FindInRouteList (pRouteFrom, pGUID, ppFormatName);
	}

	int RouteLocal (GUID *pGUID, WCHAR **ppFormatName) {
		return FindInRouteList (pRouteLocal, pGUID, ppFormatName);
	}

	int RouteTo (WCHAR *uri, WCHAR **ppFormatName) {
		return FindInRouteList (pRouteTo, uri, ppFormatName);
	}

	int RouteFrom (WCHAR *uri, WCHAR **ppFormatName) {
		return FindInRouteList (pRouteFrom, uri, ppFormatName);
	}

	int RouteLocal (WCHAR *uri, WCHAR **ppFormatName) {
		return FindInRouteList (pRouteLocal, uri, ppFormatName);
	}

	// reverse lookup
	int RouteLocalReverseLookup(WCHAR *szFormatName, WCHAR **ppUri) {
		return FindUriInRouteList(pRouteLocal,szFormatName,ppUri);
	}

	int RouteLocalReverseLookup(WCHAR *szFormatName, GUID **ppGUID) {
		return FindGuidInRouteList(pRouteLocal,szFormatName,ppGUID);
	}

	MachineParameters (void) {
		memset (this, 0, sizeof(*this));
	}

	~MachineParameters (void) {
		int i;

		if (hLibLPCRT)
			FreeLibrary (hLibLPCRT);

		while (pRouteTo) {
			ROUTER_LIST	*pNext = pRouteTo->pNext;
			g_funcFree (pRouteTo, g_pvFreeData);
			pRouteTo = pNext;
		}

		while (pRouteFrom) {
			ROUTER_LIST	*pNext = pRouteFrom->pNext;
			g_funcFree (pRouteFrom, g_pvFreeData);
			pRouteFrom = pNext;
		}

		while (pRouteLocal) {
			ROUTER_LIST	*pNext = pRouteLocal->pNext;
			g_funcFree (pRouteLocal, g_pvFreeData);
			pRouteLocal = pNext;
		}

		if (lpszDirName)
			g_funcFree (lpszDirName, g_pvFreeData);

		if (lpszHostName)
			g_funcFree (lpszHostName, g_pvFreeData);

		if (lpszDebugQueueFormatName)
			g_funcFree (lpszDebugQueueFormatName, g_pvFreeData);

		if (lpszOutFRSQueueFormatName)
			g_funcFree (lpszOutFRSQueueFormatName, g_pvFreeData);

		for (i = 0; i < MAX_VROOTS; i++) {
			if (!VRootList[i].wszVRoot)
				break;

			g_funcFree (VRootList[i].wszVRoot, g_pvFreeData);
		}
	}
};

void DeleteRemoteHeapInfo(void *pvData);
BOOL DoesHeapInfoBelongToCaller(void *pvContext, void *pvData);

typedef struct {
	// Number of references this process has to heap mgr.
	DWORD  dwRefs;
	// Process that this remote heap is associated with
	HANDLE hProcess;
	// The remote heap itself
	HANDLE hHeap;
} REMOTE_HEAP_INFO;

class CRemoteAllocMgr {
private:
	// List of remote heaps.  Track this so we know what to alloc
	// off of, and also for cleanup purposes
	SVSLinkManager m_remoteHeaps;

	REMOTE_HEAP_INFO *FindRemoteHeapOfCaller(void) {
		REMOTE_HEAP_INFO *pRemoteInfo = 
			(REMOTE_HEAP_INFO*)m_remoteHeaps.FindEntryFiltered(DoesHeapInfoBelongToCaller,(void*)GetCallerVMProcessId());
		return pRemoteInfo;
	}

	// If the caller process is the same as current process, then we must not
	// use the remote alloc APIs (since the kernel APIs don't support this)
	// but instead fall back to standard heap functions.
	BOOL IsCallerProcSameAsCurrent(void) {
		return (GetCallerVMProcessId() == GetCurrentProcessId());
	}

public:
	BOOL InitForProcess(void);
	BOOL DeInitForProcess(void);
	BYTE *DuplicateBufferAndTranslate(const BYTE *pbData, DWORD cbData);
	WCHAR *DuplicateStringAndTranslate(const WCHAR *szData);
	BYTE *AllocOnCallerHeap(DWORD dwData);
	BYTE *TranslateData(BYTE *pbData);
	void FreeData(BYTE *pbData);
	
	CRemoteAllocMgr() : m_remoteHeaps(sizeof(REMOTE_HEAP_INFO),DeleteRemoteHeapInfo)
	{
			;
	}
};


class GlobalMemory : public SVSAllocClass, public SVSSynch {
public:
	SVSAttrTimer		  *pTimer;
	FixedMemDescr		  *pPacketMem;
	FixedMemDescr		  *pTreeNodeMem;
	FixedMemDescr		  *pAckNodeMem;
	HashDatabase		  *pStringHash;
	CRemoteAllocMgr        remoteAlloc;

	SVSTree				*pTimeoutTree;

	int				    fInitialized;

	GlobalMemory (void);

	~GlobalMemory (void) {
		if (pTimeoutTree)
			delete pTimeoutTree;

		if (pPacketMem)
			svsutil_ReleaseFixedNonEmpty (pPacketMem);
		if (pTreeNodeMem)
			svsutil_ReleaseFixedNonEmpty (pTreeNodeMem);
		if (pAckNodeMem)
			svsutil_ReleaseFixedEmpty    (pAckNodeMem);
		if (pTimer)
			svsutil_FreeAttrTimer        (pTimer);
		if (pStringHash)
			svsutil_DestroyStringHash    (pStringHash);
	}

	void Cycle (BOOL fReInitialize);

	friend DWORD WINAPI scapi_UserControlThread (LPVOID lpParameter);
};

#define SCFILE_QP_FORMAT_OS			0
#define SCFILE_QP_FORMAT_TCP		1
#define SCFILE_QP_FORMAT_HTTP		2
#define SCFILE_QP_FORMAT_HTTPS		3

//
//	Externs
//
extern class MachineParameters		*gMachine;
extern class GlobalMemory			*gMem;
extern class ScQueueManager			*gQueueMan;
extern class ScSessionManager		*gSessionMan;
extern class ScOverlappedSupport	*gOverlappedSupport;
extern class ScSequenceCollection	*gSeqMan;

extern int				 fApiInitialized;
extern unsigned long     glServiceState;

//
//	Function prototypes
//
void scapi_EnterInputLoop (void);

int scmain_Shutdown (BOOL fReInitialize);
int scmain_Init (void);
int scmain_ForceExit (void);

DWORD WINAPI scmain_Startup (LPVOID pvParam);

HRESULT scapi_Console (void);

void scerror_Complain (WCHAR *lpszFormat, ...);
void scerror_Complain (int iFormat, ...);
void scerror_Inform (WCHAR *lpszFormat, ...);
void scerror_Inform (int iFormat, ...);

int scerror_AssertOut (void *pvParam, WCHAR *lpszFormat, ...);

BOOL MySafeStrcpy(wchar_t* pszDest, size_t cchDest, const wchar_t* pszSrc);



#if defined (SC_VERBOSE)
extern unsigned int g_bCurrentMask;

void scerror_DebugOutPrintArgs(WCHAR *lpszFormat, va_list args);
void scerror_DebugOutPrint(WCHAR *lpszFormat, ...);

int scerror_DebugOut (unsigned int fMask, WCHAR *lpszFormat, ...);
void scerror_DebugInitialize (void);

#define scerror_DebugOutM(mask,format)    if (mask & g_bCurrentMask) scerror_DebugOutPrint format
#else
#define scerror_DebugOutM(mask,format)
#endif

#endif			/* __sc_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -