tl;dr
I'm trying to understand the difference of running a program directly via double clicking the executable vs running it through a terminal or programatically via CreateProcess
in windows 10.
long version
Because this is my problem, executing an old game (circa 2003 using D3D8) through double clicking in windows 10 works okay. Executing the game through an seconday executable (also circa 2003) using CreateProcess
seems to sometimes work okay.
But executing it through my new golang executable never works. I get a very tiny screen instead. So I want to understand what's the technical difference.
For reference, my golang code goes like: (tiny screen)
cmd := exec.Command(filepath.Join(".", "Game.exe"))
err := cmd.Start()
Disassembling the secondary executable gives me this: (normal screen)
CPU Disasm
Address Hex dump Command Comments
004043AF |. 51 PUSH ECX ; /pProcessInformation = 59C7F521 -> {hProcess=???,hThread=???,ProcessID=???,ThreadID=???}
004043B0 |. 52 PUSH EDX ; |pStartupInfo => OFFSET LOCAL.16
004043B1 |. 68 28E54000 PUSH OFFSET 0040E528 ; |CurrentDirectory = "."
004043B6 |. 50 PUSH EAX ; |pEnvironment => NULL
004043B7 |. 50 PUSH EAX ; |CreationFlags => 0
004043B8 |. 6A 01 PUSH 1 ; |InheritHandles = TRUE
004043BA |. 50 PUSH EAX ; |pThreadSecurity => NULL
004043BB |. 50 PUSH EAX ; |pProcessSecurity => NULL
004043BC |. 68 10E54000 PUSH OFFSET 0040E510 ; |CommandLine = "Game.exe"
004043C1 |. 50 PUSH EAX ; |ApplicationName => NULL
004043C2 |. FF15 8CB04000 CALL DWORD PTR DS:[<&KERNEL32.CreateProc ; \KERNEL32.CreateProcessA
When I say the game is a tiny screen it shows up like this:
versus this when it is executed directly with double click: (don't mind it being black its just the normal startup)
Additional info: Actually the problem only exists in windows 10. Windows 7 is completely fine.
For windows 10, the only way to make it normal screen is to use this setting:
When that is used, I get the normal screen when using double click or the secondary executable. But its still a tiny screen on my Golang app.
dwXSize
anddwYSize
members of a STARTUPINFO structure? – BioclimatologyCreateProcess[Ex]
gets called in both the cases. – Membranous__COMPAT_LAYER
(e.g. to the value "16BitColor"). This allows propagating the compatibility layer to child processes that inherit the parent's environment variables. You can of course manually add the__COMPAT_LAYER
variable. – BrummellCreateProcessW
isn't writing this shim data in your case when it's set in the registry key "[HKLM|HKCU]\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers". In my test with a debugger and procmon, I can see it query the registry and write the data to the PEBpShimData
in the child process. (It's kind of hacky that they implement this by having the parent process write directly to the PEB of the child. By now they should have migrated this to use a creation attribute that's passed toNtCreateUserProcess
.) – Brummell