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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:19:46+00:00 2026-05-18T09:19:46+00:00

What can be a reason? From DllMain() on DLL_PROCESS_ATTACH I’m calling IDirect3D9::CreateDevice() and it

  • 0

What can be a reason?

From DllMain() on DLL_PROCESS_ATTACH I’m calling IDirect3D9::CreateDevice() and it hangs

code is straightforward, just like:

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    if (ul_reason_for_call = DLL_PROCESS_ATTACH) {
        IDirect3D9* d3d = Direct3DCreate9(D3D_SDK_VERSION);

        D3DPRESENT_PARAMETERS pp = {};
        pp.BackBufferWidth = 1;
        pp.BackBufferHeight = 1;
        pp.BackBufferFormat = D3DFMT_X8R8G8B8;
        pp.BackBufferCount = 1;
        pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
        pp.Windowed = TRUE;

        IDirect3DDevice9* device = NULL;
        HRESULT hr = d3d->CreateDevice(
            D3DADAPTER_DEFAULT, 
            D3DDEVTYPE_HAL, 
            GetDesktopWindow(), 
            D3DCREATE_HARDWARE_VERTEXPROCESSING, 
            &pp, 
            &device);

        device->Release();
        d3d->Release();
    }
    return TRUE;
}

GetDesktopWindow() is used for simplicity, I tried to create own window and use it, the same result

  • 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-18T09:19:47+00:00Added an answer on May 18, 2026 at 9:19 am

    You cannot do these kind of things in DllMain. Specifically, you cannot call functions from other DLLs. You can only do this from an exported function, when it is called by the main application.

    Quoting the docs on MSDN:

    Threads in DllMain hold the loader lock so no additional DLLs can be dynamically loaded or initialized.

    Calling functions that require DLLs other than Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions load other system components.

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

Sidebar

Related Questions

anybody knows what can be the reason for when i start a service from
For some reason I can't find any results from my valid index of 3552
For some reason I can not remove an event handler from the FileSystemWatcher. This
This seems like it should be quite simple, but for some reason I can't
For some reason I can't find a way to get the equivalents of sqlite's
For some reason I can't use runat=server as an attribute for the input tag
For some reason I can't hide WPF Toolkit's DataGridColumn. I am trying to do
For some reason I can't get this script to run when I add the
For some reason i can't get the variable 'total' to define at all... I
I'm thinking that the reason I can't do this is because it might be

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.