• Welcome to Theos PowerBasic Museum 2017.

zTrace converted to C/C++

Started by Patrice Terrier, May 05, 2013, 08:21:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Patrice Terrier

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Patrice Terrier

#1
I did a small change to the thread creation source code and i added two missing {} in the WM_COMMAND, to let it work.

Now the zTrace.dll 64-bit is alive, at least by me  ;D

that would help me to further debug my 64-bit DLL(s)...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

Patrice,
  I was able to compile in both 32 and 64 bit with the cl from the 7.1 SDK.
I get the zTrace window when testing but the text is gibberish.
Can you show just a simple demo of it's use?

James

Patrice Terrier

James--

it is using UNICODE !!!

I shall post very soon the compiled version for 32/64 bit (both working in Unicode)
The original PowerBASIC version works in ANSI.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

James C. Fuller

I know it's unicode and I did figure out you need to pass a WCHAR string but I wanted to see a c++ snippet of calling it from you.

BTW I compiled both 32 and 64 bit dll's without name mangling so I can easily call zTrace from any language.

Good work.

James



James C. Fuller

Ok I got it.
It was in the declare so I could pass a wstring -> ws.c_str()
I needed const and you should probably add it to the function also.
James


typedef LONG_PTR (__cdecl *BCXFPROT1)(const WCHAR*);

static BCXFPROT1 zTrace;

int WINAPI WinMain (HINSTANCE  hInst,HINSTANCE  hPrev,LPSTR  CmdLine,int CmdShow)
{

// **********[ DLL Declarations ]**********

HMODULE  H_ZTRACE64 = LoadLibrary("ztrace64.dll");
zTrace=(BCXFPROT1)GetProcAddress(H_ZTRACE64, "zTrace");

// ****************************************

  wstring  ws;
  LONG_PTR  rv;
  ws= L"James";
  rv= zTrace( ws.c_str());
  MessageBox (GetActiveWindow(),(join(2,"rv = ",str(rv))),"",0);
}

James C. Fuller

Patrice,
I only tested the zTrace function but the dll's I created work with:

MinGW gcc 32/64
MinGw g++ 32/64
VC++(wiin 7.1 sdk) 32/64
Borland c++ 5.5 32
PellesC 7R   32/64
Tiny c 32

James