Benvenuto! Effettua l'accesso oppure registrati.
Hai perso l'e-mail di attivazione?

08/10/2024, 20:56

Login with username, password and session length
4 Visitatori, 0 Utenti

Autore Topic: Extract Cabinet Language Pack  (Letto 2390 volte)

0 Utenti e 1 Visitatore stanno visualizzando questo topic.

Offline OnePiece

  • Eng2ita Friends
  • **
  • Post: 3.126
  • Karma: -3278
Extract Cabinet Language Pack
« il: 25/01/2013, 03:20 »
lpkinstallEx.exe (Extract Cabinet Language Pack)
Aggiornato (Gennaio 25 2013)
Aggiornato (Gennaio 25 2013)
Aggiornato (Gennaio 25 2013)
Aggiornato (Gennaio 25 2013)
Aggiornato (Gennaio 25 2013)
Hash MD5 F05EA2F22BF68FD8BC3386AE9A8A16AD
Filesize: 370 KB (379127 byte)


per quelli che non vogliono includere il reshaker.exe nei loro exe, ecco un esempio (codice del lpkinstallEx.exe)
Codice: [Seleziona]
;;OnePiece

#RequireAdmin

Global $aResName[1001][2] = [[0,1000]]

Local $lpkPath, $lpkFilename, $lpkBinary, $hFile

Local $lpkPath = FileOpenDialog("seleziona Language Pack Installer", @DesktopDir & "\", "Language Pack Installer (*.exe)", 1 + 4)
If @Error Then
    MsgBox(4096, "", "Nessun file di selezionato")
Exit
EndIf

$lpkFilename = FileGetVersion($lpkPath, "OriginalFilename")
If $lpkFilename = "" Then $lpkFilename = "LanguagePackInstaller.cab"
$lpkFilename = StringTrimRight($lpkFilename, 4) & ".cab"

$lpkBinary = _ResourceGetEx("", 10, 0, 0, $lpkPath)
If @Error Then
    MsgBox(16, "Error", @Error)
Exit
EndIf

$hFile = FileOpen(@DesktopDir & "\" & $lpkFilename, 26)
FileWrite($hFile, $lpkBinary)
FileClose($hFile)

;;;; http://msdn.microsoft.com/en-us/library/windows/desktop/ff468901%28v=vs.85%29.aspx
;;;; http://www.autoitscript.com/forum/topic/51103-resources-udf/
Func _ResourceGetEx($ResName, $ResType = 10, $ResLang = 0, $iFlags = 0, $DLL = -1) ; $RT_RCDATA = 10
Local $hInstance, $TypeResName = "wstr", $InfoBlock, $GlobalMemoryBlock, $MemoryPointer, $ResSize, $ResData, $aResult

If $DLL = -1 Then
$hInstance = DllCall("kernel32.dll", "handle", "GetModuleHandleW", "ptr", 0)
Else
$hInstance = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $DLL, "ptr", 0, "dword", 2)
EndIf
If @Error Or Not $hInstance[0] Then Return SetError(1, @Error, 0)
$hInstance = $hInstance[0]

If $ResName = "" Then
$aResName[0][0] = 0
_ResourceEnumNames($hInstance, $ResType)
If Not $aResName[0][0] Then Return SetError(3, 0, 0)
$ResName = $aResName[1][0]
If $aResName[1][1] Then $TypeResName = "int"
ElseIf StringIsDigit($ResName) Then
$ResName = "#" & Number($ResName)
EndIf

If $ResLang <> 0 Then
$InfoBlock = DllCall("kernel32.dll", "ptr", "FindResourceExW", "ptr", $hInstance, "int", $ResType, $TypeResName, $ResName, "WORD", $ResLang)
Else
$InfoBlock = DllCall("kernel32.dll", "ptr", "FindResourceW", "ptr", $hInstance, $TypeResName, $ResName, "int", $ResType)
EndIf
If @Error Or Not $InfoBlock[0] Then Return SetError(2, @Error, 0)
$InfoBlock = $InfoBlock[0]

$ResSize = DllCall("kernel32.dll", "dword", "SizeofResource", "ptr", $hInstance, "ptr", $InfoBlock)
If @Error Or Not $ResSize[0] Then Return SetError(3, @Error, 0)
$ResSize = $ResSize[0]

$GlobalMemoryBlock = DllCall("kernel32.dll", "ptr", "LoadResource", "ptr", $hInstance, "ptr", $InfoBlock)
If @Error Or Not $GlobalMemoryBlock[0] Then Return SetError(4, @Error, 0)
$GlobalMemoryBlock = $GlobalMemoryBlock[0]

$MemoryPointer = DllCall("kernel32.dll", "ptr", "LockResource", "ptr", $GlobalMemoryBlock)
If @Error Or Not $MemoryPointer[0] Then Return SetError(5, @Error, 0)
$MemoryPointer = $MemoryPointer[0]

If BitAND($iFlags, 1) = 1 Then
$ResData = DllStructGetData(DllStructCreate("char[" & $ResSize & "]", $MemoryPointer), 1)
ElseIf BitAND($iFlags, 2) = 2 Then
$ResData = DllStructGetData(DllStructCreate("wchar[" & $ResSize & "]", $MemoryPointer), 1)
Else
$ResData = DllStructGetData(DllStructCreate("byte[" & $ResSize & "]", $MemoryPointer), 1)
EndIf

If $DLL <> -1 Then DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hInstance)
If @Error Then Return SetError(6, @Error, 0)

Return $ResData
EndFunc

Func _ResourceEnumNames($hModule, $iType)
Local $aRet, $hEnumProc = DllCallbackRegister('__EnumResNamesProc', 'int', 'ptr;ptr;ptr;long_ptr')
If IsString($hModule) Then
$hModule = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $hModule, "ptr", 0, "dword", 2)
If @Error Or $hModule[0] = 0 Then Return SetError(1, DllCallbackFree($hEnumProc), 0)
$aRet = DllCall("kernel32.dll", "int", "EnumResourceNamesW", "ptr", $hModule[0], "int", $iType, "ptr", DllCallbackGetPtr($hEnumProc), "long_ptr", 0)
DllCallbackFree($hEnumProc)
DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hModule[0])
Else
$aRet = DllCall("kernel32.dll", "int", "EnumResourceNamesW", "ptr", $hModule, "int", $iType, "ptr", DllCallbackGetPtr($hEnumProc), "long_ptr", 0)
DllCallbackFree($hEnumProc)
EndIf
EndFunc

Func __EnumResNamesProc($hModule, $pType, $pName, $lParam)
#forceref $hModule, $pType, $lParam
Local $aRet = DllCall("kernel32.dll", "int", "lstrlenW", "ptr", $pName)
If @Error Or Not $aRet[0] Then
$aResName[0][0] += 1
$aResName[$aResName[0][0]][0] = Number($pName)
$aResName[$aResName[0][0]][1] = 1
Else
$aResName[0][0] += 1
$aResName[$aResName[0][0]][0] = DllStructGetData(DllStructCreate("wchar[" & ($aRet[0] + 1) & "]", $pName), 1)
EndIf
If $aResName[0][0] = $aResName[0][1] Then
$aResName[0][1] *= 2
ReDim $aResName[$aResName[0][1]  + 1][2]
EndIf
Return 1
EndFunc

per di più
http://msdn.microsoft.com/en-us/library/windows/desktop/ff468901%28v=vs.85%29.aspx
http://www.autoitscript.com/forum/topic/51103-resources-udf/
http://www.autoitscript.com/forum/topic/98712-winapiex-udf/

Ciao a tutti.
« Ultima modifica: 25/01/2013, 03:36 da OnePiece »
   

 

Un addon-pack per AutoIT

Aperto da BAT

Risposte: 8
Visite: 7863
Ultimo post 14/10/2010, 20:19
da Yza_K