├── LICENSE
├── README.md
├── ReadSocket.py
├── RemoteDebugView.sln
├── RemoteDebugView
├── RemoteDebugView.vcxproj
├── RemoteDebugView.vcxproj.filters
├── RemoteDebugView.vcxproj.user
├── exports.def
└── main.cpp
├── RemoteDebugViewHarness
├── RemoteDebugViewHarness.vcxproj
├── RemoteDebugViewHarness.vcxproj.filters
├── RemoteDebugViewHarness.vcxproj.user
└── main.cpp
└── RemoteDebugViewLib
├── RemoteDebugViewLib.cpp
├── RemoteDebugViewLib.h
├── RemoteDebugViewLib.vcxproj
├── RemoteDebugViewLib.vcxproj.filters
└── RemoteDebugViewLib.vcxproj.user
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 hotnops
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RemoteDebugView
2 | A DLL that serves OutputDebugString content over a TCP connection
3 |
4 | # Usage
5 | You will need to compile the DLL and then call the exported function (Default: DebugView). You can invoke the function using rundll
6 |
7 | ```
8 | rundll32 RemoteDebugView.dll,DebugView
9 | ```
10 |
11 | This will start a TCP server bound to localhost on a configured port (Default: 3232). Here is a sample program to write to Debug buffer:
12 |
13 |
14 |
15 |
16 | Then, use a tool such as netcat to read the debug output. Included is a rudimentary python tool that reads output from a socket.
17 |
18 |
19 |
20 |
21 |
22 | # Why
23 | There's been a few times where a tool I wrote is crashing in target space, and I don't have a great way to capture debug output. Starting up DebugView on the target machine is not an option, unless RDP is an option. RemoteDebugView will capture any strings passed to the OutputDebugString(W) functions and host it on a TCP port, so that an operator can use a wide variety of tools to extract helpful debug messages from the target.
24 |
25 | Additionally, many programs output *very* interesting information to the Debug buffer, and may assist operators in finding local vulnerabilities or information leakage.
26 |
27 |
28 | ... and then sometimes, you tested and tested, only to have your tool crash in target space. You *could* try to replicate the enivironment locally and trigger the issue, but why not just do it live?
29 |
30 |
31 | 
32 |
33 | I find myself doing this more often than I care to admit.
34 |
--------------------------------------------------------------------------------
/ReadSocket.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | import socket
4 | import sys
5 |
6 | host = sys.argv[1]
7 | port = sys.argv[2]
8 |
9 | print(f"[*] Connecting to {host}:{port}")
10 |
11 | readSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
12 | readSocket.connect ((host, int(port)))
13 |
14 | try:
15 | while (True):
16 | print(readSocket.recv(4096).decode("utf-8"))
17 | except KeyboardInterrupt:
18 | sys.exit(0)
--------------------------------------------------------------------------------
/RemoteDebugView.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31424.327
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoteDebugView", "RemoteDebugView\RemoteDebugView.vcxproj", "{2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {52C52183-F48E-4A12-AE68-5F125BD1858C} = {52C52183-F48E-4A12-AE68-5F125BD1858C}
9 | EndProjectSection
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoteDebugViewLib", "RemoteDebugViewLib\RemoteDebugViewLib.vcxproj", "{52C52183-F48E-4A12-AE68-5F125BD1858C}"
12 | EndProject
13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoteDebugViewHarness", "RemoteDebugViewHarness\RemoteDebugViewHarness.vcxproj", "{1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}"
14 | ProjectSection(ProjectDependencies) = postProject
15 | {52C52183-F48E-4A12-AE68-5F125BD1858C} = {52C52183-F48E-4A12-AE68-5F125BD1858C}
16 | EndProjectSection
17 | EndProject
18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DebugPrintMessage", "DebugPrintMessage\DebugPrintMessage.vcxproj", "{EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}"
19 | EndProject
20 | Global
21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
22 | Debug|x64 = Debug|x64
23 | Debug|x86 = Debug|x86
24 | Release|x64 = Release|x64
25 | Release|x86 = Release|x86
26 | EndGlobalSection
27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
28 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Debug|x64.ActiveCfg = Debug|x64
29 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Debug|x64.Build.0 = Debug|x64
30 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Debug|x86.ActiveCfg = Debug|Win32
31 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Debug|x86.Build.0 = Debug|Win32
32 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Release|x64.ActiveCfg = Release|x64
33 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Release|x64.Build.0 = Release|x64
34 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Release|x86.ActiveCfg = Release|Win32
35 | {2B2EE2D9-F2D5-4F15-AFCC-5AF76831EBBC}.Release|x86.Build.0 = Release|Win32
36 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Debug|x64.ActiveCfg = Debug|x64
37 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Debug|x64.Build.0 = Debug|x64
38 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Debug|x86.ActiveCfg = Debug|Win32
39 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Debug|x86.Build.0 = Debug|Win32
40 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Release|x64.ActiveCfg = Release|x64
41 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Release|x64.Build.0 = Release|x64
42 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Release|x86.ActiveCfg = Release|Win32
43 | {52C52183-F48E-4A12-AE68-5F125BD1858C}.Release|x86.Build.0 = Release|Win32
44 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Debug|x64.ActiveCfg = Debug|x64
45 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Debug|x64.Build.0 = Debug|x64
46 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Debug|x86.ActiveCfg = Debug|Win32
47 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Debug|x86.Build.0 = Debug|Win32
48 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Release|x64.ActiveCfg = Release|x64
49 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Release|x64.Build.0 = Release|x64
50 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Release|x86.ActiveCfg = Release|Win32
51 | {1C0ECC5F-A2D8-4F11-8D2C-86868073D38C}.Release|x86.Build.0 = Release|Win32
52 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Debug|x64.ActiveCfg = Debug|x64
53 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Debug|x64.Build.0 = Debug|x64
54 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Debug|x86.ActiveCfg = Debug|Win32
55 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Debug|x86.Build.0 = Debug|Win32
56 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Release|x64.ActiveCfg = Release|x64
57 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Release|x64.Build.0 = Release|x64
58 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Release|x86.ActiveCfg = Release|Win32
59 | {EA9F2EAE-CAF4-4225-A3DE-CBA9F1554664}.Release|x86.Build.0 = Release|Win32
60 | EndGlobalSection
61 | GlobalSection(SolutionProperties) = preSolution
62 | HideSolutionNode = FALSE
63 | EndGlobalSection
64 | GlobalSection(ExtensibilityGlobals) = postSolution
65 | SolutionGuid = {4B7FD464-6891-44EE-99EE-9CE3FF187380}
66 | EndGlobalSection
67 | EndGlobal
68 |
--------------------------------------------------------------------------------
/RemoteDebugView/RemoteDebugView.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {2b2ee2d9-f2d5-4f15-afcc-5af76831ebbc}
25 | RemoteDebugView
26 | 10.0
27 |
28 |
29 |
30 | DynamicLibrary
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | DynamicLibrary
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | DynamicLibrary
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | DynamicLibrary
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 | $(SolutionDir)$(Platform)\$(Configuration)\
76 |
77 |
78 | false
79 | $(SolutionDir)$(Platform)\$(Configuration)\
80 |
81 |
82 | true
83 | $(SolutionDir)$(Platform)\$(Configuration)\
84 |
85 |
86 | false
87 | $(SolutionDir)$(Platform)\$(Configuration)\
88 |
89 |
90 |
91 | Level3
92 | true
93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
94 | true
95 | $(SolutionDir)RemoteDebugViewLib
96 |
97 |
98 | Console
99 | true
100 | exports.def
101 | $(SolutionDir)$(Platform)\$(Configuration)\
102 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
103 |
104 |
105 |
106 |
107 | Level3
108 | true
109 | true
110 | true
111 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
112 | true
113 | $(SolutionDir)RemoteDebugViewLib
114 |
115 |
116 | Console
117 | true
118 | true
119 | true
120 | exports.def
121 | $(SolutionDir)$(Platform)\$(Configuration)\
122 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
123 |
124 |
125 |
126 |
127 | Level3
128 | true
129 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
130 | true
131 | $(SolutionDir)RemoteDebugViewLib
132 |
133 |
134 | Console
135 | true
136 | exports.def
137 | $(SolutionDir)$(Platform)\$(Configuration)\
138 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
139 |
140 |
141 |
142 |
143 | Level3
144 | true
145 | true
146 | true
147 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
148 | true
149 | $(SolutionDir)RemoteDebugViewLib
150 |
151 |
152 | Console
153 | true
154 | true
155 | true
156 | exports.def
157 | $(SolutionDir)$(Platform)\$(Configuration)\
158 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/RemoteDebugView/RemoteDebugView.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/RemoteDebugView/RemoteDebugView.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RemoteDebugView/exports.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 | EXPORTS
3 | DebugView @1
--------------------------------------------------------------------------------
/RemoteDebugView/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 |
5 | void
6 | DebugView()
7 | {
8 | Run();
9 | }
--------------------------------------------------------------------------------
/RemoteDebugViewHarness/RemoteDebugViewHarness.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {1c0ecc5f-a2d8-4f11-8d2c-86868073d38c}
25 | RemoteDebugViewHarness
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 | $(SolutionDir)$(Platform)\$(Configuration)\
76 |
77 |
78 | false
79 | $(SolutionDir)$(Platform)\$(Configuration)\
80 |
81 |
82 | true
83 | $(SolutionDir)$(Platform)\$(Configuration)\
84 |
85 |
86 | false
87 | $(SolutionDir)$(Platform)\$(Configuration)\
88 |
89 |
90 |
91 | Level3
92 | true
93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
94 | true
95 | $(SolutionDir)RemoteDebugViewLib
96 |
97 |
98 | Console
99 | true
100 | $(SolutionDir)$(Platform)\$(Configuration)\
101 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
102 |
103 |
104 |
105 |
106 | Level3
107 | true
108 | true
109 | true
110 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
111 | true
112 | $(SolutionDir)RemoteDebugViewLib
113 |
114 |
115 | Console
116 | true
117 | true
118 | true
119 | $(SolutionDir)$(Platform)\$(Configuration)\
120 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
121 |
122 |
123 |
124 |
125 | Level3
126 | true
127 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
128 | true
129 | $(SolutionDir)RemoteDebugViewLib
130 |
131 |
132 | Console
133 | true
134 | $(SolutionDir)$(Platform)\$(Configuration)\
135 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
136 |
137 |
138 |
139 |
140 | Level3
141 | true
142 | true
143 | true
144 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
145 | true
146 | $(SolutionDir)RemoteDebugViewLib
147 |
148 |
149 | Console
150 | true
151 | true
152 | true
153 | $(SolutionDir)$(Platform)\$(Configuration)\
154 | RemoteDebugViewLib.lib;%(AdditionalDependencies)
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
--------------------------------------------------------------------------------
/RemoteDebugViewHarness/RemoteDebugViewHarness.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/RemoteDebugViewHarness/RemoteDebugViewHarness.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RemoteDebugViewHarness/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 |
5 | int
6 | main(int argc, char* argv[])
7 | {
8 | Run();
9 | }
--------------------------------------------------------------------------------
/RemoteDebugViewLib/RemoteDebugViewLib.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include
5 |
6 |
7 | #define DWBUF_SIZE 4096
8 | #define TIMEOUT_INTERVAL 100
9 | // I doubled the buffer size because
10 | // i'm lazy
11 | #define PRINTBUF_SIZE 8192
12 |
13 | #define LISTEN_PORT 3232
14 |
15 |
16 |
17 |
18 | WCHAR wcBufferName[] = L"DBWIN_BUFFER";
19 | WCHAR wcBufferReady[] = L"DBWIN_BUFFER_READY";
20 | WCHAR wcDataReady[] = L"DBWIN_DATA_READY";
21 |
22 | // Referencing: http://unixwiz.net/techtips/outputdebugstring.html
23 | struct DBWIN_BUFFER {
24 | DWORD dwProcessId;
25 | BYTE data[DWBUF_SIZE - sizeof(DWORD)];
26 | };
27 |
28 | BOOL
29 | WriteDebugToSocket
30 | (
31 | SOCKET sSocket
32 | )
33 | {
34 | BOOL bRetVal = FALSE;
35 | CHAR printBuffer[PRINTBUF_SIZE] = { 0 };
36 | DBWIN_BUFFER* pBuffer = NULL;
37 | DWORD dwStatus = 0;
38 | HANDLE hDataReady = NULL;
39 | HANDLE hBufferReady = NULL;
40 | HANDLE hSharedMemory = NULL;
41 |
42 | // Initialize the handles and the shared memory section
43 | hBufferReady = OpenEvent
44 | (
45 | EVENT_ALL_ACCESS,
46 | FALSE,
47 | wcBufferReady
48 | );
49 |
50 | if (NULL == hBufferReady)
51 | {
52 | hBufferReady = CreateEvent
53 | (
54 | NULL,
55 | FALSE,
56 | TRUE,
57 | wcBufferReady
58 | );
59 | if (NULL == hBufferReady)
60 | {
61 | goto exit;
62 | }
63 | }
64 |
65 | hDataReady = OpenEvent
66 | (
67 | SYNCHRONIZE,
68 | FALSE,
69 | wcDataReady
70 | );
71 |
72 | if (NULL == hDataReady)
73 | {
74 | hDataReady = CreateEvent
75 | (
76 | NULL,
77 | FALSE,
78 | FALSE,
79 | wcDataReady
80 | );
81 | if (NULL == hDataReady)
82 | {
83 | goto exit;
84 | }
85 | }
86 |
87 | hSharedMemory = OpenFileMapping
88 | (
89 | FILE_MAP_READ,
90 | FALSE,
91 | wcBufferName
92 | );
93 |
94 | if (NULL == hSharedMemory)
95 | {
96 | hSharedMemory = CreateFileMapping
97 | (
98 | INVALID_HANDLE_VALUE,
99 | NULL,
100 | PAGE_READWRITE,
101 | 0,
102 | sizeof(DBWIN_BUFFER),
103 | wcBufferName
104 | );
105 | if (NULL == hSharedMemory)
106 | {
107 | goto exit;
108 | }
109 | }
110 |
111 | pBuffer = (DBWIN_BUFFER*)MapViewOfFile
112 | (
113 | hSharedMemory,
114 | SECTION_MAP_READ,
115 | 0,
116 | 0,
117 | 0
118 | );
119 |
120 | if (NULL == pBuffer)
121 | {
122 | goto exit;
123 | }
124 |
125 | while (true)
126 | {
127 | dwStatus = 0;
128 | dwStatus = WaitForSingleObject
129 | (
130 | hDataReady,
131 | TIMEOUT_INTERVAL
132 | );
133 |
134 | if (WAIT_OBJECT_0 == dwStatus)
135 | {
136 | SYSTEMTIME time = { 0 };
137 | GetSystemTime
138 | (
139 | &time
140 | );
141 |
142 | snprintf
143 | (
144 | printBuffer,
145 | 8192,
146 | "[%04d/%02d/%02d %02d:%02d:%02d] (%d) : %s",
147 | time.wYear,
148 | time.wMonth,
149 | time.wDay,
150 | time.wHour,
151 | time.wMinute,
152 | time.wSecond,
153 | pBuffer->dwProcessId,
154 | pBuffer->data
155 | );
156 |
157 | dwStatus = send
158 | (
159 | sSocket,
160 | printBuffer,
161 | strnlen(printBuffer, PRINTBUF_SIZE),
162 | 0
163 | );
164 |
165 | SetEvent
166 | (
167 | hBufferReady
168 | );
169 |
170 | if (SOCKET_ERROR == dwStatus)
171 | {
172 | goto exit;
173 | }
174 | }
175 | else if (WAIT_FAILED == dwStatus)
176 | {
177 | goto exit;
178 | }
179 | }
180 |
181 |
182 | exit:
183 |
184 | if (NULL != pBuffer)
185 | {
186 | UnmapViewOfFile
187 | (
188 | pBuffer
189 | );
190 | pBuffer = 0;
191 | }
192 |
193 | if (NULL != hSharedMemory)
194 | {
195 | CloseHandle
196 | (
197 | hSharedMemory
198 | );
199 | hSharedMemory = NULL;
200 | }
201 |
202 | if (NULL != hDataReady)
203 | {
204 | CloseHandle
205 | (
206 | hDataReady
207 | );
208 | hDataReady = NULL;
209 | }
210 |
211 | if (NULL != hBufferReady)
212 | {
213 | CloseHandle
214 | (
215 | hBufferReady
216 | );
217 | hBufferReady = NULL;
218 | }
219 |
220 | return bRetVal;
221 | }
222 |
223 |
224 | BOOL
225 | ListenForConnections
226 | (
227 | WSADATA wsaData
228 | )
229 | {
230 | BOOL bRetVal = FALSE;
231 | DWORD dwStatus = 0;
232 | SOCKADDR_IN addr = { 0 };
233 | SOCKET sClient = INVALID_SOCKET;
234 | SOCKET sListen = INVALID_SOCKET;
235 |
236 | if (0 != dwStatus)
237 | {
238 | goto exit;
239 | }
240 |
241 | sListen = WSASocket
242 | (
243 | AF_INET,
244 | SOCK_STREAM,
245 | 0,
246 | NULL,
247 | 0,
248 | 0
249 | );
250 |
251 | if (INVALID_SOCKET == sListen)
252 | {
253 | goto exit;
254 | }
255 |
256 | addr.sin_family = AF_INET;
257 | addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
258 | addr.sin_port = htons(LISTEN_PORT);
259 |
260 | dwStatus = bind
261 | (
262 | sListen,
263 | (PSOCKADDR)&addr,
264 | sizeof(addr)
265 | );
266 |
267 | if (SOCKET_ERROR == dwStatus)
268 | {
269 | goto exit;
270 | }
271 |
272 | dwStatus = listen
273 | (
274 | sListen,
275 | SOMAXCONN
276 | );
277 |
278 | if (SOCKET_ERROR == dwStatus)
279 | {
280 | goto exit;
281 | }
282 |
283 | sClient = accept
284 | (
285 | sListen,
286 | NULL,
287 | NULL
288 | );
289 |
290 | if (INVALID_SOCKET == sClient)
291 | {
292 | goto exit;
293 | }
294 |
295 | closesocket
296 | (
297 | sListen
298 | );
299 |
300 | WriteDebugToSocket
301 | (
302 | sClient
303 | );
304 |
305 | exit:
306 |
307 | closesocket
308 | (
309 | sClient
310 | );
311 |
312 | return bRetVal;
313 | }
314 |
315 | BOOL
316 | Run()
317 | {
318 | BOOL bRetVal = FALSE;
319 | DWORD dwStatus = 0;
320 | HANDLE hKillEvent = NULL;
321 | WSADATA wsaData = { 0 };
322 |
323 | CreateEvent
324 | (
325 | NULL,
326 | TRUE,
327 | FALSE,
328 | L"dbgview"
329 | );
330 |
331 | dwStatus = WSAStartup
332 | (
333 | MAKEWORD(2, 2),
334 | &wsaData
335 | );
336 |
337 | // Sit in a loop and wait for something to connect
338 | // in. If the kill event is set, break out and stop
339 | while (TRUE)
340 | {
341 | ListenForConnections
342 | (
343 | wsaData
344 | );
345 |
346 | dwStatus = WaitForSingleObject
347 | (
348 | hKillEvent,
349 | 0
350 | );
351 |
352 | if (WAIT_OBJECT_0 == dwStatus)
353 | {
354 | bRetVal = TRUE;
355 | break;
356 | }
357 | }
358 |
359 | WSACleanup();
360 |
361 | return bRetVal;
362 | }
--------------------------------------------------------------------------------
/RemoteDebugViewLib/RemoteDebugViewLib.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | BOOL
4 | Run();
--------------------------------------------------------------------------------
/RemoteDebugViewLib/RemoteDebugViewLib.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {52c52183-f48e-4a12-ae68-5f125bd1858c}
25 | RemoteDebugViewLib
26 | 10.0
27 |
28 |
29 |
30 | StaticLibrary
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | StaticLibrary
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | StaticLibrary
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | StaticLibrary
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 | $(SolutionDir)$(Platform)\$(Configuration)\
76 |
77 |
78 | false
79 | $(SolutionDir)$(Platform)\$(Configuration)\
80 |
81 |
82 | true
83 | $(SolutionDir)$(Platform)\$(Configuration)\
84 |
85 |
86 | false
87 | $(SolutionDir)$(Platform)\$(Configuration)\
88 |
89 |
90 |
91 | Level3
92 | true
93 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
94 | true
95 |
96 |
97 | Console
98 | true
99 |
100 |
101 | Ws2_32.lib
102 |
103 |
104 |
105 |
106 | Level3
107 | true
108 | true
109 | true
110 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
111 | true
112 |
113 |
114 | Console
115 | true
116 | true
117 | true
118 |
119 |
120 | Ws2_32.lib
121 |
122 |
123 |
124 |
125 | Level3
126 | true
127 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
128 | true
129 |
130 |
131 | Console
132 | true
133 |
134 |
135 | Ws2_32.lib
136 |
137 |
138 |
139 |
140 | Level3
141 | true
142 | true
143 | true
144 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
145 | true
146 |
147 |
148 | Console
149 | true
150 | true
151 | true
152 |
153 |
154 | Ws2_32.lib
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/RemoteDebugViewLib/RemoteDebugViewLib.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/RemoteDebugViewLib/RemoteDebugViewLib.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------