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

  • SEARCH
  • Home
  • 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 6475069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:39:41+00:00 2026-05-25T06:39:41+00:00

I have a dll that I injected in a process. It searches ‘file://’ until

  • 0

I have a dll that I injected in a process. It searches ‘file://’ until it finds invalid symbol. After a few mins it crashes the main process. Why is that? How can I check? I found that with smaller stack size on CreateThread it crashes faster, so it can be somehow stack overflow, but I’m not allocating nothing, but a single struct.

BOOL APIENTRY DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:

        CreateThread(NULL, 500, SampleFunction, 0, 0, NULL);            
            break;

        case DLL_THREAD_ATTACH:

            break;

        case DLL_THREAD_DETACH:
            break;

        case DLL_PROCESS_DETACH:
            break;
    }

    /* Return success */
    return TRUE;
}



int Send(char* strDataToSend) {
    HWND hWnd = FindWindow(NULL, "Test");
    if (hWnd) {
        COPYDATASTRUCT cpd;
        cpd.dwData = 0;
        cpd.cbData = (strlen(strDataToSend) + 1) * 2;
        cpd.lpData = (PVOID)strDataToSend;
        SendMessage(hWnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM)&cpd);
    }
}

int isurl(char c) {
    char* chars = "-._~:/?#[]@!$&'()*+,;=%";
    for(int i = 0; i < strlen(chars); i++) {
        if (chars[i] == c || isalnum(c)) {
            return 1;
        }           
    }

    return 0;
}

TESTDLLMAPI void WINAPI SampleFunction(void) {
    MessageBox(0,"LOADED !",0,0);
    MEMORY_BASIC_INFORMATION info;  
    MEMORY_BASIC_INFORMATION* pinfo = &info;

    while(1) {


    int cnt = 0;
    unsigned long addr = 0;
    do {
        ZeroMemory(&info, sizeof(info));

        if (!VirtualQueryEx(GetCurrentProcess(), (LPCVOID) addr, pinfo, sizeof(info))) {
            //MessageBox(0,"FAILED",0,0);
        }       

            if (info.State == 0x1000) {
            if (info.Protect == PAGE_READONLY || info.Protect == PAGE_READWRITE) {
                __try {

                if (info.RegionSize < 128) continue;

                for(long i = 0; i < info.RegionSize - 10; i+=7) {

                char* buff = info.BaseAddress;
                    if (buff[i] == 'f' && buff[i+1] == 'i' && buff[i+2] == 'l' && buff[i+3] == 'e' && buff[i+4] == ':' && buff[i+5] == '/' && buff[i+6] == '/') {

                        long start = i;
                        long end   = start+7;

                        while(end < info.RegionSize - 10 && isurl(buff[end])) end++; 

                        int len = end - start + 1;
                        char* test = (char*) calloc(len, 1);
                        //memcpy(test, buff+start, len);
                        int k = 0;
                        for (int j = start; j <= end; j++, k++) {
                            test[k] = buff[j];
                        }


                            Send(test);
                                                    free(test); 
                            cnt++;      
                        }

                    }
                } __finally {}
            }
        }

        addr = (unsigned long) info.BaseAddress + (unsigned long) info.RegionSize;
    } while (addr != 0 && addr < 0x7FFF0000);

    Sleep(1000);

}
  • 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-25T06:39:42+00:00Added an answer on May 25, 2026 at 6:39 am

    In your Send function you’re setting the buffer size to the length of the string x2 but you are passing the data in a pointer to a char, which is one byte.


    A few more tips:

    • You’re reading memory in increments of 7 at a time. There are two problems with this:
      • as an example, what if the end of info.RegionSize - 10 is at 500000, and i = 499999? You’ll read 6 bytes past which will cause a crash.
      • "file://" isn’t necessarily going to be found at a place in memory with an address that is a multiple of 7. If you happen to be testing “123file://….” then you’ll simply miss it, because you’ll find “123file” and “://….”
    • VirtualQueryEx(GetCurrentProcess(), ... is redundant. Just use VirtualQuery.
    • You’re calling VirtualQuery with the address 0.
    • There is a much easier way to perform the string-comparison you are trying to accomplish – strstr.
    • Is it just me or is that do/while an infinite loop?
    • Your function isn’t even closed.
    • I can’t see what purpose cnt is supposed to serve.
    • You created a thread in DllMain. you should close handles to threads with CloseHandle once you’re no longer going to use them (in this case, i.e. right after you’ve created it)

    I rewrote your SampleFunction for you. I wrote the on the go and it probably won’t compile, but you should get the general idea.

    #include <windows.h>
    
    BOOL IsPageReaable(PMEMORY_BASIC_INFORMATION pmbi)
    {
      if (pmbi->Protect & PAGE_GUARD)
        return FALSE;
    
      if (pmbi->Protect &
        (PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE
        | PAGE_EXECUTE_WRITECOPY | PAGE_READONLY
        | PAGE_READWRITE | PAGE_WRITECOPY))
        return TRUE;
    
      return FALSE;
    }
    
    #define POLL_INTERVAL 1000
    
    TESTDLLMAPI VOID WINAPI SampleFunction(VOID)
    {
      MEMORY_BASIC_INFO mbi;
      ULONG_PTR         ulAddress = GetModuleHandle(NULL); // base address
      LPSTR             lpszBase;
    
      ZeroMemory(&mbi, sizeof(mbi));
      if (!VirtualQuery(ulAddress, &mbi, sizeof(mbi)))
        return;
    
      if (!IsPageReadable(&mbi))
        return;
    
      lpszBase = info.BaseAddress;
      for (;; Sleep(POLL_INTERVAL))
      {
        for (ULONG_PTR i = 0; i < info.RegionSize; i++)
        {
          int   j;
          LPSTR lpszBuffer;
    
          if (strstr(&lpszBase[i], "file://") == NULL)
            continue;
    
          j = i + 1;
          do {
            j++;
          } while (j < info.RegionSize && isurl(lpszBase[j])
    
          lpszBuffer = (LPSTR)HeapAlloc(GetProcessHeap, HEAP_ZERO_MEMORY, sizeof(CHAR) * (j - i + 1));
          if (lpszBuffer != NULL)
          {
            CopyMemory(lpszBuffer, &lpszBase[i], j - i);
            Send(lpszBuffer);
            HeapFree(GetProcessHeap(), 0, lpszbuffer);
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have to inject a dll into some process .now i want that after
I have a simple dll that is being injected into a target process using
I have c++ dll that i am converting to c++/cli. After setting /clr compiler
I have a .dll injected into the address space of another process. The target
I have injected a managed .NET DLL into a .NET process. I've seen some
I have an DLL that has this in its h file: extern C __declspec(dllexport)
I have a DLL that contains all my object I need to build my
I have a DLL that is written in C++ and I want to suppress
I have a DLL that I can use to pull the following information about
I have a DLL that's compiled, and I don't have the source code for

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.