Aetopia / NoSteamWebHelper

A program that disables Steam's CEF/Chromium Embedded Framework.
GNU General Public License v3.0
123 stars 6 forks source link

not working anymore or is it just me? #10

Closed veksha closed 7 months ago

Aetopia commented 7 months ago

What's exactly the issue?

Please don't make issues if you don't provide any context.

veksha commented 7 months ago

sorry. context: NoSteamWebHelper does nothing for me. steam launches and webhelper process launches too. same as running steam.exe. no difference.

Steam Beta Branch: Stable Client Steam Version: 1705108172 Steam Client Build Date: Sat, Jan 13 2:54 AM UTC -08:00 Steam Web Build Date: Fri, Jan 12 7:02 PM UTC -08:00 Steam API Version: SteamClient021

Aetopia commented 7 months ago

The webhelper is terminated when an app/game starts up.

veksha commented 7 months ago

I compiled code, debugged and found a reason.

dwSize was 35 for me, so dll name was truncated in memory:

image

35 is the length of "D:\Games\Steam\NoSteamWebHelper.exe" string, because dwSize is the same var that is used for holding length of "NoSteamWebHelper.dll" wide char length and then it gets overwritten with 35 later in code and then used again by WriteProcessMemory with wrong vaule.

if your path has longer length it explains why it was working for you and not working for me. so to reproduce this bug you can temporarily move your steam to "D:\Games\Steam" for example.

Fix:

diff --git a/src/WinMain.c b/src/WinMain.c
index 25ee536..a83fbd4 100644
--- a/src/WinMain.c
+++ b/src/WinMain.c
@@ -7,7 +7,7 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
   HANDLE hProcess = GetCurrentProcess();
   WCHAR *lpExeName = NULL;
   DWORD cbData = 0,
-        dwSize = sizeof(WCHAR) * (wcslen(L"NoSteamWebHelper.dll") + 1);
+        dwSize = 0;
   SHELLEXECUTEINFOW sei = {.cbSize = sizeof(SHELLEXECUTEINFOW),
                            .lpParameters = lpCmdLine,
                            .lpFile = L"steam.exe",
@@ -38,6 +38,7 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
   }

   (VOID) ShellExecuteExW(&sei);
+  dwSize = sizeof(WCHAR) * (wcslen(L"NoSteamWebHelper.dll") + 1);
   lpBaseAddress = VirtualAllocEx(sei.hProcess, NULL, dwSize, MEM_COMMIT, PAGE_READWRITE);
   (VOID) WriteProcessMemory(sei.hProcess, lpBaseAddress, L"NoSteamWebHelper.dll", dwSize, NULL);
   (VOID) CloseHandle(CreateRemoteThread(sei.hProcess, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryW, lpBaseAddress, 0, NULL));
Aetopia commented 7 months ago

Feel free to submit a PR which fixes this issue, if you desire.