ReactOS  0.4.14-dev-317-g96040ec
vcdcontroltool.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winsvc.h>
#include <winreg.h>
#include <commctrl.h>
#include <commdlg.h>
#include <wchar.h>
#include <ndk/rtltypes.h>
#include <ndk/rtlfuncs.h>
#include <vcdioctl.h>
#include "resource.h"
Include dependency graph for vcdcontroltool.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define IOCTL_CDROM_BASE   FILE_DEVICE_CD_ROM
 
#define IOCTL_CDROM_EJECT_MEDIA   CTL_CODE(IOCTL_CDROM_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
 

Functions

static HANDLE OpenMaster (VOID)
 
static HANDLE OpenLetter (WCHAR Letter)
 
static VOID RefreshDevicesList (WCHAR Letter)
 
VOID SetServiceState (BOOLEAN Started)
 
INT_PTR QueryDriverInfo (HWND hDlg)
 
static VOID StartDriver (VOID)
 
static VOID StopDriver (VOID)
 
static INT_PTR HandleDriverCommand (WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK DriverDialogProc (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 
static VOID DriverControl (VOID)
 
static INT_PTR SetMountFileName (HWND hDlg, LPARAM lParam)
 
FORCEINLINE DWORD Min (DWORD a, DWORD b)
 
static VOID PerformMount (VOID)
 
static INT_PTR HandleMountCommand (WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK MountDialogProc (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 
static VOID AddDrive (VOID)
 
static WCHAR GetSelectedDriveLetter (VOID)
 
static VOID MountImage (VOID)
 
static VOID RemountImage (VOID)
 
static VOID EjectDrive (VOID)
 
static VOID RemoveDrive (VOID)
 
static INT_PTR HandleCommand (WPARAM wParam, LPARAM lParam)
 
static VOID ResetStats (VOID)
 
static INT_PTR HandleNotify (LPARAM lParam)
 
static INT_PTR CreateListViewColumns (HWND hDlg)
 
static INT_PTR CALLBACK MainDialogProc (HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 
INT WINAPI wWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR Cmd, int iCmd)
 

Variables

HWND hWnd
 
HWND hMountWnd
 
HWND hDriverWnd
 
HINSTANCE hInstance
 
WCHAR wMountLetter
 

Macro Definition Documentation

◆ IOCTL_CDROM_BASE

#define IOCTL_CDROM_BASE   FILE_DEVICE_CD_ROM

Definition at line 25 of file vcdcontroltool.c.

◆ IOCTL_CDROM_EJECT_MEDIA

#define IOCTL_CDROM_EJECT_MEDIA   CTL_CODE(IOCTL_CDROM_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)

Definition at line 26 of file vcdcontroltool.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file vcdcontroltool.c.

Function Documentation

◆ AddDrive()

static VOID AddDrive ( VOID  )
static

Definition at line 555 of file vcdcontroltool.c.

556 {
557  WCHAR Letter;
558  BOOLEAN Res;
560  HANDLE hMaster;
561 
562  /* Open the driver */
563  hMaster = OpenMaster();
564  if (hMaster != INVALID_HANDLE_VALUE)
565  {
566  /* Issue the create IOCTL */
567  Res = DeviceIoControl(hMaster, IOCTL_VCDROM_CREATE_DRIVE, NULL, 0, &Letter, sizeof(WCHAR), &BytesRead, NULL);
568  CloseHandle(hMaster);
569 
570  /* If it failed, reset the drive letter */
571  if (!Res)
572  {
573  Letter = 0;
574  }
575 
576  /* Refresh devices list. If it succeed, we pass the created drive letter
577  * So that, user can directly click on "mount" to mount an image, without
578  * needing to select appropriate device.
579  */
581  }
582 }
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static HANDLE OpenMaster(VOID)
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define IOCTL_VCDROM_CREATE_DRIVE
Definition: vcdioctl.h:2
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR Letter
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by HandleCommand().

◆ CreateListViewColumns()

static INT_PTR CreateListViewColumns ( HWND  hDlg)
static

Definition at line 878 of file vcdcontroltool.c.

879 {
880  WCHAR szText[255];
881  LVCOLUMNW lvColumn;
882  HWND hListView;
883 
884  hWnd = hDlg;
885  hListView = GetDlgItem(hDlg, IDC_MAINDEVICES);
886 
887  /* Select the whole line, not just the first column */
889 
890  /* Set up the first column */
891  ZeroMemory(&lvColumn, sizeof(LVCOLUMNW));
892  lvColumn.pszText = szText;
893  lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
894  lvColumn.fmt = LVCFMT_LEFT;
895  lvColumn.cx = 100;
896  szText[0] = 0;
897  LoadString(hInstance, IDS_DRIVE, szText, sizeof(szText) / sizeof(WCHAR));
898  szText[(sizeof(szText) / sizeof(WCHAR)) - 1] = L'\0';
899  SendMessage(hListView, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvColumn);
900 
901  /* Set up the second column */
902  szText[0] = 0;
903  lvColumn.cx = 350;
904  LoadString(hInstance, IDS_MAPPEDIMAGE, szText, sizeof(szText) / sizeof(WCHAR));
905  szText[(sizeof(szText) / sizeof(WCHAR)) - 1] = L'\0';
906  SendMessage(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvColumn);
907 
908  /* Make sure stats are at 0 */
909  ResetStats();
910 
911  /* And populate our device list */
913 
914  return TRUE;
915 }
#define TRUE
Definition: types.h:120
#define LVCF_WIDTH
Definition: commctrl.h:2583
#define LVCF_TEXT
Definition: commctrl.h:2584
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2730
#define LVCFMT_LEFT
Definition: commctrl.h:2594
#define ZeroMemory
Definition: winbase.h:1642
HINSTANCE hInstance
#define LVCF_SUBITEM
Definition: commctrl.h:2585
#define IDS_DRIVE
Definition: resource.h:33
static const WCHAR szText[]
Definition: dialog.c:139
HWND hWnd
#define LVM_INSERTCOLUMNW
Definition: commctrl.h:2628
#define IDC_MAINDEVICES
Definition: resource.h:9
#define IDS_MAPPEDIMAGE
Definition: resource.h:34
LONG_PTR LPARAM
Definition: windef.h:208
static VOID ResetStats(VOID)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR pszText
Definition: commctrl.h:2563
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2720
static const WCHAR L[]
Definition: oid.c:1250
#define LVCF_FMT
Definition: commctrl.h:2582
#define SendMessage
Definition: winuser.h:5744
#define LoadString
Definition: winuser.h:5720
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by MainDialogProc().

◆ DriverControl()

static VOID DriverControl ( VOID  )
static

Definition at line 387 of file vcdcontroltool.c.

388 {
389  /* Just create a new window with our driver control dialog */
392  NULL,
394  0);
395 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
HINSTANCE hInstance
smooth NULL
Definition: ftsmooth.c:416
static INT_PTR CALLBACK DriverDialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
#define IDD_DRIVERWINDOW
Definition: resource.h:5
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by HandleCommand().

◆ DriverDialogProc()

static INT_PTR CALLBACK DriverDialogProc ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 364 of file vcdcontroltool.c.

368 {
369  /* Dispatch the message */
370  switch (Message)
371  {
372  case WM_INITDIALOG:
373  return QueryDriverInfo(hDlg);
374 
375  case WM_COMMAND:
377 
378  case WM_CLOSE:
379  return DestroyWindow(hDlg);
380  }
381 
382  return FALSE;
383 }
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
#define WM_CLOSE
Definition: winuser.h:1603
CHAR Message[80]
Definition: alive.c:5
static INT_PTR HandleDriverCommand(WPARAM wParam, LPARAM lParam)
#define WM_COMMAND
Definition: winuser.h:1722
INT_PTR QueryDriverInfo(HWND hDlg)
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139

Referenced by DriverControl().

◆ EjectDrive()

static VOID EjectDrive ( VOID  )
static

Definition at line 693 of file vcdcontroltool.c.

694 {
695  WCHAR Letter;
696  HANDLE hLet;
698 
699  /* Get the select drive letter */
701  if (Letter != 0)
702  {
703  /* Open it */
704  hLet = OpenLetter(Letter);
705  if (hLet != INVALID_HANDLE_VALUE)
706  {
707  /* And ask the driver for an ejection */
709 
710  CloseHandle(hLet);
711 
712  /* Refresh the list, to display the fact the image is now unmounted but
713  * still known by the driver
714  * Make sure it's selected as it was previously selected.
715  */
717  }
718  }
719 }
#define IOCTL_CDROM_EJECT_MEDIA
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static HANDLE OpenLetter(WCHAR Letter)
static WCHAR GetSelectedDriveLetter(VOID)
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR Letter
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by HandleCommand().

◆ GetSelectedDriveLetter()

static WCHAR GetSelectedDriveLetter ( VOID  )
static

Definition at line 586 of file vcdcontroltool.c.

587 {
588  INT iItem;
589  HWND hListView;
590  LVITEM lvItem;
591  WCHAR szText[255];
592 
593  /* Get the select device in the list view */
594  hListView = GetDlgItem(hWnd, IDC_MAINDEVICES);
595  iItem = SendMessage(hListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
596  /* If there's one... */
597  if (iItem != -1)
598  {
599  ZeroMemory(&lvItem, sizeof(LVITEM));
600  lvItem.pszText = szText;
601  lvItem.cchTextMax = sizeof(szText) / sizeof(WCHAR);
602  szText[0] = 0;
603 
604  /* Get the item text, it will be the drive letter */
605  SendMessage(hListView, LVM_GETITEMTEXT, iItem, (LPARAM)&lvItem);
606  return szText[0];
607  }
608 
609  /* Nothing selected */
610  return 0;
611 }
#define LVM_GETITEMTEXT
Definition: commctrl.h:2678
#define ZeroMemory
Definition: winbase.h:1642
#define LVNI_SELECTED
Definition: commctrl.h:2420
int32_t INT
Definition: typedefs.h:56
static const WCHAR szText[]
Definition: dialog.c:139
HWND hWnd
#define IDC_MAINDEVICES
Definition: resource.h:9
LONG_PTR LPARAM
Definition: windef.h:208
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SendMessage
Definition: winuser.h:5744
#define LVITEM
Definition: commctrl.h:2371
#define LVM_GETNEXTITEM
Definition: commctrl.h:2429

Referenced by EjectDrive(), HandleNotify(), MountImage(), RemountImage(), and RemoveDrive().

◆ HandleCommand()

static INT_PTR HandleCommand ( WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 750 of file vcdcontroltool.c.

752 {
753  WORD Msg;
754 
755  /* Dispatch the message for the controls we manage */
756  Msg = LOWORD(wParam);
757  switch (Msg)
758  {
759  case IDC_MAINCONTROL:
760  DriverControl();
761  return TRUE;
762 
763  case IDC_MAINOK:
765  return TRUE;
766 
767  case IDC_MAINADD:
768  AddDrive();
769  return TRUE;
770 
771  case IDC_MAINMOUNT:
772  MountImage();
773  return TRUE;
774 
775  case IDC_MAINREMOUNT:
776  RemountImage();
777  return TRUE;
778 
779  case IDC_MAINEJECT:
780  EjectDrive();
781  return TRUE;
782 
783  case IDC_MAINREMOVE:
784  RemoveDrive();
785  return TRUE;
786  }
787 
788  return FALSE;
789 }
#define TRUE
Definition: types.h:120
#define IDC_MAINREMOVE
Definition: resource.h:15
#define IDC_MAINMOUNT
Definition: resource.h:16
#define IDC_MAINREMOUNT
Definition: resource.h:18
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
static VOID RemoveDrive(VOID)
HWND hWnd
struct @1593 Msg[]
#define IDC_MAINCONTROL
Definition: resource.h:19
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDC_MAINOK
Definition: resource.h:8
#define IDC_MAINEJECT
Definition: resource.h:17
static VOID AddDrive(VOID)
#define IDC_MAINADD
Definition: resource.h:14
static VOID MountImage(VOID)
static VOID DriverControl(VOID)
static VOID RemountImage(VOID)
#define LOWORD(l)
Definition: pedump.c:82
static VOID EjectDrive(VOID)

Referenced by MainDialogProc().

◆ HandleDriverCommand()

static INT_PTR HandleDriverCommand ( WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 336 of file vcdcontroltool.c.

338 {
339  WORD Msg;
340 
341  /* Dispatch the message for the controls we manage */
342  Msg = LOWORD(wParam);
343  switch (Msg)
344  {
345  case IDC_DRIVEROK:
347  return TRUE;
348 
349  case IDC_DRIVERSTART:
350  StartDriver();
351  return TRUE;
352 
353  case IDC_DRIVERSTOP:
354  StopDriver();
355  return TRUE;
356  }
357 
358  return FALSE;
359 }
#define TRUE
Definition: types.h:120
#define IDC_DRIVERSTART
Definition: resource.h:28
HWND hDriverWnd
static VOID StopDriver(VOID)
static VOID StartDriver(VOID)
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
#define IDC_DRIVEROK
Definition: resource.h:26
struct @1593 Msg[]
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDC_DRIVERSTOP
Definition: resource.h:29
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DriverDialogProc().

◆ HandleMountCommand()

static INT_PTR HandleMountCommand ( WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 508 of file vcdcontroltool.c.

510 {
511  WORD Msg;
512 
513  /* Dispatch the message for the controls we manage */
514  Msg = LOWORD(wParam);
515  switch (Msg)
516  {
517  case IDC_MOUNTCANCEL:
519  return TRUE;
520 
521  case IDC_MOUNTOK:
522  PerformMount();
523  return TRUE;
524  }
525 
526  return FALSE;
527 }
#define IDC_MOUNTCANCEL
Definition: resource.h:21
#define TRUE
Definition: types.h:120
#define IDC_MOUNTOK
Definition: resource.h:20
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
struct @1593 Msg[]
HWND hMountWnd
unsigned short WORD
Definition: ntddk_ex.h:93
#define LOWORD(l)
Definition: pedump.c:82
static VOID PerformMount(VOID)

Referenced by MountDialogProc().

◆ HandleNotify()

static INT_PTR HandleNotify ( LPARAM  lParam)
static

Definition at line 815 of file vcdcontroltool.c.

816 {
817  WCHAR Letter;
818  LPNMHDR NmHdr;
819  WCHAR szText[255];
820  HWND hEditText;
821  DWORD ClusterSector, SectorSize, FreeClusters, Clusters, Sectors;
822 
823  NmHdr = (LPNMHDR)lParam;
824 
825  /* We only want notifications on click on our devices list */
826  if (NmHdr->code == NM_CLICK &&
827  NmHdr->idFrom == IDC_MAINDEVICES)
828  {
829  /* Get the newly selected device */
831  if (Letter != 0)
832  {
833  /* Setup its name */
834  szText[0] = Letter;
835  szText[1] = L':';
836  szText[2] = 0;
837 
838  /* And get its capacities */
839  if (GetDiskFreeSpace(szText, &ClusterSector, &SectorSize, &FreeClusters, &Clusters))
840  {
841  /* Nota: the application returns the total amount of clusters and sectors
842  * So, compute it
843  */
844  Sectors = ClusterSector * Clusters;
845 
846  /* And now, update statistics about the device */
847  hEditText = GetDlgItem(hWnd, IDC_MAINSECTORS);
848  wsprintf(szText, L"%ld", Sectors);
849  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
850 
851  hEditText = GetDlgItem(hWnd, IDC_MAINSIZE);
852  wsprintf(szText, L"%ld", SectorSize);
853  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
854 
855  hEditText = GetDlgItem(hWnd, IDC_MAINFREE);
856  wsprintf(szText, L"%ld", FreeClusters);
857  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
858 
859  hEditText = GetDlgItem(hWnd, IDC_MAINTOTAL);
860  wsprintf(szText, L"%ld", Clusters);
861  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
862 
863  return TRUE;
864  }
865  }
866 
867  /* We failed somewhere, make sure we're at 0 */
868  ResetStats();
869 
870  return TRUE;
871  }
872 
873  return FALSE;
874 }
#define TRUE
Definition: types.h:120
NTSTATUS FreeClusters(PNTFS_VCB Vcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, ULONG ClustersToFree)
Definition: attrib.c:1057
#define GetDiskFreeSpace
Definition: winbase.h:3631
struct tagNMHDR * LPNMHDR
UINT code
Definition: winuser.h:3133
static const WCHAR szText[]
Definition: dialog.c:139
HWND hWnd
static WCHAR GetSelectedDriveLetter(VOID)
UINT_PTR idFrom
Definition: winuser.h:3132
#define IDC_MAINDEVICES
Definition: resource.h:9
LONG_PTR LPARAM
Definition: windef.h:208
static VOID ResetStats(VOID)
#define IDC_MAINSECTORS
Definition: resource.h:10
#define WM_SETTEXT
Definition: winuser.h:1599
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define IDC_MAINTOTAL
Definition: resource.h:13
WCHAR Letter
#define NM_CLICK
Definition: commctrl.h:130
#define IDC_MAINSIZE
Definition: resource.h:11
#define SendMessage
Definition: winuser.h:5744
_In_ ULONG SectorSize
Definition: halfuncs.h:291
#define wsprintf
Definition: winuser.h:5766
LPARAM lParam
Definition: combotst.c:139
#define IDC_MAINFREE
Definition: resource.h:12

Referenced by MainDialogProc().

◆ MainDialogProc()

static INT_PTR CALLBACK MainDialogProc ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 920 of file vcdcontroltool.c.

924 {
925  /* Dispatch the message */
926  switch (Message)
927  {
928  case WM_INITDIALOG:
929  return CreateListViewColumns(hDlg);
930 
931  case WM_COMMAND:
932  return HandleCommand(wParam, lParam);
933 
934  case WM_NOTIFY:
935  return HandleNotify(lParam);
936 
937  case WM_CLOSE:
938  return DestroyWindow(hDlg);
939 
940  case WM_DESTROY:
941  PostQuitMessage(0);
942  return TRUE;
943  }
944 
945  return FALSE;
946 }
#define TRUE
Definition: types.h:120
static INT_PTR HandleNotify(LPARAM lParam)
static INT_PTR CreateListViewColumns(HWND hDlg)
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_CLOSE
Definition: winuser.h:1603
CHAR Message[80]
Definition: alive.c:5
#define WM_COMMAND
Definition: winuser.h:1722
static INT_PTR HandleCommand(WPARAM wParam, LPARAM lParam)
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_NOTIFY
Definition: richedit.h:61

Referenced by wWinMain().

◆ Min()

FORCEINLINE DWORD Min ( DWORD  a,
DWORD  b 
)

Definition at line 418 of file vcdcontroltool.c.

419 {
420  return (a > b ? b : a);
421 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by PerformMount().

◆ MountDialogProc()

static INT_PTR CALLBACK MountDialogProc ( HWND  hDlg,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 532 of file vcdcontroltool.c.

536 {
537  /* Dispatch the message */
538  switch (Message)
539  {
540  case WM_INITDIALOG:
541  return SetMountFileName(hDlg, lParam);
542 
543  case WM_COMMAND:
545 
546  case WM_CLOSE:
547  return DestroyWindow(hDlg);
548  }
549 
550  return FALSE;
551 }
static INT_PTR HandleMountCommand(WPARAM wParam, LPARAM lParam)
BOOL WINAPI DestroyWindow(_In_ HWND)
WPARAM wParam
Definition: combotst.c:138
static INT_PTR SetMountFileName(HWND hDlg, LPARAM lParam)
#define WM_CLOSE
Definition: winuser.h:1603
CHAR Message[80]
Definition: alive.c:5
#define WM_COMMAND
Definition: winuser.h:1722
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139

Referenced by MountImage().

◆ MountImage()

static VOID MountImage ( VOID  )
static

Definition at line 615 of file vcdcontroltool.c.

616 {
617  WCHAR szFilter[255];
618  WCHAR szFileName[MAX_PATH];
619  OPENFILENAMEW ImageOpen;
620 
621  /* Get the selected drive letter
622  * FIXME: I make it global, because I don't know how to pass
623  * it properly to the later involved functions.
624  * Feel free to improve (without breaking ;-))
625  */
627  /* We can only mount if we have a device */
628  if (wMountLetter != 0)
629  {
630  /* First of all, we need an image to mount */
631  ZeroMemory(&ImageOpen, sizeof(OPENFILENAMEW));
632 
633  ImageOpen.lStructSize = sizeof(ImageOpen);
634  ImageOpen.hwndOwner = NULL;
635  ImageOpen.lpstrFilter = szFilter;
636  ImageOpen.lpstrFile = szFileName;
637  ImageOpen.nMaxFile = MAX_PATH;
639 
640  /* Get our filter (only supported images) */
641  szFileName[0] = 0;
642  szFilter[0] = 0;
643  LoadString(hInstance, IDS_FILTER, szFilter, sizeof(szFilter) / sizeof(WCHAR));
644  szFilter[(sizeof(szFilter) / sizeof(WCHAR)) - 1] = L'\0';
645 
646  /* Get the image name */
647  if (!GetOpenFileName(&ImageOpen))
648  {
649  /* The user canceled... */
650  return;
651  }
652 
653  /* Start the mount dialog, so that user can select mount options */
656  NULL,
658  (LPARAM)szFileName);
659  }
660 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
static INT_PTR CALLBACK MountDialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
#define MAKEINTRESOURCE
Definition: winuser.h:591
DWORD Flags
Definition: commdlg.h:373
LPCWSTR lpstrFilter
Definition: commdlg.h:363
#define IDS_FILTER
Definition: resource.h:37
LPWSTR lpstrFile
Definition: commdlg.h:367
#define ZeroMemory
Definition: winbase.h:1642
HINSTANCE hInstance
#define GetOpenFileName
Definition: commdlg.h:665
DWORD lStructSize
Definition: commdlg.h:360
static WCHAR GetSelectedDriveLetter(VOID)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
LPTSTR szFilter
Definition: mplay32.c:30
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR wMountLetter
#define MAX_PATH
Definition: compat.h:26
DWORD nMaxFile
Definition: commdlg.h:368
HWND hwndOwner
Definition: commdlg.h:361
static const WCHAR L[]
Definition: oid.c:1250
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define IDD_MOUNTWINDOW
Definition: resource.h:4
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define LoadString
Definition: winuser.h:5720

Referenced by HandleCommand().

◆ OpenLetter()

static HANDLE OpenLetter ( WCHAR  Letter)
static

Definition at line 48 of file vcdcontroltool.c.

49 {
50  WCHAR Device[255];
51 
52  /* Make name */
53  wsprintf(Device, L"\\\\.\\%c:", Letter);
54 
55  /* And open */
58 }
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
WCHAR Letter
#define GENERIC_READ
Definition: compat.h:124
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define wsprintf
Definition: winuser.h:5766

Referenced by EjectDrive(), PerformMount(), RefreshDevicesList(), RemountImage(), and RemoveDrive().

◆ OpenMaster()

static HANDLE OpenMaster ( VOID  )
static

Definition at line 39 of file vcdcontroltool.c.

40 {
41  /* Just open the device */
42  return CreateFile(L"\\\\.\\\\VirtualCdRom", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
44 }
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904

Referenced by AddDrive(), and RefreshDevicesList().

◆ PerformMount()

static VOID PerformMount ( VOID  )
static

Definition at line 425 of file vcdcontroltool.c.

426 {
427  HWND hControl;
428  WCHAR szFileName[MAX_PATH];
429  MOUNT_PARAMETERS MountParams;
430  UNICODE_STRING NtPathName;
431  HANDLE hLet;
433  BOOLEAN bPersist, Res;
434  WCHAR szKeyName[256];
435  HKEY hKey;
436 
437  /* Zero our input structure */
438  ZeroMemory(&MountParams, sizeof(MOUNT_PARAMETERS));
439 
440  /* Do we have to suppress UDF? */
441  hControl = GetDlgItem(hMountWnd, IDC_MOUNTUDF);
442  if (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
443  {
444  MountParams.Flags |= MOUNT_FLAG_SUPP_UDF;
445  }
446 
447  /* Do we have to suppress Joliet? */
448  hControl = GetDlgItem(hMountWnd, IDC_MOUNTJOLIET);
449  if (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED)
450  {
451  MountParams.Flags |= MOUNT_FLAG_SUPP_JOLIET;
452  }
453 
454  /* Should the mount be persistent? */
456  bPersist = (SendMessage(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED);
457 
458  /* Get the file name */
459  hControl = GetDlgItem(hMountWnd, IDC_MOUNTIMAGE);
460  GetWindowText(hControl, szFileName, sizeof(szFileName) / sizeof(WCHAR));
461 
462  /* Get NT path for the driver */
463  if (RtlDosPathNameToNtPathName_U(szFileName, &NtPathName, NULL, NULL))
464  {
465  /* Copy it in the parameter structure */
466  wcsncpy(MountParams.Path, NtPathName.Buffer, 255);
467  MountParams.Length = Min(NtPathName.Length, 255 * sizeof(WCHAR));
468  RtlFreeHeap(RtlGetProcessHeap(), 0, NtPathName.Buffer);
469 
470  /* Open the device */
471  hLet = OpenLetter(wMountLetter);
472  if (hLet != INVALID_HANDLE_VALUE)
473  {
474  /* And issue the mount IOCTL */
475  Res = DeviceIoControl(hLet, IOCTL_VCDROM_MOUNT_IMAGE, &MountParams, sizeof(MountParams), NULL, 0, &BytesRead, NULL);
476 
477  CloseHandle(hLet);
478 
479  /* Refresh the list so that our mount appears */
481 
482  /* If mount succeed and has to persistent, write it to registry */
483  if (Res && bPersist)
484  {
485  wsprintf(szKeyName, L"SYSTEM\\CurrentControlSet\\Services\\Vcdrom\\Parameters\\Device%c", wMountLetter);
487  {
488  wcsncpy(szKeyName, MountParams.Path, MountParams.Length);
489  szKeyName[MountParams.Length / sizeof(WCHAR)] = 0;
490  RegSetValueExW(hKey, L"IMAGE", 0, REG_SZ, (BYTE *)szKeyName, MountParams.Length);
491 
492  szKeyName[0] = wMountLetter;
493  szKeyName[1] = L':';
494  szKeyName[2] = 0;
495  RegSetValueExW(hKey, L"DRIVE", 0, REG_SZ, (BYTE *)szKeyName, 3 * sizeof(WCHAR));
496 
497  RegCloseKey(hKey);
498  }
499  }
500  }
501  }
502 
504 }
#define MOUNT_FLAG_SUPP_UDF
Definition: vcdioctl.h:15
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1642
#define IOCTL_VCDROM_MOUNT_IMAGE
Definition: vcdioctl.h:4
BOOL WINAPI DestroyWindow(_In_ HWND)
#define GetWindowText
Definition: winuser.h:5699
static HANDLE OpenLetter(WCHAR Letter)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE DWORD Min(DWORD a, DWORD b)
#define BM_GETCHECK
Definition: winuser.h:1900
HWND hMountWnd
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define IDC_MOUNTUDF
Definition: resource.h:23
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDC_MOUNTIMAGE
Definition: resource.h:22
WCHAR wMountLetter
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
#define IDC_MOUNTJOLIET
Definition: resource.h:24
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define IDC_MOUNTPERSIST
Definition: resource.h:25
WCHAR Path[255]
Definition: vcdioctl.h:10
#define MOUNT_FLAG_SUPP_JOLIET
Definition: vcdioctl.h:16
#define BST_CHECKED
Definition: winuser.h:197
#define SendMessage
Definition: winuser.h:5744
#define wsprintf
Definition: winuser.h:5766
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define RegCreateKeyEx
Definition: winreg.h:501
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
static VOID RefreshDevicesList(WCHAR Letter)
#define REG_SZ
Definition: layer.c:22

Referenced by HandleMountCommand().

◆ QueryDriverInfo()

INT_PTR QueryDriverInfo ( HWND  hDlg)

Definition at line 200 of file vcdcontroltool.c.

201 {
202  DWORD dwSize;
203  SC_HANDLE hMgr, hSvc;
204  LPQUERY_SERVICE_CONFIGW pConfig;
205  WCHAR szText[2 * MAX_PATH];
206  HWND hControl;
208 
209  hDriverWnd = hDlg;
210 
211  /* Open service manager */
213  if (hMgr != NULL)
214  {
215  /* Open our service */
216  hSvc = OpenService(hMgr, L"Vcdrom", SERVICE_QUERY_CONFIG | SERVICE_QUERY_STATUS);
217  if (hSvc != NULL)
218  {
219  /* Probe its config size */
220  if (!QueryServiceConfig(hSvc, NULL, 0, &dwSize) &&
222  {
223  /* And get its config */
224  pConfig = HeapAlloc(GetProcessHeap(), 0, dwSize);
225 
226  if (QueryServiceConfig(hSvc, pConfig, dwSize, &dwSize))
227  {
228  /* Display name & driver */
229  wsprintf(szText, L"%s:\n(%s)", pConfig->lpDisplayName, pConfig->lpBinaryPathName);
230  hControl = GetDlgItem(hDriverWnd, IDC_DRIVERINFO);
231  SendMessage(hControl, WM_SETTEXT, 0, (LPARAM)szText);
232  }
233 
234  HeapFree(GetProcessHeap(), 0, pConfig);
235  }
236 
237  /* Get its status */
238  if (QueryServiceStatus(hSvc, &Status))
239  {
240  if (Status.dwCurrentState != SERVICE_RUNNING &&
241  Status.dwCurrentState != SERVICE_START_PENDING)
242  {
244  }
245  else
246  {
248  }
249  }
250 
251  CloseServiceHandle(hSvc);
252  }
253 
254  CloseServiceHandle(hMgr);
255  }
256 
257  /* FIXME: we don't allow uninstall/install */
258  {
260  EnableWindow(hControl, FALSE);
262  EnableWindow(hControl, FALSE);
263  }
264 
265  /* Display our sub window */
266  ShowWindow(hDlg, SW_SHOW);
267 
268  return TRUE;
269 }
#define TRUE
Definition: types.h:120
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
#define QueryServiceConfig
Definition: winsvc.h:580
HWND hDriverWnd
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define SERVICE_START_PENDING
Definition: winsvc.h:22
VOID SetServiceState(BOOLEAN Started)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define OpenService
Definition: winsvc.h:576
#define IDC_DRIVERINFO
Definition: resource.h:31
static const WCHAR szText[]
Definition: dialog.c:139
#define SERVICE_RUNNING
Definition: winsvc.h:24
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
#define SW_SHOW
Definition: winuser.h:769
#define WM_SETTEXT
Definition: winuser.h:1599
#define OpenSCManager
Definition: winsvc.h:575
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI QueryServiceStatus(SC_HANDLE hService, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:2788
#define IDC_DRIVERINSTALL
Definition: resource.h:27
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SendMessage
Definition: winuser.h:5744
LPWSTR lpBinaryPathName
Definition: winsvc.h:159
#define SERVICE_QUERY_CONFIG
Definition: winsvc.h:53
#define wsprintf
Definition: winuser.h:5766
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define IDC_DRIVERREMOVE
Definition: resource.h:30
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by DriverDialogProc().

◆ RefreshDevicesList()

static VOID RefreshDevicesList ( WCHAR  Letter)
static

Definition at line 62 of file vcdcontroltool.c.

63 {
64  HWND hListView;
65  WCHAR szFormat[50];
66  WCHAR szText[MAX_PATH + 50];
67  WCHAR szImage[MAX_PATH];
68  HANDLE hMaster, hLet;
69  DWORD BytesRead, i;
70  DRIVES_LIST Drives;
71  BOOLEAN Res;
73  LVITEMW lvItem;
74  LRESULT lResult;
75  INT iSelected;
76 
77  /* Get our list view */
78  hListView = GetDlgItem(hWnd, IDC_MAINDEVICES);
79 
80  /* Purge it */
81  SendMessage(hListView, LVM_DELETEALLITEMS, 0, 0);
82 
83  /* Now, query the driver for all the devices */
84  hMaster = OpenMaster();
85  if (hMaster != INVALID_HANDLE_VALUE)
86  {
87  Res = DeviceIoControl(hMaster, IOCTL_VCDROM_ENUMERATE_DRIVES, NULL, 0, &Drives, sizeof(Drives), &BytesRead, NULL);
88  CloseHandle(hMaster);
89 
90  if (Res)
91  {
92  /* Loop to add all the devices to the list */
93  iSelected = -1;
94  for (i = 0; i < Drives.Count; ++i)
95  {
96  /* We'll query device one by one */
97  hLet = OpenLetter(Drives.Drives[i]);
98  if (hLet != INVALID_HANDLE_VALUE)
99  {
100  /* Get info about the mounted image */
102  if (Res)
103  {
104  /* First of all, add our driver letter to the list */
105  ZeroMemory(&lvItem, sizeof(LVITEMW));
106  lvItem.mask = LVIF_TEXT;
107  lvItem.pszText = szText;
108  lvItem.iItem = i;
109  szText[0] = Drives.Drives[i];
110  szText[1] = L':';
111  szText[2] = 0;
112 
113  /* If it worked, we'll complete with the info about the device:
114  * (mounted? which image?)
115  */
116  lResult = SendMessage(hListView, LVM_INSERTITEM, 0, (LPARAM)&lvItem);
117  if (lResult != -1)
118  {
119  /* If it matches arg, that's the letter to select at the end */
120  if (Drives.Drives[i] == Letter)
121  {
122  iSelected = lResult;
123  }
124 
125  /* We'll fill second column with info */
126  lvItem.iSubItem = 1;
127 
128  /* Gather the image path */
129  if (Image.Length != 0)
130  {
131  memcpy(szImage, Image.Path, Image.Length);
132  szImage[(Image.Length / sizeof(WCHAR))] = L'\0';
133  }
134 
135  /* It's not mounted... */
136  if (Image.Mounted == 0)
137  {
138  /* If we don't have an image, set default text instead */
139  if (Image.Length == 0)
140  {
141  szImage[0] = 0;
142  LoadString(hInstance, IDS_NONE, szImage, sizeof(szImage) / sizeof(WCHAR));
143  szImage[(sizeof(szImage) / sizeof(WCHAR)) - 1] = L'\0';
144  }
145 
146  /* Display the last known image */
147  szFormat[0] = 0;
148  LoadString(hInstance, IDS_NOMOUNTED, szFormat, sizeof(szFormat) / sizeof(WCHAR));
149  szFormat[(sizeof(szFormat) / sizeof(WCHAR)) - 1] = L'\0';
150 
151  swprintf(szText, szFormat, szImage);
152  lvItem.pszText = szText;
153  }
154  else
155  {
156  /* Mounted, just display the image path */
157  lvItem.pszText = szImage;
158  }
159 
160  /* Set text */
161  SendMessage(hListView, LVM_SETITEM, lResult, (LPARAM)&lvItem);
162  }
163  }
164 
165  /* Don't leak our device */
166  CloseHandle(hLet);
167  }
168  }
169 
170  /* If we had something to select, then just do it */
171  if (iSelected != -1)
172  {
173  ZeroMemory(&lvItem, sizeof(LVITEMW));
174 
175  lvItem.mask = LVIF_STATE;
176  lvItem.iItem = iSelected;
177  lvItem.state = LVIS_FOCUSED | LVIS_SELECTED;
179  SendMessage(hListView, LVM_SETITEMSTATE, iSelected, (LPARAM)&lvItem);
180  }
181  }
182  }
183 }
#define IDS_NOMOUNTED
Definition: resource.h:35
#define CloseHandle
Definition: compat.h:398
#define IDS_NONE
Definition: resource.h:122
static PWSTR Image
Definition: pageheap.c:13
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1642
HINSTANCE hInstance
int32_t INT
Definition: typedefs.h:56
UINT stateMask
Definition: commctrl.h:2360
static HANDLE OpenMaster(VOID)
static HANDLE OpenLetter(WCHAR Letter)
#define LVIF_TEXT
Definition: commctrl.h:2305
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const WCHAR szText[]
Definition: dialog.c:139
HWND hWnd
#define LVM_INSERTITEM
Definition: commctrl.h:2402
int iSubItem
Definition: commctrl.h:2358
#define IDC_MAINDEVICES
Definition: resource.h:9
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define LVIS_SELECTED
Definition: commctrl.h:2315
LONG_PTR LPARAM
Definition: windef.h:208
USHORT Count
Definition: vcdioctl.h:20
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR pszText
Definition: commctrl.h:2361
#define IOCTL_VCDROM_ENUMERATE_DRIVES
Definition: vcdioctl.h:5
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT mask
Definition: commctrl.h:2356
#define LVM_SETITEMSTATE
Definition: commctrl.h:2668
static const WCHAR L[]
Definition: oid.c:1250
WCHAR Letter
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define IOCTL_VCDROM_GET_IMAGE_PATH
Definition: vcdioctl.h:6
UINT state
Definition: commctrl.h:2359
#define LVM_DELETEALLITEMS
Definition: commctrl.h:2409
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define LVM_SETITEM
Definition: commctrl.h:2395
#define SendMessage
Definition: winuser.h:5744
WCHAR Drives[26]
Definition: vcdioctl.h:21
#define LVIF_STATE
Definition: commctrl.h:2308
LONG_PTR LRESULT
Definition: windef.h:209
#define LoadString
Definition: winuser.h:5720
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
#define LVIS_FOCUSED
Definition: commctrl.h:2314

Referenced by AddDrive(), CreateListViewColumns(), EjectDrive(), PerformMount(), RemountImage(), RemoveDrive(), StartDriver(), and StopDriver().

◆ RemountImage()

static VOID RemountImage ( VOID  )
static

Definition at line 664 of file vcdcontroltool.c.

665 {
666  WCHAR Letter;
667  HANDLE hLet;
669 
670  /* Get the select drive letter */
672  if (Letter != 0)
673  {
674  /* Open it */
675  hLet = OpenLetter(Letter);
676  if (hLet != INVALID_HANDLE_VALUE)
677  {
678  /* And ask the driver for a remount */
680 
681  CloseHandle(hLet);
682 
683  /* Refresh the list, to display the fact the image is now mounted.
684  * Make sure it's selected as it was previously selected.
685  */
687  }
688  }
689 }
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static HANDLE OpenLetter(WCHAR Letter)
static WCHAR GetSelectedDriveLetter(VOID)
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR Letter
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_STORAGE_LOAD_MEDIA
Definition: ntddstor.h:99
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by HandleCommand().

◆ RemoveDrive()

static VOID RemoveDrive ( VOID  )
static

Definition at line 723 of file vcdcontroltool.c.

724 {
725  WCHAR Letter;
726  HANDLE hLet;
728 
729  /* Get the select drive letter */
731  if (Letter != 0)
732  {
733  /* Open it */
734  hLet = OpenLetter(Letter);
735  if (hLet != INVALID_HANDLE_VALUE)
736  {
737  /* And ask the driver for a deletion */
739 
740  CloseHandle(hLet);
741 
742  /* Refresh the list, to make the device disappear */
744  }
745  }
746 }
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static HANDLE OpenLetter(WCHAR Letter)
static WCHAR GetSelectedDriveLetter(VOID)
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR Letter
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_VCDROM_DELETE_DRIVE
Definition: vcdioctl.h:3
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by HandleCommand().

◆ ResetStats()

static VOID ResetStats ( VOID  )
static

Definition at line 792 of file vcdcontroltool.c.

793 {
794  HWND hEditText;
795  static const WCHAR szText[] = { L'0', 0 };
796 
797  /* Simply set '0' in all the edittext controls we
798  * manage regarding statistics.
799  */
800  hEditText = GetDlgItem(hWnd, IDC_MAINSECTORS);
801  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
802 
803  hEditText = GetDlgItem(hWnd, IDC_MAINSIZE);
804  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
805 
806  hEditText = GetDlgItem(hWnd, IDC_MAINFREE);
807  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
808 
809  hEditText = GetDlgItem(hWnd, IDC_MAINTOTAL);
810  SendMessage(hEditText, WM_SETTEXT, 0, (LPARAM)szText);
811 }
static const WCHAR szText[]
Definition: dialog.c:139
HWND hWnd
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_MAINSECTORS
Definition: resource.h:10
#define WM_SETTEXT
Definition: winuser.h:1599
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define IDC_MAINTOTAL
Definition: resource.h:13
#define IDC_MAINSIZE
Definition: resource.h:11
#define SendMessage
Definition: winuser.h:5744
#define IDC_MAINFREE
Definition: resource.h:12

Referenced by CreateListViewColumns(), and HandleNotify().

◆ SetMountFileName()

static INT_PTR SetMountFileName ( HWND  hDlg,
LPARAM  lParam 
)
static

Definition at line 399 of file vcdcontroltool.c.

401 {
402  HWND hEditText;
403 
404  hMountWnd = hDlg;
405 
406  /* Set the file name that was passed when creating dialog */
407  hEditText = GetDlgItem(hMountWnd, IDC_MOUNTIMAGE);
408  SendMessage(hEditText, WM_SETTEXT, 0, lParam);
409 
410  /* Show our window */
411  ShowWindow(hDlg, SW_SHOW);
412 
413  return TRUE;
414 }
#define TRUE
Definition: types.h:120
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HWND hMountWnd
#define SW_SHOW
Definition: winuser.h:769
#define WM_SETTEXT
Definition: winuser.h:1599
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_MOUNTIMAGE
Definition: resource.h:22
#define SendMessage
Definition: winuser.h:5744
LPARAM lParam
Definition: combotst.c:139

Referenced by MountDialogProc().

◆ SetServiceState()

VOID SetServiceState ( BOOLEAN  Started)

Definition at line 186 of file vcdcontroltool.c.

187 {
188  HWND hControl;
189 
190  /* If started, disable start button */
192  EnableWindow(hControl, !Started);
193 
194  /* If started, enable stop button */
195  hControl = GetDlgItem(hDriverWnd, IDC_DRIVERSTOP);
196  EnableWindow(hControl, Started);
197 }
#define IDC_DRIVERSTART
Definition: resource.h:28
HWND hDriverWnd
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDC_DRIVERSTOP
Definition: resource.h:29

Referenced by DECLARE_INTERFACE_(), QueryDriverInfo(), StartDriver(), and StopDriver().

◆ StartDriver()

static VOID StartDriver ( VOID  )
static

Definition at line 273 of file vcdcontroltool.c.

274 {
275  SC_HANDLE hMgr, hSvc;
276 
277  /* Open the SC manager */
279  if (hMgr != NULL)
280  {
281  /* Open the service matching our driver */
282  hSvc = OpenService(hMgr, L"Vcdrom", SERVICE_START);
283  if (hSvc != NULL)
284  {
285  /* Start it */
286  /* FIXME: improve */
287  StartService(hSvc, 0, NULL);
288 
289  CloseServiceHandle(hSvc);
290 
291  /* Refresh the list in case there were persistent mounts */
293 
294  /* Update buttons */
296  }
297 
298  CloseServiceHandle(hMgr);
299  }
300 }
#define StartService
Definition: winsvc.h:585
#define TRUE
Definition: types.h:120
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
VOID SetServiceState(BOOLEAN Started)
#define OpenService
Definition: winsvc.h:576
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
#define OpenSCManager
Definition: winsvc.h:575
static const WCHAR L[]
Definition: oid.c:1250
#define SERVICE_START
Definition: winsvc.h:57
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by HandleDriverCommand().

◆ StopDriver()

static VOID StopDriver ( VOID  )
static

Definition at line 304 of file vcdcontroltool.c.

305 {
306  SC_HANDLE hMgr, hSvc;
308 
309  /* Open the SC manager */
311  if (hMgr != NULL)
312  {
313  /* Open the service matching our driver */
314  hSvc = OpenService(hMgr, L"Vcdrom", SERVICE_STOP);
315  if (hSvc != NULL)
316  {
317  /* Stop it */
318  /* FIXME: improve */
320 
321  CloseServiceHandle(hSvc);
322 
323  /* Refresh the list to clear it */
325 
326  /* Update buttons */
328  }
329 
330  CloseServiceHandle(hMgr);
331  }
332 }
#define SC_MANAGER_CONNECT
Definition: winsvc.h:14
VOID SetServiceState(BOOLEAN Started)
#define OpenService
Definition: winsvc.h:576
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:577
smooth NULL
Definition: ftsmooth.c:416
#define OpenSCManager
Definition: winsvc.h:575
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define SERVICE_STOP
Definition: winsvc.h:58
BOOL WINAPI ControlService(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus)
Definition: scm.c:619
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
static VOID RefreshDevicesList(WCHAR Letter)

Referenced by HandleDriverCommand(), and UsermodeMethod().

◆ wWinMain()

INT WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 950 of file vcdcontroltool.c.

954 {
955  MSG Msg;
956 
957  hInstance = hInst;
958 
959  /* Just start our main window */
962  NULL,
964  0);
965  /* And dispatch messages in case of a success */
966  if (hWnd != NULL)
967  {
968  while (GetMessageW(&Msg, NULL, 0, 0) != 0)
969  {
972  }
973  }
974 
975  return 0;
976 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HINSTANCE hInstance
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HWND hWnd
smooth NULL
Definition: ftsmooth.c:416
struct @1593 Msg[]
static INT_PTR CALLBACK MainDialogProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam)
HINSTANCE hInst
Definition: dxdiag.c:13
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define IDD_MAINWINDOW
Definition: resource.h:3

Variable Documentation

◆ hDriverWnd

HWND hDriverWnd

Definition at line 32 of file vcdcontroltool.c.

Referenced by HandleDriverCommand(), QueryDriverInfo(), and SetServiceState().

◆ hInstance

◆ hMountWnd

HWND hMountWnd

Definition at line 31 of file vcdcontroltool.c.

Referenced by HandleMountCommand(), PerformMount(), and SetMountFileName().

◆ hWnd

◆ wMountLetter

WCHAR wMountLetter

Definition at line 35 of file vcdcontroltool.c.

Referenced by MountImage(), and PerformMount().