• ? bcompiler_write_constant
  • bcompiler_write_file ?
  • ����ѧԺ www.cainiaoplay.com
  • PHP Manual
  • bcompiler ����
  • д�뿪ʼλ���Լ� exe �����ļ��Ľ�β�ź�

bcompiler_write_exe_footer

(PECL bcompiler >= 0.4)

bcompiler_write_exe_footer — д�뿪ʼλ���Լ� exe �����ļ��Ľ�β�ź�

˵��

bcompiler_write_exe_footer ( resource $filehandle , int $startpos ) : bool

һ�� EXE�������ִ�У��ļ��� 3 ������ɣ�

  • The stub ����ִ�д��룬����һ��������� c ���� ������ PHP ��������bcompiler ��չ��������ֽ��벢��ʼ������ָ������������ main�� ����ķ��������� main::main����
  • �ֽ��루������ʱδѹ����
  • bcompiler �� EXE β��

Ϊ�˵õ��ʺϵ� stub ����Ա���λ�� bcompiler CVS examples/embed Ŀ¼�� ���� php_embed �� stub phpe.c��

����

filehandle

fopen()���ص�һ���ļ������

startpos

�ֽ������ļ��п�ʼ��λ�ã�����ͨ�� ftell() ��ȡ��

����ֵ

�ɹ�ʱ���� TRUE�� ������ʧ��ʱ���� FALSE��

����

Example #1 bcompiler_write_exe_footer() ����

<?php

/* ����������ļ���example.exe�� */
$fh = fopen("example.exe", "w");

/* 1) д��һ�� stub ��phpe.exe�� */
$size = filesize("phpe.exe");
$fr = fopen("phpe.exe", "r");
fwrite($fh, fread($fr, $size), $size);
$startpos = ftell($fh);

/* 2) д���ֽ��� */
bcompiler_write_header($fh);
bcompiler_write_class($fh, "myclass");
bcompiler_write_function($fh, "main");
bcompiler_write_footer($fh);

/* 3) д�� EXE β�� */
bcompiler_write_exe_footer($fh, $startpos);

/* �ر�������ļ� */
fclose($fh);
?>

ע��

Warning

�˺�����ʵ�����ġ��˺����ı��󣬰������Ƽ�������ĵ���������δ���� PHP �����汾��δ֪ͨ�ͱ��޸ġ�ʹ�ñ����������Ե� ��

�μ�

  • bcompiler_write_header() - д�� bcompiler ͷ
  • bcompiler_write_class() - д�붨���������ֽ���
  • bcompiler_write_footer() - д�뵥���ַ� \x00 ���ڱ�ʶ�������ݵĽ�β