Border sandboxed indicator
int __stdcall SbieApi_EnumBoxes(int num, wchar_t *name)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!
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
The following function enumerates the list of sandboxes, one at a time.
Returns the index number to use for the next call. Sample code:
* * *
The following function gets the list of sandboxed programs for a specific sandbox in the current, in some other, or in all logon sessions.
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.
Code: Select all
LONG SbieApi_EnumBoxes(
LONG index, // initialize to -1
WCHAR *box_name) // WCHAR [34]
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]
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
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.
not entirely true,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.
you can stick with ULONG, and use 0xffffffff instead of -1
-1 (signed) == 0xffffffff(unsigned)
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).
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).
Here is the new version which supports multiple borders: borderGuard_multi
New features:
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?
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?
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?
Micahs, per the discussion here, there is a new Contributed Utilities page. Let me know if you want to add your utility there.
tzuk
@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"
Just what it sounds like! 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!)
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"
Just what it sounds like! 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!)
Who is online
Users browsing this forum: No registered users and 0 guests