Executing injected code on main thread menu

User Tag List

Results 1 to 1 of 1
  1. #1
    mozartmclaus's Avatar Private
    Reputation
    6
    Join Date
    May 2012
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Executing injected code on main thread

    Ok, no I have working DLL injector. Injection and function calls are all besed on CreateRemoteThread.
    Notepad's.exe anticheating protection didn't notice anything
    Later I will set up IPC communication and may be build C# wrapper around this thing.

    The problem with CreateRemoteThread is its overhead and danger of interference with the other threads.
    Of cource I can create permanent thread, which will process my IPC messages when it's in the signaled state, so the overhead isn't really big problem.
    The second problem I realized (thanks to forum members) that I will need to call at least some functions on the remoe main thread as they will
    need TLS of the main.

    Now im looking for a elegant way to do this. Here are some variants

    1) Suspend main thread, store context, resume on my code, when finished restore context and continue it as if nothing happened.
    This is very dangerous, it will either corrupt the data or run into deadlock sooner or later.

    2) Eventually I may install thread local hook (SetWindowsHookEx, WH_CALLWNDPROC).
    Do you know if the hook will be executed on the main thread (assuming its in the same virtual address space and is set up for the main thread).
    If not i can forget this option.

    3) Hook some of the remote functions (I rememeber EndScene was mentioned) via small stub routine.
    This will make sure that my code is not executed concurrent to main thread and should keep the data safe.
    However i will need to modify code section, I think such modification can be easily detected by simple CRC check, and probably will be (warden).

    4) Eventually it may be possible to highjack context (and TLS) of the main thread and execute my own thread with this context.
    Even if the function execute corrent, I may loose the changes if they are TLS specific, as I will need to throw my copy of TLS away when im finished.

    Would be great to hear your ideas, may be even small code snippets.
    It's long time ago that I programmed assembler and native C, but the skills come back fast.
    My previous progect was reversing Flash based online RPG game.
    However in flash its much easier to get readable source code and inject your code into target process.
    Last edited by mozartmclaus; 05-23-2012 at 05:48 PM.

    Executing injected code on main thread

Similar Threads

  1. Do LUA addons execute in Wow's main thread?
    By ggg898 in forum WoW Memory Editing
    Replies: 15
    Last Post: 01-12-2020, 01:32 PM
  2. Injecting code to main thread
    By kajko in forum WoW Memory Editing
    Replies: 4
    Last Post: 05-11-2015, 05:48 PM
  3. [Internal] Executing from the main thread without detours
    By Jadd in forum Wildstar Memory Editing
    Replies: 5
    Last Post: 07-09-2014, 10:01 PM
  4. [Bot] Injection code into wow. Do you have to call functions from the main thread?
    By Miivers in forum World of Warcraft Bots and Programs
    Replies: 2
    Last Post: 01-13-2014, 02:56 PM
  5. Bugs when injecting code
    By bigtimt in forum WoW Memory Editing
    Replies: 4
    Last Post: 10-03-2008, 05:33 AM
All times are GMT -5. The time now is 06:29 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search