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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2002 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: James Moore <jmoore@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#if HAVE_W32API
#ifndef PHP_W32API_H
#define PHP_W32API_H
extern zend_module_entry w32api_module_entry;
#define phpext_w32api_ptr &w32api_module_entry
#ifdef PHP_WIN32
#define PHP_W32API_API __declspec(dllexport)
#else
#define PHP_W32API_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
ZEND_BEGIN_MODULE_GLOBALS(w32api)
HashTable *regfuncs; // HashTable of Registered function handles
HashTable *libraries; // HashTable holding pointers to the libariers
HashTable *types; // Handles for users' types
int le_dynaparm; // Resource handle
DWORD call_type; // Type of call we use when calling a DLL.
ZEND_END_MODULE_GLOBALS(w32api)
#ifdef ZTS
#define W32_G(v) TSRMG(w32api_globals_id, zend_w32api_globals *, v)
#else
#define W32_G(v) (w32api_globals.v)
#endif
#define W32_REG_CONST(cname) REGISTER_LONG_CONSTANT(#cname, cname, CONST_CS | CONST_PERSISTENT);
#define DC_MICROSOFT 0x0000 // Default
#define DC_BORLAND 0x0001 // Borland compat
#define DC_CALL_CDECL 0x0010 // __cdecl
#define DC_CALL_STD 0x0020 // __stdcall
#define DC_RETVAL_MATH4 0x0100 // Return value in ST
#define DC_RETVAL_MATH8 0x0200 // Return value in ST
#define DC_CALL_STD_BO (DC_CALL_STD | DC_BORLAND)
#define DC_CALL_STD_MS (DC_CALL_STD | DC_MICROSOFT)
#define DC_CALL_STD_M8 (DC_CALL_STD | DC_RETVAL_MATH8)
#define DC_FLAG_ARGPTR 0x00000002
typedef struct W32APIFE {
FARPROC fp; // Pointer to the function
char *rettype; // return value type
int retvaltype; // if complex = 1 if simple = 0
} W32APIFE;
typedef struct _field {
char *fname; // Fields name
char *type; // Type of field
int fsize; // size of field
} field;
typedef struct runtime_struct {
char *name; // structs name
long size; // structs size
void *fields; // pointer to an array of fields
} runtime_struct;
#pragma pack(1) // Set struct packing to one byte
typedef union RESULT { // Various result types
int Int; // Generic four-byte type
long Long; // Four-byte long
void *Pointer; // 32-bit pointer
float Float; // Four byte real
double Double; // 8-byte real
__int64 int64; // big int (64-bit)
} RESULT;
typedef struct DYNAPARM {
DWORD dwFlags; // Parameter flags
int nWidth; // Byte width
union { //
DWORD dwArg; // 4-byte argument
void *pArg; // Pointer to argument
};
} DYNAPARM;
PHP_W32API_API RESULT php_w32api_dynamic_dll_call(
int Flags,
DWORD lpFunction,
int nArgs,
DYNAPARM Param[],
LPVOID pRet,
int nRetSize
);
static void php_w32api_init_globals(zend_w32api_globals *w32api_globals);
static void php_w32api_dtor_libary(void *data);
static void php_w32api_unload_libraries();
PHP_MINFO_FUNCTION(w32api);
PHP_MINIT_FUNCTION(w32api);
PHP_MSHUTDOWN_FUNCTION(w32api);
PHP_FUNCTION(w32api_register_function);
PHP_FUNCTION(w32api_invoke_function);
PHP_FUNCTION(w32api_deftype);
PHP_FUNCTION(w32api_init_dtype);
PHP_FUNCTION(w32api_set_call_method);
static void register_constants(int module_number);
static void w32api_free_dynaparm(zend_rsrc_list_entry *rsrc TSRMLS_DC);
void get_arg_pointer(zval **value, void ** argument);
DYNAPARM w32api_convert_zval_to_dynparam(zval ** carg TSRMLS_DC);
#endif /* PHP_W32API_H */
#endif /* HAVE_W32API */
|