ObjReader Community

SDK programming => 64-bit SDK programming => Topic started by: James Fuller on July 14, 2020, 12:12:59 pm

Title: zTrace from dll
Post by: James Fuller on July 14, 2020, 12:12:59 pm
Patrice,
  Can zTrace be used from a dll?
If so would you show an example?

Thank you and be safe,

James
Title: Re: zTrace from dll
Post by: Patrice Terrier on July 14, 2020, 04:33:14 pm
OF COURSE !!!

Code: [Select]
long zTrace(IN WCHAR* sPtr) {
    long nRet = 0;
    static HMODULE hDll;
    if (hDll == 0) {
        if (sizeof(LONG_PTR) == 8) {
            hDll = LoadLibrary(L"zTrace64");
        }
        else {
            hDll = LoadLibrary(L"zTrace32");
        }
    }
    if (hDll) {
        long_proc(WCHAR*);
        static zProc hProc;
        if (hProc == 0) { hProc = (zProc)GetProcAddress(hDll, "zTrace"); }
        if (hProc) { nRet = hProc(sPtr); }
    }
    return nRet;
}
Title: Re: zTrace from dll
Post by: James Fuller on July 14, 2020, 09:30:26 pm
Thank you but...
missed a line:
#define long_proc typedef long (__stdcall *zProc)

I thought it might be different for a dll  but it is the same as the code I use for an exe.

James
 
Title: Re: zTrace from dll
Post by: Patrice Terrier on July 14, 2020, 11:11:57 pm
#define long_proc typedef long (__stdcall *zProc)

Yes, there is no difference.

The first purpose of zTrace was to help me to debug both WinLIFT.dll and GDImage.dll...
Title: Re: zTrace from dll
Post by: James Fuller on July 17, 2020, 11:42:28 am
Patrice,
  It is the only debugging tool I use.
One issue I have is setting up the create debug.txt file from the dll I my trying to debug as there is no real place to stop the output so I can click on the zTrace window. Any suggestions?

James
Title: Re: zTrace from dll
Post by: Patrice Terrier on July 17, 2020, 02:13:53 pm
James

Sorry, i am unsure to understand what you mean by "there is no real place to stop the output so I can click on the zTrace window".

What you can do is to display a messagebox before full completion, to give you a chance to read the debug content.
Or you can use the zDebug option to create a zDebug.txt report.