Skip to content

Commit

Permalink
1.15.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Dec 17, 2024
1 parent 4b07542 commit b733669
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
3 changes: 1 addition & 2 deletions Sandboxie/core/drv/file_flt.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ _FX FLT_PREOP_CALLBACK_STATUS File_PreOperation(
if (ulOwnerPid)
{
proc = Process_Find((HANDLE)ulOwnerPid, NULL); // is this a sandboxed process?
if (proc && proc != PROCESS_TERMINATED &&
!proc->ipc_allowSpoolerPrintToFile) // if process specifically allowed to use spooler print to file, we can skip everything below
if (proc && !proc->terminated && !proc->ipc_allowSpoolerPrintToFile) // if process specifically allowed to use spooler print to file, we can skip everything below
{
FLT_FILE_NAME_INFORMATION *pTargetFileNameInfo = NULL;
BOOLEAN result = FALSE;
Expand Down
38 changes: 19 additions & 19 deletions Sandboxie/core/drv/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ _FX PROCESS *Process_Find(HANDLE ProcessId, KIRQL *out_irql)
// Process_FindSandboxed
//---------------------------------------------------------------------------


#ifdef XP_SUPPORT
_FX PROCESS *Process_FindSandboxed(HANDLE ProcessId, KIRQL *out_irql)
{
PROCESS* proc = Process_Find(ProcessId, out_irql);
Expand All @@ -552,30 +552,30 @@ _FX PROCESS *Process_FindSandboxed(HANDLE ProcessId, KIRQL *out_irql)
}
return proc;
}

#endif

//---------------------------------------------------------------------------
// Process_Find_ByHandle
//---------------------------------------------------------------------------


_FX PROCESS *Process_Find_ByHandle(HANDLE Handle, KIRQL *out_irql)
{
NTSTATUS Status;
PEPROCESS ProcessObject = NULL;
PROCESS* Process = NULL;

Status = ObReferenceObjectByHandle(Handle, PROCESS_QUERY_INFORMATION, *PsProcessType, UserMode, (PVOID*)&ProcessObject, NULL);
if (NT_SUCCESS(Status)) {

Process = Process_Find(PsGetProcessId(ProcessObject), out_irql);

// Dereference the process object
ObDereferenceObject(ProcessObject);
}

return Process;
}
//_FX PROCESS *Process_Find_ByHandle(HANDLE Handle, KIRQL *out_irql)
//{
// NTSTATUS Status;
// PEPROCESS ProcessObject = NULL;
// PROCESS* Process = NULL;
//
// Status = ObReferenceObjectByHandle(Handle, PROCESS_QUERY_INFORMATION, *PsProcessType, UserMode, (PVOID*)&ProcessObject, NULL);
// if (NT_SUCCESS(Status)) {
//
// Process = Process_Find(PsGetProcessId(ProcessObject), out_irql);
//
// // Dereference the process object
// ObDereferenceObject(ProcessObject);
// }
//
// return Process;
//}


//---------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion Sandboxie/core/drv/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ void Process_Unload(BOOLEAN FreeLock);

PROCESS *Process_Find(HANDLE ProcessId, KIRQL *out_irql);

#ifdef XP_SUPPORT
PROCESS *Process_FindSandboxed(HANDLE ProcessId, KIRQL *out_irql);
#endif

PROCESS *Process_Find_ByHandle(HANDLE Handle, KIRQL *out_irql);
//PROCESS *Process_Find_ByHandle(HANDLE Handle, KIRQL *out_irql);

// Start supervising a new process

Expand Down
10 changes: 5 additions & 5 deletions Sandboxie/core/drv/process_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ _FX NTSTATUS Process_Api_Start(PROCESS *proc, ULONG64 *parms)
KIRQL irql;

proc2 = Process_Find((HANDLE)(-user_box_parm), &irql);
if (proc2)
if (proc2 && !proc2->terminated)
box = Box_Clone(Driver_Pool, proc2->box);

ExReleaseResourceLite(Process_ListLock);
Expand Down Expand Up @@ -245,7 +245,7 @@ _FX NTSTATUS Process_Api_Query(PROCESS *proc, ULONG64 *parms)
if (ProcessId) {

proc = Process_Find(ProcessId, &irql);
if (! proc) {
if (!proc || proc->terminated) {
ExReleaseResourceLite(Process_ListLock);
KeLowerIrql(irql);
return STATUS_INVALID_CID;
Expand Down Expand Up @@ -343,7 +343,7 @@ _FX NTSTATUS Process_Api_QueryInfo(PROCESS *proc, ULONG64 *parms)
if (ProcessId) {

proc = Process_Find(ProcessId, &irql);
if (! proc) {
if (!proc || proc->terminated) {
ExReleaseResourceLite(Process_ListLock);
KeLowerIrql(irql);
return STATUS_INVALID_CID;
Expand Down Expand Up @@ -663,7 +663,7 @@ _FX NTSTATUS Process_Api_QueryProcessPath(PROCESS *proc, ULONG64 *parms)
if (ProcessId) {

proc = Process_Find(ProcessId, &irql);
if ((! proc) || proc->terminated) {
if (!proc || proc->terminated) {
ExReleaseResourceLite(Process_ListLock);
KeLowerIrql(irql);
return STATUS_INVALID_CID;
Expand Down Expand Up @@ -779,7 +779,7 @@ _FX NTSTATUS Process_Api_QueryPathList(PROCESS *proc, ULONG64 *parms)

proc = Process_Find(args->process_id.val, &irql);

if (! proc) {
if (!proc || proc->terminated) {

ExReleaseResourceLite(Process_ListLock);
KeLowerIrql(irql);
Expand Down
7 changes: 6 additions & 1 deletion Sandboxie/core/drv/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,12 @@ _FX ACCESS_MASK Thread_CheckObject_CommonEx(
KIRQL irql;
PROCESS* proc2 = Process_Find(pid, &irql);

if (proc2 && !proc2->bHostInject) {
//
// Process_CreateTerminated creates a process object without a box,
// in that case we need to ignore it.
//

if (proc2 && !proc2->box && !proc2->bHostInject) {

ACCESS_MASK WriteAccess;
if (EntireProcess)
Expand Down
2 changes: 1 addition & 1 deletion Sandboxie/core/drv/token.c
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ _FX NTSTATUS Token_Api_Filter(PROCESS* proc, ULONG64* parms)
ProbeForWrite(pHandle, sizeof(HANDLE), sizeof(HANDLE));

proc = Process_Find(ProcessId, &irql);
if (! proc) {
if (!proc || proc->terminated) {
ExReleaseResourceLite(Process_ListLock);
KeLowerIrql(irql);
return STATUS_INVALID_CID;
Expand Down
2 changes: 2 additions & 0 deletions Sandboxie/core/drv/util_asm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ endif
;----------------------------------------------------------------------------

ifdef _WIN64
ifdef XP_SUPPORT

EXTERN Process_FindSandboxed : proc

Expand Down Expand Up @@ -129,6 +130,7 @@ Process_FindSandboxed64 PROC FRAME

Process_FindSandboxed64 ENDP

endif
endif

;----------------------------------------------------------------------------
Expand Down

0 comments on commit b733669

Please sign in to comment.