首页 > 其他 > 详细

测试01

时间:2018-01-08 23:24:06      阅读:238      评论:0      收藏:0      [点我收藏+]

1、

unit formMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Memo1: TMemo;
    edtDestHWnd: TEdit;
    Label1: TLabel;
    Button4: TButton;
    Button5: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private

  public
    procedure TestParam(_i :integer; _f :single; _d :double; _pc :PChar; _pi :PInteger);stdcall;
    procedure Test(_i, _j :integer);stdcall;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var hWnd1 :HWND;
begin
  hWnd1 := strtoint($+trim(edtDestHWnd.Text));
  PostMessage(hWnd1, WM_USER+1000, 0, 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
var hWnd1 :HWND;
begin
  hWnd1 := strtoint($+trim(edtDestHWnd.Text));
  PostMessage(hWnd1, WM_USER+1001, 0, 0);
end;

procedure TForm1.Button3Click(Sender: TObject);
var hWnd1 :HWND;
begin
  hWnd1 := strtoint($+trim(edtDestHWnd.Text));
  SendMessage(hWnd1, WM_USER+1001, 0, 0);
end;

{$O-}
procedure TForm1.Button4Click(Sender: TObject);
var pc, pc1 :PChar;
    i, j :integer;
    str :string;
    iLow, iHigh :integer;
    d :double;
    f :single;
begin
pc := ABC;

  j := integer(@i);
  str := inttohex(j, 8);//str: ‘0018F574‘
  j := integer(pc);
  str := inttohex(j, 8);// str: ‘00403277‘
  j := integer(@pc);
  str := inttohex(j, 8);// str: ‘00403277‘

  d := 3.0;
  pc1 := PChar(@d);

  CopyMemory(@iLow, pc1, 4);
  CopyMemory(@iHigh, @pc1[4], 4);
  str := inttohex(iLow, 8); // 0
  str := inttohex(iHigh, 8);// str: ‘40080000‘

  f := 2.0;
  CopyMemory(@j, @f, 4);
  str := inttohex(j, 8);// str: ‘40000000‘

  TestParam(1, 2.0, 3.0, pc, @i);
end;
{$O+}
{$O-}
procedure TForm1.Test(_i, _j: integer);stdcall;
begin
  try
    _i := _i div  _j;
  finally
    _i := 3;
  end;
end;

procedure TForm1.TestParam(_i: integer; _f: single; _d: double; _pc :PChar; _pi :PInteger);stdcall;
begin

end;
{$O+}

procedure TForm1.Button5Click(Sender: TObject);
begin
//  Test(6, 3);
  Test(6, 0);
end;

end.

 

2、

#include <stdio.h>
#include <windows.h>

void __stdcall TestParam(int _i, float _f, double _d, char* _pc, int* _pi)
{
}

void __stdcall Test(int _i, int _j)
{
    //__try
    //{
        _i = _i / _j;
    //}
    //__finally
    //{
    //    _i = 3;
    //}
}

void main()
{
    __asm
    {
        mov eax,eax
        mov eax,eax
        mov eax,eax
        //int 3
    }
    Test(6, 0);
}

//void main()
//{
//    char * pc = "ABC";
//    printf("pc : %X\n", (int)pc);
//
//    char *pc1 = NULL;
//    float f = 2.0;
//    double d = 3.0;
//
//    DWORD dwLow = 0, dwHigh=0;
//
//    pc1 = (char*)&f;
//    memcpy(&dwLow, pc1, 4);
//    printf("f : %X\n", dwLow);
//
//    pc1 = (char*)&d;
//    memcpy(&dwLow, pc1, 4);
//    memcpy(&dwHigh, &pc1[4], 4);
//    printf("d[low] : %X\n", dwLow);
//    printf("d[high] : %X\n", dwHigh);
//
//    int i = 6;
//    printf("&i : %X\n", (int)&i);
//
//    TestParam(1, f, d, pc, &i);
//
//}

 

3、

4、

5、

 

测试01

原文:https://www.cnblogs.com/debugskill/p/8245468.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!