Solved svchost.exe cannot create window

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

XdarionX

Dying Light Hacker
Dank Tier VIP
Dank Tier Donator
Mar 30, 2018
847
23,408
114
Game Name
N/A
Anticheat
N/A
Tutorial Link
N/A
How long you been coding/hacking?
3 years
Coding Language
c++
Hello,
i have been just trying some random stuff around and i found out that if i inject a dll into svchost.exe and try to create a window, the function succeeds but no window is being created. same dll i have injected in process created by regular user and it worked. Im building it x64 Release and injecting as admin. I have tried debugging it but all functions returned success. also i found out that i cannot create message box. (nothing happens) do someone know why i cannot create the window inside svchost? thanks
C++:
LRESULT WINAPI OverlayAPI(HWND WindowHandle, UINT Message, WPARAM WP, LPARAM LP) {
    return DefWindowProcW(WindowHandle, Message, WP, LP);
}

DWORD WINAPI MainThread(LPVOID hModule) {

    DWORD Width = 1920;
    DWORD Height = 1080;

    LPWSTR Caption = L"My Caption";
    WNDCLASSEX MyClass;
    MyClass.cbClsExtra = NULL;
    MyClass.cbSize = sizeof(WNDCLASSEX);
    MyClass.cbWndExtra = NULL;
    MyClass.hbrBackground = CreateSolidBrush(NULL);
    MyClass.hCursor = LoadCursorW(NULL, IDC_ARROW);
    MyClass.hIcon = LoadIconW(NULL, IDI_APPLICATION);
    MyClass.hIconSm = LoadIconW(NULL, IDI_APPLICATION);
    MyClass.hInstance = NULL;
    MyClass.lpfnWndProc = OverlayAPI;
    MyClass.lpszClassName = Caption;
    MyClass.lpszMenuName = Caption;
    MyClass.style = CS_VREDRAW | CS_HREDRAW;

    RegisterClassExW(&MyClass);

    HWND hwnd = CreateWindowExW(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_LAYERED, Caption, Caption, WS_POPUP, NULL, NULL, Width, Height, NULL, NULL, NULL, NULL);

    SetLayeredWindowAttributes(hwnd, NULL, NULL, LWA_COLORKEY);
    ShowWindow(hwnd, SW_SHOW);

    SetPixel(GetDC(hwnd), 1, 1, RGB(255, 0, 0));

    MSG msg;
    while (GetMessageW(&msg, NULL, NULL, NULL) > NULL) {
        TranslateMessage(&msg);
        DispatchMessageW(&msg);

        Sleep(10);
    }

    return NULL;
}

DWORD WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) {

    if (dwReason == DLL_PROCESS_ATTACH)
        CreateThread(NULL, NULL, MainThread, hModule, NULL, NULL);

    return TRUE;
}
 

timb3r

Semi-Retired
Dank Tier VIP
Jul 15, 2018
765
24,668
47
Windows Service applications run in a different window station than the interactive station of the logged-on user. A window station is a secure object that contains a Clipboard, a set of global atoms, and a group of desktop objects. Because the station of the Windows service is not an interactive station, dialog boxes raised from within a Windows service application will not be seen and may cause your program to stop responding. Similarly, error messages should be logged in the Windows event log rather than raised in the user interface.
https://docs.microsoft.com/en-us/do.../introduction-to-windows-service-applications
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
Timb3rs got it, but just to illustrate, using Process Hacker you can see which session things are in

For starters, services and other system processes are in cyan/baby blue
And if i check the token tab of a service like svchost we see:



compared to a regular program:

 
  • Like
Reactions: XdarionX

timb3r

Semi-Retired
Dank Tier VIP
Jul 15, 2018
765
24,668
47
Going a bit further the reason Microsoft made this change was it was common for programs running with system level privileges to create windows i.e antivirus programs. The issue was that a window has to be intractable by the user so it was possible to use something known as a shatter attack to force a privileged program to execute your code.

I used this technique back in the XP days to gain access to the sam file and dump the domain administrator credentials from a local unprivileged user (thanks symantec).
 
  • Like
Reactions: XdarionX and Rake
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods