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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:13:59+00:00 2026-05-27T05:13:59+00:00

I am trying to hook a function to cmd.exe process the dll is injected

  • 0

I am trying to hook a function to cmd.exe process
the dll is injected just fine the problem is i can’t get the cmd.exe to call my function
when im trying to enter the word “dir” on the command prompt it’s showing me the same results instade of changing the first name to ‘dan’
what am i doing wrong?

HANDLE WINAPI newFindFirstFileA(__in   LPCTSTR lpFileName, __out  LPWIN32_FIND_DATA lpFindFileData) 
{
    WIN32_FIND_DATA FindFileData;
    HANDLE hFind = FindFirstFile(lpFileName, &FindFileData);
    *FindFileData.cFileName = L'Dan';
    lpFindFileData = &FindFileData;
    return hFind;
}


BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    switch (reason)
    {
        case DLL_PROCESS_ATTACH:
        MessageBox(NULL,L"DLL Was injected!", L"Message" ,NULL);

        /* Hooking function */
        DWORD* dw = (DWORD*)GetProcAddress( GetModuleHandleA("kernel32.dll"), "FindFirstFileA" );
        *dw = (DWORD)newFindFirstFileA;
        break;
    }  

    /* Returns TRUE on success, FALSE on failure */
    return TRUE;
}
  • 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-27T05:13:59+00:00Added an answer on May 27, 2026 at 5:13 am

    GetProcAddress does not return the pointer to IAT entry. Instead, it returns the location of the actual function. Thus, *dw = (DWORD) newFindFirstFileA would overwrite the prolog of the FindFirstFileA function, which would be disastrous. Refer to this article for detailed explanation for hooking an API

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

Sidebar

Related Questions

How can I cast WIN32_FIND_DATA to LPVOID? I am trying to hook a function
Trying to hook into the function comment_text() supplied by Wordpress API to wrap the
Can we use the addTarget function to hook into the UIControlEventTouchUpInside event with the
I'm trying to add a function I created to a hook, but the obvious
I have this hook function that works fine on x86. Thanks to Bo Persson.
I'm trying to hook the sys_execve() function on the Linux 3.x kernel by modifying
I'm in the process of trying to hook StructureMap in to an existing webforms
I've been trying to write a DLL in C. Install hook sets up the
I was trying to hook a custom recv() winsock2.0 method to a remote process,
I've been trying to properly hook/detour a virtual function in a class object, and

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.