diff --git a/ContainerCreate.cpp b/ContainerCreate.cpp index e3f6a12..71e99df 100644 --- a/ContainerCreate.cpp +++ b/ContainerCreate.cpp @@ -82,10 +82,10 @@ BOOL RunExecutableInContainer(CHAR *executable_path) break; } - InitializeProcThreadAttributeList(NULL, 1, NULL, &attribute_size); + InitializeProcThreadAttributeList(NULL, 2, NULL, &attribute_size); startup_info.lpAttributeList = (LPPROC_THREAD_ATTRIBUTE_LIST)malloc(attribute_size); - if(!InitializeProcThreadAttributeList(startup_info.lpAttributeList, 1, NULL, &attribute_size)) + if(!InitializeProcThreadAttributeList(startup_info.lpAttributeList, 2, NULL, &attribute_size)) { printf("InitializeProcThreadAttributeList() failed, last error: %d", GetLastError()); break; @@ -98,7 +98,17 @@ BOOL RunExecutableInContainer(CHAR *executable_path) break; } - if(!CreateProcessA(executable_path, NULL, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, +#define PROC_THREAD_ATTRIBUTE_ALL_APPLICATION_PACKAGES_POLICY \ + ProcThreadAttributeValue (ProcThreadAttributeAllApplicationPackagesPolicy, FALSE, TRUE, FALSE) + + DWORD all_applications_package_policy = 0x01; + if (!UpdateProcThreadAttribute(startup_info.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_ALL_APPLICATION_PACKAGES_POLICY, &all_applications_package_policy, + sizeof(all_applications_package_policy), NULL, NULL)) { + printf("UpdateProcThreadAttribute() (2) failed, last error: %d", GetLastError()); + break; + } + + if(!CreateProcessA(executable_path, NULL, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, (LPSTARTUPINFOA)&startup_info, &process_info)) { printf("Failed to create process %s, last error: %d\n", executable_path, GetLastError()); @@ -243,11 +253,8 @@ BOOL GrantNamedObjectAccess(PSID appcontainer_sid, CHAR *object_name, SE_OBJECT_ } while (FALSE); - if(original_acl) - LocalFree(original_acl); - if(new_acl) LocalFree(new_acl); return success; -} \ No newline at end of file +} diff --git a/ContainerTest.cpp b/ContainerTest.cpp index 68bbfa2..9ae0005 100644 --- a/ContainerTest.cpp +++ b/ContainerTest.cpp @@ -76,7 +76,7 @@ void FilesystemTest() void ProcessListTest() { printf("[+] Running process list testing...\n"); - tagPROCESSENTRY32W process_entry; + PROCESSENTRY32W process_entry; HANDLE snapshot; process_entry.dwSize = sizeof(process_entry); @@ -84,12 +84,12 @@ void ProcessListTest() snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(snapshot) { - if(Process32First(snapshot, &process_entry)) + if(Process32First(snapshot, (LPPROCESSENTRY32)&process_entry)) { do { - printf("Found process: %ws\n", process_entry.szExeFile); - } while (Process32Next(snapshot, &process_entry)); + printf("Found process: %s\n", process_entry.szExeFile); + } while (Process32Next(snapshot, (LPPROCESSENTRY32)&process_entry)); } CloseHandle(snapshot); }else{ @@ -183,4 +183,4 @@ void CreateFileTest(CHAR *file_path) printf("Opening of file %s failed but was not blocked\n", file_path); } } -} \ No newline at end of file +}