Nikolas92 Posted September 21, 2017 Share Posted September 21, 2017 (edited) How to use _WinAPI_UpdateResource to remove some text in .mui file? Currently I use this, but I am not sure will editing mui files in this way make them corrupt? expandcollapse popup#NoTrayIcon #RequireAdmin #include <Constants.au3> #include <GUIConstants.au3> #include <Security.au3> #include <WinAPI.au3> #include <APIResConstants.au3> #include <WinAPIRes.au3> #include <String.au3> Opt("WinWaitDelay", 0) Opt("MouseClickDelay", 0) Opt("MouseClickDownDelay", 0) Opt("MouseClickDragDelay", 0) Opt("SendKeyDelay", 0) Opt("SendKeyDownDelay", 0) Opt("WinTitleMatchMode", 3) FileChangeDir(StringRegExpReplace(@ScriptDir, '\\+$', '')) Global Const $SID_ALL_APP_PACKAGES_GROUP = 'S-1-15-2-1' Global $MetroGroupExist = False Global $AccountInfo = _Security__LookupAccountSid($SID_ALL_APP_PACKAGES_GROUP) If IsArray($AccountInfo) Then $MetroGroupExist = True MsgBox(0,'','resource editing is about to start') _SubinaclFull(@WindowsDir & '\en-US\explorer.exe.mui') $aFile = @WindowsDir & '\en-US\explorer.exe.mui' $hFileOpen = FileOpen($aFile, $FO_READ + $FO_BINARY) $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) $hInstance = _WinAPI_LoadLibraryEx($aFile, $LOAD_LIBRARY_AS_DATAFILE) $MenuList = '205|206|213' $MenuToCheck = StringSplit($MenuList, '|') For $i = 1 to $MenuToCheck[0] $hResource = _WinAPI_FindResource($hInstance, $RT_MENU, Number($MenuToCheck[$i])) $iSize = _WinAPI_SizeOfResource($hInstance, $hResource) $hData = _WinAPI_LoadResource($hInstance, $hResource) $pData = _WinAPI_LockResource($hData) $tData = DllStructCreate('byte[' & $iSize & ']', $pData) $MenuData = StringTrimLeft(DllStructGetData($tData, 1), 2) If $MenuData <> '' Then $sFileRead = StringReplace($sFileRead, $MenuData, _StringRepeat('F', StringLen($MenuData))) Next _WinAPI_FreeLibrary($hInstance) FileMove(@WindowsDir & '\en-US\explorer.exe.mui', @WindowsDir & '\en-US\explorer.exe.mui.bak', $FC_OVERWRITE + $FC_CREATEPATH) $hFileOpen = FileOpen($aFile, $FO_APPEND + $FO_BINARY) FileWrite($hFileOpen, $sFileRead) FileClose($hFileOpen) MsgBox(0,'error ' & _WinAPI_GetLastError(),'done') Func _SubinaclFull($sPath, $recurse = True) $MetroGroupAce = '' If $MetroGroupExist = True Then $MetroGroupAce = ' /GRANT="ALL APPLICATION PACKAGES"=R' If StringRight($sPath, 1) <> '\' Then $sPath = $sPath & '\' $PathForSubinacl = StringTrimRight(StringReplace($sPath, @WindowsDir & '\System32\', @WindowsDir & '\Sysnative\'), 1) RunWait(StringRegExpReplace(@WorkingDir, '\\+$', '') & '\subinacl.exe' & ' /nostatistic /noverbose /file "' & $PathForSubinacl & '" /GRANT=System=F /GRANT=Administrators=F /GRANT=Users=F /GRANT=Everyone=F /GRANT=' & @UserName & '=F' & $MetroGroupAce & ' /SETOWNER=Everyone', '', @SW_HIDE) If $recurse = True and StringInStr(FileGetAttrib(StringTrimRight($sPath, 1)), "D") Then RunWait(StringRegExpReplace(@WorkingDir, '\\+$', '') & '\subinacl.exe' & ' /nostatistic /noverbose /subdirectories "' & $PathForSubinacl & '\*" /GRANT=System=F /GRANT=Administrators=F /GRANT=Users=F /GRANT=Everyone=F /GRANT=' & @UserName & '=F' & $MetroGroupAce & ' /SETOWNER=Everyone', '', @SW_HIDE) EndFunc Want to remove all from 205, 206 and 213 so that only this remains: Edited September 21, 2017 by Nikolas92 Link to comment Share on other sites More sharing options...
Nikolas92 Posted September 22, 2017 Author Share Posted September 22, 2017 Any way to use _WinAPI_UpdateResource to edit menu text in .mui file? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 22, 2017 Moderators Share Posted September 22, 2017 @Nikolas92 please wait at least 24 hours before bumping your thread. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Nikolas92 Posted September 23, 2017 Author Share Posted September 23, 2017 bump Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now