winevt_c 0.1.0-x64-mingw32 → 0.1.1-x64-mingw32

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: ac299bdab5f61eb7108f022f7e930aba63aeb4b5a0aabe048a53f9d7868c7b6f
4
- data.tar.gz: 1fe7f4beddd3550b12554ed94e17a3ec5428d5ed08933baecb1f44954fef1af5
3
+ metadata.gz: bfa938cac989d5c12314ad59291a24b89a80312f8c514d2f99f77d35d2272370
4
+ data.tar.gz: 00c375feaa5bc65c1d23dba9ceddaa215ab6a16f82170c1178661aba02c092d4
5
5
  SHA512:
6
- metadata.gz: c01f8be8e34a1cef3ff02f7a8dccb05e4321682a97b89cfbcc93cef31741c6725eb9d41e3924af7eef5a1704fda886735fd4671d9ba5923662944f4d638a5fa7
7
- data.tar.gz: 1ff1ecf9a1bff6a6d4948e4c5d16e314d5c8b06aa412a6de2bb108026ec56e312d87f18a20aad2a23b3790db992a30bf6e11d17b20013c67936b692331b49980
6
+ metadata.gz: 41a89c35d39ea59a78f59cb09afd273865952954ecd8c6bc22e02cd9be16944e8b218f1492abecc0772ab25a0f6336476e4a888d6d1ef4817e2b1bdbf8f1ace6
7
+ data.tar.gz: c2700a0f9ab3141fd2d00649a6df35b70a8bec2a045b8227e2a48b2aa3e148f3f2551459fa2e6212f8ee5e0793c69bad922cfab870adda83e050cf2aa7a95417
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # winevt_c
2
2
 
3
+ [![Build status](https://ci.appveyor.com/api/projects/status/hr3phv8ihvgc68oj/branch/master?svg=true)](https://ci.appveyor.com/project/cosmo0920/winevt-c/branch/master)
4
+
3
5
  ## Installation
4
6
 
5
7
  Add this line to your application's Gemfile:
data/ext/winevt/winevt.c CHANGED
@@ -32,7 +32,7 @@ static void subscribe_free(void *ptr);
32
32
  static void query_free(void *ptr);
33
33
  static void bookmark_free(void *ptr);
34
34
  static char* render_event(EVT_HANDLE handle, DWORD flags);
35
- static DWORD WINAPI SubscriptionCallback(EVT_SUBSCRIBE_NOTIFY_ACTION action, PVOID pContext, EVT_HANDLE hEvent);
35
+ static char* wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen);
36
36
 
37
37
  static const rb_data_type_t rb_winevt_channel_type = {
38
38
  "winevt/channel", {
@@ -128,7 +128,6 @@ rb_winevt_channel_each(VALUE self)
128
128
  DWORD bufferSize = 0;
129
129
  DWORD bufferUsed = 0;
130
130
  DWORD status = ERROR_SUCCESS;
131
- ULONG len;
132
131
 
133
132
  RETURN_ENUMERATOR(self, 0, 0);
134
133
 
@@ -166,9 +165,7 @@ rb_winevt_channel_each(VALUE self)
166
165
  }
167
166
  }
168
167
 
169
- len = WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
170
- if (!(result = malloc(len))) return "";
171
- WideCharToMultiByte(CP_UTF8, 0, buffer, -1, result, len, NULL, NULL);
168
+ result = wstr_to_mbstr(CP_UTF8, buffer, -1);
172
169
 
173
170
  rb_yield(rb_str_new2(result));
174
171
  }
@@ -176,6 +173,18 @@ rb_winevt_channel_each(VALUE self)
176
173
  return Qnil;
177
174
  }
178
175
 
176
+ static char *
177
+ wstr_to_mbstr(UINT cp, const WCHAR *wstr, int clen)
178
+ {
179
+ char *ptr;
180
+ int len = WideCharToMultiByte(cp, 0, wstr, clen, NULL, 0, NULL, NULL);
181
+ if (!(ptr = malloc(len))) return 0;
182
+ WideCharToMultiByte(cp, 0, wstr, clen, ptr, len, NULL, NULL);
183
+
184
+ return ptr;
185
+ }
186
+
187
+
179
188
  static void
180
189
  subscribe_free(void *ptr)
181
190
  {
@@ -568,7 +577,7 @@ static char* render_event(EVT_HANDLE handle, DWORD flags)
568
577
  ULONG bufferSize = 0;
569
578
  ULONG bufferSizeNeeded = 0;
570
579
  EVT_HANDLE event;
571
- ULONG len, status, count;
580
+ ULONG status, count;
572
581
  char* errBuf;
573
582
  char* result;
574
583
  LPTSTR msgBuf;
@@ -607,16 +616,15 @@ static char* render_event(EVT_HANDLE handle, DWORD flags)
607
616
  NULL, status,
608
617
  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
609
618
  &msgBuf, 0, NULL);
610
- len = WideCharToMultiByte(CP_UTF8, 0, msgBuf, -1, NULL, 0, NULL, NULL);
611
- if (!(result = malloc(len))) return "";
612
- WideCharToMultiByte(CP_UTF8, 0, msgBuf, -1, result, len, NULL, NULL);
619
+ result = wstr_to_mbstr(CP_ACP, msgBuf, -1);
613
620
 
614
621
  rb_raise(rb_eWinevtQueryError, "ErrorCode: %d\nError: %s\n", status, result);
615
622
  }
616
623
 
617
- len = WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
618
- if (!(result = malloc(len))) return "";
619
- WideCharToMultiByte(CP_UTF8, 0, buffer, -1, result, len, NULL, NULL);
624
+ result = wstr_to_mbstr(CP_UTF8, buffer, -1);
625
+
626
+ if (buffer)
627
+ free(buffer);
620
628
 
621
629
  return result;
622
630
  }
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.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.1.0
4
+ version: 0.1.1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-11 00:00:00.000000000 Z
11
+ date: 2019-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler