Changeset 1541 for trunk/gsinstaller
- Timestamp:
- 2000-09-13T05:41:01+12:00 (24 years ago)
- Location:
- trunk/gsinstaller
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/FilePath.cpp
r1536 r1541 357 357 parent = this->parent(); 358 358 359 if (parent->equals(thisFile. getFileName()))359 if (parent->equals(thisFile.cString())) 360 360 { 361 361 delete parent; … … 380 380 { 381 381 // is this writeable by user?; if so we're okay 382 if (thisFile.isWriteable() )382 if (thisFile.isWriteable() || true) 383 383 { 384 384 reply = true; -
trunk/gsinstaller/FilePath.h
r1539 r1541 15 15 { 16 16 private: 17 string path; // full path of this item18 17 bool is_aRoot; // indicates whether this directory/file is a file root 19 18 void _init(string path, string subPath); 19 protected: 20 string path; // full path of this item 20 21 public: 21 22 FilePath(); -
trunk/gsinstaller/file.cpp
r1524 r1541 10 10 { struct stat statData; 11 11 12 if (this-> name.length() < 5)12 if (this->path.length() < 5) 13 13 { this->does_exist = true; 14 14 this->size = 0; … … 17 17 } 18 18 else 19 { if (stat (this-> name.c_str(), &statData) == -1)19 { if (stat (this->path.c_str(), &statData) == -1) 20 20 { this->does_exist = false; 21 21 this->size = 0; … … 36 36 struct dirent * entry; 37 37 38 directory = opendir(this-> name.c_str());38 directory = opendir(this->path.c_str()); 39 39 if (directory == NULL) 40 40 { return; … … 49 49 } 50 50 51 childName = this-> name;51 childName = this->path; 52 52 childName.append("\\"); 53 53 childName.append(entry->d_name); … … 62 62 } 63 63 64 File::File(string filename) 65 { this->name= filename;64 File::File(string filename) : FilePath(filename) 65 { // this->path = filename; 66 66 this->_getDetails(); 67 67 if (this->is_dir) … … 70 70 } 71 71 72 /* 72 73 File::File(string filename, unsigned long filesize) 73 { this-> name= filename;74 { this->path = filename; 74 75 this->_getDetails(); 75 76 if (this->is_dir) … … 77 78 } 78 79 } 80 */ 79 81 80 82 unsigned long File::getDiskSpace(DiskSpace &diskSpace) … … 94 96 } 95 97 96 const char *File::getFileName() 97 { return this->name.c_str(); 98 /* 99 const char *File::cString() 100 { return this->path.c_str(); 98 101 } 102 */ 99 103 100 104 unsigned long File::getRawFileSize() -
trunk/gsinstaller/file.h
r1539 r1541 13 13 14 14 #include "DiskSpace.h" 15 #include "FilePath.h" 15 16 16 class File 17 class File : public FilePath 17 18 { 18 19 private: … … 29 30 public: 30 31 File(); 31 File(string filename, unsigned long filesize);32 32 File(string filename); 33 33 void copy(char *destination); … … 37 37 unsigned long getRawFileSize(); 38 38 unsigned long getFileSize(); 39 const char *getFileName();39 // const char *cString(); 40 40 unsigned long getDiskSpace(DiskSpace &diskSpace); 41 41 vector<File>::iterator childBegin(); -
trunk/gsinstaller/fileCopier.cpp
r1536 r1541 36 36 char *fileCopySet::destination(File *file) 37 37 { 38 const char *oldname = file-> getFileName();38 const char *oldname = file->cString(); 39 39 char *newname = (char *) malloc(strlen(oldname) - strlen(this->sourceDir.cString()) + strlen(this->destDir.cString()) + 1); 40 40 … … 62 62 destination = this->destination(file); 63 63 64 FilePath destPath(destination); 65 FilePath *destDir = destPath.parent(); 66 if (!destDir->ensureWriteablePath()) 67 { delete destDir; 68 return false; 69 } 70 delete destDir; 71 64 72 // get read and write file handles 65 read_handle = fopen(file-> getFileName(), "rb");73 read_handle = fopen(file->cString(), "rb"); 66 74 if (read_handle == NULL) 67 75 { … … 104 112 if (monitor != NULL) 105 113 { 106 monitor->copied(file-> getFileName(), destination, false);114 monitor->copied(file->cString(), destination, false); 107 115 } 108 116 delete destination; … … 135 143 if (monitor != NULL) 136 144 { 137 monitor->copied(file-> getFileName(), thisDestDir, true);145 monitor->copied(file->cString(), thisDestDir, true); 138 146 } 139 147 -
trunk/gsinstaller/gsPlatform.cpp
r1536 r1541 3 3 #define ACCESS_READ 0x01 4 4 #define ACCESS_WRITE 0x02 5 6 #include <stdio.h> 5 7 6 8 gsPlatform::gsPlatform() … … 38 40 39 41 bool gsPlatform::isUserAdministrator() 40 { 42 { 41 43 if (this->isWindowsNT()) 42 44 { … … 44 46 PSID adminId; 45 47 PACL aclData; 46 PSECURITY_DESCRIPTOR psdAdmin ;47 SID_IDENTIFIER_AUTHORITY systemSidAuthority ;48 PSECURITY_DESCRIPTOR psdAdmin = NULL; 49 SID_IDENTIFIER_AUTHORITY systemSidAuthority = SECURITY_NT_AUTHORITY; 48 50 GENERIC_MAPPING genericMapping; 49 51 PRIVILEGE_SET privilegeSet; 50 DWORD aclSize, status, structureSize;52 DWORD aclSize, accessMask, status, structureSize; 51 53 BOOL result; 52 54 … … 57 59 { 58 60 if (GetLastError() != ERROR_NO_TOKEN) 59 { 61 { 60 62 return false; 61 63 } … … 63 65 // if we didn't have an access token, take the process token instead 64 66 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) 65 { 67 { 66 68 return false; 67 69 } … … 73 75 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, 74 76 &adminId)) 75 { 77 { 76 78 return false; 77 79 } … … 100 102 // initalise the acl block 101 103 if (!InitializeAcl(aclData, aclSize, ACL_REVISION2)) 102 { 103 return false; 104 } 104 { 105 return false; 106 } 107 108 accessMask = ACCESS_READ | ACCESS_WRITE; 109 110 105 111 106 112 // try to add the given item to the Access Control Entry (ACE) list (ACL) 107 if (!AddAccessAllowedAce(aclData, ACL_REVISION2, ACCESS_READ | ACCESS_WRITE, adminId))108 { 113 if (!AddAccessAllowedAce(aclData, ACL_REVISION2, accessMask, adminId)) 114 { 109 115 return false; 110 116 } … … 127 133 genericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; 128 134 135 structureSize = sizeof(PRIVILEGE_SET); 136 129 137 // do the actual access check 130 138 if (!AccessCheck (psdAdmin, token, ACCESS_READ, &genericMapping, 131 139 &privilegeSet, &structureSize, &status, &result)) 132 { 133 return false; 140 { return false; 134 141 } 135 142 136 143 // end impersonisation 137 144 RevertToSelf(); 145 146 LocalFree(psdAdmin); 147 LocalFree(aclData); 148 FreeSid(adminId); 138 149 return result; 139 150 } … … 151 162 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, 152 163 &token)) 153 { 154 return false; 155 } 156 164 { 165 return false; 166 } 167 157 168 LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); 158 169 -
trunk/gsinstaller/gsProfile.cpp
r1498 r1541 85 85 itemValue.c_str(), this->fileName.c_str())) 86 86 { DWORD error = GetLastError(); 87 char buffer[20];87 /* char buffer[20]; 88 88 sprintf(buffer, "%lx", error); 89 MessageBox(0, buffer, "", MB_OK); 89 MessageBox(0, buffer, "", MB_OK);*/ 90 return false; 90 91 } 91 92 return true; -
trunk/gsinstaller/gsProgman.cpp
r1536 r1541 158 158 LPITEMIDLIST pidl; 159 159 160 if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) == NOERROR) 161 { SHGetPathFromIDList(pidl, buffer); 162 163 // Create the folder as required 164 FilePath *path = new FilePath(buffer, groupName); 165 if (!CreateDirectory((char *) path->cString(), NULL)) 166 { // it probably existed already - if so skip it! 167 DWORD reason = GetLastError(); 168 if (reason != ERROR_ALREADY_EXISTS) 169 { return false; 170 } 160 if (this->platform->isUserAdministrator()) 161 { if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR) 162 { return false; 163 } 164 } 165 else 166 { if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR) 167 { return false; 168 } 169 } 170 SHGetPathFromIDList(pidl, buffer); 171 172 // Create the folder as required 173 FilePath *path = new FilePath(buffer, groupName); 174 if (!CreateDirectory((char *) path->cString(), NULL)) 175 { // it probably existed already - if so skip it! 176 DWORD reason = GetLastError(); 177 if (reason != ERROR_ALREADY_EXISTS) 178 { return false; 171 179 } 172 180 } … … 200 208 FilePath * fullPath; 201 209 202 if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR) 203 { return false; 210 if (this->platform->isUserAdministrator()) 211 { if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR) 212 { return false; 213 } 214 } 215 else 216 { if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR) 217 { return false; 218 } 204 219 } 205 220 206 221 SHGetPathFromIDList(pidl, buffer); 207 fullPath = new FilePath(4, buffer, groupName.c_str(), iconName.c_str(), " .lnk");222 fullPath = new FilePath(4, buffer, groupName.c_str(), iconName.c_str(), "!.lnk"); 208 223 209 224 // check if the shortcut already exists then don't create this again … … 279 294 LPITEMIDLIST pidl; 280 295 281 if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) == NOERROR) 282 { SHGetPathFromIDList(pidl, buffer); 283 284 // Create the folder as required 285 FilePath *path = new FilePath(buffer, groupName); 286 if (!RemoveDirectory((char *) path->cString())) 287 { // TODO: find cause of failure to remove 288 DWORD reason = GetLastError(); 289 if (reason != 0) 290 { return false; 291 } 296 if (this->platform->isUserAdministrator()) 297 { if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR) 298 { return false; 299 } 300 } 301 else 302 { if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR) 303 { return false; 304 } 305 } 306 SHGetPathFromIDList(pidl, buffer); 307 308 // Create the folder as required 309 FilePath *path = new FilePath(buffer, groupName); 310 if (!RemoveDirectory((char *) path->cString())) 311 { // TODO: find cause of failure to remove 312 DWORD reason = GetLastError(); 313 if (reason != 0) 314 { return false; 292 315 } 293 316 } … … 316 339 FilePath * fullPath; 317 340 318 if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR) 319 { return false; 320 } 341 // if the user is adminstrator, take the folder from the common programs folder 342 // (in the "All Users" profile) 343 if (this->platform->isUserAdministrator()) 344 { if (SHGetSpecialFolderLocation(0, CSIDL_COMMON_PROGRAMS, &pidl) != NOERROR) 345 { return false; 346 } 347 } 348 // otherwise get it from the user's own programs folder in their profile 349 else 350 { if (SHGetSpecialFolderLocation(0, CSIDL_PROGRAMS, &pidl) != NOERROR) 351 { return false; 352 } 353 } 321 354 322 355 // get path of folder from shell -
trunk/gsinstaller/gsinstall.cpp
r1539 r1541 38 38 bool config_complete = false; 39 39 40 dirSelector *rootSelector = NULL; 41 40 42 typedef vector<dirSelector *> dirSelVector; 41 43 42 44 class GSInstall : public installManager 43 { 45 { 44 46 private: 45 47 configureFile *configFile; // the installation configure file … … 680 682 { case PSN_SETACTIVE: 681 683 { dirSelector *selector = ((dirSelector *) GetWindowLong(Dialog, GWL_USERDATA)); 684 685 // bodge to set the dialogue path to the correct value 686 if (selector != rootSelector) 687 { selector->setPath(rootSelector->selectedPath()); 688 SetDlgItemText(Dialog, dirpath_PATH, selector->selectedPath()); 689 } 690 682 691 if (selector->isFinal()) 683 692 { PropSheet_SetWizButtons(GetParent(Dialog), PSWIZB_BACK | PSWIZB_FINISH); … … 734 743 { GSInstall_dirPathData *data = new GSInstall_dirPathData; 735 744 745 // create the directory Selector 736 746 data->dirSelect = new dirSelector(prompt, optPrompt, title, installer.installPath()); 737 747 data->dirSelect->setFinal(isFinal); 738 748 749 // if there is no extant root selector, make this it 750 if (rootSelector == NULL) 751 { rootSelector = data->dirSelect; 752 } 753 754 // add this directory selector to the installer 739 755 installer.addSelectedDir(data->dirSelect); 740 756 757 // set up the rest of the page 741 758 ppage.dwSize = sizeof(PROPSHEETPAGE); 742 759 ppage.dwFlags = PSP_USETITLE; … … 788 805 } 789 806 else // cheat as the executable etc. is already installed 790 { 807 { 791 808 pshead.ppsp = &ppage[1]; 792 809 } … … 815 832 816 833 long FAR PASCAL GSInstallWindProc(HWND Window, WORD Message, WPARAM wParameter, LPARAM lParameter) 817 { 834 { 818 835 long reply = 0; 819 836 … … 830 847 831 848 case WM_USER: 832 { 849 { 833 850 // uninstall action 834 851 if (strstr(app_cmdLine, "-u") != NULL) … … 1007 1024 1008 1025 // config_init("ReTreeval"); 1009 1026 1010 1027 // accel = LoadAccelerators(Current, "ReTreevalMenu"); 1011 1028 -
trunk/gsinstaller/launchApp.cpp
r1498 r1541 53 53 } 54 54 55 MessageBox(0, exePath.cString(), runLine.c_str(), MB_OK); 56 55 57 // execute the process 56 58 if (CreateProcess((LPSTR) exePath.cString(), 57 runLine != ""? (LPSTR) runLine.c_str() : NULL,59 (runLine != "" && false) ? (LPSTR) runLine.c_str() : NULL, 58 60 NULL, NULL, FALSE, 0, NULL, NULL, 59 61 &startup, &process) == 0) 60 62 { DWORD error = GetLastError(); 63 MessageBox(0, "Failed", "Failed", MB_OK); 61 64 return -2; 62 65 } -
trunk/gsinstaller/registry.cpp
r1536 r1541 22 22 LONG reply; 23 23 24 reply = RegOpenKeyEx(key, name, 0, KEY_QUERY_VALUE , keyout);24 reply = RegOpenKeyEx(key, name, 0, KEY_QUERY_VALUE | KEY_SET_VALUE, keyout); 25 25 if (reply != ERROR_SUCCESS) 26 26 {
Note:
See TracChangeset
for help on using the changeset viewer.