Exemplo n.º 1
0
	bool CreateProcess(char* fileName)
	{
		cursorIndex++;

		CStringA message = "Loading '";
		message.Add(fileName);
		message.Add("'...");

		WriteText(message._ptr(), (cursorIndex / 24) * 40, cursorIndex % 24, 0xA);

		dword smid = 0;
		bool loaded = true;
		dword fileSize = GetFileSize(fileName);
		if (fileSize != 0)
		{
			smid = KeAllocSharedMem(fileSize);
			ReadFile(smid, fileName);
		}
		else
		{
			loaded = false;
		}

		if (loaded)
		{
			byte* drvImage = KeMapSharedMem(smid);
			if (!KeCreateProcess(drvImage, fileSize, fileName))
				loaded = false;
			KeReleaseSharedMem(smid);
		}

		if (loaded)
			WriteText("OK", message.Len() + (cursorIndex / 24) * 40, cursorIndex % 24, 0xA);
		else
			WriteText("Fail", message.Len() + (cursorIndex / 24) * 40, cursorIndex % 24, 0xC);

		return loaded;
	}