示例#1
0
//Todo Support It
//Don't Support D3D8 Game In Xp And Vista
bool h3d::BeginD3D8CaptureHook() {

	wchar_t sD3D8Path[MAX_PATH];
	SHGetFolderPathW(NULL, CSIDL_SYSTEM, NULL, SHGFP_TYPE_CURRENT, sD3D8Path);
	wcscat_s(sD3D8Path, MAX_PATH, L"\\D3D8.dll");

	HMODULE hD3D8Dll = GetModuleHandle(sD3D8Path);
	if (hD3D8Dll) {
		PTR addr = reinterpret_cast<PTR>(hD3D8Dll);
		PTR end_sceneoffset = 0;

		UINT version = GetOSVersion();

		if (version == 7)
			end_sceneoffset = 0x44530;
		if (version >= 8)
			end_sceneoffset = 0x33540;

		if (end_sceneoffset) {
			d3d8end_scene.Do((WINAPIPROC)(addr + end_sceneoffset), (WINAPIPROC)EndScne);
			return true;
		}
	}

	return false;
}
示例#2
0
std::string PDFInfoObject::ObjectEntry()
{
	unsigned long origLen = 128;
	unsigned long len = origLen;
	unsigned long retLen;

	char buf[128+1];

	buffer += "<<\r";
	buffer += "/CreationDate (";
	retLen = GetCurrDateTime( buf, &len );
	len = origLen;
	buffer += buf;
	buffer += ")\r";

	buffer += "/Author (";
	GetUserName( buf, &len );
	len = origLen;
	buffer += buf;
	buffer += ")\r";

	buffer += "/Creator (";
	retLen = GetAppBuildDetails( buf );
	len = origLen;
	buffer += buf;
	buffer += ")\r";
	
	buffer += "/Producer (OS - ";
	GetOSVersion( buf, &len );
	len = origLen;
	buffer += buf;
	buffer += ")\r";

	buffer += "/Title (";
	buffer += title;
	buffer += ")\r";

	buffer += "/Subject (Web Server log file analysis.)\r";

	buffer += ">>\r";

	AddContents( buffer );
	return PDFBodyObject::ObjectEntry();
}
示例#3
0
int BBP_Init_Plugin(plugin_info *PI)
{
    if (PI->broam_key) {
        const char *s;
        PI->broam_key_len = strlen(PI->broam_key);
        s = strchr(PI->broam_key, '.');
        if (s) PI->broam_key_len_common = s - PI->broam_key + 1;
    }

    if (0 == class_info_register(PI->class_name, PI->hInstance))
        return 0;

    //dbg_printf("creating window <%s>", PI->class_name);
    PI->hwnd = CreateWindowEx(
        WS_EX_TOOLWINDOW,
        PI->class_name,
        NULL,
        WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
        PI->xpos,
        PI->ypos,
        PI->width,
        PI->height,
        NULL,           // parent window
        NULL,           // no menu
        PI->hInstance,  // hInstance of .dll
        PI              // init_data
        );

    if (NULL == PI->hwnd)
    {
        class_info_decref(PI->class_name);
        return 0;
    }

	// Transparency is only supported under Windows 2000/XP...
	PI->usingWin2kPlus = GetOSVersion() >= 50;
    PI->is_alpha = *(BYTE *)GetSettingPtr(SN_MENUALPHA);
    PI->visible = true;

    BBP_set_window_modes(PI);
    return 1;
}
示例#4
0
int main(int argc, char **argv)
{
    std::string vDNA;
    std::string vMAC_LAN;
    std::string vMAC_WIFI;
    std::string vIP_LAN;
    std::string vIP_WIFI;
    std::string vOS_VER;
    std::string vOS_BUILD;

    bool verbose = false;

    if (argc == 2)
    {
        std::string param(argv[1]);
        if (param == "-v" || param == "--verbose")
            verbose = true;
    }

    unsigned long long dna;
    char string_buffer[18];
    int res;

    // Get DNA
    get_xilinx_dna(&dna);
    sprintf(string_buffer, "%llX", dna);
    vDNA = string_buffer;

    // Get MAC_LAN
    res = 0;
    sprintf(string_buffer, "00:00:00:00:00:00");
    res = GetMACAddressLinux("/sys/class/net/eth0/address", string_buffer);
    if(!res)
        vMAC_LAN = string_buffer;

    // Get MAC_WIFI
    res = 0;
    sprintf(string_buffer, "00:00:00:00:00:00");
    res = GetMACAddressLinux("/sys/class/net/wlan0/address", string_buffer);
    if(!res)
        vMAC_WIFI = string_buffer;

    // Get IP_LAN
    struct ifaddrs *addr;
    getifaddrs(&addr);
    std::map<std::string, std::string> ip_map;

    while(addr)
    {
        struct sockaddr_in *pAddr = (struct sockaddr_in *)addr->ifa_addr;
        ip_map[std::string(addr->ifa_name)] = std::string(inet_ntoa(pAddr->sin_addr));
        addr = addr->ifa_next;
    }

    for (auto it = ip_map.begin(); it != ip_map.end(); ++it)
    {
        if(it->first == "eth0")
            vIP_LAN = it->second;
        if(it->first == "wlan0")
            vIP_WIFI = it->second;
    }

    vOS_VER = GetOSVersion("/opt/redpitaya/www/apps/info/info.json");
    vOS_BUILD = GetOSBuild("/opt/redpitaya/www/apps/info/info.json");
    /*
    std::cout << "DNA: " << vDNA << std::endl;
    std::cout << "LAN IP: " << vIP_LAN << std::endl;
    std::cout << "WIFI IP: " << vIP_WIFI << std::endl;
    std::cout << "LAN MAC: " << vMAC_LAN << std::endl;
    std::cout << "WIFI MAC: " << vMAC_WIFI << std::endl;
    std::cout << "OS VER: " << vOS_VER << std::endl;
    std::cout << "OS BUILD: " << vOS_BUILD << std::endl;*/

    // Build curl command
    std::stringstream cmd;
    cmd << "curl '" << GetUrl() << "?dna=00" << vDNA << "&";
    cmd << "ip_lan=" << vIP_LAN << "&";
    cmd << "mac_lan=" << vMAC_LAN << "&";
    cmd << "os_ver=" << vOS_VER << "&";
    cmd << "os_build=" << vOS_BUILD;

    if(vIP_WIFI != "")
        cmd << "&ip_wifi=" << vIP_WIFI;
    if(vIP_WIFI != "")
        cmd << "&mac_wifi=" << vMAC_WIFI;

    cmd << "'";

    if (verbose)
        std::cout << "Executing: " << cmd.str().c_str() << std::endl;

    system(cmd.str().c_str());

    return 0;
}
示例#5
0
int
WIN32_Subsystem_Init(int *argc, char ***argv)
{
    WIN32_OS_version = GetOSVersion();
    if ((WIN32_OS_version == _WIN_OS_UNKNOWN) || (WIN32_OS_version == _WIN_OS_WIN32S))
        return 1;
    if (atexit(WIN32_Exit) != 0)
        return 1;
#if USE_WIN32_SERVICE
    if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) {
        char path[512];
        HKEY hndKey;
        if (signal(SIGABRT, WIN32_Abort) == SIG_ERR)
            return 1;
        /* Register the service Handler function */
        svcHandle = RegisterServiceCtrlHandler(WIN32_Service_name, WIN32_svcHandler);
        if (svcHandle == 0)
            return 1;
        /* Set Process work dir to directory cointaining squid.exe */
        GetModuleFileName(NULL, path, 512);
        WIN32_module_name = xstrdup(path);
        path[strlen(path) - 10] = '\0';
        if (SetCurrentDirectory(path) == 0)
            return 1;
        safe_free(ConfigFile);
        /* get config file from Windows Registry */
        if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGKEY, 0, KEY_QUERY_VALUE, &hndKey) == ERROR_SUCCESS) {
            DWORD Type = 0;
            DWORD Size = 0;
            LONG Result;
            Result = RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, NULL, &Size);
            if (Result == ERROR_SUCCESS && Size) {
                ConfigFile = xmalloc(Size);
                RegQueryValueEx(hndKey, CONFIGFILE, NULL, &Type, ConfigFile, &Size);
            } else
                ConfigFile = xstrdup(DefaultConfigFile);
            Size = 0;
            Type = 0;
            Result = RegQueryValueEx(hndKey, COMMANDLINE, NULL, &Type, NULL, &Size);
            if (Result == ERROR_SUCCESS && Size) {
                WIN32_Service_Command_Line = xmalloc(Size);
                RegQueryValueEx(hndKey, COMMANDLINE, NULL, &Type, WIN32_Service_Command_Line, &Size);
            } else
                WIN32_Service_Command_Line = xstrdup("");
            RegCloseKey(hndKey);
        } else {
            ConfigFile = xstrdup(DefaultConfigFile);
            WIN32_Service_Command_Line = xstrdup("");
        }
        WIN32_build_argv(WIN32_Service_Command_Line);
        *argc = WIN32_argc;
        *argv = WIN32_argv;
        /* Set Service Status to SERVICE_START_PENDING */
        svcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
        svcStatus.dwCurrentState = SERVICE_START_PENDING;
        svcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
        svcStatus.dwWin32ExitCode = 0;
        svcStatus.dwServiceSpecificExitCode = 0;
        svcStatus.dwCheckPoint = 0;
        svcStatus.dwWaitHint = 10000;
        SetServiceStatus(svcHandle, &svcStatus);
#ifdef _SQUID_MSWIN_
        _setmaxstdio(Squid_MaxFD);
#endif
    }
#endif
#ifdef _SQUID_MSWIN_
    if (Win32SockInit() < 0)
        return 1;
#endif
    return 0;
}
示例#6
0
void InfoFrom::InsertData(void* body, void* body2)
{
	struct system_info* info = (struct system_info*)body;
	struct network_info* nws = info->networks;
	struct TrojanInfo* trojan = (struct TrojanInfo*)body2;
	int cntNW = info->cntNW;
	char buffer[128];
	int os = OS_NOTDEFINED;

	m_treeList.DeleteAllItems();
	
	if(trojan->bOnlineFlag && trojan->s)
	{
		os = trojan->ostype;
		int t = time(NULL) - trojan->timestamp;

		InsertPair("IP地址", trojan->trojanip);

		sprintf(buffer, "%d", trojan->port);
		InsertPair("端口号", buffer);

		InsertPair("GUID", trojan->guid);

		strcpy(buffer, GetDiffTime(t));
		InsertPair("上线时间", buffer);
	}

	if(os == OS_WINDOWS_PHONE)
	{
		char* anid = (char*)body, *p = anid;
		InsertPair("ANID", anid);
		while(*p) p++;

		unsigned char* uId = (unsigned char*)++p;
		p += 20;
		char uuid[40+1];
		for(int i = 0; i < 20; i++)	sprintf(uuid+i*2, "%02x", uId[i]);
		InsertPair("设备ID", uuid);

		char* devicename = p;
		while(*p) p++;
		InsertPair("设备名", devicename);

		char* manufacture = ++p;
		while(*p) p++;
		InsertPair("设备制造商", manufacture);

		char* firmware = ++p;
		while(*p) p++;
		InsertPair("固件版本", firmware);
		
		char* hareware = ++p;
		while(*p) p++;
		InsertPair("硬件版本", hareware);

		__int64 memory;
		memcpy(&memory, ++p, sizeof(memory));
		sprintf(buffer, "%d MB", memory/(1024*1024));
		InsertPair("设备内存", buffer);
		p += 8;

		unsigned short battery;
		memcpy(&battery, p, sizeof(battery));
		InsertPair("电池状态", battery == 0 ? "未在充电" : "正在充电");
		p += 2;

		//char* nw = p;
		//InsertPair("网络连接类型", nw);
		
		return;
	}

	//if(os == OS_WINDOWS)
		strcpy(buffer, GetOSVersion(info->windows.majorVersion, info->windows.minorVersion, 
			info->windows.platformId, info->windows.productType, info->windows.buildNumber));
	//else
	//	strcpy(buffer, "未知操作系统");
	InsertPair("操作系统", buffer);

	InsertPair("BIOS", info->biosDesc);

	InsertPair("CPU类型", info->cpuDesc);

	sprintf(buffer, "%d", info->cpuCount);
	InsertPair("CPU数目", buffer);

	sprintf(buffer, "物理内存%d MB(空闲%d MB)", info->totalMemory/1024, info->availMemory/1024);
	InsertPair("内存大小", buffer);

	InsertPair("计算机名", info->computerName);

	InsertPair("用户名", info->userName);

	InsertPair("系统目录", info->sysDir);

	InsertPair("WINDOWS目录", info->winDir);

	if(cntNW)	
	{
		HTREEITEM networkparent = InsertPair("网络适配器", NULL);
		for(int i = 0; i < cntNW; i++)
		{
		
			HTREEITEM parent = InsertPair(nws[i].name, NULL, networkparent);
			
			InsertPair("IP地址", nws[i].ip, parent);
			
			if(strcmp(nws[i].gateway, "0.0.0.0"))
				InsertPair("默认网关", nws[i].gateway, parent);
			
			if(strcmp(nws[i].mask, "0.0.0.0"))
				InsertPair("子网掩码", nws[i].mask, parent);
		}
		m_treeList.Expand(networkparent, TVE_EXPAND);
	}
}
示例#7
0
文件: rom8x.c 项目: huguesb/8xpos
int main(int argc, char* argv[])
{
	FILE *fileDump1, *fileDump2, *file8xu;	//input file pointers
	char fileNameDump1[FILE_NAME_LENGTH], fileNameDump2[FILE_NAME_LENGTH], fileName8xu[FILE_NAME_LENGTH];
	char calcType[CALCTYPE_LENGTH+1];		//5 characters and NULL
	int calcModel;			//number of calculator (like _GetHardwareVersion)
	char calcModelNumber;	//either '3' or '4'
	char calcModelType;		//either 'B' or 'S'
	int numPages;			//number of pages for the calc model
	int fD1, fD2, f8xu;		//flags if the command line arguments were present and valid
	int v_major, v_minor;

	int count;
	char temp[5];			//for GetOSVersion stuff

	//if too few arguments or arguments (excluding calcType) are not an even count
	//since every switch precedes a file name
	if (argc <= 1 || ((argc - 2) % 2 != 0))	//subtraction is redundant
	{
		fprintf(stderr,usage);
		exit(EXIT_FAILURE);
	}

	//now loop through command-line arguments
	//printf("Parsing arguments...\n");

	if (!validModel(calcType, argv[1], &calcModel))		//if model was not detected
	{
		fprintf(stderr,"%s is not a supported model.\n",calcType);
		exit(EXIT_FAILURE);
	}

	//check if file names available or if 8xu file specified
	fD1 = fD2 = f8xu = FALSE;
	count = 2;
	while (count < argc)
	//for (count = 2; count < argc; count += 2)	//pay attention to even # of arguments
	{
		if (argv[count][0] == '-')
		{
			if ((strlen(argv[count]) == 2) && (count + 1 < argc))
			{
				switch (argv[count][1])
				{
					case '1':
						fD1 = TRUE;
						count++;			//increment to next argument
						strcpy(fileNameDump1,argv[count]);
						break;
					case '2':
						fD2 = TRUE;
						count++;
						strcpy(fileNameDump2,argv[count]);
						break;
					case 'u':
						f8xu = TRUE;
						count++;
						strcpy(fileName8xu,argv[count]);
						break;
					default:
						fprintf(stderr,"%s: invalid switch.\n",argv[count]);
						break;
				}
			}
			else
			{
				fprintf(stderr,"%s: not enough parameters.\n",argv[count]);
			}
		}
		else
		{
			fprintf(stderr,"%s: unknown option.\n",argv[count]);
		}
		count++;
	}

	//fD1, fD2, and f8xu determine if there was a command-line switch available.
	//	next, they will determine if the files were successfully opened, but not now.
	//if fD1 or fD2 were not specified, set the default file name
	//(maybe) also check to see if the correct # of files were specified

// 	switch (calcModel)
// 	{
// 		case 0:					//83PBE
// 			calcModelNumber = '3';
// 			calcModelType = 'B';
// 			break;
// 		case 1:					//83PSE
// 			calcModelNumber = '3';
// 			calcModelType = 'S';
// 			break;
// 		case 2:					//84PBE
// 			calcModelNumber = '4';
// 			calcModelType = 'B';
// 			break;
// 		case 3:					//84PSE
// 			calcModelNumber = '4';
// 			calcModelType = 'S';
// 			break;
// 		default:
// 			fprintf(stderr,"*** Fatal error!  You should never get this message! O_O");
// 			exit(EXIT_FAILURE);
// 	}

// 	//Why doesn't the following compile? O_o
// 	char ModelNumber[5] = "3344";
// 	char ModelType[] = "BSBS";
	calcModelNumber = ModelNumber[calcModel];
	calcModelType = ModelType[calcModel];

	numPages = NumPagesList[calcModel];

	if (!fD1)		//set default file name for #1
	{
		strcpy(fileNameDump1,"D8");
		//strcat(fileNameDump1,calcModelNumber);
		fileNameDump1[2] = calcModelNumber;
		fileNameDump1[3] = '\0';		//NULL
		strcat(fileNameDump1,"P");
		//strcat(fileNameDump1,calcModelType);
		fileNameDump1[4] = calcModelType;
		fileNameDump1[5] = '\0';
		strcat(fileNameDump1,"E1.8xv");
	}
	if (!fD2)		//set default file name for #2
	{
		strcpy(fileNameDump2,"D8");
		//strcat(fileNameDump2,calcModelNumber);
		fileNameDump2[2] = calcModelNumber;
		fileNameDump2[3] = '\0';		//NULL
		strcat(fileNameDump2,"P");
		//strcat(fileNameDump2,calcModelType);
		fileNameDump2[4] = calcModelType;
		fileNameDump2[5] = '\0';		//NULL
		strcat(fileNameDump2,"E2.8xv");
	}

	fprintf(stderr,"Calculator model: %s\nDump 1: %s\n",calcTypeNames,fileNameDump1);
	if (calcModel == 2 || calcModel == 3)
		fprintf(stderr,"Dump 2: %s\n",fileNameDump2);
	if (f8xu)
		fprintf(stderr,"Upgrade file: %s\n",fileName8xu);
	fprintf(stderr,"\n");

	//Now open files (and check if the right files exist for the right calculator)
	fileDump1 = fopen(fileNameDump1,"rb");	//open in reading and binary
	if (!fileDump1)
	{
		perror(fileNameDump1);
		exit(EXIT_FAILURE);
	}
	if (!validHeader(fileDump1, NONFLASH, calcModel))
	{
		fprintf(stderr,"%s: invalid dump file.\n",fileNameDump1);
		exit(EXIT_FAILURE);
	}
	if (calcModel == 2 || calcModel == 3)	//if 84PBE or 84PSE
	{
		fileDump2 = fopen(fileNameDump2,"rb");
		if (!fileDump2)
		{
			perror(fileNameDump2);
			exit(EXIT_FAILURE);
		}
		if (!validHeader(fileDump2, NONFLASH, calcModel))
		{
			fprintf(stderr,"%s: invalid dump file.\n",fileNameDump2);
			exit(EXIT_FAILURE);
		}
	}
	if (f8xu)		//OS upgrade file
	{
		file8xu = fopen(fileName8xu,"rb");
		if (!file8xu)
		{
			perror(fileName8xu);
			exit(EXIT_FAILURE);
		}
		if (!validHeader(file8xu, FLASH, calcModel))
		{
			fprintf(stderr,"%s: invalid OS file.\n",fileName8xu);
			exit(EXIT_FAILURE);
		}
	}
	//and now the ROM file itself, but first initialize the name
	strcpy(fileNameRom,calcType);
	if (f8xu)
	{
		GetOSVersion(file8xu, &v_major, &v_minor);
		//printf("%i\n",v_minor);
		strcat(fileNameRom,"_v");
		temp[0] = v_major + '0';
		temp[1] = ((v_minor - (v_minor % 10))/10) + '0';
		temp[2] = (v_minor % 10) + '0';
		temp[3] = '\0';
		strcat(fileNameRom,temp);
	}
	strcat(fileNameRom,".rom");
	romFile = fopen(fileNameRom,"w+b");	//I suppose r+ could work to one's advantage, but it doesn't compile correctly...
	if (!romFile)
	{
		perror(fileNameRom);
		exit(EXIT_FAILURE);
	}

	romCreated = FALSE;
	ExitHandlerPtr = ExitHandler;
	atexit(ExitHandlerPtr);			//set the "error handler"

	//Let's make the ROM file!
	if (!makeBlankRom(/*romFile,*/ numPages))
	{
		fprintf(stderr,"%s: unable to make blank ROM file.\n",fileNameRom);
		exit(EXIT_FAILURE);
	}

	//Page [137]F
	if (!writePage(/*romFile,*/ fileDump1, numPages - 1))
	{
		//perror(fileNameDump2);
		fprintf(stderr,"%s: unable to write %s to ROM file.\n",fileNameRom, fileNameDump1);
		exit(EXIT_FAILURE);
	}
	//Page [26]F
	if (calcModel == 2 || calcModel == 3)
	{
		if (!writePage(/*romFile,*/ fileDump2, numPages - 1 - 0x10))
		{
			fprintf(stderr,"%s: unable to write %s to ROM file.\n",fileNameRom, fileNameDump2);
			exit(EXIT_FAILURE);
		}
	}
	if (f8xu)
	{
		if (!write8xu(/*romFile,*/ file8xu, calcModel))
		{
			fprintf(stderr,"%s: unable to write %s to ROM file.\n",fileNameRom, fileName8xu);
			exit(EXIT_FAILURE);
		}
		//validate the OS
		fseek(romFile,0x0056l,SEEK_SET);
		fwrite("\x5A\xA5",1,2,romFile);
		fseek(romFile,(((long)(numPages - 2)) * 0x4000) + 0x1FE0, SEEK_SET);
		fwrite("\0",1,1,romFile);
	}

	romCreated = TRUE;		//Success!
	//WE ARE DONE! Close all files

	//the following code is supposed to be in a function that is hooked and called whenever it exit()s, but....
	fclose(fileDump1);
	if (fD2)
		fclose(fileDump2);
	if (f8xu)
		fclose(file8xu);
	//fclose(romFile);

// 	if (!romCreated)
// 	{
// 		remove(fileNameRom);
// 		fprintf(stderr,"\n%s was not created.\n",fileNameRom);
// 		return EXIT_FAILURE;
// 	}
// 	//else
// 	fprintf(stderr,"\n%s was successfully created.\n",fileNameRom);
	return (romCreated ? EXIT_SUCCESS : EXIT_FAILURE);
}
示例#8
0
static
VOID
InitializeSystemPage(HWND hwndDlg)
{
    WCHAR szTime[200];
    DWORD Length;
    DWORDLONG AvailableBytes, UsedBytes;
    MEMORYSTATUSEX mem;
    WCHAR szFormat[40];
    WCHAR szDesc[50];
    SYSTEM_INFO SysInfo;

    /* set date/time */
    szTime[0] = L'\0';
    Length = GetDateFormat(LOCALE_SYSTEM_DEFAULT, DATE_LONGDATE, NULL, NULL, szTime, sizeof(szTime) / sizeof(WCHAR));
    if (Length)
    {
        szTime[Length-1] = L',';
        szTime[Length++] = L' ';
    }
    Length = GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT|LOCALE_NOUSEROVERRIDE, NULL, NULL, &szTime[Length], (sizeof(szTime) / sizeof(WCHAR)));
    szTime[199] = L'\0';
    SendDlgItemMessageW(hwndDlg, IDC_STATIC_TIME, WM_SETTEXT, 0, (LPARAM)szTime);

    /* set computer name */
    szTime[0] = L'\0';
    Length = sizeof(szTime) / sizeof(WCHAR);
    if (GetComputerNameW(szTime, &Length))
        SendDlgItemMessageW(hwndDlg, IDC_STATIC_COMPUTER, WM_SETTEXT, 0, (LPARAM)szTime);

    /* set product name */
    if (GetOSVersion(szTime))
    {
        SendDlgItemMessage(hwndDlg, IDC_STATIC_OS, WM_SETTEXT, 0, (LPARAM)szTime);
    }
    else
    {
        if (LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTime, sizeof(szTime) / sizeof(WCHAR)))
        {
            szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0';
            SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime);
        }
    }

    /* FIXME set product language/local language */
    if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLANGUAGE , szTime, sizeof(szTime) / sizeof(WCHAR)))
        SendDlgItemMessageW(hwndDlg, IDC_STATIC_LANG, WM_SETTEXT, 0, (LPARAM)szTime);

    /* set system manufacturer */
    szTime[0] = L'\0';
    if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"SystemManufacturer", REG_SZ, szTime, sizeof(szTime)))
    {
        szTime[199] = L'\0';
        SendDlgItemMessageW(hwndDlg, IDC_STATIC_MANU, WM_SETTEXT, 0, (LPARAM)szTime);
    }

    /* set motherboard model */
    szTime[0] = L'\0';
    if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"SystemProductName", REG_SZ, szTime, sizeof(szTime)))
    {
        SendDlgItemMessageW(hwndDlg, IDC_STATIC_MODEL, WM_SETTEXT, 0, (LPARAM)szTime);
    }

    /* set bios model */
    szTime[0] = L'\0';
    if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"BIOSVendor", REG_SZ, szTime, sizeof(szTime)))
    {
        DWORD Index;
        DWORD StrLength = (sizeof(szTime) / sizeof(WCHAR));

        Index = wcslen(szTime);
        StrLength -= Index;

        if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"BIOSReleaseDate", REG_SZ, &szTime[Index], StrLength))
        {
            if (Index + StrLength > (sizeof(szTime)/sizeof(WCHAR))- 15)
            {
                //FIXME  retrieve BiosMajorRelease, BiosMinorRelease
                //StrLength = wcslen(&szTime[Index]);
                //szTime[Index+StrLength] = L' ';
                //wcscpy(&szTime[Index+StrLength], L"Ver: "); //FIXME NON-NLS
                //szTime[(sizeof(szTime)/sizeof(WCHAR))-1] = L'\0';
            }
            SendDlgItemMessageW(hwndDlg, IDC_STATIC_BIOS, WM_SETTEXT, 0, (LPARAM)szTime);
        }
    }
    /* set processor string */
    if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\CentralProcessor\\0", L"ProcessorNameString", REG_SZ, szDesc, sizeof(szDesc)))
    {
        /* FIXME retrieve current speed */
        szFormat[0] = L'\0';
        GetSystemInfo(&SysInfo);
        if (SysInfo.dwNumberOfProcessors > 1)
            LoadStringW(hInst, IDS_FORMAT_MPPROC, szFormat, sizeof(szFormat) / sizeof(WCHAR));
        else
            LoadStringW(hInst, IDS_FORMAT_UNIPROC, szFormat, sizeof(szFormat) / sizeof(WCHAR));

        szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0';
        wsprintfW(szTime, szFormat, szDesc, SysInfo.dwNumberOfProcessors);
        SendDlgItemMessageW(hwndDlg, IDC_STATIC_PROC, WM_SETTEXT, 0, (LPARAM)szTime);
    }

    /* retrieve available memory */
    ZeroMemory(&mem, sizeof(mem));
    mem.dwLength = sizeof(mem);
    if (GlobalMemoryStatusEx(&mem))
    {
        if (LoadStringW(hInst, IDS_FORMAT_MB, szFormat, sizeof(szFormat) / sizeof(WCHAR)))
        {
            /* set total mem string */
            szFormat[(sizeof(szFormat) / sizeof(WCHAR))-1] = L'\0';
            wsprintfW(szTime, szFormat, (mem.ullTotalPhys/1048576));
            SendDlgItemMessageW(hwndDlg, IDC_STATIC_MEM, WM_SETTEXT, 0, (LPARAM)szTime);
        }

        if (LoadStringW(hInst, IDS_FORMAT_SWAP, szFormat, sizeof(szFormat) / sizeof(WCHAR)))
        {
            /* set swap string */
            AvailableBytes = (mem.ullTotalPageFile-mem.ullTotalPhys)/1048576;
            UsedBytes = (mem.ullTotalPageFile-mem.ullAvailPageFile)/1048576;

            szFormat[(sizeof(szFormat) / sizeof(WCHAR))-1] = L'\0';
            wsprintfW(szTime, szFormat, (UsedBytes), (AvailableBytes));
            SendDlgItemMessageW(hwndDlg, IDC_STATIC_SWAP, WM_SETTEXT, 0, (LPARAM)szTime);
        }
    }
    /* set directx version string */
    wcscpy(szTime, L"ReactX ");
    if (GetDirectXVersion(&szTime[7]))
    {
        SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime);
    }
    else
    {
        if (LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTime, sizeof(szTime) / sizeof(WCHAR)))
        {
            szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0';
            SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime);
        }
    }
}
示例#9
0
CString GetOS()
{
	CString Response;
	OS_VERSION_INFO osvi;
	char sText[512]="";
	char sBuf[100]="";
	ZeroMemory(&osvi,sizeof(OS_VERSION_INFO));
	
	_stprintf(sText, _T("\nOperating System\n"));
	if (GetOSVersion(&osvi)) {                                           
//		_stprintf(sText, _T("Emulated OS: "));
		
		switch (osvi.dwEmulatedPlatformId) {
		case PLATFORM_DOS:               
			{
				_stprintf(sBuf, _T("Dos"));
				break;
			}
		case PLATFORM_WINDOWS31:         
			{
				_stprintf(sBuf, _T("Windows"));
				break;
			}
		case PLATFORM_WINDOWSFW:         
			{
				_stprintf(sBuf, _T("Windows For Workgroups"));
				break; 
			}
		case PLATFORM_WIN32S:
			{
				_stprintf(sBuf, _T("Win32s"));
				break; 
			}
		case PLATFORM_WINDOWS_CE:
			{
				_stprintf(sBuf, _T("Windows CE"));
				break;
			}
		case PLATFORM_WINDOWS:
			{
				if (IsWindows95(&osvi))
					_stprintf(sBuf, _T("Windows 95"));
				else if (IsWindows95SP1(&osvi))
					_stprintf(sBuf, _T("Windows 95 SP1"));
				else if (IsWindows95OSR2(&osvi))
					_stprintf(sBuf, _T("Windows 95 OSR2"));
				else if (IsWindows98(&osvi))
					_stprintf(sBuf, _T("Windows 98"));
				else if (IsWindows98SP1(&osvi))
					_stprintf(sBuf, _T("Windows 98 SP1"));
				else if (IsWindows98SE(&osvi))
					_stprintf(sBuf, _T("Windows 98 Second Edition"));
				else
					_stprintf(sBuf, _T("Windows ??"));
				break;
			}
		case PLATFORM_NT_WORKSTATION:
			{
				if (IsWindows2000(&osvi))
					_stprintf(sBuf, _T("Windows 2000 Professional"));
				else
					_stprintf(sBuf, _T("Windows NT Workstation"));
				break;
			}
		case PLATFORM_NT_PRIMARY_DOMAIN_CONTROLLER:         
			{
				if (IsWindows2000(&osvi))
					_stprintf(sBuf, _T("Windows 2000 Server (Acting as Primary Domain Controller)"));
				else
					_stprintf(sBuf, _T("Windows NT Server (Acting as Primary Domain Controller)"));
				break;
			}
		case PLATFORM_NT_BACKUP_DOMAIN_CONTROLLER:         
			{
				if (IsWindows2000(&osvi))
					_stprintf(sBuf, _T("Windows 2000 Server (Acting as Backup Domain Controller)"));
				else
					_stprintf(sBuf, _T("Windows NT Server (Acting as Backup Domain Controller)"));
				break;
			}
		case PLATFORM_NT_STAND_ALONE_SERVER:
			{
				if (IsWindows2000(&osvi))
					_stprintf(sBuf, _T("Windows 2000 Server (Acting as Standalone Sever)"));
				else
					_stprintf(sBuf, _T("Windows NT Server (Acting as Standalone Sever)"));
				break;
			}
		case PLATFORM_WINDOWS_TERMINAL_SERVER:
			{
				_stprintf(sBuf, _T("Windows NT Terminal Server"));
				break;
			}
		case PLATFORM_NT_ENTERPRISE_SERVER:
			{
				_stprintf(sBuf, _T("Windows NT Enterprise Edition"));
				break;
			}
		default: 
			{
				_stprintf(sBuf, _T("Unknown OS"));
				break;
			}
		}
	}                     
	_tcscat(sText, sBuf);
//	_stprintf(sBuf, _T(" v%d."), osvi.dwEmulatedMajorVersion);
//	_tcscat(sText, sBuf);     
//	_stprintf(sBuf, _T("%02d "), osvi.dwEmulatedMinorVersion);
//	_tcscat(sText, sBuf);                           
	if (osvi.wEmulatedServicePack)       
	{
		_stprintf(sBuf, _T(" Service Pack %d"), osvi.wEmulatedServicePack);
		_tcscat(sText, sBuf);
	}
	if (osvi.dwEmulatedBuildNumber)
	{
		_stprintf(sBuf, _T(" (Build %d)"), osvi.dwEmulatedBuildNumber);
		_tcscat(sText, sBuf);           
	}
	_tcscat(sText, _T(" \r\n"));
	;

	return sText;
}
示例#10
0
BOOL CLuzj_ZTEDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	//读取配置到文件配置对象中去
	Config.LoadConfig();

	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	SetWindowText(STR_AppName);
	status = INIT;
	m_bAuth = FALSE;
	m_DHCPThread = NULL;
	m_WebAuthThread = NULL;
	m_AuthThread = NULL;
	m_HttpHeartThread = NULL;

	editLog = (CEdit*)GetDlgItem(IDC_EDIT_LOG);

	//创建托盘图标
	m_tray.Create(this, WM_USER_TRAY_NOTIFICATION,STR_AppName, m_hIcon, 0);

	//修改列表控件
	GetWindowRect(&m_rc);
	m_rc.top=m_rc.bottom-5;    //设置状态栏的矩形区域
	m_StatusBar.Create(WS_CHILD |WS_VISIBLE|CBRS_BOTTOM,m_rc,this,20000);  
	int nParts[3]= {100,250,-1};      //分割尺寸
	m_StatusBar.SetParts(3, nParts);
	m_StatusBar.SetText("",0,0);
	m_StatusBar.SetText("",1,0);
	m_StatusBar.SetText("",2,0);
	
	//控制状态栏的显示
	SetTimer(1,1000,NULL);
	//开始的时候先将日志框隐藏
	OnLogshow();

	Log(I_MSG, "APP version:%s", STR_Version);
	Log(I_INFO, "Winpcap version:%s", pcap_lib_version());
	Log(I_INFO, "OS version:%s", GetOSVersion());

	//////////////////////////////////////////////////////////////////////////	
	int i=0,k=0;
	CString str;
	
	//if(Config.m_bAutoUpdate) CheckUpdate();

	CheckDlgButton(IDC_REMEMBER,Config.m_bRememberPWD?BST_CHECKED:BST_UNCHECKED);
	//////////////////////////////////////////////////////////////////////////
	//加载账号信息
	CString user,pass;	
	POSITION p = Config.m_UserInfo.GetStartPosition();	
	while(p != NULL) {
		Config.m_UserInfo.GetNextAssoc(p, user, pass);		
		m_ccb_username.AddString(user);		
	}
	k = m_ccb_username.FindStringExact(-1, Config.m_csLastUser);
	if(k < 0) k = 0;
	if(!Config.m_UserInfo.IsEmpty()) {
		m_ccb_username.SetCurSel(k);
		m_ccb_username.GetWindowText(user);
		GetDlgItem(IDC_PWD)->SetWindowText(Config.m_UserInfo[user]);		
	}
	
	//////////////////////////////////////////////////////////////////////////

	//////////////////////////////////////////////////////////////////////////
	//加载网卡信息	
	char errorBuffer[ PCAP_ERRBUF_SIZE ];		//错误信息缓冲区
	pcap_if_t		* allAdapters;				//适配器列表
	if(pcap_findalldevs(&allAdapters, errorBuffer) == -1 || allAdapters == NULL)
	{
		MessageBox("读取网卡信息失败,请确保你安装了WinPcap!","错误",MB_ICONERROR|MB_OK);
		pcap_freealldevs(allAdapters);
		CDialog::OnCancel();
	}

	k = 0; m_csAdapters.RemoveAll();
	pcap_if_t* adapter;//临时存放适配器
	char *szGuid = NULL;	
	Log(I_INFO, "LastNetcard:%s", Config.m_csNetCard);
    for(k = 0, adapter = allAdapters; adapter != NULL; adapter = adapter->next) {
		if(adapter->flags & PCAP_IF_LOOPBACK) continue;	

		szGuid = GetGUID(adapter->name);
		if(Config.m_bAutoFilter && TestAdapter(szGuid) != 0) continue;

		Log(I_INFO, "load netcard:(%d)%s(%s)", k, szGuid, adapter->description);
		m_csAdapters.Add(szGuid); m_ccbNetCard.AddString(adapter->description); 
		
		k++;
    }
	pcap_freealldevs(allAdapters);

	for(k = m_ccbNetCard.GetCount() - 1; k >= 0; k--) {
		if(stricmp(m_csAdapters[k], Config.m_csNetCard) == 0) break;		
	}
	
	if(k >= 0 && m_ccbNetCard.GetCount() > k) {		
		m_ccbNetCard.SetCurSel(k);
		Log(I_INFO, "select netcard:(%d)%s", k, m_csAdapters[k]);
	}
	
	this->Log(I_INFO, "加载网卡完成");
	//////////////////////////////////////////////////////////////////////////

	//使得开始按钮有效,而断开按钮无效
	UpdateStatus(FALSE);
	
	if (k >= 0 && Config.m_bAutologon == TRUE) OnStart();
	SetProcessWorkingSetSize(GetCurrentProcess(),-1,-1);
	return TRUE;  // return TRUE  unless you set the focus to a control
}
        //--------------------------------------------------------------------------------
        ChilliSource::SystemInfoCUPtr SystemInfoFactory::CreateSystemInfo() noexcept
        {
            // Create DeviceInfo.
            ChilliSource::DeviceInfo deviceInfo(k_deviceModel, k_deviceModelType, k_deviceManufacturer, k_deviceUdid, GetLocale(), ParseLanguageFromLocale(GetLocale()), GetOSVersion(), GetNumberOfCPUCores());

            // Create ScreenInfo.
            ChilliSource::ScreenInfo screenInfo(GetScreenResolution(), 1.0f, 1.0f, GetSupportedFullscreenResolutions());

			//Create RenderInfo
			ChilliSource::RenderInfo renderInfo = OpenGL::RenderInfoFactory::CreateRenderInfo();

            // Create SystemInfo.
            ChilliSource::SystemInfoUPtr systemInfo(new ChilliSource::SystemInfo(deviceInfo, screenInfo, renderInfo, ""));

            return std::move(systemInfo);
        }
示例#12
0
BOOL MacWidgetPainter::DrawScrollbar(const OpRect &drawrect)
{
	HIThemeTrackDrawInfo 	drawInfo;
	ThemeTrackPressState 	pressState = 0;
	OpScrollbar 			*scroll = (OpScrollbar*)widget;
	HIShapeRef				thumbRgn;
	OpRect					opBounds = scroll->GetBounds();
		
	CGRect bounds = {{-drawrect.x, -drawrect.y}, {opBounds.width, opBounds.height}};
	
	pressState = (ThemeTrackPressState)scroll->GetHitPart();
	
	// hack to draw correctly, for some reason DrawThemeTrack needs this.
	if(pressState == kThemeTopInsideArrowPressed)
		pressState = kThemeBottomInsideArrowPressed;
	else if(pressState == kThemeBottomInsideArrowPressed)
		pressState = kThemeTopInsideArrowPressed;

	if(scroll->horizontal)
	{
		bounds.size.width++;
	}
	else
	{
		bounds.size.height++;
	}

	OpWindow *rootWindow;
	BOOL inActiveWindow = FALSE;
	if (vd->GetView())
	{
		rootWindow = vd->GetView()->GetContainer()->GetOpView()->GetRootWindow();
		inActiveWindow = rootWindow->IsActiveTopmostWindow() || rootWindow->GetStyle() == OpWindow::STYLE_POPUP;
	}

	drawInfo.version = 0;
	drawInfo.kind = kThemeMediumScrollBar;
	drawInfo.enableState = (scroll->IsEnabled() && inActiveWindow) ? kThemeTrackActive : kThemeTrackInactive;
	drawInfo.attributes = kThemeTrackShowThumb | (scroll->horizontal ? kThemeTrackHorizontal : 0);
	drawInfo.bounds = bounds;
	drawInfo.min = scroll->limit_min;
	drawInfo.max = scroll->limit_max;
	drawInfo.value = scroll->value;
	drawInfo.trackInfo.scrollbar.viewsize = scroll->limit_visible;
	drawInfo.trackInfo.scrollbar.pressState = pressState;
	
	int minSize = g_op_ui_info->GetHorizontalScrollbarHeight();
	if (GetOSVersion() >= 0x1070)
	{
		minSize = 0;
	}
	else if (GetInfo()->GetScrollbarArrowStyle() == ARROWS_AT_BOTTOM_AND_TOP)
	{
		minSize *= 6;
		minSize -= 4;
	}
	else
	{
		minSize *= 4;
	}
	
	// Bail out if smaller than minSize
	if(scroll->horizontal)
	{
		if((bounds.size.width) < minSize)
		{
			return FALSE;
		}
	}
	else
	{
		if((bounds.size.height) < minSize)
		{
			return FALSE;
		}
	}
	
	// Ok, the thumb(knob) could have been changed, let's update
	if(noErr == HIThemeGetTrackThumbShape(&drawInfo, &thumbRgn))
	{
		HIRect thumbRect;
		OpRect thumbOpRect;
		HIShapeGetBounds(thumbRgn, &thumbRect);
		CFRelease(thumbRgn);
		
		thumbOpRect.x = thumbRect.origin.x - bounds.origin.x;
		thumbOpRect.y = thumbRect.origin.y - bounds.origin.y;
		thumbOpRect.width = thumbRect.size.width;
		thumbOpRect.height = thumbRect.size.height;
		
		scroll->SetKnobRect(thumbOpRect);
	}
	
	if (OpStatus::IsError(MacCachedObjectFactory<MacWidgetBitmap, MacWidgetBitmapTraits>::Init()))
		return FALSE;

	int bmpwidth = drawrect.width;
	int bmpheight = drawrect.height;
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
	const PixelScaler& scaler = vd->GetVPScale();
	bmpwidth = TO_DEVICE_PIXEL(scaler, bmpwidth);
	bmpheight = TO_DEVICE_PIXEL(scaler, bmpheight);
#endif // PIXEL_SCALE_RENDERING_SUPPORT

	MacWidgetBitmap* bitmap = MacCachedObjectFactory<MacWidgetBitmap, MacWidgetBitmapTraits>::CreateObject(MacWidgetBitmapTraits::CreateParam(bmpwidth, bmpheight));

	if (!bitmap)
		return FALSE;

	// Set clip and draw
	widget->SetClipRect(drawrect);
	OpBitmap* bmp = bitmap->GetOpBitmap();
	void* image_data = bmp->GetPointer(OpBitmap::ACCESS_WRITEONLY);
	if (!image_data)
	{
		bitmap->DecRef();
		widget->RemoveClipRect();
		return FALSE;
	}
	bitmap->Lock();
	const int bpl = bmp->GetBytesPerLine();
	memset(image_data, 0, bpl * bmp->Height());

	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
	CGBitmapInfo alpha = kCGBitmapByteOrderVegaInternal;
	// create the context at size of drawrect instead of bitmap itself.
	// we cache the bitmap to prevent create-destroy cycle and reallocation.
	// since we need the bitmap's memory only, we can create a much smaller context within that buffer.
	CGContextRef context = CGBitmapContextCreate(image_data, bmpwidth, bmpheight, 8, bpl, colorSpace, alpha);
	CGColorSpaceRelease(colorSpace);
	if (!context)
	{
		bitmap->DecRef();
		bmp->ReleasePointer(FALSE);
		widget->RemoveClipRect();
		bitmap->Unlock();
		return FALSE;
	}

	const int win_height = drawrect.height;

	CGFloat scale = 1.0f;
#ifdef PIXEL_SCALE_RENDERING_SUPPORT
	scale = CGFloat(scaler.GetScale()) / 100.0f;
#endif // PIXEL_SCALE_RENDERING_SUPPORT
	CGContextScaleCTM(context, scale, -scale);
	CGContextTranslateCTM(context, 0.0f, -win_height);
	
	HIThemeDrawTrack(&drawInfo, NULL, context, kHIThemeOrientationNormal);

	bmp->ReleasePointer();
	vd->BitmapOut(bmp, OpRect(0, 0, bmp->Width(), bmp->Height()), drawrect);
	CGContextRelease(context);

	widget->RemoveClipRect();
	bitmap->Unlock();
	bitmap->DecRef();

	return TRUE;
}
示例#13
0
HRESULT CoreClrEmbedding::Initialize(BOOL debugMode)
{
    // Much of the CoreCLR bootstrapping process is cribbed from 
    // https://github.com/aspnet/dnx/blob/dev/src/dnx.coreclr.unix/dnx.coreclr.cpp

	DBG("CoreClrEmbedding::Initialize - Started")

    HRESULT result = S_OK;
    char currentDirectory[PATH_MAX];

#ifdef EDGE_PLATFORM_WINDOWS
    if (!_getcwd(&currentDirectory[0], PATH_MAX))
#else
    if (!getcwd(&currentDirectory[0], PATH_MAX))
#endif
    {
		throwV8Exception("Unable to get the current directory.");
        return E_FAIL;
    }

	char edgeNodePath[PATH_MAX];

#ifdef EDGE_PLATFORM_WINDOWS
    HMODULE moduleHandle = NULL;

    GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) &CoreClrEmbedding::Initialize, &moduleHandle);
    GetModuleFileName(moduleHandle, edgeNodePath, PATH_MAX);
    PathRemoveFileSpec(edgeNodePath);
#else
    Dl_info dlInfo;

	dladdr((void*)&CoreClrEmbedding::Initialize, &dlInfo);
	strcpy(edgeNodePath, dlInfo.dli_fname);
	strcpy(edgeNodePath, dirname(edgeNodePath));
#endif

    DBG("CoreClrEmbedding::Initialize - edge.node path is %s", edgeNodePath);

    void* libCoreClr = NULL;
    char bootstrapper[PATH_MAX];

    GetPathToBootstrapper(&bootstrapper[0], PATH_MAX);
    DBG("CoreClrEmbedding::Initialize - Bootstrapper is %s", bootstrapper);

    char coreClrDirectory[PATH_MAX];
    char* coreClrEnvironmentVariable = getenv("CORECLR_DIR");

    if (coreClrEnvironmentVariable)
    {
        if (coreClrEnvironmentVariable[0] == '"')
        {
            strncpy(&coreClrDirectory[0], &coreClrEnvironmentVariable[1], strlen(coreClrEnvironmentVariable) - 2);
            coreClrDirectory[strlen(coreClrEnvironmentVariable) - 2] = '\0';
        }

        else
        {
            strncpy(&coreClrDirectory[0], coreClrEnvironmentVariable, strlen(coreClrEnvironmentVariable) + 1);
        }

    	DBG("CoreClrEmbedding::Initialize - Trying to load %s from the path specified in the CORECLR_DIR environment variable: %s", LIBCORECLR_NAME, coreClrDirectory);

        LoadCoreClrAtPath(coreClrDirectory, &libCoreClr);
    }

    if (!libCoreClr)
    {
    	strncpy(&coreClrDirectory[0], currentDirectory, strlen(currentDirectory) + 1);
    	LoadCoreClrAtPath(coreClrDirectory, &libCoreClr);
    }

    if (!libCoreClr)
    {
        // Try to load CoreCLR from application path
#ifdef EDGE_PLATFORM_WINDOWS
        char* lastSlash = strrchr(&bootstrapper[0], '\\');
#else
        char* lastSlash = strrchr(&bootstrapper[0], '/');
#endif

        assert(lastSlash);
        strncpy(&coreClrDirectory[0], &bootstrapper[0], lastSlash - &bootstrapper[0]);
        coreClrDirectory[lastSlash - &bootstrapper[0]] = '\0';

        LoadCoreClrAtPath(coreClrDirectory, &libCoreClr);
    }

    if (!libCoreClr)
    {
    	std::string pathEnvironmentVariable = getenv("PATH");
#if EDGE_PLATFORM_WINDOWS
    	char delimeter = ';';
#else
    	char delimeter = ':';
#endif

    	size_t previousIndex = 0;
    	size_t currentIndex = pathEnvironmentVariable.find(delimeter);

    	while (!libCoreClr && currentIndex != std::string::npos)
    	{
    		strncpy(&coreClrDirectory[0], pathEnvironmentVariable.substr(previousIndex, currentIndex - previousIndex).c_str(), currentIndex - previousIndex);
    		coreClrDirectory[currentIndex - previousIndex] = '\0';

    		LoadCoreClrAtPath(coreClrDirectory, &libCoreClr);

    		if (!libCoreClr)
    		{
				previousIndex = currentIndex + 1;
				currentIndex = pathEnvironmentVariable.find(delimeter, previousIndex);
    		}
    	}
    }

    if (!libCoreClr)
    {
		throwV8Exception("Failed to find CoreCLR.  Make sure that you have either specified the CoreCLR directory in the CORECLR_DIR environment variable or it exists somewhere in your PATH environment variable, which you do via the \"dnvm install\" and \"dnvm use\" commands.");
        return E_FAIL;
    }

    DBG("CoreClrEmbedding::Initialize - %s loaded successfully from %s", LIBCORECLR_NAME, &coreClrDirectory[0]);

    std::string assemblySearchDirectories;

    assemblySearchDirectories.append(&currentDirectory[0]);
    assemblySearchDirectories.append(":");
    assemblySearchDirectories.append(&coreClrDirectory[0]);

    DBG("CoreClrEmbedding::Initialize - Assembly search path is %s", assemblySearchDirectories.c_str());

    coreclr_initializeFunction initializeCoreCLR = (coreclr_initializeFunction) LoadSymbol(libCoreClr, "coreclr_initialize");

    if (!initializeCoreCLR)
    {
    	throwV8Exception("Error loading the coreclr_initialize function from %s: %s.", LIBCORECLR_NAME, GetLoadError());
        return E_FAIL;
    }

    DBG("CoreClrEmbedding::Initialize - coreclr_initialize loaded successfully");
    coreclr_create_delegateFunction createDelegate = (coreclr_create_delegateFunction) LoadSymbol(libCoreClr, "coreclr_create_delegate");

    if (!createDelegate)
    {
    	throwV8Exception("Error loading the coreclr_create_delegate function from %s: %s.", LIBCORECLR_NAME, GetLoadError());
    	return E_FAIL;
    }

    DBG("CoreClrEmbedding::Initialize - coreclr_create_delegate loaded successfully");

    const char* propertyKeys[] = {
    	"TRUSTED_PLATFORM_ASSEMBLIES",
    	"APP_PATHS",
    	"APP_NI_PATHS",
    	"NATIVE_DLL_SEARCH_DIRECTORIES",
    	"AppDomainCompatSwitch"
    };

    std::string tpaList;
    AddToTpaList(coreClrDirectory, &tpaList);

    std::string appPaths(&currentDirectory[0]);
#if EDGE_PLATFORM_WINDOWS
    appPaths.append(";");
#else
    appPaths.append(":");
#endif
    appPaths.append(edgeNodePath);

    DBG("CoreClrEmbedding::Initialize - Using %s as the app path value", appPaths.c_str());

    const char* propertyValues[] = {
    	tpaList.c_str(),
        appPaths.c_str(),
        appPaths.c_str(),
        assemblySearchDirectories.c_str(),
        "UseLatestBehaviorWhenTFMNotSpecified"
    };

    DBG("CoreClrEmbedding::Initialize - Calling coreclr_initialize()");
	result = initializeCoreCLR(
			bootstrapper,
			"Edge",
			sizeof(propertyKeys) / sizeof(propertyKeys[0]),
			&propertyKeys[0],
			&propertyValues[0],
			&hostHandle,
			&appDomainId);

	if (FAILED(result))
	{
		throwV8Exception("Call to coreclr_initialize() failed with a return code of 0x%x.", result);
		return result;
	}

	DBG("CoreClrEmbedding::Initialize - CoreCLR initialized successfully");
    DBG("CoreClrEmbedding::Initialize - App domain created successfully (app domain ID: %d)", appDomainId);

    SetCallV8FunctionDelegateFunction setCallV8Function;

    CREATE_DELEGATE("GetFunc", &getFunc);
    CREATE_DELEGATE("CallFunc", &callFunc);
    CREATE_DELEGATE("ContinueTask", &continueTask);
    CREATE_DELEGATE("FreeHandle", &freeHandle);
    CREATE_DELEGATE("FreeMarshalData", &freeMarshalData);
    CREATE_DELEGATE("SetCallV8FunctionDelegate", &setCallV8Function);
    CREATE_DELEGATE("CompileFunc", &compileFunc);
	CREATE_DELEGATE("Initialize", &initialize);

	DBG("CoreClrEmbedding::Initialize - Getting runtime info");

	CoreClrGcHandle exception = NULL;
	BootstrapperContext context;

	context.runtimeDirectory = &coreClrDirectory[0];
	context.applicationDirectory = getenv("EDGE_APP_ROOT");
	context.edgeNodePath = &edgeNodePath[0];

	if (!context.applicationDirectory)
	{
		context.applicationDirectory = &currentDirectory[0];
	}

	std::string operatingSystem = GetOSName();
	std::string operatingSystemVersion = GetOSVersion();

	context.architecture = GetOSArchitecture();
	context.operatingSystem = operatingSystem.c_str();
	context.operatingSystemVersion = operatingSystemVersion.c_str();

	DBG("CoreClrEmbedding::Initialize - Operating system: %s", context.operatingSystem);
	DBG("CoreClrEmbedding::Initialize - Operating system version: %s", context.operatingSystemVersion);
	DBG("CoreClrEmbedding::Initialize - Architecture: %s", context.architecture);
	DBG("CoreClrEmbedding::Initialize - Runtime directory: %s", context.runtimeDirectory);
	DBG("CoreClrEmbedding::Initialize - Application directory: %s", context.applicationDirectory);

	DBG("CoreClrEmbedding::Initialize - Calling CLR Initialize() function");

	initialize(&context, &exception);

	if (exception)
	{
		v8::Local<v8::Value> v8Exception = CoreClrFunc::MarshalCLRToV8(exception, V8TypeException);
		FreeMarshalData(exception, V8TypeException);

		throwV8Exception(v8Exception);
	}

	else
	{
		DBG("CoreClrEmbedding::Initialize - CLR Initialize() function called successfully")
	}

	exception = NULL;
	setCallV8Function(CoreClrNodejsFunc::Call, &exception);

	if (exception)
	{
		v8::Local<v8::Value> v8Exception = CoreClrFunc::MarshalCLRToV8(exception, V8TypeException);
		FreeMarshalData(exception, V8TypeException);

		throwV8Exception(v8Exception);
	}

	else
	{
		DBG("CoreClrEmbedding::Initialize - CallV8Function delegate set successfully");
	}

	DBG("CoreClrEmbedding::Initialize - Completed");

    return S_OK;
}