winevt_c 0.10.0 → 0.10.1

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: 87d082b15698183b841886fbdffe603679006050fc91c7ea6043bf5987275e3f
4
- data.tar.gz: ab529bd44369e0c256263aee77ba416a42469bbaf71b0de9f523db81921bbfef
3
+ metadata.gz: 9d3ebf96df7a93d6d2a4dae15cba8cc7a76617e752f758aeb8c355c43abd988d
4
+ data.tar.gz: de33f1ee85dacba17dbe5b32e98a45d4a57fdde7d931db70dd3b4e054f22c82b
5
5
  SHA512:
6
- metadata.gz: a5b728bc6422d8fc1a17ab10fbbc6ad10aa673b3faec5b035269826859ef4e14bd63def67a69618c21a2e4d1a7951d2d2f2881676ee049348b996bb706b21ec5
7
- data.tar.gz: '0483519d86d5abd1fe5672ee124fdadf839bd9f9a50b41cb1aaac37dd886154dc0a4e5af4d6901c4cc6f2da9e99ad6e98e82cfb8cf6630a69dd3dda0d127ddfa'
6
+ metadata.gz: 83bbe0ca77653a773bf29005236478865f1efb9917f312b5fc8f37485a3ddd068962f4eb2bac7da99916fcd0553b78ed140ac1900441c397e767bad39915c09d
7
+ data.tar.gz: fdf8aba88fb62518e52ea4dc65d44247706c5a578e078c224a850323737af2d886afc525fd431ca2652a8a65e375bfc2c960b94667e4839c155ab82f5b3462f1
data/ext/winevt/winevt.c CHANGED
@@ -5,6 +5,7 @@ VALUE rb_cQuery;
5
5
  VALUE rb_cEventLog;
6
6
  VALUE rb_cSubscribe;
7
7
  VALUE rb_eWinevtQueryError;
8
+ VALUE rb_eChannelNotFoundError;
8
9
  VALUE rb_eRemoteHandlerError;
9
10
 
10
11
  static ID id_call;
@@ -17,6 +18,7 @@ Init_winevt(void)
17
18
  rb_cQuery = rb_define_class_under(rb_cEventLog, "Query", rb_cObject);
18
19
  rb_cSubscribe = rb_define_class_under(rb_cEventLog, "Subscribe", rb_cObject);
19
20
  rb_eWinevtQueryError = rb_define_class_under(rb_cQuery, "Error", rb_eStandardError);
21
+ rb_eChannelNotFoundError = rb_define_class_under(rb_cEventLog, "ChannelNotFoundError", rb_eStandardError);
20
22
  rb_eRemoteHandlerError = rb_define_class_under(rb_cSubscribe, "RemoteHandlerError", rb_eRuntimeError);
21
23
 
22
24
  Init_winevt_channel(rb_cEventLog);
@@ -37,7 +37,8 @@ VALUE wstr_to_rb_str(UINT cp, const WCHAR* wstr, int clen);
37
37
  #if defined(__cplusplus)
38
38
  [[ noreturn ]]
39
39
  #endif /* __cplusplus */
40
- void raise_system_error(VALUE error, DWORD errorCode);
40
+ void raise_system_error(VALUE error, DWORD errorCode);
41
+ void raise_channel_not_found_error(VALUE channelPath);
41
42
  VALUE render_to_rb_str(EVT_HANDLE handle, DWORD flags);
42
43
  EVT_HANDLE connect_to_remote(LPWSTR computerName, LPWSTR domain,
43
44
  LPWSTR username, LPWSTR password,
@@ -58,6 +59,7 @@ extern VALUE rb_cChannel;
58
59
  extern VALUE rb_cBookmark;
59
60
  extern VALUE rb_cSubscribe;
60
61
  extern VALUE rb_eWinevtQueryError;
62
+ extern VALUE rb_eChannelNotFoundError;
61
63
  extern VALUE rb_eRemoteHandlerError;
62
64
  extern VALUE rb_cLocale;
63
65
  extern VALUE rb_cSession;
@@ -131,6 +131,9 @@ rb_winevt_query_initialize(VALUE argc, VALUE *argv, VALUE self)
131
131
  hRemoteHandle, evtChannel, evtXPath, EvtQueryChannelPath | EvtQueryTolerateQueryErrors);
132
132
  err = GetLastError();
133
133
  if (err != ERROR_SUCCESS) {
134
+ if (err == ERROR_EVT_CHANNEL_NOT_FOUND) {
135
+ raise_channel_not_found_error(channel);
136
+ }
134
137
  raise_system_error(rb_eRuntimeError, err);
135
138
  }
136
139
  winevtQuery->offset = 0L;
@@ -248,10 +248,17 @@ rb_winevt_subscribe_subscribe(int argc, VALUE* argv, VALUE self)
248
248
  if (hSignalEvent != NULL) {
249
249
  CloseHandle(hSignalEvent);
250
250
  }
251
+
251
252
  if (rb_obj_is_kind_of(rb_session, rb_cSession)) {
252
253
  rb_raise(rb_eRemoteHandlerError, "Remoting subscription is not working. errCode: %ld\n", status);
253
- } else {
254
+ }
255
+
256
+ switch (status) {
257
+ case ERROR_EVT_CHANNEL_NOT_FOUND:
258
+ raise_channel_not_found_error(rb_path);
259
+ default:
254
260
  raise_system_error(rb_eWinevtQueryError, status);
261
+ break;
255
262
  }
256
263
  }
257
264
 
@@ -56,6 +56,16 @@ raise_system_error(VALUE error, DWORD errorCode)
56
56
  #pragma GCC diagnostic pop
57
57
  }
58
58
 
59
+ void
60
+ raise_channel_not_found_error(VALUE channelPath)
61
+ {
62
+ #pragma GCC diagnostic push
63
+ #pragma GCC diagnostic ignored "-Wformat="
64
+ #pragma GCC diagnostic ignored "-Wformat-extra-args"
65
+ rb_raise(rb_eChannelNotFoundError, "Channel Not Found: %" PRIsVALUE, channelPath);
66
+ #pragma GCC diagnostic pop
67
+ }
68
+
59
69
  VALUE
60
70
  render_to_rb_str(EVT_HANDLE handle, DWORD flags)
61
71
  {
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winevt_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-14 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler