winevt_c 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4aea52298871b70f5fa9f0c01227cd4afb79a188b75e4870a680ed435b7d19fe
4
- data.tar.gz: 26ac8f251f2dd6cf077f7481066d1305e023986438a0fbd50fe9fec9dd97c266
3
+ metadata.gz: 1069bcfe57cfd91d05fcff1a7314929c01c675d30678b8a624c926eb0a91b09f
4
+ data.tar.gz: bea008c2cf452539b59a9d22800183797babcbb5158e5f6688dd3fd749dc4e3d
5
5
  SHA512:
6
- metadata.gz: 6e6683d23e26dfa60e4a4e31bb03a434f2e01025c1072de8930d8ca98b7090dd4128711540c65ba35b5d53ca142251bc5eb3881ad1df1af3679c5d84faa2b1f7
7
- data.tar.gz: b83a9f1f27428c75f9735297fa19abae507240956a587df4b38c9f0b983f4f1ed82dc4c30ccd64fe4cb12ad7b8ae7b6a70bb89c50bd3e280a568c9eda768d7a2
6
+ metadata.gz: 81ef978d005e6c87607cc187509f8e5ae52b33b7687100148139b050c09d61cbb813fe1e77f8ccc0a02fa881d6a8066b6f7c959f45be3ff65c79e77b03dbd247
7
+ data.tar.gz: c27480331ce8d8cfab82cd00ef4bd940e3a4224076db6641e9bb49019a2d88dac2ee73790153a20cf2bbafa1db6844b876f59cb53c249251460b6eb97b895c99
@@ -9,7 +9,9 @@
9
9
  * require 'winevt'
10
10
  * channels = []
11
11
  * @channel = Winevt::EventLog::Channel.new
12
- * # If users want to retrive all channel name, it should be set as true.
12
+ * # If users want to retrieve all channel names that
13
+ * # including type of Debug and Analytical,
14
+ * # it should be set as true.
13
15
  * @channel.force_enumerate = false
14
16
  * @channel.each do |channel|
15
17
  * channels << channel
@@ -117,7 +119,7 @@ DWORD is_subscribable_channel_p(EVT_HANDLE hChannel, BOOL force_enumerate)
117
119
  DWORD status = ERROR_SUCCESS;
118
120
 
119
121
  for (int Id = 0; Id < EvtChannelConfigPropertyIdEND; Id++) {
120
- if (!EvtGetChannelConfigProperty(hChannel, (EVT_CHANNEL_CONFIG_PROPERTY_ID)Id, 0, dwBufferSize, pProperty, &dwBufferUsed)) {
122
+ if (!EvtGetChannelConfigProperty(hChannel, (EVT_CHANNEL_CONFIG_PROPERTY_ID)Id, 0, dwBufferSize, pProperty, &dwBufferUsed)) {
121
123
  status = GetLastError();
122
124
  if (ERROR_INSUFFICIENT_BUFFER == status) {
123
125
  dwBufferSize = dwBufferUsed;
@@ -126,18 +128,20 @@ DWORD is_subscribable_channel_p(EVT_HANDLE hChannel, BOOL force_enumerate)
126
128
  pProperty = pTemp;
127
129
  pTemp = NULL;
128
130
  EvtGetChannelConfigProperty(hChannel, (EVT_CHANNEL_CONFIG_PROPERTY_ID)Id, 0, dwBufferSize, pProperty, &dwBufferUsed);
131
+ status = GetLastError();
129
132
  } else {
130
133
  free(pProperty);
131
134
 
132
135
  status = ERROR_OUTOFMEMORY;
133
- rb_raise(rb_eRuntimeError, "realloc failed with %ld\n", status);
136
+
137
+ goto cleanup;
134
138
  }
135
139
  }
136
140
 
137
- if (ERROR_SUCCESS != (status = GetLastError())) {
141
+ if (ERROR_SUCCESS != status) {
138
142
  free(pProperty);
139
143
 
140
- rb_raise(rb_eRuntimeError, "EvtGetChannelConfigProperty failed with %ld\n", GetLastError());
144
+ goto cleanup;
141
145
  }
142
146
  }
143
147
 
@@ -146,6 +150,8 @@ DWORD is_subscribable_channel_p(EVT_HANDLE hChannel, BOOL force_enumerate)
146
150
  break;
147
151
  }
148
152
 
153
+ cleanup:
154
+
149
155
  free(pProperty);
150
156
 
151
157
  return status;
@@ -246,6 +252,10 @@ rb_winevt_channel_each(VALUE self)
246
252
  _TRUNCATE,
247
253
  "EvtOpenChannelConfig failed with %lu.\n",
248
254
  GetLastError());
255
+
256
+ EvtClose(winevtChannel->channels);
257
+ winevtChannel->channels = NULL;
258
+
249
259
  free(buffer);
250
260
  buffer = NULL;
251
261
  bufferSize = 0;
@@ -254,8 +264,35 @@ rb_winevt_channel_each(VALUE self)
254
264
  }
255
265
 
256
266
  status = is_subscribable_channel_p(hChannelConfig, winevtChannel->force_enumerate);
257
- if (status != ERROR_SUCCESS)
267
+ EvtClose(hChannelConfig);
268
+
269
+ if (status == ERROR_INVALID_DATA) {
270
+ free(buffer);
271
+ buffer = NULL;
272
+ bufferSize = 0;
273
+
258
274
  continue;
275
+ }
276
+
277
+ if (status == ERROR_OUTOFMEMORY) {
278
+ EvtClose(winevtChannel->channels);
279
+ winevtChannel->channels = NULL;
280
+
281
+ free(buffer);
282
+ buffer = NULL;
283
+ bufferSize = 0;
284
+
285
+ rb_raise(rb_eRuntimeError, "realloc failed\n");
286
+ } else if (status != ERROR_SUCCESS) {
287
+ EvtClose(winevtChannel->channels);
288
+ winevtChannel->channels = NULL;
289
+
290
+ free(buffer);
291
+ buffer = NULL;
292
+ bufferSize = 0;
293
+
294
+ rb_raise(rb_eRuntimeError, "is_subscribe_channel_p is failed with %ld\n", status);
295
+ }
259
296
 
260
297
  utf8str = wstr_to_rb_str(CP_UTF8, buffer, -1);
261
298
 
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake