Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 258371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:10:30+00:00 2026-05-11T22:10:30+00:00

So I’ve got an application that starts another application with my DLL injected (with

  • 0

So I’ve got an application that starts another application with my DLL injected (with Detours). The entry point is DllMain. I can’t do much from DllMain, and certainly cannot loop. So how do I call my DLL monitor functions every x seconds? I read you cannot create a thread from DllMain (at least until it returns) and its true because it crashed me. So I tried creating it in the attach thread event and it crashed me. So now what I’m trying to do is inject it again (incase Detours fails) so I can get the module handle. Then I get the address of an initializer function which creates my thread. I get the module handle fine, but I don’t think I can get the function address. I made the function empty, and it still crashed me. So it doesn’t even get as far as calling the function. Visual Studio said I have no read access.

So what am I suppose to do? What do you do to loop your DLL functions when you don’t own the attached program (exe).

//Application.exe
STARTUPINFO si = {sizeof(STARTUPINFO)};
        PROCESS_INFORMATION pi = {0};

        DetourCreateProcessWithDll(filename, NULL, NULL, NULL, TRUE, 
                                    CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED, NULL, path,
                                    &si, &pi, detoured, hook, NULL);

        processID = pi.dwProcessId;

        hDll = InjectDLL(processID, hook);


if(hDll != NULL)
{
STARTER Starter = (STARTER)GetProcAddress(hDll, "Starter");

if(Starter != NULL)
    Starter();
}

        ResumeThread(pi.hThread);

The function Starter is extern C exported and looks fine inspected (it’s ordinal 1).

I have no idea what could possibly be wrong, and merely hope someone out there has had experience with this topic and crashing.

Here’s the DLL code:

//Hook.h
extern "C"
{
    void __declspec(dllexport) Starter(void);
}

//Hook.cpp
void Starter(void)
{

}

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:10:30+00:00Added an answer on May 11, 2026 at 10:10 pm

    You can’t do it that way because the DLL is injected into a different process and you’re trying to execute the function in the address space of your hooking process.

    What you’ll have to do is call CreateRemoteThread, passing in the address that you get from GetProcAddress in the lpStartAddress parameter. This will create a new thread on the remote process, and execute the function in the address space of that process, in the context of the new thread.

    BTW, technically you should be able to create a new thread in DllMain/DLL_PROCESS_ATTACH, as long as you’re not doing any synchronizing with other threads, though it’s not recommended. I’m not sure what issues might exist if doing this when the DLL is being injected though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 181k
  • Answers 181k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I can't really see that there should be a problem… May 12, 2026 at 4:12 pm
  • Editorial Team
    Editorial Team added an answer Your byte array must have some encoding. The encoding cannot… May 12, 2026 at 4:12 pm
  • Editorial Team
    Editorial Team added an answer There are quite a few Unicode-only languages. Georgian is one… May 12, 2026 at 4:12 pm

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have text I am displaying in SIlverlight that is coming from a CMS
I have a French site that I want to parse, but am running into
In order to apply a triggered animation to all ToolTip s in my app,
So I'm getting a new job working with databases (Microsoft SQL Server to be

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.