Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash with FOLDERID_LocalAppDataLow not found #88

Merged
merged 1 commit into from
Apr 23, 2013

Conversation

asinbow
Copy link
Contributor

@asinbow asinbow commented Oct 31, 2012

The macro DEFINE_KNOWN_FOLDER was copied from <KnownFolder.h>, it will link FOLDERID_LocalAppDataLow to an external dll.
but for some system(to me, Windows 7, Chinese Edition), the symbol can't be found at runtime, so FOLDERID_LocalAppDataLow becomes GUID_NULL, and at line 52, it will fail with crash.

Really strange.

Let's inspect <KnownFolder.h> again, there are two styles of DEFINE_KNOWN_FOLDER:

#ifdef INITGUID
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID DECLSPEC_SELECTANY name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
#else
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID name
#endif // INITGUID

Shall we use the first one without extern?

The macro DEFINE_KNOWN_FOLDER was copied from <KnownFolder.h>,
it will link FOLDERID_LocalAppDataLow to an external dll,
but for some system(to me, Windows 7, Chinese Edition), the symbol can't be found at runtime,
so FOLDERID_LocalAppDataLow becomes GUID_NULL, and at line 52, it will fail with crash.

Really strange.

Let's inspect <KnownFolder.h> again, there are two styles of DEFINE_KNOWN_FOLDER:

#ifdef INITGUID
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID DECLSPEC_SELECTANY name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
#else
#define DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID name
#endif // INITGUID

Shall we use the first one without `extern`?
@asinbow
Copy link
Contributor Author

asinbow commented Oct 31, 2012

Let's rethink about this code:

  1. at line 52, getKnownFolderPath could fail, make pszPath NULL. Better to check HRESULT to avoid crash.
  2. DEFINE_KNOWN_FOLDER can be found <KnownFolder.h>, why redefine it? Maybe for compiler compatibility.
  3. where to release HMODULE library?

Thank you for pay attention.

@taxilian
Copy link
Member

Interesting. I'll have to make sure this still works on the english/russian version, but assuming it works on mine as well as the other one did I'll accept this.

@asinbow
Copy link
Contributor Author

asinbow commented Nov 14, 2012

These days I compiled my project on VS2010, found a 'not found' link error, just because the EXTERN_C.
Maybe we should define a new macro all by ourselves,

#define FB_DEFINE_KNOWN_FOLDER(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        const GUID DECLSPEC_SELECTANY name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }

Well, I do not know whether it would work in other cases, but the issue FOLDERID_LocalAppDataLow links to GUID_NULL at runtime does exists where using 'EXTERN_C'.

Thank you for paying attention.

taxilian added a commit that referenced this pull request Apr 23, 2013
fix crash with FOLDERID_LocalAppDataLow not found
@taxilian taxilian merged commit 7c55fb4 into firebreath:master Apr 23, 2013
starsolaris pushed a commit to starsolaris/FireBreath that referenced this pull request Mar 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants