line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::MprApi;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7534
|
use 5.006;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
61
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
#use warnings;
|
6
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
87
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1162
|
use Socket;
|
|
1
|
|
|
|
|
4658
|
|
|
1
|
|
|
|
|
1522
|
|
9
|
1
|
|
|
1
|
|
2456
|
use Win32::API;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export
|
16
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead.
|
17
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants.
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This allows declaration use Win32::MprApi ':all';
|
20
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
21
|
|
|
|
|
|
|
# will save memory.
|
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = (
|
23
|
|
|
|
|
|
|
'all' => [ qw( MprConfigServerConnect MprConfigServerDisconnect MprConfigGetGuidName MprConfigGetFriendlyName ) ]
|
24
|
|
|
|
|
|
|
);
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw();
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $MprConfigServerConnect = new Win32::API ('Mprapi', 'MprConfigServerConnect', ['P', 'P'], 'N') or croak 'can\'t find MprConfigServerConnect() function';
|
33
|
|
|
|
|
|
|
my $MprConfigServerDisconnect = new Win32::API ('Mprapi', 'MprConfigServerDisconnect', ['N'], 'N') or croak 'can\'t find MprConfigServerDisconnect() function';
|
34
|
|
|
|
|
|
|
my $MprConfigGetGuidName = new Win32::API ('Mprapi', 'MprConfigGetGuidName', ['N', 'P', 'P', 'N'], 'N') or croak 'can\'t find MprConfigGetGuidName() function';
|
35
|
|
|
|
|
|
|
my $MprConfigGetFriendlyName = new Win32::API ('Mprapi', 'MprConfigGetFriendlyName', ['N', 'P', 'P', 'N'], 'N') or croak 'can\'t find MprConfigGetFriendlyName() function';
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Preloaded methods go here.
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use enum qw(
|
40
|
|
|
|
|
|
|
NO_ERROR=0
|
41
|
|
|
|
|
|
|
:MAX_INTERFACE_
|
42
|
|
|
|
|
|
|
NAME_LENGTH=128
|
43
|
|
|
|
|
|
|
:MAX_ADAPTER_
|
44
|
|
|
|
|
|
|
ADDRESS_LENGTH=8
|
45
|
|
|
|
|
|
|
DESCRIPTION_LENGTH=128
|
46
|
|
|
|
|
|
|
NAME=128
|
47
|
|
|
|
|
|
|
NAME_LENGTH=256
|
48
|
|
|
|
|
|
|
:ERROR_
|
49
|
|
|
|
|
|
|
SUCCESS=0
|
50
|
|
|
|
|
|
|
NOT_SUPPORTED=50
|
51
|
|
|
|
|
|
|
INVALID_PARAMETER=87
|
52
|
|
|
|
|
|
|
BUFFER_OVERFLOW=111
|
53
|
|
|
|
|
|
|
INSUFFICIENT_BUFFER=122
|
54
|
|
|
|
|
|
|
NO_DATA=232
|
55
|
|
|
|
|
|
|
);
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
our $DEBUG = 0;
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#################################
|
60
|
|
|
|
|
|
|
# PUBLIC Functions (exportable) #
|
61
|
|
|
|
|
|
|
#################################
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#######################################################################
|
64
|
|
|
|
|
|
|
# Win32::MprApi::MprConfigServerConnect()
|
65
|
|
|
|
|
|
|
#
|
66
|
|
|
|
|
|
|
# The MprConfigServerConnect function connects to the Windows 2000
|
67
|
|
|
|
|
|
|
# router to be configured. Call this function before making any other
|
68
|
|
|
|
|
|
|
# calls to the server. The handle returned by this function is used in
|
69
|
|
|
|
|
|
|
# subsequent calls to configure interfaces and transports on the server.
|
70
|
|
|
|
|
|
|
#
|
71
|
|
|
|
|
|
|
#######################################################################
|
72
|
|
|
|
|
|
|
# Prototype
|
73
|
|
|
|
|
|
|
#
|
74
|
|
|
|
|
|
|
# DWORD MprConfigServerConnect(
|
75
|
|
|
|
|
|
|
# LPWSTR lpwsServerName,
|
76
|
|
|
|
|
|
|
# HANDLE* phMprConfig
|
77
|
|
|
|
|
|
|
# );
|
78
|
|
|
|
|
|
|
#
|
79
|
|
|
|
|
|
|
# Parameters
|
80
|
|
|
|
|
|
|
# lpwsServerName
|
81
|
|
|
|
|
|
|
# [in] Pointer to a Unicode string that specifies the name of the
|
82
|
|
|
|
|
|
|
# remote server to configure. If this parameter is NULL, the
|
83
|
|
|
|
|
|
|
# function returns a handle to the router configuration on the local machine .
|
84
|
|
|
|
|
|
|
# phMprConfig
|
85
|
|
|
|
|
|
|
# [out] Pointer to a handle variable. This variable receives a
|
86
|
|
|
|
|
|
|
# handle to the router configuration.
|
87
|
|
|
|
|
|
|
#
|
88
|
|
|
|
|
|
|
# Return Values
|
89
|
|
|
|
|
|
|
# If the function succeeds, the return value is NO_ERROR.
|
90
|
|
|
|
|
|
|
# If the function fails, the return value is one of the following error codes.
|
91
|
|
|
|
|
|
|
#
|
92
|
|
|
|
|
|
|
# Value Meaning
|
93
|
|
|
|
|
|
|
# ERROR_INVALID_PARAMETER The phMprConfig parameter is NULL.
|
94
|
|
|
|
|
|
|
# ERROR_NOT_ENOUGH_MEMORY Insufficient resources to complete the operation.
|
95
|
|
|
|
|
|
|
# Other Use FormatMessage to retrieve the system error message that
|
96
|
|
|
|
|
|
|
# corresponds to the error code returned.
|
97
|
|
|
|
|
|
|
#
|
98
|
|
|
|
|
|
|
# Usage:
|
99
|
|
|
|
|
|
|
# $ret = MprConfigServerConnect(\$ServerName, \$hMprConfig);
|
100
|
|
|
|
|
|
|
#
|
101
|
|
|
|
|
|
|
#######################################################################
|
102
|
|
|
|
|
|
|
sub MprConfigServerConnect
|
103
|
|
|
|
|
|
|
{
|
104
|
|
|
|
|
|
|
if(scalar(@_) ne 2)
|
105
|
|
|
|
|
|
|
{
|
106
|
|
|
|
|
|
|
croak 'Usage: MprConfigServerConnect(\\\$ServerName, \\\$hMprConfig)';
|
107
|
|
|
|
|
|
|
}
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $lpwsServerName = shift;
|
110
|
|
|
|
|
|
|
my $phMprConfig = shift;
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# $MprConfigServerConnect = new Win32::API ('Mprapi', 'MprConfigServerConnect', ['P', 'P'], 'N') or croak 'can\'t find MprConfigServerConnect() function';
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# prepare buffer
|
115
|
|
|
|
|
|
|
$$phMprConfig = pack("L", 0);
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# function call
|
118
|
|
|
|
|
|
|
my $ret = $MprConfigServerConnect->Call(_ToUnicodeSz($$lpwsServerName), $$phMprConfig);
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
if($ret != NO_ERROR)
|
121
|
|
|
|
|
|
|
{
|
122
|
|
|
|
|
|
|
$DEBUG and carp sprintf "MprConfigServerConnect() %s\n", Win32::FormatMessage($ret);
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# unpack handle for later uses...
|
126
|
|
|
|
|
|
|
$$phMprConfig = unpack('L', $$phMprConfig);
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return $ret;
|
129
|
|
|
|
|
|
|
}
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#######################################################################
|
133
|
|
|
|
|
|
|
# Win32::MprApi::MprConfigServerDisconnect()
|
134
|
|
|
|
|
|
|
#
|
135
|
|
|
|
|
|
|
# The MprConfigServerDisconnect function disconnects a connection made
|
136
|
|
|
|
|
|
|
# by a previous call to MprConfigServerConnect.
|
137
|
|
|
|
|
|
|
#
|
138
|
|
|
|
|
|
|
#######################################################################
|
139
|
|
|
|
|
|
|
# Usage:
|
140
|
|
|
|
|
|
|
# $ret = MprConfigServerDisconnect($hMprConfig);
|
141
|
|
|
|
|
|
|
#
|
142
|
|
|
|
|
|
|
# Parameters:
|
143
|
|
|
|
|
|
|
# hMprConfig
|
144
|
|
|
|
|
|
|
# [in] Handle to a router configuration obtained from a previous call to MprConfigServerConnect.
|
145
|
|
|
|
|
|
|
#
|
146
|
|
|
|
|
|
|
#######################################################################
|
147
|
|
|
|
|
|
|
# function MprConfigServerDisconnect
|
148
|
|
|
|
|
|
|
#
|
149
|
|
|
|
|
|
|
# The MprConfigServerDisconnect function disconnects a connection made
|
150
|
|
|
|
|
|
|
# by a previous call to MprConfigServerConnect.
|
151
|
|
|
|
|
|
|
#
|
152
|
|
|
|
|
|
|
#
|
153
|
|
|
|
|
|
|
# void MprConfigServerDisconnect(
|
154
|
|
|
|
|
|
|
# HANDLE hMprConfig
|
155
|
|
|
|
|
|
|
# );
|
156
|
|
|
|
|
|
|
#
|
157
|
|
|
|
|
|
|
#
|
158
|
|
|
|
|
|
|
#######################################################################
|
159
|
|
|
|
|
|
|
sub MprConfigServerDisconnect
|
160
|
|
|
|
|
|
|
{
|
161
|
|
|
|
|
|
|
if(scalar(@_) ne 1)
|
162
|
|
|
|
|
|
|
{
|
163
|
|
|
|
|
|
|
croak 'Usage: MprConfigServerDisconnect(\$hMprConfig)';
|
164
|
|
|
|
|
|
|
}
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
my $hMprConfig = shift;
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# $MprConfigServerDisconnect = new Win32::API ('Mprapi', 'MprConfigServerDisconnect', ['N'], 'N') or croak 'can\'t find MprConfigServerDisconnect() function';
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# function call
|
171
|
|
|
|
|
|
|
$MprConfigServerDisconnect->Call($hMprConfig);
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
return undef;
|
174
|
|
|
|
|
|
|
}
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#######################################################################
|
178
|
|
|
|
|
|
|
# Win32::MprApi::MprConfigGetGuidName()
|
179
|
|
|
|
|
|
|
#
|
180
|
|
|
|
|
|
|
# The MprConfigGetGuidName function returns the GUID name for an
|
181
|
|
|
|
|
|
|
# interface that corresponds to the specified friendly name.
|
182
|
|
|
|
|
|
|
#
|
183
|
|
|
|
|
|
|
#######################################################################
|
184
|
|
|
|
|
|
|
# Usage:
|
185
|
|
|
|
|
|
|
# $ret = MprConfigGetGuidName($hMprConfig, \$FriendlyName, \$GUIDName [, $dwBufferSize]);
|
186
|
|
|
|
|
|
|
#
|
187
|
|
|
|
|
|
|
# Output:
|
188
|
|
|
|
|
|
|
# $ret = 0 for success, a number for error
|
189
|
|
|
|
|
|
|
#
|
190
|
|
|
|
|
|
|
# Parameters:
|
191
|
|
|
|
|
|
|
#
|
192
|
|
|
|
|
|
|
# $hMprConfig
|
193
|
|
|
|
|
|
|
# [in] Handle to the router configuration. Obtain this handle by calling MprConfigServerConnect.
|
194
|
|
|
|
|
|
|
# $pszFriendlyName
|
195
|
|
|
|
|
|
|
# [in] Pointer to a Unicode string that specifies the friendly name for the interface.
|
196
|
|
|
|
|
|
|
# $pszBuffer
|
197
|
|
|
|
|
|
|
# [out] Pointer to a buffer that receives the GUID name for the interface.
|
198
|
|
|
|
|
|
|
# $dwBufferSize
|
199
|
|
|
|
|
|
|
# [in] Specifies the size, in bytes, of the buffer pointed to by pszBuffer.
|
200
|
|
|
|
|
|
|
#
|
201
|
|
|
|
|
|
|
#######################################################################
|
202
|
|
|
|
|
|
|
#
|
203
|
|
|
|
|
|
|
# DWORD MprConfigGetGuidName(
|
204
|
|
|
|
|
|
|
# HANDLE hMprConfig,
|
205
|
|
|
|
|
|
|
# PWCHAR pszFriendlyName,
|
206
|
|
|
|
|
|
|
# PWCHAR pszBuffer,
|
207
|
|
|
|
|
|
|
# DWORD dwBufferSize
|
208
|
|
|
|
|
|
|
# );
|
209
|
|
|
|
|
|
|
#
|
210
|
|
|
|
|
|
|
#######################################################################
|
211
|
|
|
|
|
|
|
sub MprConfigGetGuidName
|
212
|
|
|
|
|
|
|
{
|
213
|
|
|
|
|
|
|
if((scalar(@_) ne 3) and (scalar(@_) ne 4))
|
214
|
|
|
|
|
|
|
{
|
215
|
|
|
|
|
|
|
croak 'Usage: MprConfigGetGuidName(\$hMprConfig, \\\$FriendlyName, \\\$GUIDName [, \$dwBufferSize])';
|
216
|
|
|
|
|
|
|
}
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
my $phMprConfig = shift;
|
219
|
|
|
|
|
|
|
my $szFriendlyName = shift;
|
220
|
|
|
|
|
|
|
my $pszBuffer = shift;
|
221
|
|
|
|
|
|
|
my $dwBufferSize = shift || 256;
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# $MprConfigGetGuidName = new Win32::API ('Mprapi', 'MprConfigGetGuidName', ['N', 'P', 'P', 'N'], 'N') or croak 'can\'t find MprConfigGetGuidName() function';
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# prepare buffer
|
226
|
|
|
|
|
|
|
$$pszBuffer = "\x00" x $dwBufferSize;
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# function call
|
229
|
|
|
|
|
|
|
my $ret = $MprConfigGetGuidName->Call($phMprConfig, _ToUnicodeSz($$szFriendlyName), $$pszBuffer, $dwBufferSize);
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
if($ret != NO_ERROR)
|
232
|
|
|
|
|
|
|
{
|
233
|
|
|
|
|
|
|
$DEBUG and carp sprintf "MprConfigGetGuidName() %s\n", Win32::FormatMessage($ret);
|
234
|
|
|
|
|
|
|
}
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# translate resulting guid name from wide char
|
237
|
|
|
|
|
|
|
$$pszBuffer = _FromUnicode($$pszBuffer);
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
return $ret;
|
240
|
|
|
|
|
|
|
}
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
#######################################################################
|
244
|
|
|
|
|
|
|
# Win32::MprApi::MprConfigGetFriendlyName()
|
245
|
|
|
|
|
|
|
#
|
246
|
|
|
|
|
|
|
# The MprConfigGetFriendlyName function returns the friendly name for
|
247
|
|
|
|
|
|
|
# an interface that corresponds to the specified GUID name.
|
248
|
|
|
|
|
|
|
#
|
249
|
|
|
|
|
|
|
#######################################################################
|
250
|
|
|
|
|
|
|
# Usage:
|
251
|
|
|
|
|
|
|
# $ret = MprConfigGetFriendlyName($hMprConfig, \$GUIDName, \$FriendlyName [, $BufferSize]);
|
252
|
|
|
|
|
|
|
#
|
253
|
|
|
|
|
|
|
# Output:
|
254
|
|
|
|
|
|
|
# $ret = 0 for success, a number for error
|
255
|
|
|
|
|
|
|
#
|
256
|
|
|
|
|
|
|
# Parameters:
|
257
|
|
|
|
|
|
|
#
|
258
|
|
|
|
|
|
|
# $hMprConfig
|
259
|
|
|
|
|
|
|
# [in] Handle to the router configuration. Obtain this handle by calling MprConfigServerConnect.
|
260
|
|
|
|
|
|
|
# $pszGuidName
|
261
|
|
|
|
|
|
|
# [in] Pointer to a null-terminated Unicode string that specifies the GUID name for the interface.
|
262
|
|
|
|
|
|
|
# $pszBuffer
|
263
|
|
|
|
|
|
|
# [out] Pointer to a buffer that receives the friendly name for the interface.
|
264
|
|
|
|
|
|
|
# $dwBufferSize
|
265
|
|
|
|
|
|
|
# [in] Specifies the size, in bytes, of the buffer pointed to by pszBuffer.
|
266
|
|
|
|
|
|
|
#
|
267
|
|
|
|
|
|
|
#######################################################################
|
268
|
|
|
|
|
|
|
#
|
269
|
|
|
|
|
|
|
# DWORD MprConfigGetFriendlyName(
|
270
|
|
|
|
|
|
|
# HANDLE hMprConfig,
|
271
|
|
|
|
|
|
|
# PWCHAR pszFriendlyName,
|
272
|
|
|
|
|
|
|
# PWCHAR pszBuffer,
|
273
|
|
|
|
|
|
|
# DWORD dwBufferSize
|
274
|
|
|
|
|
|
|
# );
|
275
|
|
|
|
|
|
|
#
|
276
|
|
|
|
|
|
|
#######################################################################
|
277
|
|
|
|
|
|
|
sub MprConfigGetFriendlyName
|
278
|
|
|
|
|
|
|
{
|
279
|
|
|
|
|
|
|
if((scalar(@_) ne 3) and (scalar(@_) ne 4))
|
280
|
|
|
|
|
|
|
{
|
281
|
|
|
|
|
|
|
croak 'Usage: MprConfigGetFriendlyName(\$hMprConfig, \\\$GUIDName, \\\$FriendlyName [, \$BufferSize])';
|
282
|
|
|
|
|
|
|
}
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
my $phMprConfig = shift;
|
285
|
|
|
|
|
|
|
my $szGuidName = shift;
|
286
|
|
|
|
|
|
|
my $pszBuffer = shift;
|
287
|
|
|
|
|
|
|
my $dwBufferSize = shift || 256;
|
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
# $MprConfigGetFriendlyName = new Win32::API ('Mprapi', 'MprConfigGetFriendlyName', ['N', 'P', 'P', 'N'], 'N') or croak 'can\'t find MprConfigGetFriendlyName() function';
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# prepare buffer
|
292
|
|
|
|
|
|
|
$$pszBuffer = "\x00" x $dwBufferSize;
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# function call
|
295
|
|
|
|
|
|
|
my $ret = $MprConfigGetFriendlyName->Call($phMprConfig, _ToUnicodeSz($$szGuidName), $$pszBuffer, $dwBufferSize);
|
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
if($ret != NO_ERROR)
|
298
|
|
|
|
|
|
|
{
|
299
|
|
|
|
|
|
|
$DEBUG and carp sprintf "MprConfigGetFriendlyName() %s\n", Win32::FormatMessage($ret);
|
300
|
|
|
|
|
|
|
}
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# translate resulting friendly name from wide char
|
303
|
|
|
|
|
|
|
$$pszBuffer = _FromUnicode($$pszBuffer);
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
return $ret;
|
306
|
|
|
|
|
|
|
}
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
######################################
|
310
|
|
|
|
|
|
|
# PRIVATE Functions (not exportable) #
|
311
|
|
|
|
|
|
|
######################################
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
#######################################################################
|
314
|
|
|
|
|
|
|
# WCHAR = _ToUnicodeChar(string)
|
315
|
|
|
|
|
|
|
# converts a perl string in a 16-bit (pseudo) unicode string
|
316
|
|
|
|
|
|
|
#######################################################################
|
317
|
|
|
|
|
|
|
sub _ToUnicodeChar
|
318
|
|
|
|
|
|
|
{
|
319
|
|
|
|
|
|
|
my $string = shift or return(undef);
|
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
$string =~ s/(.)/$1\x00/sg;
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
return $string;
|
324
|
|
|
|
|
|
|
}
|
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
#######################################################################
|
328
|
|
|
|
|
|
|
# WSTR = _ToUnicodeSz(string)
|
329
|
|
|
|
|
|
|
# converts a perl string in a null-terminated 16-bit (pseudo) unicode string
|
330
|
|
|
|
|
|
|
#######################################################################
|
331
|
|
|
|
|
|
|
sub _ToUnicodeSz
|
332
|
|
|
|
|
|
|
{
|
333
|
|
|
|
|
|
|
my $string = shift or return(undef);
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
return _ToUnicodeChar($string."\x00");
|
336
|
|
|
|
|
|
|
}
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
#######################################################################
|
340
|
|
|
|
|
|
|
# string = _FromUnicode(WSTR)
|
341
|
|
|
|
|
|
|
# converts a null-terminated 16-bit unicode string into a regular perl string
|
342
|
|
|
|
|
|
|
#######################################################################
|
343
|
|
|
|
|
|
|
sub _FromUnicode
|
344
|
|
|
|
|
|
|
{
|
345
|
|
|
|
|
|
|
my $string = shift or return(undef);
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
$string = unpack("Z*", pack( "C*", unpack("S*", $string)));
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
return($string);
|
350
|
|
|
|
|
|
|
}
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
1;
|
354
|
|
|
|
|
|
|
__END__
|