ReactOS  0.4.13-dev-982-g9853eab
vfdlib.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SAVE_PARAM
 

Macros

#define VFD_LIBRARY_FILENAME   "vfd.dll"
 
#define VFD_NOTIFY_MESSAGE   "VfdNotifyMessage"
 
#define VFD_MSGBOX_TITLE   "Virtual Floppy Drive"
 
#define VFDEXT_DESCRIPTION   "VFD shell extension"
 
#define VFDEXT_MENU_REGKEY   "Drive\\shellex\\ContextMenuHandlers\\VFD"
 
#define VFDEXT_DND_REGKEY   "Drive\\shellex\\DragDropHandlers\\VFD"
 
#define VFDEXT_PROP_REGKEY   "Drive\\shellex\\PropertySheetHandlers\\VFD"
 
#define VFDEXT_INFO_REGKEY   "Drive\\shellex\\{00021500-0000-0000-C000-000000000046}"
 
#define IS_WINDOWS_NT()   ((GetVersion() & 0xff) < 5)
 
#define VFDTRACE(LEVEL, STRING)
 
#define INVALID_FILE_ATTRIBUTES   ((DWORD)-1)
 

Typedefs

typedef struct _SAVE_PARAM SAVE_PARAM
 
typedef struct _SAVE_PARAM PSAVE_PARAM
 
typedef const SAVE_PARAM CSAVE_PARAM
 
typedef const SAVE_PARAMPCSAVE_PARAM
 

Functions

DWORD FormatBufferFat (PUCHAR pBuffer, ULONG nSectors)
 
DWORD ExtractZipInfo (HANDLE hFile, ULONG *pSize)
 
DWORD ExtractZipImage (HANDLE hFile, PUCHAR *pBuffer, PULONG pLength)
 
DWORD GuiSaveParam (HWND hParent, PCSAVE_PARAM pParam)
 
void ShowContextMenu (HWND hDlg, HWND hCtl, LPARAM lParam)
 
void ShowHelpWindow (HWND hDlg, UINT nCtl)
 
void SetControlText (HWND hWnd, UINT nCtrl, DWORD nMsg)
 
PCSTR SystemMessage (DWORD nError)
 
PSTR ModuleMessage (DWORD nFormat,...)
 

Variables

HINSTANCE g_hDllModule
 
UINT g_cDllRefCnt
 
UINT g_nNotifyMsg
 

Macro Definition Documentation

◆ INVALID_FILE_ATTRIBUTES

#define INVALID_FILE_ATTRIBUTES   ((DWORD)-1)

Definition at line 174 of file vfdlib.h.

◆ IS_WINDOWS_NT

#define IS_WINDOWS_NT ( )    ((GetVersion() & 0xff) < 5)

Definition at line 142 of file vfdlib.h.

◆ VFD_LIBRARY_FILENAME

#define VFD_LIBRARY_FILENAME   "vfd.dll"

Definition at line 17 of file vfdlib.h.

◆ VFD_MSGBOX_TITLE

#define VFD_MSGBOX_TITLE   "Virtual Floppy Drive"

Definition at line 53 of file vfdlib.h.

◆ VFD_NOTIFY_MESSAGE

#define VFD_NOTIFY_MESSAGE   "VfdNotifyMessage"

Definition at line 48 of file vfdlib.h.

◆ VFDEXT_DESCRIPTION

#define VFDEXT_DESCRIPTION   "VFD shell extension"

Definition at line 58 of file vfdlib.h.

◆ VFDEXT_DND_REGKEY

#define VFDEXT_DND_REGKEY   "Drive\\shellex\\DragDropHandlers\\VFD"

Definition at line 60 of file vfdlib.h.

◆ VFDEXT_INFO_REGKEY

#define VFDEXT_INFO_REGKEY   "Drive\\shellex\\{00021500-0000-0000-C000-000000000046}"

Definition at line 62 of file vfdlib.h.

◆ VFDEXT_MENU_REGKEY

#define VFDEXT_MENU_REGKEY   "Drive\\shellex\\ContextMenuHandlers\\VFD"

Definition at line 59 of file vfdlib.h.

◆ VFDEXT_PROP_REGKEY

#define VFDEXT_PROP_REGKEY   "Drive\\shellex\\PropertySheetHandlers\\VFD"

Definition at line 61 of file vfdlib.h.

◆ VFDTRACE

#define VFDTRACE (   LEVEL,
  STRING 
)

Definition at line 167 of file vfdlib.h.

Typedef Documentation

◆ CSAVE_PARAM

Definition at line 101 of file vfdlib.h.

◆ PCSAVE_PARAM

Definition at line 101 of file vfdlib.h.

◆ PSAVE_PARAM

◆ SAVE_PARAM

Function Documentation

◆ ExtractZipImage()

DWORD ExtractZipImage ( HANDLE  hFile,
PUCHAR pBuffer,
PULONG  pLength 
)

Definition at line 182 of file vfdzip.c.

186 {
188  DWORD result;
189  DWORD ret;
190 
191  PZIP_HEADER zip_hdr;
192  ULONG compressed;
194  PUCHAR file_cache;
196  int zlib_ret;
197 
198  VFDTRACE(0,
199  ("[VFD] VfdExtractImz - IN\n"));
200 
201  *pBuffer = NULL;
202  *pLength = 0;
203 
204  //
205  // Read PKZIP local file header of the first file in the file
206  // -- An IMZ file actually is just a ZIP file with a different
207  // extension, which contains a single floppy image file
208  //
209  if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) != 0) {
210  ret = GetLastError();
211 
212  VFDTRACE(0,(
213  "SetFilePointer - %s", SystemMessage(ret)));;
214 
215  return ret;
216  }
217 
220 
221  ret = GetLastError();
222 
223  VFDTRACE(0,(
224  "ReadFile - %s", SystemMessage(ret)));;
225 
226  return ret;
227  }
228 
229  zip_hdr = (PZIP_HEADER)buf;
230 
231  // check local file header signature
232 
233  if (zip_hdr->header_signature != ZIP_LOCAL_SIGNATURE) {
234 
235  VFDTRACE(0,
236  ("[VFD] PKZIP header signature not found.\n"));
237 
238  return ERROR_INVALID_DATA;
239  }
240 
241  // check compression method
242 
243  if (zip_hdr->compression_method != Z_DEFLATED) {
244 
245  VFDTRACE(0,
246  ("[VFD] Bad PKZIP compression method.\n"));
247 
248  return ERROR_NOT_SUPPORTED;
249  }
250 
251  if (zip_hdr->general_flags & 0x01) {
252  // encrypted zip not supported
253 
254  VFDTRACE(0,
255  ("[VFD] PKZIP encrypted.\n"));
256 
257  return ERROR_NOT_SUPPORTED;
258  }
259 
260  // check uncompressed image size
261 
262  compressed = zip_hdr->compressed_size;
263  uncompressed = zip_hdr->uncompressed_size;
264 
265  switch (uncompressed) {
266  case VFD_SECTOR_TO_BYTE(320):
267  case VFD_SECTOR_TO_BYTE(360):
268  case VFD_SECTOR_TO_BYTE(640):
269  case VFD_SECTOR_TO_BYTE(720):
270  case VFD_SECTOR_TO_BYTE(1280):
271  case VFD_SECTOR_TO_BYTE(1440):
272  case VFD_SECTOR_TO_BYTE(1640):
273  case VFD_SECTOR_TO_BYTE(2400):
274  case VFD_SECTOR_TO_BYTE(2880):
275  case VFD_SECTOR_TO_BYTE(3360):
276  case VFD_SECTOR_TO_BYTE(3444):
277  case VFD_SECTOR_TO_BYTE(5760):
278  break;
279 
280  default:
281  VFDTRACE(0,
282  ("[VFD] Unsupported image size %lu.\n",
283  uncompressed));
284 
285  return ERROR_NOT_SUPPORTED;
286  }
287 
288  // check local file header length
289  // -- Just for simplicity, the compressed data must start in the
290  // first sector in the file: this is not a problem in most cases.
291 
293  zip_hdr->file_name_length +
295 
296  VFDTRACE(0,
297  ("[VFD] PKZIP header too long.\n"));
298 
299  return ERROR_NOT_SUPPORTED;
300  }
301 
302  // allocate memory to store uncompressed data
303 
304  file_cache = (PUCHAR)LocalAlloc(LPTR, uncompressed);
305 
306  if (!file_cache) {
307 
308  VFDTRACE(0,
309  ("[VFD] Failed to allocate file cache.\n"));
310 
311  return ERROR_OUTOFMEMORY;
312  }
313 
314  // initialize the zlib stream
315 
316  ZeroMemory(&stream, sizeof(stream));
317 
318  // set initial input data information
319 
320  stream.next_in = (PUCHAR)zip_hdr->file_name +
321  zip_hdr->file_name_length + zip_hdr->extra_field_length;
322 
323  stream.avail_in = VFD_BYTES_PER_SECTOR -
325  zip_hdr->file_name_length - zip_hdr->extra_field_length;
326 
327  // set output buffer information
328 
329  stream.next_out = file_cache;
330  stream.avail_out = uncompressed;
331 
332  zlib_ret = inflateInit2(&stream, -MAX_WBITS);
333 
334  // negative MAX_WBITS value passed to the inflateInit2() function
335  // indicates that there is no zlib header.
336  // In this case inflate() function requires an extra "dummy" byte
337  // after the compressed stream in order to complete decompression
338  // and return Z_STREAM_END. However, both compressed and uncompressed
339  // data size are already known from the pkzip header, Z_STREAM_END
340  // is not absolutely necessary to know the completion of the operation.
341 
342  if (zlib_ret != Z_OK) {
343  LocalFree(file_cache);
344 
345  VFDTRACE(0,
346  ("[VFD] inflateInit2() failed - %s.\n",
347  ZLIB_ERROR(zlib_ret)));
348 
349  return ERROR_INVALID_FUNCTION;
350  }
351 
352  for (;;) {
353 
354  // uncompress current block
355 
356  zlib_ret = inflate(&stream, Z_NO_FLUSH);
357 
358  if (zlib_ret != Z_OK) {
359  if (zlib_ret == Z_STREAM_END) {
360  ret = ERROR_SUCCESS;
361  }
362  else {
363  VFDTRACE(0,
364  ("[VFD] inflate() failed - %s.\n",
365  ZLIB_ERROR(zlib_ret)));
366 
368  }
369  break;
370  }
371 
372  if (stream.total_out >= uncompressed) {
373  // uncompress completed - no need to wait for Z_STREAM_END
374  // (inflate() would return Z_STREAM_END on the next call)
375  ret = ERROR_SUCCESS;
376  break;
377  }
378 
379  if (stream.total_in >= compressed) {
380  // somehow there is not enought compressed data
382  break;
383  }
384 
385  // read next block from file
386 
388  result <= 0) {
389 
390  ret = GetLastError();
391 
392  VFDTRACE(0,
393  ("[VFD] Read compressed data - %s.\n",
394  SystemMessage(ret)));
395  break;
396  }
397 
398  stream.avail_in = result;
399  stream.next_in = buf;
400  }
401 
402  // cleanup the zlib stream
403 
404  inflateEnd(&stream);
405 
406  // set the return information
407 
408  if (ret == ERROR_SUCCESS) {
409  *pBuffer = file_cache;
410  *pLength = uncompressed;
411  }
412  else {
413  LocalFree(file_cache);
414  }
415 
416  VFDTRACE(0,
417  ("[VFD] VfdExtractImz - OUT\n"));
418 
419  return ret;
420 }
#define ERROR_SUCCESS
Definition: deptool.c:10
USHORT extra_field_length
Definition: vfdzip.c:124
#define VFD_BYTES_PER_SECTOR
Definition: vfdio.h:40
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned char * PUCHAR
Definition: retypes.h:3
int ZEXPORT inflateEnd(z_streamp strm)
Definition: inflate.c:1277
#define VFD_SECTOR_TO_BYTE(s)
Definition: vfdio.h:45
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
static const BYTE uncompressed[]
Definition: misc.c:392
#define Z_STREAM_END
Definition: zlib.h:178
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
#define Z_OK
Definition: zlib.h:177
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
#define Z_DEFLATED
Definition: zlib.h:209
PCSTR SystemMessage(DWORD nError)
Definition: vfdlib.c:147
#define inflateInit2(strm, windowBits)
Definition: zlib.h:1800
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
#define Z_NO_FLUSH
Definition: zlib.h:168
int ZEXPORT inflate(z_streamp strm, int flush)
Definition: inflate.c:622
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define FILE_BEGIN
Definition: winbase.h:112
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define ZIP_LOCAL_SIGNATURE
Definition: vfdzip.c:85
static LPCWSTR file_name
Definition: protocol.c:146
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
USHORT file_name_length
Definition: vfdzip.c:123
unsigned int ULONG
Definition: retypes.h:1
#define LPTR
Definition: winbase.h:362
USHORT compression_method
Definition: vfdzip.c:117
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
GLuint64EXT * result
Definition: glext.h:11304
#define MAX_WBITS
Definition: zconf.h:270
struct _zip_local_file_header * PZIP_HEADER
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by VfdOpenImage().

◆ ExtractZipInfo()

DWORD ExtractZipInfo ( HANDLE  hFile,
ULONG pSize 
)

Definition at line 133 of file vfdzip.c.

136 {
137  ZIP_HEADER zip_hdr;
138  DWORD result;
139  DWORD ret;
140 
141  if (SetFilePointer(hFile, 0, NULL, FILE_BEGIN) != 0) {
142  ret = GetLastError();
143 
144  VFDTRACE(0,
145  ("SetFilePointer() - %s\n",
146  SystemMessage(ret)));
147 
148  return ret;
149  }
150 
151  if (!ReadFile(hFile, &zip_hdr, sizeof(zip_hdr), &result, NULL)) {
152  ret = GetLastError();
153 
154  VFDTRACE(0,
155  ("ReadFile() - %s\n",
156  SystemMessage(ret)));
157 
158  return ret;
159  }
160 
161  if (result != sizeof(zip_hdr) ||
164  (zip_hdr.general_flags & ZIP_FLAG_ENCRYPTED)) {
165 
166  VFDTRACE(0,
167  ("[VFD] Invalid ZIP file\n"));
168 
169  return ERROR_INVALID_DATA;
170  }
171 
172  // correct (and supported) ZIP header detected
173 
174  *pSize = zip_hdr.uncompressed_size;
175 
176  return ERROR_SUCCESS;
177 }
#define ZIP_METHOD_DEFLATED
Definition: vfdzip.c:105
#define ZIP_FLAG_ENCRYPTED
Definition: vfdzip.c:87
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
smooth NULL
Definition: ftsmooth.c:416
PCSTR SystemMessage(DWORD nError)
Definition: vfdlib.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
int ret
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define FILE_BEGIN
Definition: winbase.h:112
#define ZIP_LOCAL_SIGNATURE
Definition: vfdzip.c:85
USHORT compression_method
Definition: vfdzip.c:117
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
GLuint64EXT * result
Definition: glext.h:11304

Referenced by VfdCheckImageFile().

◆ FormatBufferFat()

DWORD FormatBufferFat ( PUCHAR  pBuffer,
ULONG  nSectors 
)

Definition at line 116 of file vfdfat.c.

119 {
120  const DOS_BPB *bpb; // BIOS Parameter Block
121  PDOS_PBR pbr; // Partition Boot Record
122  PUCHAR fat; // File Allocation Table
123  USHORT idx;
124 
125  VFDTRACE(0,
126  ("[VFD] VfdFormatImage - IN\n"));
127 
128  //
129  // Select DOS BPB parameters from media size
130  //
131  bpb = SelectDosBpb((USHORT)nSectors);
132 
133  if (!bpb) {
134  VFDTRACE(0,
135  ("[VFD] Unsupported media size %lu\n",
136  nSectors));
138  }
139 
140  //
141  // Initialize the whole area with the fill data
142  //
144  VFD_SECTOR_TO_BYTE(nSectors),
146 
147  //
148  // Make up the FAT boot record
149  //
151 
152  pbr = (PDOS_PBR)pBuffer;
153 
154  CopyMemory(pbr->jump, VFD_JUMP_CODE, sizeof(pbr->jump));
155  CopyMemory(pbr->oemid, VFD_OEM_NAME, sizeof(pbr->oemid));
156  CopyMemory(&pbr->bpb, bpb, sizeof(pbr->bpb));
157 
158  // Make up the extended BPB
159 
160  pbr->exbpb.BootSignature = 0x29;
161 
162  // use the tick count as the volume serial number
164 
166  VFD_VOLUME_LABEL, sizeof(pbr->exbpb.VolumeLabel));
167 
169  VFD_FILESYSTEM, sizeof(pbr->exbpb.FileSystemType));
170 
171  // Set the boot record signature
172 
173  *(pBuffer + VFD_BYTES_PER_SECTOR - 2) = 0x55;
174  *(pBuffer + VFD_BYTES_PER_SECTOR - 1) = 0xaa;
175 
176  //
177  // Clear FAT areas
178  //
180 
181  ZeroMemory(
182  fat,
184 
185  //
186  // Make up FAT entries for the root directory
187  //
188  for (idx = 0; idx < bpb->NumberOfFATs; idx++) {
189  *fat = bpb->MediaDescriptor;
190  *(fat + 1) = 0xff;
191  *(fat + 2) = 0xff;
192 
194  }
195 
196  //
197  // Clear root directory entries
198  //
200 
201  VFDTRACE(0,
202  ("[VFD] VfdFormatImage - OUT\n"));
203 
204  return ERROR_SUCCESS;
205 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
CHAR oemid[8]
Definition: vfdfat.c:63
USHORT SectorsPerFAT
Definition: vfdfat.c:36
#define ERROR_SUCCESS
Definition: deptool.c:10
UCHAR NumberOfFATs
Definition: vfdfat.c:32
#define VFD_BYTES_PER_SECTOR
Definition: vfdio.h:40
unsigned char * PUCHAR
Definition: retypes.h:3
DOS_BPB bpb
Definition: vfdfat.c:64
#define VFD_SECTOR_TO_BYTE(s)
Definition: vfdio.h:45
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define ZeroMemory
Definition: winbase.h:1635
#define VFD_VOLUME_LABEL
Definition: vfdfat.c:77
CHAR VolumeLabel[11]
Definition: vfdfat.c:53
#define VFD_FILESYSTEM
Definition: vfdfat.c:78
unsigned int idx
Definition: utils.c:41
PVOID pBuffer
#define FAT_DIR_ENTRY_SIZE
Definition: vfdfat.c:71
#define VFD_FORMAT_FILL_DATA
Definition: vfdio.h:51
#define CopyMemory
Definition: winbase.h:1633
#define VFD_JUMP_CODE
Definition: vfdfat.c:75
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
USHORT RootEntries
Definition: vfdfat.c:33
EXBPB exbpb
Definition: vfdfat.c:65
UCHAR BootSignature
Definition: vfdfat.c:51
#define VFD_OEM_NAME
Definition: vfdfat.c:76
CHAR FileSystemType[8]
Definition: vfdfat.c:54
ULONG VolumeSerialNumber
Definition: vfdfat.c:52
struct _DOS_PBR * PDOS_PBR
UCHAR MediaDescriptor
Definition: vfdfat.c:35
unsigned short USHORT
Definition: pedump.c:61
UCHAR jump[3]
Definition: vfdfat.c:62
USHORT ReservedSectors
Definition: vfdfat.c:31
static const DOS_BPB * SelectDosBpb(USHORT nSectors)
Definition: vfdfat.c:83
static unsigned char * fat
Definition: mkdosfs.c:542

Referenced by VfdCreateImageFile(), VfdFormatMedia(), and VfdOpenImage().

◆ GuiSaveParam()

DWORD GuiSaveParam ( HWND  hParent,
PCSAVE_PARAM  pParam 
)

Definition at line 101 of file vfdguisave.c.

104 {
105  switch (DialogBoxParam(
106  g_hDllModule,
108  hParent,
110  (LPARAM)pParam))
111  {
112  case IDOK:
113  return ERROR_SUCCESS;
114 
115  case IDCANCEL:
116  return ERROR_CANCELLED;
117 
118  default:
119  return GetLastError();
120  }
121 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDOK
Definition: winuser.h:824
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LONG_PTR LPARAM
Definition: windef.h:208
static INT CALLBACK SaveDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: vfdguisave.c:127
HINSTANCE g_hDllModule
#define DialogBoxParam
Definition: winuser.h:5665
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define IDD_SAVEDIALOG
Definition: vfdguirc.h:7
#define ERROR_CANCELLED
Definition: winerror.h:726
#define IDCANCEL
Definition: winuser.h:825

Referenced by VfdGuiClose(), and VfdGuiSave().

◆ ModuleMessage()

PSTR ModuleMessage ( DWORD  nFormat,
  ... 
)

Definition at line 124 of file vfdlib.c.

126 {
127  PSTR p;
128  va_list args;
129 
130  va_start(args, nFormat);
131 
132  if (!FormatMessage(
135  g_hDllModule, nFormat, 0, (LPTSTR)&p, 0, &args)) {
136  p = NULL;
137  }
138 
139  va_end(args);
140 
141  return p;
142 }
Definition: match.c:390
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define va_end(ap)
Definition: acmsvcex.h:90
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
HINSTANCE g_hDllModule
#define FormatMessage
Definition: winbase.h:3609
signed char * PSTR
Definition: retypes.h:7
#define va_start(ap, A)
Definition: acmsvcex.h:91
GLfloat GLfloat p
Definition: glext.h:8902
#define args
Definition: format.c:66

Referenced by AddMenuItem(), CVfdShExt::DoVfdDrop(), OnBrowse(), OnOK(), SetControlText(), ShowHelpWindow(), VfdGuiClose(), VfdGuiFormat(), VfdImageTip(), and VfdMakeFileDesc().

◆ SetControlText()

void SetControlText ( HWND  hWnd,
UINT  nCtrl,
DWORD  nMsg 
)

Definition at line 350 of file vfdguiut.c.

354 {
355  PSTR p = NULL;
356 
357  if (nMsg) {
358  p = ModuleMessage(nMsg);
359  }
360 
361  if (nCtrl) {
362  SetDlgItemText(hWnd, nCtrl, p);
363  }
364  else {
365  SetWindowText(hWnd, p);
366  }
367 
368  if (p) {
369  LocalFree(p);
370  }
371 }
PSTR ModuleMessage(DWORD nFormat,...)
Definition: vfdlib.c:124
HWND hWnd
Definition: settings.c:17
smooth NULL
Definition: ftsmooth.c:416
#define SetDlgItemText
Definition: winuser.h:5750
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
signed char * PSTR
Definition: retypes.h:7
#define SetWindowText
Definition: winuser.h:5758
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by OnImage(), OnInit(), OnMediaType(), OnPropInit(), and OnTarget().

◆ ShowContextMenu()

void ShowContextMenu ( HWND  hDlg,
HWND  hCtl,
LPARAM  lParam 
)

Definition at line 456 of file vfdguiut.c.

460 {
461  POINT pt;
462  UINT id;
463  HMENU hMenu;
464 
465  pt.x = ((int)(short)LOWORD(lParam));
466  pt.y = ((int)(short)HIWORD(lParam));
467 
468  if (pt.x == -1 || pt.y == -1) {
469  RECT rc;
470 
471  GetWindowRect(hCtl, &rc);
472  pt.x = (rc.left + rc.right) / 2;
473  pt.y = (rc.top + rc.bottom) / 2;
474 
475  id = GetDlgCtrlID(hCtl);
476  }
477  else {
478  POINT pt2 = pt;
479 
480  ScreenToClient(hDlg, &pt2);
481 
482  id = GetDlgCtrlID(
483  ChildWindowFromPoint(hDlg, pt2));
484  }
485 
486  if (id < IDC_IMAGEFILE_LABEL ||
487  id > IDC_TRUNCATE) {
488  return;
489  }
490 
491  hMenu = CreatePopupMenu();
492 
493  AppendMenu(hMenu, MF_STRING, 1, "&What's This");
494 
495  if (TrackPopupMenu(hMenu, TPM_RETURNCMD,
496  pt.x, pt.y, 0, hDlg, NULL))
497  {
498  ShowHelpWindow(hDlg, id);
499  }
500 
501  DestroyMenu(hMenu);
502 }
#define pt(x, y)
Definition: drawing.c:79
#define TPM_RETURNCMD
Definition: winuser.h:2362
#define MF_STRING
Definition: winuser.h:138
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
void ShowHelpWindow(HWND hDlg, UINT nCtl)
Definition: vfdguiut.c:507
int WINAPI GetDlgCtrlID(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
#define AppendMenu
Definition: winuser.h:5632
#define IDC_IMAGEFILE_LABEL
Definition: vfdguirc.h:13
#define IDC_TRUNCATE
Definition: vfdguirc.h:35
BOOL WINAPI DestroyMenu(_In_ HMENU)
unsigned int UINT
Definition: ndis.h:50
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
HWND WINAPI ChildWindowFromPoint(_In_ HWND, _In_ POINT)
#define HIWORD(l)
Definition: typedefs.h:246
GLenum GLuint id
Definition: glext.h:5579
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define LOWORD(l)
Definition: pedump.c:82
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by OpenDialogProc(), SaveDialogProc(), and VfdPageDlgProc().

◆ ShowHelpWindow()

void ShowHelpWindow ( HWND  hDlg,
UINT  nCtl 
)

Definition at line 507 of file vfdguiut.c.

510 {
511  UINT msg;
512  RECT rc;
513  PSTR help;
514 
515  switch (nCtl) {
516  case IDC_IMAGEFILE_LABEL:
517  case IDC_IMAGEFILE:
518  msg = MSG_HELP_IMAGEFILE;
519  break;
520  case IDC_IMAGEDESC_LABEL:
521  case IDC_IMAGEFILE_DESC:
522  msg = MSG_HELP_IMAGEDESC;
523  break;
525  case IDC_TARGETFILE:
526  msg = MSG_HELP_TARGETFILE;
527  break;
528  case IDC_DISKTYPE_LABEL:
529  case IDC_DISKTYPE:
530  case IDC_DISKTYPE_FILE:
531  case IDC_DISKTYPE_RAM:
532  msg = MSG_HELP_DISKTYPE;
533  break;
534  case IDC_MEDIATYPE_LABEL:
535  case IDC_MEDIATYPE:
536  msg = MSG_HELP_MEDIATYPE;
537  break;
538  case IDC_WRITE_PROTECTED:
539  msg = MSG_HELP_PROTECT_NOW;
540  break;
541  case IDC_OPEN_PROTECTED:
542  msg = MSG_HELP_PROTECT_OPEN;
543  break;
544  case IDC_BROWSE:
545  msg = MSG_HELP_BROWSE;
546  break;
547  case IDC_OPEN:
548  msg = MSG_HELP_OPEN;
549  break;
550  case IDC_SAVE:
551  msg = MSG_HELP_SAVE;
552  break;
553  case IDC_CLOSE:
554  msg = MSG_HELP_CLOSE;
555  break;
556  case IDC_FORMAT:
557  msg = MSG_HELP_FORMAT;
558  break;
559  case IDC_CONTROL:
560  msg = MSG_HELP_CONTROL;
561  break;
562  case IDC_OVERWRITE:
563  msg = MSG_HELP_OVERWRITE;
564  break;
565  case IDC_TRUNCATE:
566  msg = MSG_HELP_TRUNCATE;
567  break;
568  default:
569  return;
570  }
571 
572  GetWindowRect(GetDlgItem(hDlg, nCtl), &rc);
573 
575 
576  if (help) {
577  VfdToolTip(hDlg, help, rc.left, (rc.top + rc.bottom) / 2, TRUE);
578  LocalFree(help);
579  }
580 }
PSTR ModuleMessage(DWORD nFormat,...)
Definition: vfdlib.c:124
#define TRUE
Definition: types.h:120
#define IDC_DISKTYPE_LABEL
Definition: vfdguirc.h:20
#define IDC_BROWSE
Definition: resource.h:21
#define IDC_MEDIATYPE_LABEL
Definition: vfdguirc.h:24
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
#define IDC_SAVE
Definition: resource.h:16
#define IDC_IMAGEFILE
Definition: vfdguirc.h:14
#define IDC_CLOSE
Definition: resource.h:52
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_MEDIATYPE
Definition: vfdguirc.h:25
void WINAPI VfdToolTip(HWND hParent, PCSTR sText, int pos_x, int pos_y, BOOL stick)
Definition: vfdguitip.c:134
#define IDC_CONTROL
Definition: vfdguirc.h:33
#define IDC_IMAGEFILE_LABEL
Definition: vfdguirc.h:13
#define IDC_TRUNCATE
Definition: vfdguirc.h:35
#define IDC_TARGETFILE_LABEL
Definition: vfdguirc.h:18
#define IDC_OPEN_PROTECTED
Definition: vfdguirc.h:27
#define IDC_DISKTYPE_FILE
Definition: vfdguirc.h:22
#define IDC_IMAGEFILE_DESC
Definition: vfdguirc.h:16
#define IDC_DISKTYPE
Definition: vfdguirc.h:21
#define IDC_OPEN
Definition: resource.h:18
#define IDC_WRITE_PROTECTED
Definition: vfdguirc.h:26
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
signed char * PSTR
Definition: retypes.h:7
unsigned int UINT
Definition: ndis.h:50
#define IDC_TARGETFILE
Definition: vfdguirc.h:19
#define msg(x)
Definition: auth_time.c:54
#define IDC_OVERWRITE
Definition: vfdguirc.h:34
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define IDC_DISKTYPE_RAM
Definition: vfdguirc.h:23
#define IDC_IMAGEDESC_LABEL
Definition: vfdguirc.h:15
int help
Definition: sort.c:20
#define IDC_FORMAT
Definition: vfdguirc.h:32

Referenced by OpenDialogProc(), SaveDialogProc(), ShowContextMenu(), and VfdPageDlgProc().

◆ SystemMessage()

PCSTR SystemMessage ( DWORD  nError)

Definition at line 147 of file vfdlib.c.

149 {
150  static CHAR msg[256];
151 
152  if (!FormatMessage(
155  NULL, nError, 0, msg, sizeof(msg), NULL)) {
156 
157  _snprintf(msg, sizeof(msg),
158  "Unknown system error %lu (0x%08x)\n", nError, nError);
159  }
160 
161  return msg;
162 }
char CHAR
Definition: xmlstorage.h:175
#define _snprintf
Definition: xmlstorage.h:200
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define FormatMessage
Definition: winbase.h:3609
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
#define msg(x)
Definition: auth_time.c:54

Referenced by CVfdShExt::DoVfdOpen(), ExtractZipImage(), ExtractZipInfo(), CVfdShExt::InvokeCommand(), OnControl(), OnImage(), OnOK(), OnTarget(), UpdateImageInfo(), VfdBroadcastLink(), VfdCheckDriverFile(), VfdCheckImageFile(), VfdCloseImage(), VfdConfigDriver(), VfdCreateImageFile(), VfdDismountVolume(), VfdFormatMedia(), VfdGetDeviceName(), VfdGetDeviceNumber(), VfdGetDriverConfig(), VfdGetDriverState(), VfdGetDriverVersion(), VfdGetGlobalLink(), VfdGetImageInfo(), VfdGetLocalLink(), VfdGetMediaState(), VfdGuiFormat(), VfdImageTip(), VfdInstallDriver(), VfdOpenDevice(), VfdOpenImage(), VfdRemoveDriver(), VfdSaveImage(), VfdSetGlobalLink(), VfdSetLocalLink(), VfdStartDriver(), VfdStopDriver(), and VfdWriteProtect().

Variable Documentation

◆ g_cDllRefCnt

UINT g_cDllRefCnt

◆ g_hDllModule

HINSTANCE g_hDllModule

◆ g_nNotifyMsg

UINT g_nNotifyMsg