Trust No Program
Reply to topic
Micahs


Joined: 26 Apr 2008
Posts: 32
Reply with quote
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!
View user's profileSend private message
Mark_


Joined: 31 Dec 2008
Posts: 108
Reply with quote
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
View user's profileSend private message
tzuk


Joined: 22 Jun 2004
Posts: 15155
Reply with quote
The following function enumerates the list of sandboxes, one at a time.

Code:
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:

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:

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
View user's profileSend private message
Micahs


Joined: 26 Apr 2008
Posts: 32
Reply with quote
Thanks for the info! I'll look into incorporating it.
View user's profileSend private message
wraithdu


Joined: 29 Jun 2007
Posts: 1410
Reply with quote
For giggles, some sample AutoIt code (should be pretty close to AHK):
Code:
$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 6:58 pm; edited 1 time in total
View user's profileSend private message
Micahs


Joined: 26 Apr 2008
Posts: 32
Reply with quote
I'm giggling like a schoolgirl. Thanks!
View user's profileSend private message
wraithdu


Joined: 29 Jun 2007
Posts: 1410
Reply with quote
n/m

fixed above


Last edited by wraithdu on Thu Jan 22, 2009 6:57 pm; edited 1 time in total
View user's profileSend private message
Mark_


Joined: 31 Dec 2008
Posts: 108
Reply with quote
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 Wink

-1 (signed) == 0xffffffff(unsigned)
View user's profileSend private message
wraithdu


Joined: 29 Jun 2007
Posts: 1410
Reply with quote
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).
View user's profileSend private message
Micahs


Joined: 26 Apr 2008
Posts: 32
Reply with quote
Here is the new version which supports multiple borders: borderGuard_multi



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.
View user's profileSend private message
Mark_


Joined: 31 Dec 2008
Posts: 108
Reply with quote
looks nice,
but:

>>Reverse sandboxed windows (Experimental)
what does it mean?
View user's profileSend private message
Guest


Reply with quote
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


Joined: 22 Jun 2004
Posts: 15155
Reply with quote
Micahs, per the discussion here, there is a new Contributed Utilities page. Let me know if you want to add your utility there.
View user's profileSend private message
Micahs


Joined: 26 Apr 2008
Posts: 32
Reply with quote
@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! Very Happy 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!)
View user's profileSend private message
Micahs


Joined: 26 Apr 2008
Posts: 32
Reply with quote
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.
View user's profileSend private message
Border sandboxed indicator
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 6 of 8  

Use the RSS feed to watch this topic for replies
  
  
 Reply to topic  

Sandboxie is Copyright © 2004-2012 by Sandboxie Holdings LLC.  All rights reserved.
Sandboxie.com | Contact Author
This site has been viewed 213,097,950 times since June 2004