Official eMule-Board: Fix For Title Menu - Official eMule-Board

Jump to content


Page 1 of 1

Fix For Title Menu fix multiple loading of msimg32.dll

#1 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 14 October 2005 - 12:36 PM

following Wiz memleak thread & my suggestment,
here's the fix for the title menu multiple loading of the
msimg32.dll library that might cause this issue
(or this will at least reduce memory usage and function call)

note that i haven't compiled the code yet but it should work
(since it's based on my improved MiniMule code & the api used in Title Menu)

Quote

...
  typedef UINT (WINAPI* LPFNGRADIENTFILL)(HDC, CONST PTRIVERTEX, DWORD, CONST PVOID, DWORD, DWORD); // Avi3k: fix & improve code
...
protected:
...
  // Avi3k: fix & improve code
  //typedef UINT (WINAPI* LPFNGRADIENTFILL)(HDC, CONST PTRIVERTEX, DWORD, CONST PVOID, DWORD, DWORD);
  static LPFNGRADIENTFILL m_pfnGradientFill;
  //HINSTANCE m_hLibMsimg32;
  // end Avi3k: fix & improve code
...


Quote

...
bool    CTitleMenu::m_bInitializedAPI = false;
LPFNGRADIENTFILL CTitleMenu::m_pfnGradientFill = NULL; // Avi3k: fix & improve code
...
CTitleMenu::CTitleMenu() {
...
  m_clText = ::GetSysColor(COLOR_CAPTIONTEXT);

  // Avi3k: fix & improve code
  if (!g_bLowColorDesktop && !m_pfnGradientFill)
  {
      m_pfnGradientFill = (LPFNGRADIENTFILL)GetProcAddress(GetModuleHandle(_T("msimg32")), "GradientFill");
  }
  // end Avi3k: fix & improve code


  m_bDrawEdge = false;
...
}
...
CTitleMenu::~CTitleMenu()
{
  // Avi3k: fix + improve code
  //if (m_hLibMsimg32)
  //  FreeLibrary(m_hLibMsimg32);
  // end Avi3k: fix + improve code

}
...


blue = add, red = comment out or remove, green = modify

if anyone can test and verify, please do so... thanx...

Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#2 User is offline   SlugFiller 

  • The one and only master slug
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 6,988
  • Joined: 15-September 02

Posted 14 October 2005 - 01:19 PM

Hmm... The library is never freed. Maybe a ref-count, or a static member that does the load/unload at constructor/destructor?
Why haven't you clicked yet?

SlugFiller rule #1: Unsolicited PMs is the second most efficient method to piss me off.
SlugFiller rule #2: The first most efficient method is unsolicited eMails.
SlugFiller rule #3: If it started in a thread, it should end in the same thread.
SlugFiller rule #4: There is absolutely no reason to perform the same discussion twice in parallel, especially if one side is done via PM.
SlugFiller rule #5: Does it say "Group: Moderators" under my name? No? Then stop telling me about who you want to ban! I really don't care! Go bother a moderator.
SlugFiller rule #6: I can understand English, Hebrew, and a bit of Japanese(standard) and Chinese(mandarin), but if you speak to me in anything but English, do expect to be utterly ignored, at best.
0

#3 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 14 October 2005 - 05:32 PM

@Slug
look at the api functions in Title Menu at the bottom,
they call the user32.dll with GetModuleHandle() without
freeing it (just calling without reference to the handle again)
and it works ok, and afaik there aren't any errors...

it should work, though if u'r not sure, u can always
move the calls from the c'tor to CTitleMenu::DrawItem()
(i did the same in MiniMule and it works like a charm ;) )

Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#4 User is offline   SlugFiller 

  • The one and only master slug
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 6,988
  • Joined: 15-September 02

Posted 14 October 2005 - 05:49 PM

Hmm... From MSDN:

Quote

The GetModuleHandle function retrieves a module handle for the specified module if the file has been mapped into the address space of the calling process.

Quote

The GetModuleHandle function returns a handle to a mapped module without incrementing its reference count.

Works for me.
Why haven't you clicked yet?

SlugFiller rule #1: Unsolicited PMs is the second most efficient method to piss me off.
SlugFiller rule #2: The first most efficient method is unsolicited eMails.
SlugFiller rule #3: If it started in a thread, it should end in the same thread.
SlugFiller rule #4: There is absolutely no reason to perform the same discussion twice in parallel, especially if one side is done via PM.
SlugFiller rule #5: Does it say "Group: Moderators" under my name? No? Then stop telling me about who you want to ban! I really don't care! Go bother a moderator.
SlugFiller rule #6: I can understand English, Hebrew, and a bit of Japanese(standard) and Chinese(mandarin), but if you speak to me in anything but English, do expect to be utterly ignored, at best.
0

#5 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 14 October 2005 - 08:16 PM

@Slug
if it works for u, then everything is ok :)
when i read the info on msdn earlier i wasn't really sure,
but the code in eMule itself in other parts reassured me.

Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#6 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 15 October 2005 - 09:22 PM

i've compiled the code and it works great
(didn't get any errors, though i ran it without debugging)

Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#7 User is offline   CiccioBastardo 

  • Doomsday Executor
  • PipPipPipPipPipPipPip
  • Group: Italian Moderators
  • Posts: 5,541
  • Joined: 22-November 03

Posted 15 October 2005 - 09:57 PM

Had to add this:

Quote

//m_hLibMsimg32 = NULL;

in CTitleMenu::CTitleMenu

Now goig to test it.

Thanks
The problem is not the client, it's the user
0

#8 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 15 October 2005 - 10:22 PM

yeah, i marked the code in green to note it needs
to be changed (that includes the entire condition)

thanx for testing, u'r welcome :flowers:

Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#9 User is offline   SlugFiller 

  • The one and only master slug
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 6,988
  • Joined: 15-September 02

Posted 15 October 2005 - 11:56 PM

Important thought: According to MSDN, this only works if msimg32.dll is otherwise loaded, and only up to the point where it is freed.

It seems it's loaded by CDialogMinTrayBtn for non 9x, but is subsequently freed, so I'd doubt this is the saver. A testrun on a 9x would confirm.

There is no msimg32.lib used. Dependency Walker confirms msimg32.dll isn't auto-loaded, directly or otherwise.

I wonder where the library is actually loaded and unloaded.
Why haven't you clicked yet?

SlugFiller rule #1: Unsolicited PMs is the second most efficient method to piss me off.
SlugFiller rule #2: The first most efficient method is unsolicited eMails.
SlugFiller rule #3: If it started in a thread, it should end in the same thread.
SlugFiller rule #4: There is absolutely no reason to perform the same discussion twice in parallel, especially if one side is done via PM.
SlugFiller rule #5: Does it say "Group: Moderators" under my name? No? Then stop telling me about who you want to ban! I really don't care! Go bother a moderator.
SlugFiller rule #6: I can understand English, Hebrew, and a bit of Japanese(standard) and Chinese(mandarin), but if you speak to me in anything but English, do expect to be utterly ignored, at best.
0

#10 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 16 October 2005 - 09:35 AM

i'll check it and if necessary, find a different solution...
maybe my suggestment (linked in the first post) will
take care of the problem but it requires the dlls to be loaded
prior to any eMule code and unloaded after everything.

btw, i haven't checked the msdn, but could it be that the
call to GetModuleHandle() loads the dll if not loaded?
gonna check the msdn again about this function.

Avi3k
retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

#11 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,630
  • Joined: 28-December 02

Posted 16 October 2005 - 09:40 AM

I wrote my own menu class and I use a static "init" and "uninit" call to load/release the library (like with my antileechclass/the prefs/the stats) - this works pretty good, maybe take that into concern :flowers:
0

#12 User is offline   Avi-3k 

  • hebMule [retired] dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,127
  • Joined: 25-June 03

Posted 16 October 2005 - 09:45 AM

thanx Wiz, that's what i had in mind
(at least one of the solutions, another is what Slug
gave which is to use a counter within the class...)

Avi3k

This post has been edited by Avi-3k: 16 October 2005 - 09:46 AM

retired developer of hebMule and eMule Skinner...
hebMule site and topic.
hebMule2 unique features: AntiLeech, AntiVirus, Fake Check, ServerFilter, WebSearches, Export Searches, Relative Priority, ModID and much much more...

eMule Skinner is an application to create/edit skins for eMule,
it's multilingual, supports mods, easy-to-use design, integrates to hebMule & Windows and lots more...

code fixes/improvements: #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11 (to check/verify: #12, #13).
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users