Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue reading game version #62

Open
ssetaiLe opened this issue Feb 9, 2021 · 11 comments
Open

Issue reading game version #62

ssetaiLe opened this issue Feb 9, 2021 · 11 comments

Comments

@ssetaiLe
Copy link

ssetaiLe commented Feb 9, 2021

java.io.IOException: null; ��	at net.moonlightflower.wc3libs.bin.GameExe.getVersionString(GameExe.java:68)
	at net.moonlightflower.wc3libs.bin.GameExe.getVersion(GameExe.java:77)
	at de.peeeq.wurstio.utils.W3InstallationData.lambda$new$0(W3InstallationData.java:48)
	at java.util.Optional.flatMap(Unknown Source)
	at de.peeeq.wurstio.utils.W3InstallationData.<init>(W3InstallationData.java:46)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.getBestW3InstallationData(MapRequest.java:380)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.<init>(MapRequest.java:75)
	at de.peeeq.wurstio.languageserver.requests.RunMap.<init>(RunMap.java:51)
	at de.peeeq.wurstio.languageserver.WurstCommands.startmap(WurstCommands.java:108)
	at de.peeeq.wurstio.languageserver.WurstCommands.execute(WurstCommands.java:51)
	at de.peeeq.wurstio.languageserver.WurstWorkspaceService.executeCommand(WurstWorkspaceService.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Feb 09, 2021 10:10:44 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SCHWERWIEGEND: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: de.peeeq.wurstio.languageserver.requests.RequestFailedException: Could not find Warcraft III installation at specified path: Optional[C:\Program Files\Warcraft III]
	at de.peeeq.wurstio.languageserver.requests.MapRequest.getBestW3InstallationData(MapRequest.java:382)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.<init>(MapRequest.java:75)
	at de.peeeq.wurstio.languageserver.requests.RunMap.<init>(RunMap.java:51)
	at de.peeeq.wurstio.languageserver.WurstCommands.startmap(WurstCommands.java:108)
	at de.peeeq.wurstio.languageserver.WurstCommands.execute(WurstCommands.java:51)
	at de.peeeq.wurstio.languageserver.WurstWorkspaceService.executeCommand(WurstWorkspaceService.java:42)
	... 16 more


@WaterKnight
Copy link
Contributor

Not sure. Could be that you/wurst have given the wrong file it tries to get the version from, the game changed something or it is OS-related (not on Windows?). The dorkbox portable executable parser fails there, the fallback uses the Windows wmic.exe to get the version from the portable executable but only receives gibberish as you see above, which it cannot parse as an integer.

@Frotty
Copy link
Member

Frotty commented Mar 19, 2021

I encountered this too and had to change my path to include _retail_\\x86_64 otherwise it would not work.

@Frotty
Copy link
Member

Frotty commented Mar 25, 2021

@Cokemonkey11

java.io.IOException: null; ��	at net.moonlightflower.wc3libs.bin.GameExe.getVersionString(GameExe.java:68)
	at net.moonlightflower.wc3libs.bin.GameExe.getVersion(GameExe.java:77)
	at de.peeeq.wurstio.utils.W3InstallationData.lambda$new$0(W3InstallationData.java:48)
	at java.util.Optional.flatMap(Optional.java:241)
	at de.peeeq.wurstio.utils.W3InstallationData.<init>(W3InstallationData.java:46)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.getBestW3InstallationData(MapRequest.java:380)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.<init>(MapRequest.java:75)
	at de.peeeq.wurstio.languageserver.requests.RunMap.<init>(RunMap.java:51)
	at de.peeeq.wurstio.languageserver.WurstCommands.startmap(WurstCommands.java:108)
	at de.peeeq.wurstio.languageserver.WurstCommands.execute(WurstCommands.java:51)
	at de.peeeq.wurstio.languageserver.WurstWorkspaceService.executeCommand(WurstWorkspaceService.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Mar 25, 2021 10:37:14 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
SEVERE: Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:67)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	... 11 more
Caused by: de.peeeq.wurstio.languageserver.requests.RequestFailedException: Could not find Warcraft III installation at specified path: Optional[C:\Games\Warcraft III]
	at de.peeeq.wurstio.languageserver.requests.MapRequest.getBestW3InstallationData(MapRequest.java:382)
	at de.peeeq.wurstio.languageserver.requests.MapRequest.<init>(MapRequest.java:75)
	at de.peeeq.wurstio.languageserver.requests.RunMap.<init>(RunMap.java:51)
	at de.peeeq.wurstio.languageserver.WurstCommands.startmap(WurstCommands.java:108)
	at de.peeeq.wurstio.languageserver.WurstCommands.execute(WurstCommands.java:51)
	at de.peeeq.wurstio.languageserver.WurstWorkspaceService.executeCommand(WurstWorkspaceService.java:42)
	... 16 more

@Cokemonkey11
Copy link
Contributor

@Frotty @ssetaiLe are either of you able to provide full logs? I would like to see this one for example, but full dump would be appreciated

https://github.com/wurstscript/WurstScript/blob/master/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/utils/W3InstallationData.java#L44

@Cokemonkey11
Copy link
Contributor

When a runmap request is sent from vscode:

I propose making the following changes:

  1. Add info-level logs to wc3libs GameExe.java to distinguish dorkbox vs WMIC results
  2. Improve error handling when WMIC approach fails (this exception's message just contains null)
  3. Extract backup WMIC method for clarity
  4. Instrument dorkbox PE with retry policy

Cokemonkey11 added a commit to Cokemonkey11/wc3libs that referenced this issue Mar 28, 2021
Frotty added a commit that referenced this issue Mar 28, 2021
#62: info-level logs for game exe version parsing
Cokemonkey11 added a commit to Cokemonkey11/wc3libs that referenced this issue Mar 28, 2021
@WaterKnight
Copy link
Contributor

@Cokemonkey11 @Frotty Can this be closed?

@Frotty
Copy link
Member

Frotty commented Jul 16, 2022

Nope, still happening.

@Cokemonkey11
Copy link
Contributor

Current status seems to be:

  1. info logs for distinguishing game version data query engine is merged
  2. More detailed exception is now thrown on failure
  3. Dependencies on PeParser have been updated

What is the latest error message @ssetaiLe ?

@Luashine
Copy link
Contributor

Luashine commented Oct 5, 2022

When I tried to reenable GameExeTest, it throws an exception on my system. Looking into it, it tries the Wc3Entry PROGRAM = new Wc3Entry("Program", EntryType.REG_SZ) entry that I've never seen before in my registry.

Gradle suite > Gradle test > wc3libs.bin.GameExeTest > extractGameVersionTest STANDARD_ERROR
    net.moonlightflower.wc3libs.port.NotFoundException
	    at net.moonlightflower.wc3libs.port.win.registry.WinRegistryGameExeFinder.find(WinRegistryGameExeFinder.java:22)
	    at net.moonlightflower.wc3libs.port.win.registry.WinRegistryGameExeFinder.find(WinRegistryGameExeFinder.java:12)
	    at net.moonlightflower.wc3libs.port.Finder.get(Finder.java:25)
	    at wc3libs.bin.GameExeTest.extractGameVersionTest(GameExeTest.java:30)

The only key I've ever seen is HKEY_CURRENT_USER\Software\Blizzard Entertainment\Warcraft III\InstallPath and InstallPathX for TFT. After installing v1.0 ROC from CD I see "Program"="C:\\war3\\Warcraft III\\Warcraft III.exe" but this path is not set in registry if you launch a game from files without an installation, and in fact, I don't have it here.

Why is the .exe not autodetected based on InstallPath? Can I rewrite this?

ROC v1.0 registry after installation
Warcraft3-ROC-v1.0-fresh.reg.txt

GameExe Test code

    try {
        File gameExeFile = new WinRegistryGameExeFinder().get(); // NotFoundException

        GameVersion gameVersion = GameExe.getVersion(gameExeFile);
        String versionStr = gameVersion.toString();
        System.out.println(versionStr);

        Pattern majorMinorRegex = Pattern.compile("^\\d+\\.\\d+");

        // Pre-Reforged and Reforged exe: "1.29.1234"
        // Classic exe: "1.0.0.1"
        // ROC Beta exe: "200.0.0.3627"
        Matcher m = majorMinorRegex.matcher(versionStr);
        assertTrue(m.find(), "Could not match game exe version, got: '" + gameVersion + "'");
        log.info("Game version extracted: " + gameVersion);

    } catch (NotFoundException e) {
        e.printStackTrace();
    }

@WaterKnight
Copy link
Contributor

When I tried to reenable GameExeTest, it throws an exception on my system. Looking into it, it tries the Wc3Entry PROGRAM = new Wc3Entry("Program", EntryType.REG_SZ) entry that I've never seen before in my registry.


The only key I've ever seen is `HKEY_CURRENT_USER\Software\Blizzard Entertainment\Warcraft III\InstallPath` and `InstallPathX` for TFT. After installing v1.0 ROC from CD I see `"Program"="C:\\war3\\Warcraft III\\Warcraft III.exe"` but this path is not set in registry if you launch a game from files without an installation, and in fact, I don't have it here.

Why is the .exe not autodetected based on `InstallPath`? Can I rewrite this?

I think I used the PROGRAM entry because it directly pointed to the game executable file rather than just the directory. But yeah, I just tested/based it on my local setup, have not tried it on a fresh installation. A problem is of course that it's partially different in different game versions.

@Luashine
Copy link
Contributor

While I continue digging for old versions, here's the CDN data for legacy->battlenet-distributed transition (with v1.28). The takeaway from it: the only official method is to use InstallPath. That's how the modern team did it.

https://github.com/mdX7/ngdp_data/blob/master/US/war3/blob/game

		"product": "War3",
		"register_game_info": {
			"registry_info": {
				"flags": 4,
				"key": "Warcraft III",
				"value": "InstallPath"
			},
			"uid_format_string": "war3",
			"valid_uids": [
				"war3"
			]
		},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants