Last active
October 19, 2023 19:49
-
-
Save amexn-me/59928f2c2900b12ec2f1f76ce39e2cb2 to your computer and use it in GitHub Desktop.
Make a Windows 32bit exe console-less (silent mode for exe built through pkg)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
) | |
func main() { | |
// Open the EXE file for reading and writing | |
filename := "to_convert_x32.exe" | |
file, err := os.OpenFile(filename, os.O_RDWR, 0644) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer file.Close() | |
// Modify the subsystem field at offset 0x180 (13th byte) | |
offset := int64(0x180) + 12 | |
newSubsystem := byte(2) | |
_, err = file.WriteAt([]byte{newSubsystem}, offset) | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Println("Subsystem changed to GUI & it will remain silent.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment