Jump to content

How to use _WinAPI_UpdateResource to edit .mui file?


Nikolas92
 Share

Recommended Posts

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?

#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:

SnapCrab_No-0000.png

Edited by Nikolas92
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...