applied libSiliconPatch.dll

This commit is contained in:
aomizu
2025-05-18 20:17:11 +09:00
parent 5ed9b83f3d
commit c9bb2786f7
3 changed files with 51 additions and 27 deletions

View File

@@ -2,4 +2,4 @@
Name = "TurtleSilicon"
ID = "com.tairasu.turtlesilicon"
Version = "0.1.0"
Build = 12
Build = 15

70
main.go
View File

@@ -201,23 +201,25 @@ func main() {
turtlewowPathLabel.Refresh()
winerosettaDllPath := filepath.Join(turtlewowPath, "winerosetta.dll")
d3d9DllPath := filepath.Join(turtlewowPath, "d3d9.dll")
libSiliconPatchDllPath := filepath.Join(turtlewowPath, "libSiliconPatch.dll") // Added check for libSiliconPatch.dll
rosettaX87DirPath := filepath.Join(turtlewowPath, "rosettax87")
dllsTextFile := filepath.Join(turtlewowPath, "dlls.txt")
// Check for libRuntimeRosettax87 as well
rosettaX87ExePath := filepath.Join(rosettaX87DirPath, "rosettax87")
libRuntimeRosettaX87Path := filepath.Join(rosettaX87DirPath, "libRuntimeRosettax87")
// Check if dlls.txt exists and contains winerosetta.dll
// Check if dlls.txt exists and contains winerosetta.dll and libSiliconPatch.dll
dllsFileValid := false
if pathExists(dllsTextFile) {
if fileContent, err := os.ReadFile(dllsTextFile); err == nil {
if strings.Contains(string(fileContent), "winerosetta.dll") {
// Updated to check for both entries for dllsFileValid to be true
if strings.Contains(string(fileContent), "winerosetta.dll") && strings.Contains(string(fileContent), "libSiliconPatch.dll") {
dllsFileValid = true
}
}
}
if pathExists(winerosettaDllPath) && pathExists(d3d9DllPath) && dirExists(rosettaX87DirPath) &&
if pathExists(winerosettaDllPath) && pathExists(d3d9DllPath) && pathExists(libSiliconPatchDllPath) && dirExists(rosettaX87DirPath) &&
pathExists(rosettaX87ExePath) && pathExists(libRuntimeRosettaX87Path) && dllsFileValid {
patchesAppliedTurtleWoW = true
} else {
@@ -321,6 +323,7 @@ func main() {
filesToCopy := map[string]string{
"winerosetta/winerosetta.dll": targetWinerosettaDll, // Adjusted path
"winerosetta/d3d9.dll": targetD3d9Dll, // Adjusted path
"winerosetta/libSiliconPatch.dll": filepath.Join(turtlewowPath, "libSiliconPatch.dll"), // Added libSiliconPatch.dll
}
for resourceName, destPath := range filesToCopy {
@@ -433,54 +436,75 @@ func main() {
// Check and update dlls.txt file
log.Printf("Checking dlls.txt file at: %s", dllsTextFile)
winerosettaEntry := "winerosetta.dll"
needsUpdate := true
libSiliconPatchEntry := "libSiliconPatch.dll" // New entry
needsWinerosettaUpdate := true
needsLibSiliconPatchUpdate := true
// Check if file exists and if winerosetta.dll is already in it
if fileContent, err := os.ReadFile(dllsTextFile); err == nil {
// Check if file exists and what it contains
if fileContentBytes, err := os.ReadFile(dllsTextFile); err == nil {
fileContent := string(fileContentBytes)
// File exists, check if it contains winerosetta.dll
if strings.Contains(string(fileContent), winerosettaEntry) {
if strings.Contains(fileContent, winerosettaEntry) {
log.Printf("dlls.txt already contains %s", winerosettaEntry)
needsUpdate = false
needsWinerosettaUpdate = false
}
// File exists, check if it contains libSiliconPatch.dll
if strings.Contains(fileContent, libSiliconPatchEntry) {
log.Printf("dlls.txt already contains %s", libSiliconPatchEntry)
needsLibSiliconPatchUpdate = false
}
} else {
// File doesn't exist, we'll create a new one
log.Printf("dlls.txt not found, will create a new one")
// File doesn't exist, we'll create a new one, so both need to be added
log.Printf("dlls.txt not found, will create a new one with both entries")
}
// Update the file if needed
if needsUpdate {
var fileContent []byte
if pathExists(dllsTextFile) {
if needsWinerosettaUpdate || needsLibSiliconPatchUpdate {
var fileContentBytes []byte
var err error
fileContent, err = os.ReadFile(dllsTextFile)
if pathExists(dllsTextFile) {
fileContentBytes, err = os.ReadFile(dllsTextFile)
if err != nil {
errMsg := fmt.Sprintf("failed to read dlls.txt: %v", err)
errMsg := fmt.Sprintf("failed to read dlls.txt for update: %v", err)
dialog.ShowError(fmt.Errorf(errMsg), myWindow)
log.Println(errMsg)
// Not treating this as fatal, will try to create/overwrite
}
}
// Append winerosetta.dll to file content
if len(fileContent) > 0 && !strings.HasSuffix(string(fileContent), "\n") {
fileContent = append(fileContent, '\n')
currentContent := string(fileContentBytes)
updatedContent := currentContent
// Ensure newline at the end of existing content if it's not empty
if len(updatedContent) > 0 && !strings.HasSuffix(updatedContent, "\n") {
updatedContent += "\n"
}
if needsWinerosettaUpdate {
if !strings.Contains(updatedContent, winerosettaEntry+"\n") { // Check with newline to avoid partial matches
updatedContent += winerosettaEntry + "\n"
log.Printf("Adding %s to dlls.txt", winerosettaEntry)
}
}
if needsLibSiliconPatchUpdate {
if !strings.Contains(updatedContent, libSiliconPatchEntry+"\n") { // Check with newline
updatedContent += libSiliconPatchEntry + "\n"
log.Printf("Adding %s to dlls.txt", libSiliconPatchEntry)
}
}
fileContent = append(fileContent, []byte(winerosettaEntry)...)
fileContent = append(fileContent, '\n')
// Write updated content back to file
if err := os.WriteFile(dllsTextFile, fileContent, 0644); err != nil {
if err := os.WriteFile(dllsTextFile, []byte(updatedContent), 0644); err != nil {
errMsg := fmt.Sprintf("failed to update dlls.txt: %v", err)
dialog.ShowError(fmt.Errorf(errMsg), myWindow)
log.Println(errMsg)
// Not treating this as fatal for patching process
} else {
log.Printf("Successfully updated dlls.txt with %s", winerosettaEntry)
log.Printf("Successfully updated dlls.txt")
}
}
log.Println("TurtleWoW patching with bundled resources completed successfully.")
patchesAppliedTurtleWoW = true
dialog.ShowInformation("Success", "TurtleWoW patching process completed using bundled resources.", myWindow)
updateAllStatuses()
}

BIN
winerosetta/libSiliconPatch.dll Executable file

Binary file not shown.