Sign in to follow this  
Followers 0
_akari_

Debugger Help

6 posts in this topic

#1 ·  Posted (edited)

Anybody please help me about this problem

I have a program sends debug message to its default debugger, this debugger has classname=#32770 and windows title=Debugwin

Can you help me to get debug message from that program to my au3 script or only show me how to change my script classname to #327770

You can see this below :

[Program.exe] -->> [Debug message] -->> [Debugwin.exe(has classname=#32770)]

(all content of debug message show in listbox1 control of Debugwin.exe)

How to :

[My AU3 Program] how to get [Debug message]

or

[My AU3 Program] how to change [classname=#32770]

Thanks for your attention.

Edited by _akari_

Share this post


Link to post
Share on other sites



dbg("The value of Variable 1 at this time is " & $var1)
Func dbg($msg)
    DllCall("kernel32.dll", "none", "OutputDebugString", "str", $msg)
EndFunc

Share this post


Link to post
Share on other sites

The obvious place to start is the debugger API from Microsoft.

After that I found this code posted by a fellow named Randy Charles Morin. I have not tested it but it's probably a place to start:

CODE
#include <windows.h>

#include <iostream>

int main( int argc, char ** argv )

{

SECURITY_ATTRIBUTES sa;

SECURITY_DESCRIPTOR sd;

sa.nLength = sizeof(SECURITY_ATTRIBUTES);

sa.bInheritHandle = TRUE;

sa.lpSecurityDescriptor = &sd;

std::cerr << "*********************\n"

"Debug Monitor Started\n"

"*********************\n";

if(::InitializeSecurityDescriptor(&sd,

SECURITY_DESCRIPTOR_REVISION) == FALSE)

{

std::cout << "InitializeSecurityDescriptor failed"

<< std::endl;

return 1;

}

if(::SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL,

FALSE) == FALSE)

{

std::cout << "SetSecurityDescriptorDacl failed"

<< std::endl;

return 1;

}

HANDLE bufferready = ::CreateEvent(&sa, FALSE, FALSE,

"DBWIN_BUFFER_READY");

if (bufferready == NULL)

{

std::cout << "CreateEvent failed" << std::endl;

return 1;

}

if (GetLastError() == ERROR_ALREADY_EXISTS)

{

std::cout << "Debugger Already Running" << std::endl;

return 1;

}

HANDLE dataready = ::CreateEvent(&sa, FALSE, FALSE,

"DBWIN_DATA_READY");

if (dataready == NULL)

{

std::cout << "CreateEvent failed" << std::endl;

::CloseHandle(bufferready);

return 1;

}

HANDLE buffer = ::CreateFileMapping(INVALID_HANDLE_VALUE,

&sa, PAGE_READWRITE, 0, 4096, "DBWIN_BUFFER");

if (buffer == NULL)

{

std::cout << "CreateFileMapping failed" << std::endl;

::CloseHandle(bufferready);

::CloseHandle(dataready);

return 1;

}

void * str = ::MapViewOfFile(buffer, FILE_MAP_READ, 0, 0,

4096);

if (str == NULL)

{

std::cout << "MapViewOfFile failed" << std::endl;

::CloseHandle(bufferready);

::CloseHandle(dataready);

::CloseHandle(buffer);

return 1;

}

char * string = (char *)str + sizeof(DWORD);

DWORD lastpid = 0xffffffff;

bool cr = true;

while (true)

{

if (::SetEvent(bufferready) == FALSE)

{

std::cout << "SetEvent failed" << std::endl;

::CloseHandle(bufferready);

::CloseHandle(dataready);

::UnmapViewOfFile(str);

::CloseHandle(buffer);

return 1;

};

if (::WaitForSingleObject(dataready, INFINITE)

!= WAIT_OBJECT_0)

{

break;

}

else

{

DWORD pid = *(DWORD *)str;

if (lastpid != pid)

{

lastpid = pid;

if (!cr)

{

std::cerr << std::endl;

cr = true;

}

}

if (cr)

{

std::cerr << lastpid << ":";

}

std::cerr << (char*)string;

cr = (*string &&

(string[::strlen(string) - 1] == '\n'));

}

}

std::cout << "WaitForSingleObject failed" << std::endl;

::CloseHandle(bufferready);

::CloseHandle(dataready);

::UnmapViewOfFile(str);

::CloseHandle(buffer);

return 1;

};

Share this post


Link to post
Share on other sites

UTen, I want to say thanks you so much to take care of my post,

I'm bad in Cpp, but I have some code I hope you will find out some opinion.

I attached my file below.

Once again. Thanks to UTen

Share this post


Link to post
Share on other sites

As far as I can see the code does not "capture" debug information. It sends a msg to window that there are data to be copied, or write a log to stdio?.

So If that is what you want you can use the dbg func I posted. Put a call to dbg in your AutoIt3 code and capture the output with your debugger or use debugview from Sysinternals (now Microsoft).

If you want AutoIt to be the capturing application and the code you posted is the sending code in the other application then you have to use GuiRegisterMsg and monitor WM_COPYDATA (search for it in the forum). The obstacle here is that you don't have a native way in autoit to change the window class name. So you would probably have to create the monitoring window with dllcalls. I belive you will find samples on how to do this from before autoit got it's own GUI functions (believe @Larry has some samples from 2004 or something)

hmm, don't know if this made any sense to you. And I don't have the time to explore this in code at the moment. Would be cool thought to create something similar to debugview (the userspace part) in AutoIt.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0