Skip to content

Commit

Permalink
Vendor libraries added
Browse files Browse the repository at this point in the history
GUI dialog with progress bar added
Now the game will be closed on Window closing, if the game loaded without Hardware acceleration support
  • Loading branch information
ivy-reps authored and iv committed Mar 29, 2022
1 parent 896e49e commit 1b9c674
Show file tree
Hide file tree
Showing 1,034 changed files with 367,976 additions and 20 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ So, I just have application written. I've written it on Golang. Just put it on f

Feel free to build it by yourself. I made binaries on my system. Also feel free to test it on VirusTotal.com ( [latest check](https://www.virustotal.com/gui/file/8d60b7ab0f2cc661518ad7cec8d1f8b80915752a591fa05054491650af5b482d?nocache=1) ) or with any other antivirus.

# How to use it
Just put that file in subdirectory *_retail_\x86_64* of the game main directory, and run.
For example Warcraft III: Reforged have installed into *C:\Program Files\Warcraft III - Reforged*, then you have to open that path, search for *_retail_* (C:\Program Files\Warcraft III - Reforged\_retail_) folder there and then for *x86_64* (C:\Program Files\Warcraft III - Reforged\_retail_\x86_64) in it. Place exe file from release sections on that folder and run. You have to run it every time you want to play the game, until Blizzard will not fix that bug.

## cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
If you compiling in Windows, you have to install [TDM-GCC](https://jmeubank.github.io/tdm-gcc/) and specify path to that compilers bin folder right before command will be specified, or in Windows Environment Variables configuration like this:
*PATH=C:\TDM-GCC-64\bin;%PATH%*

Libraries used:
* [Golang Desktop Automation. Control the mouse, keyboard, bitmap and image, read the screen, process, Window Handle and global event listener.](github.com/go-vgo/robotgo) - Used to minimize Warcraft II while restarting
* [gopsutil: psutil for golang](https://github.com/shirou/gopsutil/process) - Provide processes iteration and easier access to processes properties (process pid, process start command line)
Expand Down
31 changes: 31 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module BlizzardBrowser

go 1.17

require (
github.com/go-vgo/robotgo v0.100.10
github.com/ncruces/zenity v0.7.15
github.com/shirou/gopsutil v3.21.10+incompatible
)

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/akavel/rsrc v0.10.2 // indirect
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/josephspurrier/goversioninfo v1.3.0 // indirect
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
github.com/otiai10/gosseract v2.2.1+incompatible // indirect
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect
github.com/robotn/gohook v0.31.3 // indirect
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934 // indirect
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/vcaesar/gops v0.21.3 // indirect
github.com/vcaesar/imgo v0.30.0 // indirect
github.com/vcaesar/keycode v0.10.0 // indirect
github.com/vcaesar/tt v0.20.0 // indirect
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab // indirect
)
66 changes: 66 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ=
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 h1:Fm10/KNuoAyBm2P5P5H91Xy21hGcZnBdjR+cMdytv1M=
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947/go.mod h1:Dv9D0NUlAsaQcGQZa5kc5mqR9ua72SmA8VXi4cd+cBw=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-vgo/robotgo v0.100.10 h1:bZe7AslG6oq5ops1SWUxsPfM9Z3QQvlqfA3ezxLFNO4=
github.com/go-vgo/robotgo v0.100.10/go.mod h1:7QeIpSHX7bjeXWRPxvQeKSx9mHI+3l80Ahq+CQF0C68=
github.com/josephspurrier/goversioninfo v1.3.0 h1:pmgDhWnG8I59p5kCR09J73s/gy9JqRPAtiaUK8jixtE=
github.com/josephspurrier/goversioninfo v1.3.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/ncruces/zenity v0.7.15 h1:/QHGwXK/rpRhVsoQVG1D68AXkWr8esvCd1uaf/5SkKI=
github.com/ncruces/zenity v0.7.15/go.mod h1:zmJPBh9OQVwTd+Zce4xsqX+R2aQmjOml8TYiQnA0dy0=
github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVOV7XMi41HtzL8X2I=
github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE=
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 h1:GranzK4hv1/pqTIhMTXt2X8MmMOuH3hMeUR0o9SP5yc=
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844/go.mod h1:T1TLSfyWVBRXVGzWd0o9BI4kfoO9InEgfQe4NV3mLz8=
github.com/robotn/gohook v0.31.3 h1:kGX8iukJ9ensVRwRKnTtdojAMQOpa6KFnXDi4OA4RaI=
github.com/robotn/gohook v0.31.3/go.mod h1:wyGik0yb4iwCfJjDprtNkTyxkgQWuKoVPQ3hkz6+6js=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934 h1:2lhSR8N3T6I30q096DT7/5AKEIcf1vvnnWAmS0wfnNY=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770 h1:2uX8QRLkkxn2EpAQ6I3KhA79BkdRZfvugJUzJadiJwk=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
github.com/shirou/gopsutil v3.21.10+incompatible h1:AL2kpVykjkqeN+MFe1WcwSBVUjGjvdU8/ubvCuXAjrU=
github.com/shirou/gopsutil v3.21.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
github.com/vcaesar/gops v0.21.3 h1:VR7amkxVv9CQfsotkXrmMyT19dVuNTa1PM/oopJeIc0=
github.com/vcaesar/gops v0.21.3/go.mod h1:3e2EnlZTI9/44bqzRwkeZ3s0ZQwK2Cn4QPLx8Ii8Agk=
github.com/vcaesar/imgo v0.30.0 h1:ODQVX0EFJEh+WkKahCBtE0SqcDCIjl/kjiOplR0Ouh8=
github.com/vcaesar/imgo v0.30.0/go.mod h1:8TGnt5hjaMgwDByvMFIzUDSh5uSea4n1tAbSvnhvA6U=
github.com/vcaesar/keycode v0.10.0 h1:Qx5QE8ZXHyRyjoA2QOxBp25OKMKB+zxMVqm0FWGV0d4=
github.com/vcaesar/keycode v0.10.0/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
github.com/vcaesar/tt v0.20.0 h1:9t2Ycb9RNHcP0WgQgIaRKJBB+FrRdejuaL6uWIHuoBA=
github.com/vcaesar/tt v0.20.0/go.mod h1:GHPxQYhn+7OgKakRusH7KJ0M5MhywoeLb8Fcffs/Gtg=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab h1:rfJ1bsoJQQIAoAxTxB7bme+vHrNkRw8CqfsYh9w54cw=
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
96 changes: 76 additions & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"os"
"os/exec"
"strings"
"sync"
"time"


"github.com/go-vgo/robotgo"
"github.com/ncruces/zenity"
"github.com/shirou/gopsutil/process"
)

Expand Down Expand Up @@ -41,85 +42,140 @@ func findProcessByExeNameAndCmdLineSubStr(exeName string, cmdLine string) int32
return 0
}

var lastLineWidth int
var gameIsLoadedSuccessfully = false

func writeLine(strs ...string) {
fmt.Printf("\r"+strings.Join(strs, ","))
line := strings.Join(strs, ",")

if lastLineWidth > 0 {
fmt.Printf(strings.Repeat(" ", lastLineWidth))
}
lastLineWidth = len(line)
fmt.Printf("\r" + line)

}

func main() {
dlg, err := zenity.Progress(
zenity.Title("Retrying to start Warcraft III with HW Acceleration support"),
zenity.Pulsate(), zenity.NoCancel(),
zenity.OKLabel("Stop it!"),
)
if err != nil {
return
}
defer dlg.Close()

dlg.Text("Checking if Warcraft III started already")
dlg.Value(0)

var wg sync.WaitGroup
wg.Add(1)

done := dlg.Done()
go func() {
if _, ok := <-done; !ok {
if !gameIsLoadedSuccessfully {
if warcraftProcessPID := findProcessByExeNameAndCmdLineSubStr("Warcraft III.exe", ""); warcraftProcessPID > 0 {
prcss, _ := process.NewProcess(warcraftProcessPID)
prcss.Kill()
}
}
os.Exit(0)
}
}()

var executionAttempts int
for {
time.Sleep(1 * time.Second)
warcraftProcessPID := findProcessByExeNameAndCmdLineSubStr("Warcraft III.exe", "")

time.Sleep(time.Second)
var blizzardBrowserPID int32

warcraftProcessPID := findProcessByExeNameAndCmdLineSubStr("Warcraft III.exe", "")
if warcraftProcessPID == 0 {
writeLine("WarcraftProcessPID not found")
cmd := exec.Command(`Q:\Games\Blizzard Entertainment\Warcraft III\_retail_\x86_64\Warcraft III.exe`, "-launch")
dlg.Value(10)

dlg.Text("Starting Warcraft III...")
cmd := exec.Command(`Warcraft III.exe`, "-launch")
err := cmd.Start()
//cmd.Process.Pid
if err != nil {
log.Fatal(err)
}

prcss, _ := process.NewProcess( int32(cmd.Process.Pid) )
prcss, _ := process.NewProcess(int32(cmd.Process.Pid))
executionAttempts++

if isRunning, _ := prcss.IsRunning(); isRunning && prcss.Pid != 0 {
dlg.Text("Warcraft III started.")
dlg.Value(20)

time.Sleep(time.Second)

dlg.Text("Awaiting for BlizzardBrowser to be loaded... Meanwhile minimizing Warcraft III...")
go func() {
for {
writeLine("Warcraft III process window should be minimized now")
robotgo.MinWindow( prcss.Pid )
robotgo.MinWindow(prcss.Pid)
if blizzardBrowserPID > 0 {
break
}
time.Sleep(50 * time.Millisecond)
time.Sleep(10 * time.Millisecond)
}
}()
}
continue
}
writeLine("warcraftProcessPID found")

blizzardBrowserPID = findProcessByExeNameAndCmdLineSubStr("BlizzardBrowser.exe", "width")
if blizzardBrowserPID == 0 {
time.Sleep(1 * time.Second)
continue
}
writeLine("blizzardBrowserPID found")
dlg.Text("BlizzardBrowser loaded... Awaiting for Browser renderer subprocess...")
dlg.Value(30)

blizzardRenderPID := findProcessByExeNameAndCmdLineSubStr("BlizzardBrowser.exe", "type=ren")
if blizzardRenderPID == 0 {
time.Sleep(1 * time.Second)
continue
}
writeLine("blizzardRenderPID found")

dlg.Text("BlizzardBrowser renderer loaded... Awaiting for Browser GPU subprocess...")
dlg.Value(40)

time.Sleep(2 * time.Second)
blizzard3DPID := findProcessByExeNameAndCmdLineSubStr("BlizzardBrowser.exe", "type=gpu")
if blizzard3DPID == 0 {
writeLine("blizzard3DPID not found, rechecking")
dlg.Text("Browser GPU subprocess was not loaded. Rechecking in 2 seconds...")
time.Sleep(2 * time.Second)
blizzard3DPID2ndAttempt := findProcessByExeNameAndCmdLineSubStr("BlizzardBrowser.exe", "type=gpu")
if blizzard3DPID2ndAttempt == 0 {
writeLine("blizzard3DPID not found, finishing BlizzardBrowser process")
dlg.Text("Browser GPU subprocess was not loaded. Let's repeat it all over again Warcraft III")
time.Sleep(100 * time.Millisecond)
blizzardBrowserProcess, _ := process.NewProcess(warcraftProcessPID)
blizzardBrowserProcess.Kill()
continue
}
}
writeLine("blizzard3DPID found, rechecking")
time.Sleep(1 * time.Second)
dlg.Text("Browser GPU subprocess is loaded. Checking that it will not be crashed in 2 seconds")
dlg.Value(50)
time.Sleep(2 * time.Second)
blizzard3DPID2ndAttempt := findProcessByExeNameAndCmdLineSubStr("BlizzardBrowser.exe", "type=gpu")
if blizzard3DPID2ndAttempt == 0 {
writeLine("blizzard3DPID not found killing process")
dlg.Text("Browser GPU subprocess was not loaded. Let's repeat it all over again Warcraft III")
blizzardBrowserProcess, _ := process.NewProcess(warcraftProcessPID)
blizzardBrowserProcess.Kill()
continue
}

dlg.Text(fmt.Sprintf("Warcraft III loaded in %v attempts. Please, have fun!", executionAttempts))
dlg.Complete()
robotgo.MaxWindow(warcraftProcessPID)
writeLine(fmt.Sprintf("%v attempts of game execution was made, to wait until gpu renderer will not crash.", executionAttempts))
os.Exit(0)

break
}
gameIsLoadedSuccessfully = true
wg.Wait()
os.Exit(0)
}
20 changes: 20 additions & 0 deletions vendor/github.com/StackExchange/wmi/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions vendor/github.com/StackExchange/wmi/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b9c674

Please sign in to comment.