Author: akhaldi Date: Thu Jan 7 11:55:44 2016 New Revision: 70518
URL: http://svn.reactos.org/svn/reactos?rev=70518&view=rev Log: [0.4.0] * Merge the recent rosvboxmgmt work by Pierre in revisions 70499, 70500 and 70510. CORE-10032 ROSAPPS-303
Modified: branches/ros-branch-0_4_0/ (props changed) branches/ros-branch-0_4_0/reactos/ (props changed) branches/ros-branch-0_4_0/reactos/boot/bootdata/hivesft.inf branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/CMakeLists.txt branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/rosvboxmgmt.c
Propchange: branches/ros-branch-0_4_0/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jan 7 11:55:44 2016 @@ -1 +1 @@ -/trunk:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70436-70437,70443,70464,70470,70480,70497 +/trunk:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70436-70437,70443,70464,70470,70480,70497,70499-70500,70510
Propchange: branches/ros-branch-0_4_0/reactos/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jan 7 11:55:44 2016 @@ -20,4 +20,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70436-70437,70443,70464,70470,70480,70497 +/trunk/reactos:70000-70321,70323-70324,70328-70337,70339-70340,70347,70349,70354-70358,70360,70363,70369,70373,70375-70378,70381,70384-70385,70387-70389,70398,70400,70408,70424,70436-70437,70443,70464,70470,70480,70497,70510
Modified: branches/ros-branch-0_4_0/reactos/boot/bootdata/hivesft.inf URL: http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/reactos/boot/bo... ============================================================================== --- branches/ros-branch-0_4_0/reactos/boot/bootdata/hivesft.inf [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/reactos/boot/bootdata/hivesft.inf [iso-8859-1] Thu Jan 7 11:55:44 2016 @@ -140,6 +140,9 @@ HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","",0x00000000,"cmd /c md ""%programfiles%\Internet Explorer"" && move %windir%\iexplore.exe ""%programfiles%\Internet Explorer"" && ""%programfiles%\Internet Explorer\iexplore.exe"" /RegServer" ; Create .NET Framework InstallRoot key, reg_sz & full path HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","InstallRoot.NET",0x00000000,"cmd /c reg add HKLM\SOFTWARE\Microsoft.NETFramework /v InstallRoot /t REG_SZ /d %SystemRoot%\Microsoft.NET\Framework" + +; HACK - Start rosvboxmgmt - ROSAPPS-303 +;HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Handle VBox SF",0x00000000,"%windir%\bin\rosvboxmgmt auto"
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons",,0x00000012 HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu",,0x00000012
Modified: branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/rosapps/applica... ============================================================================== --- branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/CMakeLists.txt [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/CMakeLists.txt [iso-8859-1] Thu Jan 7 11:55:44 2016 @@ -1,4 +1,6 @@ add_executable(rosvboxmgmt rosvboxmgmt.c rosvboxmgmt.rc) set_module_type(rosvboxmgmt win32cui UNICODE) -add_importlibs(rosvboxmgmt msvcrt kernel32) +target_link_libraries(rosvboxmgmt uuid) +add_delay_importlibs(rosvboxmgmt shell32) +add_importlibs(rosvboxmgmt msvcrt kernel32 user32 ole32) add_cd_file(TARGET rosvboxmgmt DESTINATION reactos/bin FOR all)
Modified: branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/rosvboxmgmt.c URL: http://svn.reactos.org/svn/reactos/branches/ros-branch-0_4_0/rosapps/applica... ============================================================================== --- branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/rosvboxmgmt.c [iso-8859-1] (original) +++ branches/ros-branch-0_4_0/rosapps/applications/cmdutils/rosvboxmgmt/rosvboxmgmt.c [iso-8859-1] Thu Jan 7 11:55:44 2016 @@ -9,9 +9,14 @@ #include <stdio.h> #include <wchar.h> #include <windows.h> +#include <shlobj.h> +#include <shobjidl.h> +#include <shlwapi.h>
/* DON'T CHANGE ORDER!!!! */ PCWSTR devices[3] = { L"\\.\VBoxMiniRdrDN", L"\??\VBoxMiniRdrDN", L"\Device\VBoxMiniRdr" }; + +#define MAX_LEN 255
/* Taken from VBox header */ #define _MRX_MAX_DRIVE_LETTERS 26 @@ -21,6 +26,7 @@ #define IOCTL_MRX_VBOX_ADDCONN _MRX_VBOX_CONTROL_CODE(100, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_MRX_VBOX_GETLIST _MRX_VBOX_CONTROL_CODE(103, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_MRX_VBOX_GETGLOBALLIST _MRX_VBOX_CONTROL_CODE(104, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_MRX_VBOX_GETGLOBALCONN _MRX_VBOX_CONTROL_CODE(105, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_MRX_VBOX_START _MRX_VBOX_CONTROL_CODE(106, METHOD_BUFFERED, FILE_ANY_ACCESS)
BOOL performDevIoCtl(DWORD dwIoControlCode, LPVOID lpInBuffer, DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize) @@ -120,6 +126,21 @@ return 0; }
+PCWSTR getGlobalConn(CHAR id) +{ + BOOL ret; + static WCHAR name[MAX_LEN]; + + ret = performDevIoCtl(IOCTL_MRX_VBOX_GETGLOBALCONN, &id, sizeof(id), name, sizeof(name)); + if (ret == FALSE) + { + return NULL; + } + + name[MAX_LEN - 1] = 0; + return name; +} + int getGlobalList(void) { short i; @@ -135,10 +156,106 @@ return 1; }
- for (i = 0; i < _MRX_MAX_DRIVE_LETTERS; i += 2) - { - wprintf(L"%c: %s\t%c: %s\n", 'A' + i, (outputBuffer[i] & 0x80 ? L"Active" : L"Inactive"), - 'A' + (i + 1), (outputBuffer[i + 1] & 0x80 ? L"Active" : L"Inactive")); + for (i = 0; i < _MRX_MAX_DRIVE_LETTERS; ++i) + { + CHAR id = outputBuffer[i]; + BOOL active = ((id & 0x80) == 0x80); + PCWSTR name = NULL; + + if (active) + { + name = getGlobalConn(id); + } + if (name == NULL) + { + name = L"None"; + } + + wprintf(L"%c: %s (%s)%c", 'A' + i, (active ? L"Active" : L"Inactive"), name, (i & 1 ? '\n' : '\t')); + } + + return 0; +} + +BOOL CreateUNCShortcut(PCWSTR share) +{ + HRESULT res; + IShellLink *link; + IPersistFile *persist; + WCHAR path[MAX_PATH]; + WCHAR linkPath[MAX_PATH]; + + res = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (void**)&link); + if (FAILED(res)) + { + return FALSE; + } + + res = link->lpVtbl->QueryInterface(link, &IID_IPersistFile, (void **)&persist); + if (FAILED(res)) + { + link->lpVtbl->Release(link); + return FALSE; + } + + wcscpy(path, L"\\vboxsvr\"); + wcscat(path, share); + link->lpVtbl->SetPath(link, path); + + res = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, path); + if (FAILED(res)) + { + persist->lpVtbl->Release(persist); + link->lpVtbl->Release(link); + return FALSE; + } + + wsprintf(linkPath, L"%s\Browse %s (VBox).lnk", path, share); + res = persist->lpVtbl->Save(persist, linkPath, TRUE); + + persist->lpVtbl->Release(persist); + link->lpVtbl->Release(link); + + return SUCCEEDED(res); +} + +int autoStart(void) +{ + short i; + BOOL ret; + DWORD outputBufferSize; + char outputBuffer[_MRX_MAX_DRIVE_LETTERS]; + + if (startVBoxSrv() != 0) + { + return 1; + } + + outputBufferSize = sizeof(outputBuffer); + memset(outputBuffer, 0, outputBufferSize); + ret = performDevIoCtl(IOCTL_MRX_VBOX_GETGLOBALLIST, NULL, 0, &outputBuffer, outputBufferSize); + if (ret == FALSE) + { + return 1; + } + + CoInitialize(NULL); + for (i = 0; i < _MRX_MAX_DRIVE_LETTERS; ++i) + { + CHAR id = outputBuffer[i]; + BOOL active = ((id & 0x80) == 0x80); + PCWSTR name = NULL; + + if (active) + { + name = getGlobalConn(id); + } + if (name == NULL) + { + continue; + } + + CreateUNCShortcut(name); }
return 0; @@ -151,6 +268,7 @@ wprintf(L"\taddconn <letter> <share name>: add a connection\n"); wprintf(L"\tgetlist: list connections\n"); wprintf(L"\tgetgloballist: list available shares\n"); + wprintf(L"\tauto: automagically configure the VBox Shared folders and creates desktop folders\n"); }
int wmain(int argc, wchar_t *argv[]) @@ -187,6 +305,10 @@ { return getGlobalList(); } + else if (_wcsicmp(cmd, L"auto") == 0) + { + return autoStart(); + } else { printUsage();