Click here to Skip to main content
15,921,990 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error : CommandLineToArgvW is not a member of '`global namespace'' Pin
harshadha26-Mar-07 19:00
harshadha26-Mar-07 19:00 
AnswerRe: Error : CommandLineToArgvW is not a member of '`global namespace'' Pin
prasad_som26-Mar-07 19:20
prasad_som26-Mar-07 19:20 
GeneralRe: Error : CommandLineToArgvW is not a member of '`global namespace'' Pin
harshadha26-Mar-07 20:22
harshadha26-Mar-07 20:22 
GeneralRe: Error : CommandLineToArgvW is not a member of '`global namespace'' Pin
prasad_som26-Mar-07 20:27
prasad_som26-Mar-07 20:27 
QuestionItem's problem of states and action Pin
Chen-XuNuo26-Mar-07 18:13
Chen-XuNuo26-Mar-07 18:13 
AnswerRe: Item's problem of states and action Pin
Chen-XuNuo27-Mar-07 1:21
Chen-XuNuo27-Mar-07 1:21 
QuestionPrev & Next Button in PrintPreview Pin
Ram Murali26-Mar-07 17:20
Ram Murali26-Mar-07 17:20 
QuestionUsing LoadLibrary on EXE to call exported functions? Pin
rforte26-Mar-07 17:08
rforte26-Mar-07 17:08 
I have an executable with an exported function like this:
__declspec(dllexport) const wchar_t * UniqueID( void );
...
const wchar_t *
UniqueID( void )
{
return( L"XYZ00001" );
}

I then do the following in another executable:
typedef const wchar_t * (*pfnID)(void);
pfnID GetUniqueID;
HMODULE hMod = LoadLibrary( L"foo.exe" );
GetUniqueID = (pfnID)GetProcAddress( hMod, "UniqueID" );
const wchar_t * id = GetUniqueID(); // Returns a valid address but data is zero

This above code fails by returning a pointer from GetUniqueID() but the data is all zero'd out.

When I rebuild foo.exe to be a dll (foo.dll) the above code works fine.

Is it possible to use LoadLibrary() to open an executable and get an exported function? The docs say it's possible but I'm wondering if the loader isn't doing proper fixup when LoadLibrary() is called on an EXE.

I notice when I step into the code the value stuffed into @eax looks like the static address of "XYZ00001" and not the fixed-up virtual address I would expect. For example, LoadLibrary returned 0x010f0000 and my function address is at 0x011b614a but the address returned from GetUniqueID() is 0x006595a0.

When I rebuild foo.exe as foo.dll I see LoadLibrary returns 0x10000000, GetProcAddress returns 0x10001000, and GetUniqueID() returns 0x101178ac. In this instance the data is correct.

Any ideas?
QuestionRe: Using LoadLibrary on EXE to call exported functions? Pin
David Crow27-Mar-07 3:40
David Crow27-Mar-07 3:40 
QuestionAdmin Elevation through Manifest Pin
Richard Andrew x6426-Mar-07 16:45
professionalRichard Andrew x6426-Mar-07 16:45 
AnswerRe: Admin Elevation through Manifest Pin
Michael Dunn26-Mar-07 16:52
sitebuilderMichael Dunn26-Mar-07 16:52 
GeneralRe: Admin Elevation through Manifest Pin
Richard Andrew x6426-Mar-07 17:00
professionalRichard Andrew x6426-Mar-07 17:00 
GeneralRe: Admin Elevation through Manifest Pin
Richard Andrew x6426-Mar-07 17:12
professionalRichard Andrew x6426-Mar-07 17:12 
Questionvery tough socket programming problem, Pin
xyhan26-Mar-07 13:52
xyhan26-Mar-07 13:52 
AnswerRe: very tough socket programming problem, Pin
Mark Salsbery26-Mar-07 19:17
Mark Salsbery26-Mar-07 19:17 
GeneralRe: very tough socket programming problem, Pin
xyhan27-Mar-07 4:03
xyhan27-Mar-07 4:03 
GeneralRe: very tough socket programming problem, Pin
Mark Salsbery27-Mar-07 6:56
Mark Salsbery27-Mar-07 6:56 
GeneralRe: very tough socket programming problem, Pin
xyhan27-Mar-07 8:53
xyhan27-Mar-07 8:53 
GeneralRe: very tough socket programming problem, Pin
Mark Salsbery27-Mar-07 9:03
Mark Salsbery27-Mar-07 9:03 
GeneralRe: very tough socket programming problem, Pin
Moak28-Mar-07 7:57
Moak28-Mar-07 7:57 
QuestionHow to use CString class in my dll? Pin
MohammadAmiry26-Mar-07 12:55
MohammadAmiry26-Mar-07 12:55 
AnswerRe: How to use CString class in my dll? Pin
Christian Graus26-Mar-07 13:21
protectorChristian Graus26-Mar-07 13:21 
AnswerRe: How to use CString class in my dll? Pin
Nibu babu thomas26-Mar-07 18:31
Nibu babu thomas26-Mar-07 18:31 
GeneralRe: How to use CString class in my dll? Pin
MohammadAmiry26-Mar-07 23:12
MohammadAmiry26-Mar-07 23:12 
GeneralRe: How to use CString class in my dll? Pin
Nibu babu thomas26-Mar-07 23:15
Nibu babu thomas26-Mar-07 23:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.