debugprocess declaration

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

debugprocess declaration

Riccardo Mottola
Hi,


I want to add a call to DebugBreakProcess to a windows port of an
application (simulate the sending of a signal.


I added the following:


#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 // Minimal target is Windows XP

#include <windows.h>
#include <winbase.h>


yet still I get a missing declaration and a linking issue with
DebugBreakProcess when I build


In winbase.h I see:

#if (_WIN32_WINNT >= 0x0501)
WINBASEAPI BOOL WINAPI DebugBreakProcess(HANDLE);


which looks exactly as what I need

As a quick hack, I just slapped the above declaration in my source file
and it compiles, links and works.

Thus I have an issue the way I include and define the windows version I
suppose, but where/how/why?


Riccardo


------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: debugprocess declaration

Keith Marshall-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 15/05/16 00:13, Riccardo Mottola wrote:
> I want to add a call to DebugBreakProcess to a windows port of an
> application (simulate the sending of a signal.

You don't show enough of your program to let me say for sure, but...

> I added the following:
>
> #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 // Minimal target
> is Windows XP

...seeing the #undef there causes me grave suspicion that you're
trying to redefine _WIN32_WINNT, after having previously included
something with it already defined differently -- perhaps even as a
result of some header setting it to a default value, because it wasn't
already defined when you included whatever header that may have been.

Correct usage is to define _WINNT_WIN32 once, and once only, *before*
you include *any* header.

> #include <windows.h>

Is this the first, and only time you've included windows.h?  If not,
then this is a no-op.

> #include <winbase.h>

And, after including windows.h, this is definitely a no-op, because
windows.h has already included it for you; GCC will not read it a
second time.

> yet still I get a missing declaration and a linking issue with
> DebugBreakProcess when I build

If I do, (with mingw32-gcc, because it's a cross-compiler here):

  $ echo '#include <windows.h>' | mingw32-gcc -E -xc - | less -S

and search the output in less, I see (as expected) no declaration for
DebugBreakProcess(), but if I do:

  $ echo '#include <windows.h>' |
    mingw32-gcc -D _WIN32_WINNT=0x501 -E -xc - | less -S

or equivalently, (my w32api is current git-HEAD on "legacy"):

  $ echo '#include <windows.h>' |
    mingw32-gcc -D NTDDI_VERSION=NTDDI_WINXP -E -xc - | less -S

I see, (in both latter cases):

   BOOL __attribute__((__stdcall__)) DebugBreakProcess(HANDLE);

which looks like the correct pre-processed expansion of:

  WINBASEAPI BOOL WINAPI DebugBreakProcess(HANDLE);

so there really is no reason why it shouldn't work for you, just as
well as declaring it yourself, IFF you've defined the appropriate
WinNT version macros, and included windows.h *in the proper sequence*.

- --
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJXOK2xAAoJEMCtNsY0flo/fjUP/iD13rr8KIVbhihRG0s+P2Yb
QzimEGzbS2Y5M8BcHRh14MmNV8FRTpY48GbCHGWO0jjx09EPQ5uIretp0eHMveE2
aVXh+IIgfvG1QD8B9JdHNxSiH2v1R4rVq2sVqSkC+HzUcsjoY6iCljeDWojngTpD
xMlVE+q1Ex4MXiP++tTf2hofZrmPe835YAZHO3u3YWgzi9Ma3y5d7FVBvZ04Moan
SVJNsj7X6KKU3tIijr0yia5gX6t5RPLAiDj7kWibw09QEKhcEQSh+s6cnm0FENVU
7e19mlY+1VRG5B0lljN9UkzTUNQta2AfEKdeZDcIMfNORfHxnIa4VBo2NATqIpBd
aSXNKWdDQcZWymHGP6Fw0HPAqQv6FgsLOQqVJcS6+aSuv1QR/1YVIQ7LadVrjYbT
pyPwZ+3e8Rmd6Ezng6dO2S4frVnt4asYdTKqZUYyPl8YNzB/+qFMZt7rCEi2ytvb
dBwfF6oWQJIuTtXpA+Mwd5o3oKKDwuMqZQu47vCihPCiwBwhGNRTiSv0fXRlehzM
Eiw5FZ4sGNZBjLnhJk9V2oWqAW7W59CR4lMR1LNTDiupK0mews5z+ZqgoZePQ6ma
ksPsoaPd34TzBzQ689TGm6cfRKw9F2rdNCRIZ/KbwGz/4N4SKhKWrvr+A0vETft+
vLdiQ23Zv2kBazXXlSuh
=Xb8O
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: debugprocess declaration

Riccardo Mottola
Hi Keith,

Keith Marshall wrote:
> ...seeing the #undef there causes me grave suspicion that you're
> trying to redefine _WIN32_WINNT, after having previously included
> something with it already defined differently -- perhaps even as a
> result of some header setting it to a default value, because it wasn't
> already defined when you included whatever header that may have been.
>
> Correct usage is to define _WINNT_WIN32 once, and once only,*before*
> you include*any*  header.

that was it! thanks. Apparently I was including headers that indirectly
included windows headers and/or defined this (libraries).
Moving this on top of everything made it work smoothly.

This DebugBreak thing is tricky! I want to enable the GNUstep IDE
ProjectCenter debugger to debug processes without the aid of an extenal
program or add special hack functions in the code.
It mostly works now! I can run/stop/restart the program. After a couple
of time everything hangs, but that mightbe something different, I need
to check the PIDs used. The general concept seems to work now.

Riccardo

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe