Border sandboxed indicator

Utilities designed for use with Sandboxie
Micahs
Posts: 32
Joined: Sat Apr 26, 2008 12:26 am

Post by Micahs » Sat Jan 17, 2009 11:11 pm

I guess I'm the fool, and you proved it!

Yes, I can do that. Please let me know more about:

_SbieApi_EnumBoxes@8 - This might be a better way to get the boxes. I assume it will return the currently used sandbox list, wherever they may be located.

_SbieApi_EnumProcessEx@16

Thanks!

Mark_
Posts: 111
Joined: Wed Dec 31, 2008 3:48 pm

Post by Mark_ » Sun Jan 18, 2009 12:47 pm

Micahs wrote:I guess I'm the fool, and you proved it!

Yes, I can do that. Please let me know more about:

_SbieApi_EnumBoxes@8 - This might be a better way to get the boxes. I assume it will return the currently used sandbox list, wherever they may be located.

_SbieApi_EnumProcessEx@16

Thanks!
int __stdcall SbieApi_EnumBoxes(int num, wchar_t *name)
name can be max 32 chars, so atleast malloc( 32*2+2 )


first call, for num use -1
after that, use for num the return of the previous call,
until num == -1

tzuk
Sandboxie Founder
Sandboxie Founder
Posts: 16076
Joined: Tue Jun 22, 2004 12:57 pm

Post by tzuk » Sun Jan 18, 2009 4:19 pm

The following function enumerates the list of sandboxes, one at a time.

Code: Select all

LONG SbieApi_EnumBoxes(
    LONG index,    // initialize to -1
    WCHAR *box_name)    // WCHAR [34]
Returns the index number to use for the next call. Sample code:

Code: Select all

WCHAR name[34];
int index = -1;
while (1) {
        index = SbieApi_EnumBoxes(index, name);
        if (index == -1)
            break;
        SandboxNames_StringArray.add(name);
}
* * *

The following function gets the list of sandboxed programs for a specific sandbox in the current, in some other, or in all logon sessions.

Code: Select all

LONG SbieApi_EnumProcessEx(
    const WCHAR *box_name,    // WCHAR [34]
    BOOLEAN all_sessions,
    ULONG which_session,    // -1 for current session
    ULONG *boxed_pids)    // ULONG [512]
Parameters:

box_name – the sandbox name
all_sessions – if TRUE, collects information from all logon sessions while ignoring the which_session parameter. If FALSE, the which_session parameter selects the session.
which_session – if all_sessions is FALSE, specified the session number. Can specify -1 for the current session.
boxed_pids – an array of 512 ULONGs. On return, the first ULONG specifies the number of processes returned in the rest of array. The second ULONG specifies the process ID of the first sandboxed process. The third ULONG specifies the process ID of the second sandboxed process. And so on.

Returns zero on success. On failure, boxed_pids[0] is set to zero. Note that boxed_pids[0] can also be set to zero on successful completion, if there are no sandboxed processes matching the parameters.

* * *

This description is no guarantee that the API will never change. Use at your own risk.
tzuk

Micahs
Posts: 32
Joined: Sat Apr 26, 2008 12:26 am

Post by Micahs » Sun Jan 18, 2009 10:04 pm

Thanks for the info! I'll look into incorporating it.

wraithdu
Posts: 1410
Joined: Fri Jun 29, 2007 2:54 pm

Post by wraithdu » Mon Jan 19, 2009 2:58 pm

For giggles, some sample AutoIt code (should be pretty close to AHK):

Code: Select all

$SBDLL = DllOpen("C:\Program Files\Sandboxie\SbieDll.dll")

$index = -1
While 1
	; enum boxes
	$ret = DllCall($SBDLL, "long", "_SbieApi_EnumBoxes@8", "long", $index, "wstr", "")
	If $ret[0] == -1 Then ExitLoop
	ConsoleWrite("Box: " & $ret[2] & @CRLF)
	; next box
	$index = $ret[0]
	
	; enum processes in each box
	$pids = 0
	$pids = DllStructCreate("ulong[512]")
	DllCall($SBDLL, "long", "_SbieApi_EnumProcessEx@16", "wstr", $ret[2], "int", 0, "ulong", -1, "ptr", DllStructGetPtr($pids))
	$numpids = DllStructGetData($pids, 1, 1)
	If $numpids Then ConsoleWrite(@TAB & "PIDs:" & @CRLF)
	For $i = 2 To ($numpids + 1)
		$hProc = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", 0x0410, "int", 0, "dword", DllStructGetData($pids, 1, $i))
		$name = DllCall("psapi.dll", "dword", "GetModuleBaseNameW", "ptr", $hProc[0], "ptr", 0, "wstr", "", "dword", 260)
		DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hProc[0])
		ConsoleWrite(@TAB & DllStructGetData($pids, 1, $i) & @TAB & "::" & @TAB & $name[3] & @CRLF)
	Next
WEnd

DllClose($SBDLL)
Last edited by wraithdu on Thu Jan 22, 2009 1:58 pm, edited 1 time in total.

Micahs
Posts: 32
Joined: Sat Apr 26, 2008 12:26 am

Post by Micahs » Thu Jan 22, 2009 1:10 am

I'm giggling like a schoolgirl. Thanks!

wraithdu
Posts: 1410
Joined: Fri Jun 29, 2007 2:54 pm

Post by wraithdu » Thu Jan 22, 2009 12:16 pm

n/m

fixed above
Last edited by wraithdu on Thu Jan 22, 2009 1:57 pm, edited 1 time in total.

Mark_
Posts: 111
Joined: Wed Dec 31, 2008 3:48 pm

Post by Mark_ » Thu Jan 22, 2009 1:22 pm

wraithdu wrote:Not sure if you noticed, but I made one change in calling the EnumProcessEx function. tzuk said the which_session parameter is a ULONG. But to use a value of -1 (current session) it has to be a regular signed LONG.
not entirely true,
you can stick with ULONG, and use 0xffffffff instead of -1 ;)

-1 (signed) == 0xffffffff(unsigned)

wraithdu
Posts: 1410
Joined: Fri Jun 29, 2007 2:54 pm

Post by wraithdu » Thu Jan 22, 2009 1:42 pm

Well yes, but he specifically said -1. What does that value become when assigned to a ULONG variable? Is it converted to 0xffffffff or 1 or fails with an error?

EDIT - -1 gets converted to 0xffffffff when assigned to a ULONG variable. I suppose it doesn't matter, it works either way (I'll edit my code above anyway).

Micahs
Posts: 32
Joined: Sat Apr 26, 2008 12:26 am

Post by Micahs » Tue Feb 03, 2009 3:28 am

Here is the new version which supports multiple borders: borderGuard_multi

Image

New features:
  • Multiple borders
  • Borders are positioned behind the sandboxed window (except when window touches screen edge)
  • Automatic restart to apply changes to ini file (good idea Ausonius)
  • Active and Inactive windows' borders can have different transparency
  • Borders will stay within screen (good idea Guest_X)
  • Reverse sandboxed windows (Experimental)
  • Did I mention multiple borders?
I have not added the api calls to the dll yet.

Mark_
Posts: 111
Joined: Wed Dec 31, 2008 3:48 pm

Post by Mark_ » Tue Feb 03, 2009 5:54 am

looks nice,
but:

>>Reverse sandboxed windows (Experimental)
what does it mean?

Guest

Post by Guest » Tue Feb 03, 2009 5:56 am

Thanks Micahs, but this one isn't working for me.

I don't see any colored borders with it at all.

Oddly enough, reversed windows work fine (if I manually enable them) - but colored borders themselves are a no go.

If I back-level to the previous borderGuard release (with an EXE dated 2008-11-05), the borders work fine again.

I'm using Sandboxie 3.34 and the default borderGuard.ini file you included with the new "multi" package.

Any other info you would need?

tzuk
Sandboxie Founder
Sandboxie Founder
Posts: 16076
Joined: Tue Jun 22, 2004 12:57 pm

Post by tzuk » Tue Feb 03, 2009 6:41 pm

Micahs, per the discussion here, there is a new Contributed Utilities page. Let me know if you want to add your utility there.
tzuk

Micahs
Posts: 32
Joined: Sat Apr 26, 2008 12:26 am

Post by Micahs » Wed Feb 04, 2009 12:21 am

@Guest
I'm not sure what the problem could be. What os are you using? The new version uses SetWindowPos to size, move, and position the borders. This is really the only major change in the way it does its thing. If you are using Vista it may have an issue with this api call. My dad has a Vista laptop, so I can do some testing. Anyone else having this issue?

@Mark_
"Reverse sandboxed windows"
Image
Just what it sounds like! :D I have to say that this be more of a novelty than a useful feature because of focus issues. But it looks cool!

@tzuk
Yeah, if you think it's good enough, sure. Thanks! (Assuming I can get the bugs out!)

Micahs
Posts: 32
Joined: Sat Apr 26, 2008 12:26 am

Post by Micahs » Wed Feb 04, 2009 2:15 am

HERE is a new version that uses the SWP_FRAMECHANGED flag to (hopefully) force the window update. If this does not work, I can try some other things instead. I will borrow my dad's computer with Vista to do some testing.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests