static OsNetworkHandle* OsNetworkHandle_Create() { LOGFUNC(); OsNetworkHandle* handle = (OsNetworkHandle*) malloc(sizeof(OsNetworkHandle)); if ( handle == NULL ) return NULL; THandle mtx = OsMutexCreate(""); if ( mtx == kHandleNull ) { free(handle); return NULL; } handle->iMutex = mtx; handle->iSocket = -1; handle->iIntSocket = -1; handle->iFlagInterrupted = 0; LOG("Allocted OsNetworkHandle %08x\n", handle); return handle; }
int32_t OsCreate() { FILETIME ft; WSADATA wsaData; WORD ver = (2<<8)|2; // WinSock v2.2. Standard on XP and later char* noErrDlgs = getenv("OHNET_NO_ERROR_DIALOGS"); if (noErrDlgs != NULL && strcmp(noErrDlgs, "1") == 0) { _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); } GetSystemTimeAsFileTime(&ft); gStartTime = ft.dwHighDateTime; gStartTime <<= 32; gStartTime |= ft.dwLowDateTime; gTlsIndex = TlsAlloc(); if (TLS_OUT_OF_INDEXES == gTlsIndex) { return -1; } gMutex = OsMutexCreate(""); if (kHandleNull == gMutex) { TlsFree(gTlsIndex); return -1; } if (0 != WSAStartup(ver, &wsaData)) { OsMutexDestroy(gMutex); TlsFree(gTlsIndex); return -1; } gDebugSymbolHandle = GetCurrentProcess(); (void)SymInitialize(gDebugSymbolHandle, NULL, TRUE); return 0; }
OsContext* OsCreate() { FILETIME ft; WSADATA wsaData; WORD ver = (2<<8)|2; // WinSock v2.2. Standard on XP and later char* noErrDlgs = getenv("OHNET_NO_ERROR_DIALOGS"); OsContext* ctx = malloc(sizeof(*ctx)); if (noErrDlgs != NULL && strcmp(noErrDlgs, "1") == 0) { _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); } if (ctx == NULL) { return NULL; } ctx->iInterfaceChangeObserver = NULL; ctx->iTestInterfaceIndex = -1; GetSystemTimeAsFileTime(&ft); ctx->iStartTime = ft.dwHighDateTime; ctx->iStartTime <<= 32; ctx->iStartTime |= ft.dwLowDateTime; ctx->iPrevTime = 0; ctx->iTimeAdjustment = 0; ctx->iTlsIndex = TlsAlloc(); if (TLS_OUT_OF_INDEXES == ctx->iTlsIndex) { free(ctx); return NULL; } ctx->iMutex = OsMutexCreate(ctx, ""); if (kHandleNull == ctx->iMutex) { TlsFree(ctx->iTlsIndex); free(ctx); return NULL; } if (0 != WSAStartup(ver, &wsaData)) { OsMutexDestroy(ctx->iMutex); TlsFree(ctx->iTlsIndex); free(ctx); return NULL; } { HMODULE hModule = GetModuleHandle(NULL); CHAR path[MAX_PATH]; GetModuleFileName(hModule, path, MAX_PATH); ctx->iDebugSymbolHandle = GetCurrentProcess(); (void)SymInitialize(ctx->iDebugSymbolHandle, /*NULL*/path, TRUE); } return ctx; }
int32_t OsCreate() { int errnum; gettimeofday(&gStartTime, NULL); gPrevTime = gStartTime; gMutex = OsMutexCreate("DNSM"); if (gMutex == kHandleNull) return -1; errnum = pthread_key_create(&gThreadArgKey, NULL); if (errnum != 0) { OsMutexDestroy(gMutex); gMutex = kHandleNull; return -1; } return 0; }
OsContext* OsCreate() { OsContext* ctx = malloc(sizeof(*ctx)); gettimeofday(&ctx->iStartTime, NULL); ctx->iPrevTime = ctx->iStartTime; memset(&ctx->iTimeAdjustment, 0, sizeof(ctx->iTimeAdjustment)); ctx->iMutex = OsMutexCreate(ctx, "DNSM"); if (ctx->iMutex == kHandleNull) { free(ctx); return NULL; } if (pthread_key_create(&ctx->iThreadArgKey, NULL) != 0) { OsMutexDestroy(ctx->iMutex); free(ctx); return NULL; } ctx->iInterfaceChangedObserver = NULL; return ctx; }