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 8269561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:16:30+00:00 2026-06-08T06:16:30+00:00

Im trying to get a basic hook going using microsoft detours. My program is

  • 0

Im trying to get a basic hook going using microsoft detours. My program is able to successfully run CreateProcessWithDllEx and inject a dll. However, I cannot seem to resume the actual hooked program. I am using notepad for testing and I can see notepad.exe running in my process list, but the notepad window never actually comes up.

my dll is as follows:

#undef UNICODE
#include <cstdio>
#include <windows.h>
#include <detours.h>
#pragma comment(lib, "detours.lib")

typedef void (WINAPI *pFunc)(void);
DWORD WINAPI MyFunc(void);

pFunc FuncToDetour = (pFunc)DetourFindFunction("Winmm.dll", "timeGetTime"); //Set it at address to detour in 
//the process

extern "C" __declspec( dllexport )VOID NullExport( VOID )
{
}

INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
  switch(Reason)
  {
    case DLL_PROCESS_ATTACH:
    {
        DisableThreadLibraryCalls(hDLL);
        DetourTransactionBegin();
        DetourUpdateThread(GetCurrentThread());
        //DetourAttach(&(PVOID&)FuncToDetour, MyFunc);
        //DetourTransactionCommit();
    }
    break;
    case DLL_PROCESS_DETACH:
          DetourTransactionBegin();
          DetourUpdateThread(GetCurrentThread());
          DetourDetach(&(PVOID&)FuncToDetour, MyFunc);
          DetourTransactionCommit();
    break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH: 
    break;
  }
  return TRUE;
}
DWORD WINAPI MyFunc()
{
   return 0;
}

And my injector is as follows:

#undef _UNICODE
#include "stdafx.h"
#include <cstdio>
#include <windows.h>
#include <detours.h>

int main()
{
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
   ZeroMemory(&si, sizeof(STARTUPINFO));
   ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
   si.cb = sizeof(STARTUPINFO);

   WCHAR DirPath[MAX_PATH+1];
   wcscpy_s(DirPath, MAX_PATH, L"C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2010\\Projects\\hbotinjector\\Release");

   char DLLPath[MAX_PATH+1] = "C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2010\\Projects\\hbotinjector\\Release\\hbotdll.dll";

   WCHAR EXE[MAX_PATH+1]={0};
   wcscpy_s( EXE, MAX_PATH, L"C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2010\\Projects\\hbotinjector\\Release\\notepad.exe" ); 

   STARTUPINFO _StartupInfo;
   PROCESS_INFORMATION _Information;
   ZeroMemory( &_Information, sizeof( PROCESS_INFORMATION ) );  

   if(DetourCreateProcessWithDllEx( EXE, NULL, NULL, NULL, TRUE, 
CREATE_DEFAULT_ERROR_MODE | CREATE_SUSPENDED, NULL, DirPath, &_StartupInfo, &_Information,
     DLLPath, NULL ))
     {
          MessageBoxA(NULL,"INJECTED", NULL, NULL);
          ResumeThread(_Information.hThread);
          WaitForSingleObject(_Information.hProcess, INFINITE);
     }
     else
     {
          char error[100];
          sprintf(error, "%d", GetLastError());
          MessageBoxA(NULL, error, NULL, NULL);
     }

     return 0;
 }

And I build my dll with a .def file, insuring that there is the required function at ordinal 1 for detours to work properly:

LIBRARY HBOTDLL
EXPORTS

NullExport @1

Does anyone know what is causing the process from not running? As a side note, I’ve tried it with a blank dll as well where it just contains the required function at ordinal 1 and nothing else and it seems to have identical results.

Also, my injector runs forever as long as the notepad.exe process is showing in the process list. This is in response to WaitForSingleObject, which seems to indicate the process has been spawned correctly.

  • 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-06-08T06:16:32+00:00Added an answer on June 8, 2026 at 6:16 am

    On the comment of Hans Passant, I went back and realized that I had declared pi and si as well as _Information and _StartupInfo. I wasn’t zeroing out the second group I had created, and that was the group I was using. So I changed the call to CreateProcessWithDllEx to use &pi and &si. Everything works fine now.

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

Sidebar

Related Questions

I've been trying to get a basic program going with the windows API (WinMain
I'm trying to do some basic hooking with microsoft detours and I can't get
Im using xmpp4r and trying to get the hang of a basic chat feature
I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using
I'm trying to figure out how make a basic GET request using Network.HTTP.simpleHTTP that
I am new to Corona and am trying to get some basic OOP going
I've been trying to get to get a basic v8 program working under visual
Mornin', I'm trying to just get basic encryption working using System.Security.Cryptography.RjindaelManaged. I have google
I'm trying to get a basic flip animation transition working when I push a
I'm trying to get a basic datagrid for simple tabular input. The server will

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.