extern bool DoMainLoop( dlg_state * state ) /*****************************************/ { const char *diag_list[MAX_DIAGS + 1]; const char *diags; const char *dstdir; int dstlen; bool got_disk_sizes = FALSE; int i; char newdst[_MAX_PATH]; char *next; bool ret = FALSE; SetupTitle(); // display initial dialog diags = GetVariableStrVal( "DialogOrder" ); if( stricmp( diags, "" ) == 0 ) { diags = "Welcome"; } i = 0; for( ;; ) { diag_list[i] = diags; next = strchr( diags, ',' ); if( next == NULL ) break; *next = '\0'; diags = next + 1; ++i; } diag_list[i + 1] = NULL; /* process installation dialogs */ i = 0; for( ;; ) { if( i < 0 ) break; if( diag_list[i] == NULL ) { if( GetVariableIntVal( "DoCopyFiles" ) == 1 ) { if( !CheckDrive( TRUE ) ) { i = 0; } } if( GetVariableByName( "SetupPath" ) != NO_VAR ) { ret = TRUE; break; } if( diag_list[i] == NULL ) { StatusShow( TRUE ); ret = SetupOperations(); StatusShow( FALSE ); if( ret ) DoDialog( "Finished" ); break; } } if( stricmp( diag_list[i], "GetDiskSizesHere" ) == 0 ) { if( *state == DLG_NEXT ) { dstdir = GetVariableStrVal( "DstDir" ); dstlen = strlen( dstdir ); if( dstlen != 0 && (dstdir[dstlen - 1] == '\\' || dstdir[dstlen - 1] == '/') ) { strcpy( newdst, dstdir ); if( dstlen == 3 && dstdir[1] == ':' ) { newdst[dstlen] = '.'; newdst[dstlen + 1] = '\0'; } else { newdst[dstlen - 1] = '\0'; } SetVariableByName( "DstDir", newdst ); } SimSetNeedGetDiskSizes(); ResetDiskInfo(); got_disk_sizes = TRUE; } } else { *state = DoDialog( diag_list[i] ); GUIWndDirty( NULL ); StatusCancelled(); } if( *state == DLG_CAN ) { if( MsgBox( NULL, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) { CancelSetup = TRUE; break; } } else if( *state == DLG_DONE ) { CancelSetup = TRUE; break; } if( got_disk_sizes ) { if( !CheckDrive( FALSE ) ) { break; } } if( *state == DLG_SAME ) { /* nothing */ } else if( *state == DLG_NEXT || *state == DLG_SKIP ) { if( SkipDialogs ) { ++i; } else { for( ;; ) { ++i; if( diag_list[i] == NULL ) break; if( CheckDialog( diag_list[i] ) ) break; } } } else if( *state == DLG_PREV ) { for( ;; ) { --i; if( i < 0 ) break; if( CheckDialog( diag_list[i] ) ) break; } } else if( *state == DLG_START ) { i = 0; } } /* for */ return( ret ); }
static bool UseIShellLink( bool uninstall ) /*****************************************/ { WORD dir_index, icon_number; int i, num_icons, num_groups; int num_installed, num_total_install; DWORD temp; char prog_name[_MAX_PATH], prog_desc[_MAX_PATH]; char icon_name[_MAX_PATH], working_dir[_MAX_PATH]; char group[_MAX_PATH], prog_arg[_MAX_PATH], tmp[_MAX_PATH]; BOOL rc; if( uninstall ) { num_groups = SimGetNumPMGroups(); for( i = 0; i < num_groups; i++ ) { SimGetPMGroupName( i, group ); if( *group != '\0' ) { // Delete the PM Group box remove_group( group ); } } return( TRUE ); } SimGetPMGroup( group ); if( group[0] == '\0' ) { return( TRUE ); } CoInitialize( NULL ); // Create the PM Group box. if( !create_group( group ) ) { CoUninitialize(); return( FALSE ); } // Add the individual PM files to the Group box. num_icons = SimGetNumPMProgs(); StatusLines( STAT_CREATEPROGRAMFOLDER, "" ); num_total_install = 0; for( i = 0; i < num_icons; i++ ) { if( SimCheckPMCondition( i ) ) { ++num_total_install; } } num_installed = 0; StatusAmount( 0, num_total_install ); for( i = 0; i < num_icons; i++ ) { if( !SimCheckPMCondition( i ) ) { continue; } SimGetPMDesc( i, prog_desc ); dir_index = SimGetPMProgName( i, prog_name ); if( strcmp( prog_name, "GROUP" ) == 0 ) { /* creating a new group */ strcpy( group, prog_desc ); if( !create_group( group ) ) { CoUninitialize(); return( FALSE ); } } else { // Adding item to group if( dir_index == SIM_INIT_ERROR ) { working_dir[ 0 ] = '\0'; ReplaceVars( tmp, prog_name ); strcpy( prog_name, tmp ); } else { SimDirNoSlash( dir_index, working_dir ); } // Get parameters SimGetPMParms( i, tmp ); ReplaceVars( prog_arg, tmp ); // Append the subdir where the icon file is and the icon file's name. temp = SimGetPMIconInfo( i, icon_name ); dir_index = LOWORD( temp ); icon_number = HIWORD( temp ); if( icon_number == SIM_INIT_ERROR ) icon_number = 0; if( dir_index != SIM_INIT_ERROR ) { SimGetDir( dir_index, tmp ); strcat( tmp, icon_name ); strcpy( icon_name, tmp ); } // Add the new file to the already created PM Group. rc = create_icon( group, prog_name, prog_desc, prog_arg, working_dir, icon_name, icon_number ); if( rc == FALSE ) { CoUninitialize(); return( FALSE ); } } ++num_installed; StatusAmount( num_installed, num_total_install ); if( StatusCancelled() ) break; } StatusAmount( num_total_install, num_total_install ); CoUninitialize(); return( TRUE ); }
static bool UseDDE( bool uninstall ) /**********************************/ { WORD dir_index, icon_number, version; int i, num_icons, num_groups; int num_installed, num_total_install; int len; DWORD temp; bool ok; char prog_name[_MAX_PATH], prog_desc[_MAX_PATH]; char icon_name[_MAX_PATH], working_dir[_MAX_PATH]; char buff[_MAX_PATH], t1[_MAX_PATH], t2[_MAX_PATH]; HWND hwnd_pm; DWORD ddeinst = 0; // Important that this is initially 0 UINT rc; HSZ happ, htopic; HCONV hconv; char progman[] = "PROGMAN"; SimGetPMGroup( t1 ); if( t1[ 0 ] == '\0' ) { return( TRUE ); } // Initiate a conversation with the Program Manager. // NOTE: No callback provided since we only issue execute commands rc = DdeInitialize( &ddeinst, NULL, APPCMD_CLIENTONLY, 0L ); if( rc != 0 ) { return( FALSE ); } happ = DdeCreateStringHandle( ddeinst, progman, CP_WINANSI ); htopic = DdeCreateStringHandle( ddeinst, progman, CP_WINANSI ); hconv = DdeConnect( ddeinst, happ, htopic, NULL ); if( hconv == (HCONV)NULL ) { return( FALSE ); } // Disable the Program Manager so that the user can't work with it // while we are doing our stuff. hwnd_pm = FindWindow( progman, NULL ); if( hwnd_pm != NULL ) { ShowWindow( hwnd_pm, SW_RESTORE ); EnableWindow( hwnd_pm, FALSE ); } if( uninstall ) { // Delete the PM Group box num_groups = SimGetNumPMGroups(); for( i = 0; i < num_groups; i++ ) { SimGetPMGroupName( i, t1 ); if( *t1 != '\0' ) { // Delete the PM Group box sprintf( buff, "[DeleteGroup(%s)]", t1 ); ok = SendCommand( ddeinst, hconv, buff ); } } goto cleanup; // I can't believe I'm doing this } else { // Delete the PM Group box to get rid of stale icons // (Don't do this for SQL install, since user may install // the server, and then install the client) sprintf( buff, "[DeleteGroup(%s)]", t1 ); ok = SendCommand( ddeinst, hconv, buff ); // re-Create the PM Group box. SimGetPMGroupFileName( t2 ); if( t2[ 0 ] == '\0' ) { #if defined( __NT__ ) sprintf( buff, "[CreateGroup(%s,0)]", t1 ); // create a personal group #else sprintf( buff, "[CreateGroup(%s)]", t1 ); #endif } else { sprintf( buff, "[CreateGroup(%s,%s)]", t1, t2 ); } ok = SendCommand( ddeinst, hconv, buff ); } // Add the individual PM files to the Group box. num_icons = SimGetNumPMProgs(); StatusLines( STAT_CREATEPROGRAMFOLDER, "" ); num_total_install = 0; for( i = 0; i < num_icons; i++ ) { if( SimCheckPMCondition( i ) ) { ++num_total_install; } } num_installed = 0; StatusAmount( 0, num_total_install ); for( i = 0; ok && ( i < num_icons ); i++ ) { if( !SimCheckPMCondition( i ) ) { continue; } SimGetPMDesc( i, prog_desc ); dir_index = SimGetPMProgName( i, prog_name ); if( strcmp( prog_name, "GROUP" ) == 0 ) { // Delete the PM Group box to get rid of stale icons sprintf( buff, "[DeleteGroup(%s)]", prog_desc ); ok = SendCommand( ddeinst, hconv, buff ); /* creating a new group */ SimGetPMParms( i, t1 ); if( t1[ 0 ] == '\0' ) { #if defined( __NT__ ) sprintf( buff, "[CreateGroup(%s,0)]", prog_desc ); // create a personal group #else sprintf( buff, "[CreateGroup(%s)]", prog_desc ); #endif } else { sprintf( buff, "[CreateGroup(%s,%s)]", prog_desc, t1 ); } } else { /* adding item to group */ if( dir_index == SIM_INIT_ERROR ) { working_dir[0] = '\0'; ReplaceVars( t2, prog_name ); strcpy( prog_name, t2 ); } else { SimDirNoSlash( dir_index, working_dir ); } // get parameters SimGetPMParms( i, t1 ); if( t1[0] != '\0' ) { // add parameters to end of prog_name len = strlen( prog_name ); prog_name[len] = ' '; ReplaceVars( &prog_name[len + 1], t1 ); } // Append the subdir where the icon file is and the icon file's name. temp = SimGetPMIconInfo( i, icon_name ); dir_index = LOWORD( temp ); icon_number = HIWORD( temp ); if( icon_number == SIM_INIT_ERROR ) { icon_number = 0; } if( dir_index != SIM_INIT_ERROR ) { SimGetDir( dir_index, t1 ); strcat( t1, icon_name ); strcpy( icon_name, t1 ); } // Add the new file to the already created PM Group. version = (WORD)GetVersion(); if( (LOBYTE( version ) > 3) || // Version 3.1 or higher (LOBYTE( version ) == 3 && HIBYTE( version ) > 0) ) { sprintf( buff, "[ReplaceItem(%s)]", prog_desc ); SendCommand( ddeinst, hconv, buff ); sprintf( buff, "[AddItem(%s,%s,%s,%d,-1,-1,%s)]", prog_name, prog_desc, icon_name, icon_number, working_dir ); } else { sprintf( buff, "[AddItem(%s%s,%s,%s,%d)]", working_dir, prog_name, prog_desc, icon_name, icon_number ); } } ok = SendCommand( ddeinst, hconv, buff ); ++num_installed; StatusAmount( num_installed, num_total_install ); if( StatusCancelled() ) break; } StatusAmount( num_total_install, num_total_install ); cleanup: // Terminate the DDE conversation with the Program Manager. DdeFreeStringHandle( ddeinst, happ ); DdeFreeStringHandle( ddeinst, htopic ); // DdeDisconnect( hconv ); // win95 setup was crashing on ddeuninitialize //(only if running from CD)removing this call seems to be an OK workaround DdeUninitialize( ddeinst ); if( hwnd_pm != NULL ) { EnableWindow( hwnd_pm, TRUE ); } return( ok ); }
PATCH_RET_CODE Execute( byte *dest ) { char *tmp; #else PATCH_RET_CODE Execute( void ) { char tmp[4]; #if defined(__386__) #if defined(_WPATCH) extern MY_FILE NewFile; #define InNew( offset ) ( Input( &NewFile, tmp, offset, \ sizeof(hole)), \ *(hole*)tmp ) #define OutNew( off, x, type ) *(type*)tmp = (x); \ Output( &NewFile, tmp, \ off, sizeof( type ) ); #else extern byte *NewFile; #define OutNew( off, x, type ) *(type*)(NewFile+off) = (x); #define InNew( off ) *(hole*)(NewFile+off) #endif #elif defined(BDUMP) #define InNew( offset ) 1 #define OutNew( off, x, type ) ( x ) #undef Dump #define Dump( x ) printf x #undef DOPROMPT #undef DOBACKUP #define DOPROMPT 0 #define DOBACKUP 0 #else extern MY_FILE NewFile; extern void Input( MY_FILE *file, void *tmp, foff off, size_t len ); #define InNew( offset ) ( Input( &NewFile, tmp, offset, \ sizeof(hole)), \ *(hole*)tmp ) extern void Output( MY_FILE *file, void *tmp, foff off, size_t len ); #define OutNew( off, x, type ) *(type*)tmp = (x); \ Output( &NewFile, tmp, \ off, sizeof( type ) ); #endif #endif patch_cmd cmd; byte next; hole diff; foff size; foff incr; foff iters; foff old_size; foff new_size; foff checksum; foff new_offset; foff old_offset; char ch; int havenew; PATCH_RET_CODE ret; PATCH_RET_CODE ret2; #ifdef BDIFF char *dummy = NULL; #endif havenew = 1; #ifdef BDIFF InitPatch( &dummy ); #endif old_size = InPatch( foff ); new_size = InPatch( foff ); checksum = InPatch( foff ); ret = OpenOld( old_size, DOPROMPT, new_size, checksum ); if( ret != PATCH_RET_OKAY ) goto error1; ret = OpenNew( new_size ); if( ret != PATCH_RET_OKAY ) goto error2; InitHoles(); for( ;; ) { #if defined( INSTALL_PROGRAM ) #if defined( WINNT ) || defined( WIN ) || defined( OS2 ) if( StatusCancelled() ) { ret = PATCH_RET_CANCEL; goto error3; } #endif #endif cmd = InPatch( patch_cmd ); if( cmd == CMD_DONE ) break; switch( cmd ) { case CMD_DIFFS: new_offset = InPatch( foff ); size = InPatch( foff ); Dump(( "Different new-%8.8lx size-%8.8lx\n", new_offset, size )); while( size != 0 ) { OutNew( new_offset, InPatch( byte ), byte ); ++new_offset; --size; } break; case CMD_SAMES: new_offset = InPatch( foff ); old_offset = InPatch( foff ); size = InPatch( foff ); Dump(( "Similar new-%8.8lx old-%8.8lx size-%8.8lx\n", new_offset, old_offset, size)); while( size != 0 ) { OutNew( new_offset, InOld( old_offset ), byte ); ++new_offset; ++old_offset; --size; } break; case CMD_ITER_HOLES: new_offset = InPatch( foff ); diff = InPatch( hole ); iters = InPatch( foff ); incr = InPatch( foff ); ch = InPatch( byte ); Dump(( "IterHole new-%8.8lx diff-%8.8lx iter-%8.8lx inc-%8.8lx\n", new_offset, diff, iters, incr )); while( iters != 0 ) { AddHole( new_offset, diff ); new_offset += incr; --iters; } break; case CMD_HOLES: new_offset = InPatch( foff ); diff = InPatch( hole ); for( ;; ) { Dump(( "Hole new-%8.8lx diff-%8.8lx\n",new_offset,diff)); AddHole( new_offset, diff ); next = InPatch( byte ); if( next == 0 ) break; if( ( next & 0x80 ) == 0 ) { new_offset += (foff)next & 0x7f; } else if( ( next & 0x40 ) == 0 ) { new_offset += ( (foff)next & 0x3f ) << 8; new_offset += (foff)InPatch( byte ); } else { new_offset += ( (foff)next & 0x3f ) << 16; new_offset += (foff)InPatch(byte) << 8; new_offset += (foff)InPatch(byte); } } break; default: PatchError( ERR_BAD_PATCHFILE, PatchName ); ret = PATCH_BAD_PATCH_FILE; goto error3; } } ret = PATCH_RET_OKAY; FlushHoles(); error3: FreeHoleArray(); ret2 = CloseNew( new_size, checksum, &havenew ); if( ret == PATCH_RET_OKAY ) { ret = ret2; } error2: CloseOld( havenew && DOPROMPT, DOBACKUP ); error1: ClosePatch(); return( ret ); }