httpd.exe crashes after trying running the encrypted code in the browser.
I am using the XAMPP with PHP Version 5.4.31 in Windows 7 and VC++ 2008 Express to create and compile C++ code. maybe because of the bug that stated here, http://ift.tt/1ADcRbj. it my first time building php extension and after some search, cannot find the fix that suggested to use zend_memstream to replace tmpfile function.
thank before, and sorry, my English isn’t very good
the code php_screw.c
/*
* php_screw
* (C) 2007, Kunimasa Noda/PM9.com, Inc.
* see file LICENSE for license details
*/
#define PHP_COMPILER_ID "VC9"
#include "php.h"
#include "php_ini.h"
#include "ext/standard/file.h"
#include "ext/standard/info.h"
#include stdio.h
#include stdarg.h
#include string.h
#include sys/types.h
#include sys/stat.h
#ifdef WIN32
#include windows.h
#else
#include unistd.h
#endif
#include "php_screw.h"
#include "my_screw.h"
#include "Zend/zend_hash.h"
extern zend_module_entry php_screw_module_entry;
#define screw_module_ptr &php_screw_module_entry
#define phpext_screw_ptr screw_module_ptr
BEGIN_EXTERN_C()
ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
END_EXTERN_C()
PHP_MINIT_FUNCTION(php_screw);
PHP_MSHUTDOWN_FUNCTION(php_screw);
PHP_MINFO_FUNCTION(php_screw);
FILE *pm9screw_ext_fopen(FILE *fp)
{
struct stat stat_buf;
char *datap, *newdatap;
int datalen, newdatalen;
int cryptkey_len = sizeof pm9screw_mycryptkey / 2;
int i;
fstat(fileno(fp), &stat_buf);
datalen = stat_buf.st_size - PM9SCREW_LEN;
datap = (char*)malloc(datalen);
fread(datap, datalen, 1, fp);
fclose(fp);
for(i=0; ifilename, "rb");
if (!fp) {
return org_compile_file(file_handle, type TSRMLS_CC);
}
fread(buf, PM9SCREW_LEN, 1, fp);
if (memcmp(buf, PM9SCREW, PM9SCREW_LEN) != 0) {
fclose(fp);
return org_compile_file(file_handle, type TSRMLS_CC);
}
if (file_handle->type == ZEND_HANDLE_FP) fclose(file_handle->handle.fp);
if (file_handle->type == ZEND_HANDLE_FD) close(file_handle->handle.fd);
file_handle->handle.fp = pm9screw_ext_fopen(fp);
file_handle->type = ZEND_HANDLE_FP;
file_handle->opened_path = expand_filepath(file_handle->filename, NULL TSRMLS_CC);
return org_compile_file(file_handle, type TSRMLS_CC);
}
zend_module_entry php_screw_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"php_screw",
NULL,
PHP_MINIT(php_screw),
PHP_MSHUTDOWN(php_screw),
NULL,
NULL,
PHP_MINFO(php_screw),
#if ZEND_MODULE_API_NO >= 20010901
"1.5.0", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
ZEND_GET_MODULE(php_screw);
PHP_MINFO_FUNCTION(php_screw)
{
php_info_print_table_start();
php_info_print_table_header(2, "php_screw support", "enabled");
php_info_print_table_end();
}
PHP_MINIT_FUNCTION(php_screw)
{
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
org_compile_file = zend_compile_file;
zend_compile_file = pm9screw_compile_file;
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(php_screw)
{
CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
zend_compile_file = org_compile_file;
return SUCCESS;
}
Aucun commentaire:
Enregistrer un commentaire