Code Monkey home page Code Monkey logo

Comments (6)

YueLu0116 avatar YueLu0116 commented on July 18, 2024 1

@robmikh
Today I query TokenIsAppContainer following your advice. After this query, I call CreateForMonitor and everything works fine. Don't know what happened...

void IsAppContainer() {
	HANDLE hToken = nullptr;
	if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) {
		DWORD dwSize = 0;
		BOOL fIsAppContainerProcess;
		if (!GetTokenInformation(hToken, TokenIsAppContainer, &fIsAppContainerProcess, sizeof(BOOL), &dwSize) ||
			dwSize != sizeof BOOL) {
			fIsAppContainerProcess = false;
		}
		if (fIsAppContainerProcess) {
			LOG("It is an app container. [fIsAppContainerProcess={}]", fIsAppContainerProcess);
		}
		else {
			LOG("It is NOT an app container. [fIsAppContainerProcess={}]", fIsAppContainerProcess);
		}
	}
	else {
		LOG("OpenProcessToken() error {}\n", (unsigned long)(GetLastError()));
	}
}

Codes for calling GetSidSubAuthority:

DWORD GetProcessIL(TOKEN_INFORMATION_CLASS tokenInfoCls)
{
	DWORD dwRet = 0; {
		HANDLE hToken = NULL;
		if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) {
			DWORD dwSize = 0;
			// determine information length
			if (!GetTokenInformation(hToken, tokenInfoCls, NULL, 0, &dwSize) &&
				GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
				PTOKEN_MANDATORY_LABEL TokenInfo = (PTOKEN_MANDATORY_LABEL)malloc(dwSize);
				if (TokenInfo) {
					// get an actual information
					if (GetTokenInformation(hToken, tokenInfoCls, TokenInfo, dwSize, &dwSize)) {
						// get the integrity level
						dwRet = *GetSidSubAuthority(
							TokenInfo->Label.Sid,
							(DWORD)(*GetSidSubAuthorityCount(TokenInfo->Label.Sid) - 1)
						);
					}
					else {
						LOG("GetSidSubAuthorityCount() error {}\n", (unsigned long)GetLastError());
					}
					free(TokenInfo);
				}
				else {
					LOG("Token allocation error {}\n", (unsigned long)(GetLastError()));
				}
			}
			else {
				LOG("GetTokenInformation() error {}\n", (unsigned long)(GetLastError()));
			}
			CloseHandle(hToken);
		}
		else {
			LOG("OpenProcessToken() error {}\n", (unsigned long)(GetLastError()));
		}
	}
	return dwRet;
}

from windows.ui.composition-win32-samples.

robmikh avatar robmikh commented on July 18, 2024

IGraphicsCaptureItemInterop is not available to LowIL callers, which would include the JavaScript process in Chromium. You'll need to either construct the item from at least a MediumIL process and marshal it to the LowIL process or use the newer TryCreateFromWindowId method added in Windows 11.

from windows.ui.composition-win32-samples.

YueLu0116 avatar YueLu0116 commented on July 18, 2024

IGraphicsCaptureItemInterop is not available to LowIL callers, which would include the JavaScript process in Chromium. You'll need to either construct the item from at least a MediumIL process and marshal it to the LowIL process or use the newer TryCreateFromWindowId method added in Windows 11.

I call GetSidSubAuthority before calling CreateForMonitor and I always get SECURITY_MANDATORY_HIGH_RID. Does it mean the process is HighIL?

from windows.ui.composition-win32-samples.

robmikh avatar robmikh commented on July 18, 2024

How are you calling GetSidSubAuthority? What does it say when you query for TokenIsAppContainer from the process token? Unfortunately, I'm not very familiar with Electron, so I'm not sure how your steps are affecting the environment when we go to inspect the process token on the system side.

from windows.ui.composition-win32-samples.

w0nche0l avatar w0nche0l commented on July 18, 2024

Hi @YueLu0116, so this worked after you called both of those functions? Is it that you stopped calling it as an admin?

from windows.ui.composition-win32-samples.

Lijian1122 avatar Lijian1122 commented on July 18, 2024

Hi @YueLu0116, so this worked after you called both of those functions? Is it that you stopped calling it as an admin?

Do you resolve this problem when as admin

from windows.ui.composition-win32-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.