winevt_c 0.11.4 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4231aa8b328c8b400c7a1948fa6a05798cc404146e744b93654321e6c8df2ced
4
- data.tar.gz: ebccd019f7c62066840faf7df5b11b27ee8d249816f7a13a3e449f3ff852ccd4
3
+ metadata.gz: 6f7ef84281eaba15c88529977e4d2d84bca0c66069f89f9c66dd46b992a65cff
4
+ data.tar.gz: a1cbda6208cecadcd57d130151c15161985f2dbd57ea83599cd546910f23af47
5
5
  SHA512:
6
- metadata.gz: b6189e52e89878adcfeb09a1e100b50d5da9a053b16626582665d474c407dce402b05beea0dcc7671d27f2396dd993eec7ccce3ffe4a565f27de726fefee623f
7
- data.tar.gz: a37df6779a02e6ae99bfd5557b3cef79429c908f3201c8f47794ceb479933f2dbf0c4745ab4cc005abedf9ae27eb4081234ec3a4ccedd6438be618c9f57426fc
6
+ metadata.gz: 89e04099f849f47445c61005218e080fc21d6fb6a18cb59b51b1e17d8f28e3de85289aae4494793bacc14f08a6545a2b5775bd529dffc5710aa74dbf71b0d2e6
7
+ data.tar.gz: ade1be36ac7253dae7d72be6bd65a25424d21625da3efb1fff5a619d4e04f015ac3f6da6c6f18cc6252482361ea594cd1aabb6bf41f36894aa510023dfa70c6a
@@ -11,17 +11,22 @@ jobs:
11
11
  uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
12
  with:
13
13
  engine: cruby
14
- min_version: 3.1
14
+ min_version: 3.2
15
15
  build:
16
16
  needs: ruby-versions
17
- runs-on: 'windows-latest'
17
+ runs-on: ${{ matrix.os }}
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
+ os: ['windows-latest', 'windows-11-arm']
21
22
  ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
22
23
  exclude:
23
24
  - ruby: head
24
- name: Ruby ${{ matrix.ruby }}
25
+ - os: 'windows-11-arm'
26
+ ruby: '3.3'
27
+ - os: 'windows-11-arm'
28
+ ruby: '3.2'
29
+ name: Ruby ${{ matrix.ruby }} on ${{ matrix.os }}
25
30
  steps:
26
31
  - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
27
32
  - uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
@@ -143,8 +143,8 @@ rb_winevt_query_initialize(VALUE argc, VALUE *argv, VALUE self)
143
143
 
144
144
  winevtQuery->query = EvtQuery(
145
145
  hRemoteHandle, evtChannel, evtXPath, flags);
146
- err = GetLastError();
147
- if (err != ERROR_SUCCESS) {
146
+ if (winevtQuery->query == NULL) {
147
+ err = GetLastError();
148
148
  if (hRemoteHandle != NULL) {
149
149
  EvtClose(hRemoteHandle);
150
150
  }
@@ -175,8 +175,6 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
175
175
  struct WinevtSession* winevtSession;
176
176
  struct WinevtSubscribe* winevtSubscribe;
177
177
 
178
- hSignalEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
179
-
180
178
  TypedData_Get_Struct(
181
179
  self, struct WinevtSubscribe, &rb_winevt_subscribe_type, winevtSubscribe);
182
180
 
@@ -239,6 +237,7 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
239
237
  flags |= EvtSubscribeToFutureEvents;
240
238
  }
241
239
 
240
+ hSignalEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
242
241
  hSubscription =
243
242
  EvtSubscribe(hRemoteHandle, hSignalEvent, path, query, hBookmark, NULL, NULL, flags);
244
243
  if (!hSubscription) {
@@ -263,22 +262,13 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
263
262
  }
264
263
  }
265
264
 
266
- if (winevtSubscribe->subscription != NULL) {
267
- // should be disgarded the old event subscription handle.
268
- EvtClose(winevtSubscribe->subscription);
269
- }
270
265
 
271
266
  ALLOCV_END(wpathBuf);
272
267
  ALLOCV_END(wqueryBuf);
273
268
 
274
- winevtSubscribe->signalEvent = hSignalEvent;
275
- winevtSubscribe->subscription = hSubscription;
276
- winevtSubscribe->remoteHandle = hRemoteHandle;
277
- if (hBookmark) {
278
- winevtSubscribe->bookmark = hBookmark;
279
- } else {
280
- winevtSubscribe->bookmark = EvtCreateBookmark(NULL);
281
- if (winevtSubscribe->bookmark == NULL) {
269
+ if (!hBookmark) {
270
+ hBookmark = EvtCreateBookmark(NULL);
271
+ if (hBookmark == NULL) {
282
272
  status = GetLastError();
283
273
  if (hSubscription != NULL) {
284
274
  EvtClose(hSubscription);
@@ -290,6 +280,20 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
290
280
  }
291
281
  }
292
282
 
283
+ if (winevtSubscribe->subscription) {
284
+ EvtClose(winevtSubscribe->subscription);
285
+ }
286
+ if (winevtSubscribe->signalEvent) {
287
+ CloseHandle(winevtSubscribe->signalEvent);
288
+ }
289
+ if (winevtSubscribe->bookmark) {
290
+ EvtClose(winevtSubscribe->bookmark);
291
+ }
292
+ winevtSubscribe->signalEvent = hSignalEvent;
293
+ winevtSubscribe->subscription = hSubscription;
294
+ winevtSubscribe->remoteHandle = hRemoteHandle;
295
+ winevtSubscribe->bookmark = hBookmark;
296
+
293
297
  return Qtrue;
294
298
  }
295
299
 
@@ -132,7 +132,7 @@ guid_to_wstr(const GUID& guid)
132
132
  {
133
133
  LPOLESTR p = nullptr;
134
134
  if (FAILED(StringFromCLSID(guid, &p))) {
135
- return nullptr;
135
+ return std::wstring();
136
136
  }
137
137
  std::wstring s(p);
138
138
  CoTaskMemFree(p);
@@ -252,7 +252,11 @@ extract_user_evt_variants(PEVT_VARIANT pRenderedValues, DWORD propCount)
252
252
  if (pRenderedValues[i].GuidVal != nullptr) {
253
253
  const GUID guid = *pRenderedValues[i].GuidVal;
254
254
  std::wstring wstr = guid_to_wstr(guid);
255
- rbObj = wstr_to_rb_str(CP_UTF8, wstr.c_str(), -1);
255
+ if (!wstr.empty()) {
256
+ rbObj = wstr_to_rb_str(CP_UTF8, wstr.c_str(), -1);
257
+ } else {
258
+ rbObj = rb_utf8_str_new_cstr("?");
259
+ }
256
260
  rb_ary_push(userValues, rbObj);
257
261
  } else {
258
262
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
@@ -455,6 +459,7 @@ get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
455
459
 
456
460
  std::wstring ret(reinterpret_cast<WCHAR*>(lpMsgBuf));
457
461
  std::copy(ret.begin(), ret.end(), std::back_inserter(result));
462
+ result.push_back(L'\0');
458
463
  LocalFree(lpMsgBuf);
459
464
 
460
465
  goto cleanup;
@@ -512,6 +517,7 @@ get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
512
517
 
513
518
  std::wstring ret(reinterpret_cast<WCHAR*>(lpMsgBuf));
514
519
  std::copy(ret.begin(), ret.end(), std::back_inserter(result));
520
+ result.push_back(L'\0');
515
521
  LocalFree(lpMsgBuf);
516
522
 
517
523
  goto cleanup;
@@ -594,6 +600,10 @@ cleanup:
594
600
  if (hMetadata)
595
601
  EvtClose(hMetadata);
596
602
 
603
+ if (result.empty()) {
604
+ return _wcsdup(L"");
605
+ }
606
+
597
607
  return _wcsdup(result.data());
598
608
  }
599
609
 
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.11.4"
2
+ VERSION = "0.11.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winevt_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake