MCPcopy Create free account
hub / github.com/OpenKneeboard/OpenKneeboard / Send

Method Send

src/lib/APIEvent.cpp:97–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void APIEvent::Send() const {
98 TraceLoggingThreadActivity<gTraceProvider> activity;
99 TraceLoggingWriteStart(
100 activity,
101 "APIEvent::Send()",
102 TraceLoggingValue(this->name.c_str(), "Name"),
103 TraceLoggingBinary(this->value.c_str(), this->value.size(), "Value"));
104
105 if (!OpenMailslotHandle()) {
106 TraceLoggingWriteStop(
107 activity,
108 "APIEvent::Send()",
109 TraceLoggingValue("Couldn't open mailslot", "Result"));
110 return;
111 }
112 const auto packet = this->Serialize();
113
114 if (WriteFile(
115 gMailslotHandle.get(),
116 packet.data(),
117 static_cast<DWORD>(packet.size()),
118 nullptr,
119 nullptr)) {
120 TraceLoggingWriteStop(
121 activity, "APIEvent::Send()", TraceLoggingValue("Success", "Result"));
122 return;
123 }
124
125 gMailslotHandle.close();
126 gMailslotHandle = {};
127 TraceLoggingWriteTagged(activity, "Closed handle");
128
129 if (!OpenMailslotHandle()) {
130 TraceLoggingWriteStop(
131 activity,
132 "APIEvent::Send()",
133 TraceLoggingValue("Couldn't reopen handle", "Result"));
134 return;
135 }
136 TraceLoggingWriteTagged(activity, "Reopened handle");
137 if (WriteFile(
138 gMailslotHandle.get(),
139 packet.data(),
140 static_cast<DWORD>(packet.size()),
141 nullptr,
142 nullptr)) {
143 TraceLoggingWriteStop(
144 activity, "APIEvent::Send()", TraceLoggingValue("Success", "Result"));
145 } else {
146 TraceLoggingWriteStop(
147 activity,
148 "APIEvent::Send()",
149 TraceLoggingValue("Error", "Result"),
150 TraceLoggingValue(GetLastError(), "Error"));
151 }
152}
153
154const wchar_t* APIEvent::GetMailslotPath() {

Callers 8

wWinMainFunction · 0.45
mainFunction · 0.45
wWinMainFunction · 0.45
wWinMainFunction · 0.45
mainFunction · 0.45
SendToOpenKneeboardFunction · 0.45
OpenKneeboard_send_utf8Function · 0.45

Calls 3

SerializeMethod · 0.95
OpenMailslotHandleFunction · 0.85
getMethod · 0.45

Tested by 1

mainFunction · 0.36