ReactOS  0.4.13-dev-982-g9853eab
vfdlib.c File Reference
#include <windows.h>
#include <stdio.h>
#include "vfdtypes.h"
#include "vfdapi.h"
#include "vfdlib.h"
Include dependency graph for vfdlib.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 
BOOL WINAPI VfdIsValidPlatform ()
 
UINT WINAPI VfdGetNotifyMessage ()
 
PSTR ModuleMessage (DWORD nFormat,...)
 
PCSTR SystemMessage (DWORD nError)
 

Variables

HINSTANCE g_hDllModule = NULL
 
UINT g_cDllRefCnt = 0
 
UINT g_nNotifyMsg = 0
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 15 of file vfdlib.c.

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hInstance,
DWORD  dwReason,
LPVOID  lpReserved 
)

Definition at line 44 of file vfdlib.c.

48 {
49 #ifdef _DEBUG
50  char name[MAX_PATH];
51  HMODULE hMod;
52  DWORD size;
53 
54  if (EnumProcessModules(GetCurrentProcess(), &hMod, sizeof(hMod), &size)) {
55  GetModuleBaseName(GetCurrentProcess(), hMod, name, sizeof(name));
56  }
57  else {
58  strcpy(name, "unknown");
59  }
60 #endif // _DEBUG
61 
62  UNREFERENCED_PARAMETER(lpReserved);
63 
65  VFDTRACE(0, ("DLL_PROCESS_ATTACH - %s\n", name));
66 
67  // this DLL doesn't need DLL_THREAD_ATTACH and DLL_THREAD_DETACH
69 
70  // store the DLL instance handle
72 
73  // register the VFD notification message
75 
76  }
77  else if (dwReason == DLL_PROCESS_DETACH) {
78  VFDTRACE(0, ("DLL_PROCESS_DETACH - %s\n", name));
79  }
80 
81  return TRUE;
82 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
DWORD dwReason
Definition: misc.cpp:154
HINSTANCE hInstance
Definition: charmap.c:20
#define VFD_NOTIFY_MESSAGE
Definition: vfdlib.h:48
#define DLL_PROCESS_DETACH
Definition: compat.h:119
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI EnumProcessModules(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded)
Definition: psapi.c:542
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#define MAX_PATH
Definition: compat.h:26
HINSTANCE g_hDllModule
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
#define RegisterWindowMessage
Definition: winuser.h:5741
#define GetModuleBaseName
Definition: psapi.h:132
UINT g_nNotifyMsg
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

◆ 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().

◆ 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().

◆ VfdGetNotifyMessage()

UINT WINAPI VfdGetNotifyMessage ( )

Definition at line 115 of file vfdlib.c.

116 {
117  return g_nNotifyMsg;
118 }
UINT g_nNotifyMsg

◆ VfdIsValidPlatform()

BOOL WINAPI VfdIsValidPlatform ( )

Definition at line 87 of file vfdlib.c.

88 {
89  BOOL (WINAPI *pfnIsWow64Process)(HANDLE, PBOOL);
90  BOOL wow64;
91 
92  if (GetVersion() & 0x80000000) {
93  return FALSE; // doesn't work on Win9x
94  }
95 
96  pfnIsWow64Process = (BOOL (WINAPI *)(HANDLE, PBOOL))
97  GetProcAddress(GetModuleHandle("kernel32.dll"), "IsWow64Process");
98 
99  if (pfnIsWow64Process == NULL) {
100  return TRUE; // NT4 or 2000 -- assured to be 32 bit
101  }
102 
103  wow64 = FALSE;
104 
105  if (!pfnIsWow64Process(GetCurrentProcess(), &wow64)) {
106  return FALSE;
107  }
108 
109  return !wow64;
110 }
#define TRUE
Definition: types.h:120
#define BOOL
Definition: nt_native.h:43
DWORD WINAPI GetVersion(VOID)
Definition: version.c:22
static BOOL wow64
Definition: psapi_main.c:49
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL * PBOOL
Definition: windef.h:161
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1138
#define WINAPI
Definition: msvc.h:8
PVOID HANDLE
Definition: typedefs.h:71
#define GetModuleHandle
Definition: winbase.h:3641
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by main().

Variable Documentation

◆ g_cDllRefCnt

◆ g_hDllModule

◆ g_nNotifyMsg

UINT g_nNotifyMsg = 0