This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwing_hardware_info.c
executable file
·117 lines (87 loc) · 2.65 KB
/
wing_hardware_info.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "php_wing.h"
#include "wing.h"
#include "helper/hardware_info.h"
#include <Iphlpapi.h>
#include <string.h>
#include <ctype.h>
#include <comdef.h>
#include <Wbemidl.h>
#include "helper/wing_malloc.h"
#pragma comment(lib, "wbemuuid.lib")
#pragma comment(lib, "Iphlpapi")
#pragma comment(lib, "ws2_32")
/**
* @»ñÈ¡Íø¿¨ÊÊÅäÆ÷ÐÅÏ¢
*/
ZEND_FUNCTION( wing_adapters_info )
{
array_init( return_value );
PIP_ADAPTER_INFO pIpAdaptTab = NULL;
ULONG ulLen = 0;
GetAdaptersInfo(pIpAdaptTab, &ulLen);
if ( ulLen == 0 )
{
return ;
}
pIpAdaptTab = (PIP_ADAPTER_INFO)malloc(ulLen);
if ( pIpAdaptTab == NULL )
{
return;
}
GetAdaptersInfo(pIpAdaptTab, &ulLen);
PIP_ADAPTER_INFO pTmp = pIpAdaptTab;
while ( pTmp != NULL )
{
zval *item;
MAKE_STD_ZVAL( item );
array_init(item);
char *mac_address;
spprintf( &mac_address , 0 , "%02x-%02x-%02x-%02x-%02x-%02x", pTmp->Address[0], pTmp->Address[1], pTmp->Address[2], pTmp->Address[3], pTmp->Address[4], pTmp->Address[5]);
add_assoc_string( item, "adapter_name", pTmp->AdapterName, 1 );
add_assoc_string( item, "adapter_description", pTmp->Description, 1 );
add_assoc_string( item, "ip_address", pTmp->IpAddressList.IpAddress.String, 1 );
add_assoc_string( item, "mac_address", mac_address, 0 );
add_next_index_zval( return_value, item );
pTmp = pTmp->Next;
}
free(pIpAdaptTab);
return;
}
ZEND_FUNCTION( wing_get_cpu_id ){
array_init( return_value );
char *sql = "SELECT * FROM Win32_Processor";
WingWmic mic;
mic.query(sql);
char *processor_id_item = NULL;
while( mic.next() ) {
processor_id_item = mic.get("ProcessorId");
if( processor_id_item != NULL )
{
zval *item;
MAKE_STD_ZVAL( item );
array_init( item );
add_assoc_string( item, "processor_id", processor_id_item, 1 );
wing_free( processor_id_item );
add_next_index_zval( return_value, item );
}
}
}
ZEND_FUNCTION( wing_get_serial_number ){
array_init( return_value );
char *sql = "SELECT * FROM Win32_PhysicalMedia";
WingWmic mic;
mic.query(sql);
char *serial_number_item = NULL;
while( mic.next() ) {
serial_number_item = mic.get("SerialNumber");
if( serial_number_item != NULL )
{
zval *item;
MAKE_STD_ZVAL( item );
array_init( item );
add_assoc_string( item, "serial_number", serial_number_item, 1 );
wing_free( serial_number_item );
add_next_index_zval( return_value, item );
}
}
}