|
I got a x7e ERROR_MOD_NOT_FOUND
But thats not it
When I do the load in the main its okay When I call the exported function init_image it fails
int main(int ac,char *av[])
{
int rc = 0;
HINSTANCE hImagehlpDll;
hImagehlpDll = LoadLibrary((LPCWSTR) "imagehlp.dll" ); <--- Okay
init_image();
code in DLL source
__decspec(dllexport) void init_image(void)
{
DWORD myerror;
DWORD DWfLAGS = FORMAT_MESSAGE_FROM_SYSTEM || FORMAT_MESSAGE_ALLOCATE_BUFFER;
DWORD size = 100;
char mybuffer[100];
LPTSTR error_ptr;
imageType = IMAGE_FILE_MACHINE_I386;
pSW = NULL;
hImagehlpDll = NULL;
hImagehlpDll = LoadLibrary((LPCWSTR) "imagehlp.dll" ); <--- fails here
myerror = GetLastError();
// FormatMessage(dwFlags,NULL,myerror,NULL,error_ptr,size,NULL);
pSW = (tSW) GetProcAddress( hImagehlpDll, "StackWalk" );
return;
}
|
|
|
|
|
What does wide L mean ????
|
|
|
|
|
ForNow wrote: What does wide L mean ????
The L is not wide, but the string it precedes is.
Use the L prefix to denote a wide-character character literal or a wide-character string literal.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thankx Can I buy you lunch one day
Honestly one of the things I noticed with this problem coming from a MainFrame
Background is (using MainFrame Sercvices) When you want to use one of the Authorized
Assembler services IBM always prefaces the discription of the macro by requirements
Such as must be Authorized state or No Locks Held
There is no such documentation on Windows API's
|
|
|
|
|
ForNow wrote: There is no such documentation on Windows API's
Are you referring to MSDN?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I was refering in MSDN if they are are any requirements when using an API
shuch as no Locks held etc....
I guess I found out they are certin things I cann't do in DLLMain
Thankx again
|
|
|
|
|
A few questions regarding use of the inline key word
1) Do you use it?
2) How do you decide when to use it?
3) Do you ever actually measure the benifit of using it?
4) Can using it ever degrade performance?
5) Can the effect of using it vary on different hardware or operating systems?
|
|
|
|
|
Josh Gray wrote: 1) Do you use it?
Yeah.
Josh Gray wrote: 2) How do you decide when to use it?
When the overhead of a function call is comparable to the overhead of the function itself. For example, a simple accessor function.
Josh Gray wrote:
3) Do you ever actually measure the benifit of using it?
Very rarely.
Josh Gray wrote: 4) Can using it ever degrade performance?
I guess it's possible. If you inlined a frequently called large function you would increase the size of the EXE. Remember that the compiler has the last say however: it doesn't have to inline a function you've marked as inline if it decides it's not worth it.
Steve
|
|
|
|
|
Thanks mate
Stephen Hewitt wrote: I guess it's possible. If you inlined a frequently called large function you would increase the size of the EXE. Remember that the compiler has the last say however: it doesn't have to inline a function you've marked as inline if it decides it's not worth it.
What I've been wondering about is the effect this has on hardware optimisations. For example instruction pipe lines and cpu caching.
I'm going to do some experimenting to see if making some functions inline has any real world effect
|
|
|
|
|
Josh Gray wrote: I'm going to do some experimenting to see if making some functions inline has any real world effect
You will not see much difference if you do not disable optimizations. The MSVC compiler is very intelligent with its inlining and will very often inline your functions even if you did not ask it to.
Best Wishes,
-David Delaune
|
|
|
|
|
Josh Gray wrote: 1) Do you use it?
Actually recent Microsoft compilers are fairly good at determining which functions to inline. I still use it to make sure the compiler gets the hint. It should be noted that the __inline keyword is simply a compiler hint and may be completely ignored if the compiler determines its not the best choice. In cases where you want to overide the compilers decision you can use __forceinline. But once again this is simply a hint the compiler may ignore. Although it could be described as a 'strong hint' to the compiler.
Heres a good tip. The only 100% sure method to have your function inlined is to use the #define keyword.
Josh Gray wrote: 2) How do you decide when to use it?
Function calls have overhead, they are not free. The stack and registers of the calling function must be saved and restored. All of ther function arguments are copied into registers... then a stack frame needs to be set up for the local variables in the new function.
I mostly use it for returning member variables such as:
__inline int MyClass::GetVar() const { return myVar; }
If there is work that needs to be done many times in a loop it is sometimes better to inline the function. The compiler may choose to automatically inline the function if it meets whatever criteria. Otherwise you may be force to use __forceinline before the compiler actually takes your advice. It doesn't trust you, and maybe you shouldn't either!
for(int i = 0; i < iSomeLimit;++i)
{
DoWork(SomeArray[i]);
}
Josh Gray wrote: 3) Do you ever actually measure the benifit of using it?
Yes, you can read the RDTSC[^] counter to get a rough idea of the function performance before and after inlining.
Josh Gray wrote: 4) Can using it ever degrade performance?
Yes, most definately!
It is important NOT to inline functions that are very large in size. The reason is that the processor instruction pipeline[^]is always reading ahead and storing future instructions in the pipe so that it can execute it very fast, but it may make a mistake and cache the wrong instructions! While the processor is excuting instructions... it is at the same time trying to predict where the code will JMP to next. This is called branch prediction[^]. So if your function is extremely large it can degrade program performance by increasing page faults and cache misses.
Josh Gray wrote: 5) Can the effect of using it vary on different hardware or operating systems?
Yes.
Optimizations work differently on many flavors of Intel and AMD microprocessors because the instruction pipelines have different sizes/implementation, the branch target buffer[^] may be a different size and they may contain different sizes of L1, L2 and L3 cache.
Inline at your own risk!
Hope this helps,
-David Delaune
|
|
|
|
|
Randor wrote: Heres a good tip. The only 100% sure method to have your function inlined is to use the #define keyword.
I only ever use macros, for whatever reason, if I have no other choice; and even then with some sadness.
Steve
|
|
|
|
|
The only other things I can add on top of the other replies are:
- if a function is virtual the inline keyword is ignored (clearly it has to have an address)
- I think inline is ignored in debug builds
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Hi!
I'm developing IE toolbar and I need to know when user opens new site. I suppose that i need to add command message handler (ON_UPDATE_COMMAND_UI), but I dont know right message ID. could someone post me the right ID or correct me if i'm wrong.
Greetings
|
|
|
|
|
I posted this at the OS Forum too, I am not which is the right one for this question.
Hey Everyone,
Is there a way I can determine if the Windows Update is installing updates ?
Especially on Windows Vista and Windows XP
Thanks
|
|
|
|
|
Do you know the name of the process?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
There are 2 process running TrustedInstaller.exe and pkgmgr.exe
Both of these run in system context.
On Windows XP - Enumeration can be done (so we can figure this on windows XP)
On Windows Vista, Unless you have Debug privileges you *cannot* enumerate these running process (bummer).
The App we are currently working on cannot have debug privileges and so we are unable to enum the process.
We also looked at Windows Update Agent API to get info, But they don't have any API that would provide data that say, Hey!!, Update is running.
So, I am pretty much stuck,
Thanks for responding to my post.
|
|
|
|
|
Hello,
I have created a Doc/View wherein a dialog be displayed with some string in the edit box.I created a dialog class 'CconnectDlg' with an edit control 'm_userID'.
In the view class , added a meesage map function for one of the menu items 'OnActionConnect' and modified as below.
-------------------
void CSimulatorView::OnActionConnect()
{
CConnectDlg* connectDlg = new CConnectDlg;
INT_PTR nRet = -1;
nRet = connectDlg->DoModal();
CString s;
s.Format(_T("Returning"));
connectDlg->m_userId.SetWindowTextA(s);
delete(connectDlg);
}
--------------------
when I run this I get assertion failure and in the debug
at 'connectDlg->m_userId.SetWindowTextA(s)' shows
'CEdit hwnd=0x00000000' but not sure what am supposed to do ? why the hwnd is null ? any help is highly is welcome.
|
|
|
|
|
Wow
DoModal is a blocking call. It terminates when the dialog is closed by the user. So, you are trying to set the text of a control that doesn't exist anymore.
You should instead pass the text to your dialog (not to the edit control but to a member variable of your dialog) and set the edit control text in the OnInitDialog function.
|
|
|
|
|
sunguy wrote: CConnectDlg* connectDlg = new CConnectDlg;
Why are you using the heap for this?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: sunguy wrote:
CConnectDlg* connectDlg = new CConnectDlg;
Why are you using the heap for this?
I stopped asking this question, long time ago.
/M
|
|
|
|
|
I've never really had to use dlls before like this... So I'm not sure what to do. I need to get the GDI and user object count for a process. There is a function named "int GetCurrentProcess(HANDLE,DWORD)" that does this in the user32.dll.
So I used LoadLibrary to load the dll and I used GetProcAddress to get the address of the function. But I can't figure out how to call the function.
HMODULE myDll = LoadLibrary("user32.dll");
void* myFunc = GetProcAddress(myDll, "GetGuiResources");
So how do I use the pointer to call the function? I've tried a few things I found on Google, but I can't get it to work.
|
|
|
|
|
You don't have to do things like that. Just include Windows.h in the file were you need to use this function and be sure that you link against the User32.lib (in your project settings).
|
|
|
|
|
I tried that at first. It doesn't link. FYI, I'm using VC 6.0 (at work) unfortunately.
|
|
|
|
|
it is unlikely that it is a link time error. What error do you get exactly?
Most likely, you get a compile time error, and need to define both WINVER and _WIN32_WINNT[^] accordingly before including windows.h
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist
|
|
|
|