40 #define DBG_PROGNAME "INSTCBM.EXE"
43 #define DBG_IS_DEBUG_C
46 #define KERNEL32_DLL "kernel32.dll"
47 #define KERNEL32API_GetNativeSystemInfo "GetNativeSystemInfo"
48 typedef void (
WINAPI* PGetNativeSystemInfo)(LPSYSTEM_INFO);
55 #ifndef VER_SUITE_WH_SERVER
56 #define VER_SUITE_WH_SERVER 0x00008000
60 #define SM_SERVERR2 89
63 #ifndef VER_SUITE_STORAGE_SERVER
64 #define VER_SUITE_STORAGE_SERVER 0x00002000
68 SelfInitGenericOpenCBM(HMODULE OpenCbmDllHandle,
const char * DefaultPluginname, BOOL NoCopy);
84 NeededAccessRights(VOID)
93 scManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
97 CloseServiceHandle(scManager);
112 void GetProcessorArchitecture(WORD wProcessorArchitecture,
char szOS[])
114 if (wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
115 strcat(szOS, TEXT(
" IA64"));
116 else if (wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
117 strcat(szOS, TEXT(
" x64"));
118 else if (wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
119 strcat(szOS, TEXT(
" x86"));
121 strcat(szOS, TEXT(
" (?)"));
137 OSVERSIONINFOEXW osvi = {
sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
138 osversion_t retValue;
139 char szOS[1024] = {0};
140 PGetNativeSystemInfo pGetNativeSystemInfo;
141 ULONGLONG ConditionMask;
148 retValue = WINUNSUPPORTED;
150 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
151 ZeroMemory(&ovi,
sizeof(OSVERSIONINFOEX));
153 pGetNativeSystemInfo = (PGetNativeSystemInfo) GetProcAddress(GetModuleHandle(
KERNEL32_DLL), KERNEL32API_GetNativeSystemInfo);
154 if (pGetNativeSystemInfo != NULL)
155 pGetNativeSystemInfo(&si);
159 ovi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
163 if (GetVersionEx((OSVERSIONINFO*)&ovi))
165 DBGDO(
char *platform =
"";)
167 strcpy(szOS, TEXT(
"Microsoft "));
169 switch (ovi.dwPlatformId)
171 case VER_PLATFORM_WIN32s:
172 DBGDO(platform =
"WIN32s (huh?)";)
175 case VER_PLATFORM_WIN32_WINDOWS:
176 DBGDO(platform =
"Win 95/98/Me";)
179 case VER_PLATFORM_WIN32_NT:
180 DBGDO(platform =
"Win NT/2K/XP";)
182 switch (ovi.dwMajorVersion)
184 case 0:
case 1:
case 2:
186 retValue = WINUNSUPPORTED;
188 "Something is going wrong here...",
189 ovi.dwMajorVersion, ovi.dwMinorVersion));
190 fprintf(stderr,
"You're using Windows NT %u.%02u. THESE VERSIONS SHOULD NOT EXIST!\n",
191 ovi.dwMajorVersion, ovi.dwMinorVersion);
198 printf(
"You're using Windows NT 3.%02u. These versions are untested, but they might work.\n"
199 "If it works for you, I would be very happy if you contact me and tell me!\n",
208 switch (ovi.dwMinorVersion)
211 strcat(szOS, TEXT(
"Windows 2000"));
212 if (ovi.wProductType != VER_NT_WORKSTATION)
213 strcat(szOS, TEXT(
" Server"));
214 GetProcessorArchitecture(si.wProcessorArchitecture, szOS);
218 strcat(szOS, TEXT(
"Windows XP"));
219 GetProcessorArchitecture(si.wProcessorArchitecture, szOS);
223 if (GetSystemMetrics(SM_SERVERR2))
224 strcat(szOS, TEXT(
"Windows Server 2003 R2"));
225 else if (ovi.wSuiteMask & VER_SUITE_STORAGE_SERVER)
226 strcat(szOS, TEXT(
"Windows Storage Server 2003"));
227 else if (ovi.wSuiteMask & VER_SUITE_WH_SERVER)
228 strcat(szOS, TEXT(
"Windows Home Server"));
229 else if (ovi.wProductType == VER_NT_WORKSTATION && (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64))
230 strcat(szOS, TEXT(
"Windows XP Professional x64"));
232 strcat(szOS, TEXT(
"Windows Server 2003"));
234 if (ovi.wProductType != VER_NT_WORKSTATION)
235 GetProcessorArchitecture(si.wProcessorArchitecture, szOS);
245 if ((ovi.dwMinorVersion == 0) || (ovi.dwMinorVersion == 1) || (ovi.dwMinorVersion == 2))
247 if (ovi.dwMinorVersion == 0)
249 if (ovi.wProductType == VER_NT_WORKSTATION)
250 strcat(szOS, TEXT(
"Windows Vista"));
252 strcat(szOS, TEXT(
"Windows Server 2008"));
255 else if (ovi.dwMinorVersion == 1)
257 if (ovi.wProductType == VER_NT_WORKSTATION)
258 strcat(szOS, TEXT(
"Windows 7"));
260 strcat(szOS, TEXT(
"Windows Server 2008 R2"));
263 else if (ovi.dwMinorVersion == 2)
274 osvi.wProductType = VER_NT_WORKSTATION;
275 ConditionMask = VerSetConditionMask( 0, VER_PRODUCT_TYPE, VER_EQUAL );
276 isServer = !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, ConditionMask);
278 osvi.dwMajorVersion = 6;
279 osvi.dwMinorVersion = 3;
280 osvi.dwBuildNumber = 9600;
282 ConditionMask = VerSetConditionMask(
284 VerSetConditionMask(0, VER_MAJORVERSION, VER_EQUAL),
285 VER_MINORVERSION, VER_EQUAL),
286 VER_BUILDNUMBER, VER_EQUAL);
288 if (VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, ConditionMask))
291 strcat(szOS, TEXT(
"Windows 8.1"));
293 strcat(szOS, TEXT(
"Windows Server 2012 R2"));
298 if (retValue == WINUNSUPPORTED)
301 strcat(szOS, TEXT(
"Windows 8"));
303 strcat(szOS, TEXT(
"Windows Server 2012"));
310 GetProcessorArchitecture(si.wProcessorArchitecture, szOS);
325 ovi.dwMajorVersion, ovi.dwMinorVersion));
326 fprintf(stderr,
"You're using Windows NT %u.%02u.\n"
327 "I do not know it, but OpenCBM should work, anyway.\n",
328 ovi.dwMajorVersion, ovi.dwMinorVersion);
334 DBGDO(platform =
"unknown (huh?)";)
339 ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber,
340 platform, ovi.szCSDVersion));
355 printf(
"instcbm Version " OPENCBM_VERSION
", built on " __DATE__
" at " __TIME__
"\n");
368 printf(
"\nUsage: instcbm [options] pluginname [plugin-options] [pluginname [plugin-options] ...]\n"
369 "Install OpenCBM and one or more plugins on the system, or remove it.\n"
371 "pluginname is the name of the plugin to install. Any subsequent option is\n"
372 "passed to the plugin, and it will have a different meaning! See the\n"
373 "description of each plugin for details.\n"
376 " -h, --help display this help and exit\n"
377 " -V, --version display version information about OpenCBM\n"
378 " -r, --remove remove (uninstall) OpenCBM or a plugin\n"
379 " -u, --update update parameters if driver is already installed.\n"
380 " -c, --check only check if the installation is ok\n"
381 " -n, --nocopy do not copy the driver files into the system directory\n"
390 fprintf(stderr,
"Try `%s' --help for more information.\n", s);
425 processNumber(
const PCHAR Argument, PCHAR *NextChar, PBOOL ParameterGiven, PULONG ParameterValue)
471 *ParameterValue = strtoul(p, &p, base);
475 error = ((*p != 0) && (*p !=
',')) ? TRUE : FALSE;
479 error = *p != 0 ? TRUE : FALSE;
484 if (NextChar != NULL)
486 *NextChar = p + ((*p) ? 1 : 0);
489 if (ParameterGiven != NULL)
491 *ParameterGiven = TRUE;
528 if (Parameter->ExecuteParameterGiven)
531 printf(
"Colliding parameters were given, aborting!");
532 hint(ExecutableName);
534 Parameter->ExecuteParameterGiven = TRUE;
564 struct option longopts[] =
566 {
"help", no_argument, NULL,
'h' },
567 {
"version", no_argument, NULL,
'V' },
568 {
"remove", no_argument, NULL,
'r' },
569 {
"purge", no_argument, NULL,
'p' },
570 {
"update", no_argument, NULL,
'u' },
571 {
"check", no_argument, NULL,
'c' },
572 {
"nocopy", no_argument, NULL,
'n' },
573 {
"adapter", required_argument, NULL,
'@' },
575 {
"debugflags", required_argument, NULL,
'D' },
576 {
"buffer", no_argument, NULL,
'B' },
581 const char shortopts[] =
"-hVrpucn@:"
588 BOOL quitGlobalProcessing = FALSE;
594 Parameter->Install = TRUE;
599 while ( ! quitGlobalProcessing && (option = getopt_long(Argc, Argv, shortopts, longopts, NULL)) != -1)
605 Parameter->NoExecute = TRUE;
606 Parameter->Install = FALSE;
611 Parameter->NoExecute = TRUE;
612 Parameter->Install = FALSE;
616 error = enforceOnlyOneExecutingCommand(Parameter, Argv[0]) || error;
617 Parameter->Remove = TRUE;
618 Parameter->Install = FALSE;
622 if (Parameter->Remove) {
623 Parameter->Purge = TRUE;
627 printf(
"--purge only allowed after --remove, aborting!");
633 Parameter->Update = TRUE;
634 Parameter->Install = FALSE;
638 Parameter->CheckInstall = TRUE;
639 Parameter->Install = FALSE;
643 Parameter->NoCopy = TRUE;
647 if (Parameter->DefaultAdapter == NULL) {
651 printf(
"--adapter/-@ given more than once.");
661 error = processNumber(optarg, &next, &Parameter->DebugFlagsDriverWereGiven,
662 &Parameter->DebugFlagsDriver);
664 if (!error && next && *next)
666 error = processNumber(next, &next, &Parameter->DebugFlagsDllWereGiven,
667 &Parameter->DebugFlagsDll);
670 if (!error && next && *next)
672 error = processNumber(next, NULL, &Parameter->DebugFlagsInstallWereGiven,
673 &Parameter->DebugFlagsInstall);
675 if (!error && Parameter->DebugFlagsInstallWereGiven)
677 DbgFlags = Parameter->DebugFlagsInstall;
681 error ?
"TRUE" :
"FALSE",
682 Parameter->DebugFlagsDriver, Parameter->DebugFlagsDriverWereGiven ?
"TRUE" :
"FALSE",
683 Parameter->DebugFlagsDll, Parameter->DebugFlagsDllWereGiven ?
"TRUE" :
"FALSE",
684 Parameter->DebugFlagsInstall, Parameter->DebugFlagsInstallWereGiven ?
"TRUE" :
"FALSE"));
689 Parameter->OutputDebuggingBuffer = TRUE;
690 Parameter->NoExecute = TRUE;
691 Parameter->Install = FALSE;
697 quitGlobalProcessing = TRUE;
709 while (! error && Argv[optind++]) {
713 if (Parameter->PluginList == NULL && ! error) {
715 Parameter->NoExplicitPluginGiven = TRUE;
717 if (Parameter->Install) {
718 printf(
"ERROR: No plugin given.\n\n"
719 "Since version 0.5.0 of OpenCBM, instcbm supports different plugins\n"
720 "that correspond to different cables, connected via parallel port\n"
722 "As instcbm cannot guess which cable are available, you have to\n"
723 "specifiy which plugin (='cable support software') you want to use.\n"
725 "You have to specify it on the command-line.\n\n"
726 "Available options are:\n"
727 "\txa1541\tfor XA1541, XM1541, XAP1541 and XMP1541 cables (parallel port).\n"
728 "\txu1541\tfor XU1541 cable (cheap USB solution, with restrictions)\n"
729 "\txum1541\tfor XUM1541 cable (include ZoomFloppy).\n"
731 "If you are upgrading from OpenCBM 0.4.2 or earlier, with the same cable\n"
732 "as before, you most probably want to use the command line:\n\tinstcbm xa1541\n"
734 "If you have the ZoomFloppy, you most probably want the command line\n"
735 "\tinstcbm xum1541\n"
745 if (!error && Parameter->DefaultAdapter && ! Parameter->Update && ! Parameter->Install ) {
746 printf(
"--adapter/-@ only allowed when installing or updating, aborting!");
751 if (!error && !Parameter->PluginList) {
752 printf(
"No plugins detected, have to abort...\n");
756 if (!error && Parameter->Install && ! Parameter->DefaultAdapter && Parameter->PluginList->Name) {
790 CopyFileToNewPath(
const char *SourcePath,
const char *DestPath,
const char *Filename)
792 char *sourceFile = NULL;
793 char *destFile = NULL;
801 if (sourceFile && destFile)
805 printf(
"Copying '%s' to '%s'", sourceFile, destFile);
806 if (!CopyFile(sourceFile, destFile, FALSE))
810 printf(
" FAILED!\n");
820 fprintf(stderr,
"Error allocating memory buffers for copying '%s'.\n", Filename);
845 GetWorkingDirectory(
void)
847 char * tmpPathString;
848 unsigned int stringLength;
859 stringLength = GetCurrentDirectory(0, NULL);
867 if (tmpPathString == NULL)
876 if (GetCurrentDirectory(stringLength, tmpPathString) == 0)
879 printf(
"Could not determine the current working directory!\n");
883 DBG_ASSERT(strlen(tmpPathString) < stringLength);
885 strcat(tmpPathString,
"\\");
894 tmpPathString = NULL;
911 GetWindowsSystemDirectory(
void)
913 #ifdef USE_FAKE_WIN_DIRECTORY_AS_COPY_TARGET
916 char * tmpPathString;
917 unsigned int stringLength;
928 stringLength = GetSystemDirectory(NULL, 0);
936 if (tmpPathString == NULL)
945 if (GetSystemDirectory(tmpPathString, stringLength) == 0)
948 printf(
"Could not determine the current windows system directory!\n");
952 DBG_ASSERT(strlen(tmpPathString) < stringLength);
954 strcat(tmpPathString,
"\\");
963 tmpPathString = NULL;
981 GetWindowsDriverDirectory(
void)
983 char * tmpPathString = NULL;
984 char * driverPathString = NULL;
989 tmpPathString = GetWindowsSystemDirectory();
990 if (tmpPathString == NULL) {
1018 HMODULE openCbmDllHandle = NULL;
1024 if (openCbmDllHandle == NULL) {
1026 fprintf(stderr,
"Could not open the OpenCBM DLL.");
1030 error = SelfInitGenericOpenCBM(openCbmDllHandle,
1031 Parameter->DefaultAdapter,
1039 if (openCbmDllHandle) {
1040 FreeLibrary(openCbmDllHandle);
1047 static opencbm_plugin_install_neededfiles_t NeededFilesGeneric[] =
1049 { SYSTEM_DIR,
"opencbm.dll" },
1051 { SYSTEM_DIR,
"opencbmvdd.dll" },
1052 #endif // #ifdef _X86_
1082 GetPathForNeededFile(opencbm_plugin_install_neededfiles_t * NeededFile,
const char * PluginName,
const char * WorkingDirectory,
const char * SystemDirectory,
const char * DriverDirectory)
1084 char * filepath = NULL;
1091 if (NeededFile->FileLocationString != NULL) {
1096 switch (NeededFile->FileLocation)
1098 case LOCAL_PLUGIN_DIR:
1099 if (NULL != PluginName) {
1117 DBG_ASSERT((
"wrong enum in neededfiles array!", 0));
1121 if (filepath == NULL)
1123 DBG_ASSERT((
"internal error on building file path!", 0));
1160 GetFilenameForNeededFile(opencbm_plugin_install_neededfiles_t * NeededFile,
const char * PluginName,
const char * WorkingDirectory,
const char * SystemDirectory,
const char * DriverDirectory)
1162 char * filename = NULL;
1167 path = GetPathForNeededFile(NeededFile, PluginName, WorkingDirectory, SystemDirectory, DriverDirectory);
1175 if (filename == NULL)
1177 DBG_ASSERT((
"internal error on building file name!", 0));
1194 AreNeededFilesPresent(opencbm_plugin_install_neededfiles_t NeededFiles[])
1196 BOOL isPresent = FALSE;
1198 char * workingDirectory = NULL;
1199 char * systemDirectory = NULL;
1200 char * driverDirectory = NULL;
1202 opencbm_plugin_install_neededfiles_t * neededfiles;
1204 DWORD fileattributes;
1209 workingDirectory = GetWorkingDirectory();
1210 systemDirectory = GetWindowsSystemDirectory();
1211 driverDirectory = GetWindowsDriverDirectory();
1213 if ( ! workingDirectory || ! systemDirectory || ! driverDirectory)
1216 printf(
"Working directory = '%s',\n"
1217 "system directory = '%s',\n"
1218 "driver directory = '%s'.\n",
1219 workingDirectory, systemDirectory, driverDirectory);
1227 for (neededfiles = NeededFiles; neededfiles->FileLocation != LIST_END; neededfiles++)
1231 filename = GetFilenameForNeededFile(neededfiles, NULL, workingDirectory, systemDirectory, driverDirectory);
1233 fileattributes = GetFileAttributes(filename);
1240 if (fileattributes == 0xFFFFFFFF)
1264 IsPresentGenericOpenCBM(
void)
1304 HandleNeededFiles(opencbm_plugin_install_neededfiles_t NeededFiles[],
const char ** PathToInstalledPluginFile,
HandleNeededFilesCallback_t * Callback)
1306 char * workingDirectory = NULL;
1307 char * systemDirectory = NULL;
1308 char * driverDirectory = NULL;
1310 char * destinationPath = NULL;
1314 opencbm_plugin_install_neededfiles_t * neededfiles;
1318 if (PathToInstalledPluginFile != NULL)
1320 *PathToInstalledPluginFile = NULL;
1325 workingDirectory = GetWorkingDirectory();
1326 systemDirectory = GetWindowsSystemDirectory();
1327 driverDirectory = GetWindowsDriverDirectory();
1329 for (neededfiles = NeededFiles; (neededfiles->FileLocation != LIST_END) && ! error; neededfiles++)
1331 destinationPath = GetPathForNeededFile(neededfiles, NULL, workingDirectory, systemDirectory, driverDirectory);
1333 error = Callback(destinationPath, neededfiles->Filename);
1335 if (PathToInstalledPluginFile && *PathToInstalledPluginFile == NULL) {
1336 *PathToInstalledPluginFile =
cbmlibmisc_strcat(destinationPath, neededfiles->Filename);
1341 destinationPath = NULL;
1372 CopyNeededFilesCallback(
const char * DestinationPath,
const char * File)
1396 CopyNeededFiles(opencbm_plugin_install_neededfiles_t NeededFiles[],
const char ** PathToInstalledPluginFile)
1400 FUNC_LEAVE_BOOL(HandleNeededFiles(NeededFiles, PathToInstalledPluginFile, CopyNeededFilesCallback));
1410 LoadOpenCBMDll(BOOL AtSystemDirectory)
1412 char * systemDirectory = NULL;
1413 char * dllPath = NULL;
1419 if (AtSystemDirectory) {
1424 systemDirectory = GetWindowsSystemDirectory();
1434 if ( systemDirectory == NULL) {
1439 if (dllPath == NULL) {
1445 dll = LoadLibrary(dllPath);
1451 if (dllPath != NULL) {
1455 if (systemDirectory != NULL) {
1467 LoadDestinationOpenCBMDll(
void)
1497 SelfInitGenericOpenCBM(HMODULE OpenCbmDllHandle,
const char * DefaultPluginname, BOOL NoCopy)
1501 unsigned int DefaultLocation;
1505 DefaultLocation = NoCopy ? INDEX_DEFAULT_FILENAME_LOCAL : INDEX_DEFAULT_FILENAME_WINDIR;
1510 opencbm_plugin_install_generic = (
void *) GetProcAddress(OpenCbmDllHandle,
1511 "opencbm_plugin_install_generic");
1513 if (opencbm_plugin_install_generic == NULL) {
1515 "opencbm.dll::opencbm_plugin_install_generic()."));
1516 fprintf(stderr,
"Could not get address of "
1517 "opencbm.dll::opencbm_plugin_install_generic().\n");
1545 error = CopyNeededFiles(NeededFilesGeneric, NULL);
1550 error = SelfInitGenericOpenCBM(OpenCbmDllHandle, NULL, Parameter->NoCopy);
1569 LoadPluginDll(
const char * PluginName,
const char * PathToPluginDllFile)
1571 HMODULE pluginDll = NULL;
1582 oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
1584 pluginDll = LoadLibrary(PathToPluginDllFile);
1586 SetErrorMode(oldErrorMode);
1588 if (pluginDll == NULL) {
1589 fprintf(stderr,
"Error loading plugin '%s' at '%s'.\n", PluginName, PathToPluginDllFile);
1590 DBG_ERROR((
DBG_PREFIX "Error loading plugin '%s' at '%s'.", PluginName, PathToPluginDllFile));
1601 FreePluginDll(HMODULE PluginDll)
1605 FreeLibrary(PluginDll);
1619 GetPluginFunctionAddress(HMODULE PluginDll,
const char * FunctionName)
1625 pointer = GetProcAddress(PluginDll, FunctionName);
1645 PluginExecuteFunction(
const char * PluginName,
1646 const char * PathToPluginDllFile,
1647 const char * FunctionName,
1648 BOOL (*Callback)(
const char * PluginName,
void * FunctionPointer,
void * Context),
1652 HMODULE pluginDll = NULL;
1657 void * functionPointer = NULL;
1659 pluginDll = LoadPluginDll(PluginName, PathToPluginDllFile);
1661 if (pluginDll == NULL) {
1665 functionPointer = GetPluginFunctionAddress(pluginDll, FunctionName);
1667 error = Callback(PluginName, functionPointer, Context);
1672 FreePluginDll(pluginDll);
1689 perform_opencbm_plugin_install_do_install(
const char * PluginName,
void * FunctionPointer,
void * Context)
1698 if (opencbm_plugin_install_do_install == NULL) {
1706 fprintf(stderr,
"Installation of plugin '%s' failed!\n", PluginName);
1739 const char * pathToInstalledPluginFile = NULL;
1745 printf(
"++++ Install: '%s' with filename '%s'.\n", PluginInstallParameter->Name, PluginInstallParameter->FileName);
1748 char * workingDirectory = GetWorkingDirectory();
1750 pathToInstalledPluginFile =
cbmlibmisc_strcat(workingDirectory, PluginInstallParameter->FileName);
1754 if ( CopyNeededFiles(PluginInstallParameter->NeededFiles, &pathToInstalledPluginFile) ) {
1759 if ( pathToInstalledPluginFile == NULL ) {
1763 opencbm_plugin_install_plugin_data = (
void *) GetProcAddress(context->
OpenCbmDllHandle,
1764 "opencbm_plugin_install_plugin_data");
1766 if (opencbm_plugin_install_plugin_data == NULL) {
1768 "opencbm.dll::opencbm_plugin_install_plugin_data()"));
1769 fprintf(stderr,
"Could not get address of "
1770 "opencbm.dll::opencbm_plugin_install_plugin_data()");
1784 error = PluginExecuteFunction(PluginInstallParameter->Name,
1785 pathToInstalledPluginFile,
1786 "opencbm_plugin_install_do_install",
1787 perform_opencbm_plugin_install_do_install,
1788 PluginInstallParameter);
1815 HMODULE openCbmDllHandle = NULL;
1823 memset(&callbackContext, 0,
sizeof(callbackContext));
1826 if (openCbmDllHandle == NULL) {
1828 fprintf(stderr,
"Could not open the OpenCBM DLL.");
1832 if ( Parameter->NoCopy ) {
1833 error = SelfInitGenericOpenCBM(openCbmDllHandle, NULL, Parameter->NoCopy);
1835 else if ( ! IsPresentGenericOpenCBM() )
1839 if ( CopyGenericOpenCBM(openCbmDllHandle, Parameter) ) {
1847 error =
PluginForAll(Parameter, InstallPluginCallback, &callbackContext);
1849 error = UpdateOpenCBM(Parameter) || error;
1853 if (openCbmDllHandle) {
1854 FreeLibrary(openCbmDllHandle);
1873 RemoveOpenCbmFilesCallback(
const char * DestinationPath,
const char * Filename)
1875 char * fileToDelete = NULL;
1888 fprintf(stderr,
"Trying to delete '%s'.\n", fileToDelete);
1889 DeleteFile(fileToDelete);
1907 RemoveOpenCbmFiles(opencbm_plugin_install_neededfiles_t NeededFiles[])
1911 FUNC_LEAVE_BOOL(HandleNeededFiles(NeededFiles, NULL, RemoveOpenCbmFilesCallback));
1925 perform_opencbm_plugin_install_do_uninstall(
const char * PluginName,
void * FunctionPointer,
void * Context)
1934 if (opencbm_plugin_install_do_uninstall == NULL) {
1942 fprintf(stderr,
"Uninstallation of plugin '%s' failed!\n", PluginName);
1969 error = PluginExecuteFunction(PluginInstallParameter->Name,
1970 PluginInstallParameter->FileName,
1971 "opencbm_plugin_install_do_uninstall",
1972 perform_opencbm_plugin_install_do_uninstall,
1973 PluginInstallParameter);
1979 error = RemoveOpenCbmFiles(PluginInstallParameter->NeededFiles);
1997 RemoveGenericOpenCBM(HMODULE OpenCbmDllHandle)
2004 error = RemoveOpenCbmFiles(NeededFilesGeneric);
2029 HMODULE openCbmDllHandle = NULL;
2045 memset(&callbackContext, 0,
sizeof(callbackContext));
2048 if (openCbmDllHandle == NULL) {
2050 fprintf(stderr,
"Could not open the OpenCBM DLL.");
2054 if ( ! IsPresentGenericOpenCBM() ) {
2056 fprintf(stderr,
"trying to remove OpenCBM, but it is not installed!\n");
2066 error =
PluginForAll(Parameter, RemovePluginCallback, &callbackContext);
2074 if ( RemoveGenericOpenCBM(openCbmDllHandle) ) {
2082 if (openCbmDllHandle) {
2083 FreeLibrary(openCbmDllHandle);
2143 memset(¶meter, 0,
sizeof(parameter));
2144 parameter.PluginList = NULL;
2147 parameter.OsVersion = GetOsVersion();
2149 if (parameter.OsVersion == WINUNSUPPORTED) {
2151 printf(
"Sorry, this version of Windows is not supported!\n");
2156 if (processargs(Argc, Argv, ¶meter)) {
2158 fprintf(stderr,
"Error processing command line arguments.\n");
2163 if (parameter.NoExecute) {
2167 if (parameter.AdminNeeded && !NeededAccessRights()) {
2169 "Please try installing only as administrator."));
2170 printf(
"You do not have necessary privileges.\n"
2171 "Please try installing only as administrator.\n");
2181 if (parameter.CheckInstall) {
2182 retValue = CheckOpenCBM(¶meter);
2184 else if (parameter.Remove) {
2187 retValue = RemoveOpenCBM(¶meter);
2189 else if (parameter.Update) {
2192 retValue = UpdateOpenCBM(¶meter);
2194 else if (parameter.Install) {
2197 retValue = InstallOpenCBM(¶meter);
2200 fprintf(stderr,
"Internal problem: Which command has been given to instcbm?\n");
2207 if (parameter.OutputDebuggingBuffer)
struct cbm_install_parameter_plugin_s cbm_install_parameter_plugin_t
#define FUNC_LEAVE_INT(_xxx)
Header for installation routines.
char * cbmlibmisc_strdup(const char *const OldString)
Duplicate a given string.
#define FUNC_LEAVE_HMODULE(_xxx)
Define makros for debugging purposes.
BOOL PluginForAll(cbm_install_parameter_t *InstallParameter, PluginForAll_Callback_t *Callback, void *Context)
Execute a callback function for all plugins in the plugin list.
void cbmlibmisc_strfree(const char *String)
Free a string.
HMODULE LoadLocalOpenCBMDll(void)
@@@
#define FUNC_LEAVE_TYPE(_xxx, _TYPE, _FORMAT)
BOOL CBMAPIDECL opencbm_plugin_install_do_uninstall(void *Context)
@@@
Define the IOCTL codes for the opencbm driver.
struct cbm_install_parameter_s cbm_install_parameter_t
#define FUNC_LEAVE_PTR(_xxx, _TYPE)
BOOL HandleNeededFilesCallback_t(const char *DestinationPath, const char *File)
Type of the callback function for HandleNeededFiles()
char * cbmlibmisc_stralloc(unsigned int Length)
allocate memory for a string of a given size
BOOL ProcessPluginCommandlineAndAddIt(cbm_install_parameter_t *Parameter, const char *const Plugin, int Argc, char *const Argv[])
Process the command-line parameters for a plugin and add that plugin to the plugin list...
struct InstallPluginCallback_context_s InstallPluginCallback_context_t
@@@
BOOL get_all_installed_plugins(cbm_install_parameter_t *InstallParameter)
Get all the installed plugins.
#define FUNC_LEAVE_BOOL(_xxx)
char * cbmlibmisc_strcat(const char *First, const char *Second)
Concatenate two strings.
BOOL CBMAPIDECL opencbm_plugin_install_generic(const char *DefaultPluginname, unsigned int DefaultLocation)
@@@
#define DBG_SUCCESS(_xxx)
cbm_install_parameter_t * Parameter
Defining OpenCBM version.
#define FUNC_LEAVE_STRING(_xxx)
BOOL CBMAPIDECL opencbm_plugin_install_plugin_data(const char *Pluginname, const char *Filepath, const CbmPluginInstallProcessCommandlineData_t *CommandlineData)
@@@
Define makros and functions which account for differences between the different architectures.
BOOL CBMAPIDECL opencbm_plugin_install_do_install(void *Context)
@@@
Internal API for opencbm installation.
Some functions for string handling.
void PluginListFree(cbm_install_parameter_t *InstallParameter)
Free all the memory occupied by plugin management.
int __cdecl main(int Argc, char **Argv)
Main function.