program
Project2;
uses
Windows , PsAPI;
procedure CvtInt;
asm
OR CL , CL
JNZ @ CvtLoop
@ C1 : OR EAX , EAX
JNS @ C2
NEG EAX
CALL @ C2
MOV AL , '-'
INC ECX
DEC ESI
MOV [ ESI ] , AL
RET
@ C2 : MOV ECX , 10
@ CvtLoop :
PUSH EDX
PUSH ESI
@ D1 : XOR EDX , EDX
DIV ECX
DEC ESI
ADD DL , '0'
CMP DL , '0' + 10
JB @ D2
ADD DL ,( 'A' - '0') - 10
@ D2 : MOV [ ESI ] , DL
OR EAX , EAX
JNE @ D1
POP ECX
POP EDX
SUB ECX , ESI
SUB EDX , ECX
JBE @ D5
ADD ECX , EDX
MOV AL , '0'
SUB ESI , EDX
JMP @ z
@ zloop : MOV [ ESI + EDX ] , AL
@ z : DEC EDX
JNZ @ zloop
MOV [ ESI ] , AL
@ D5 :
end;
function IntToStr( Value : Integer) : string;
// FmtStr(Result, '%d', [Value]);
asm
PUSH ESI
MOV ESI , ESP
SUB ESP , 16
XOR ECX , ECX // base: 0 for signed decimal
PUSH EDX // result ptr
XOR EDX , EDX // zero filled field width: 0 for no leading zeros
CALL CvtInt //--函数在下图
MOV EDX , ESI
POP EAX // result ptr
CALL System .@ LStrFromPCharLen
ADD ESP , 16
POP ESI
end;
var
pid : array [ 0 .. 65535 ] of DWORD;
size : DWORD;
begin
if EnumProcesses( @ pid , 65535 , size) then
MessageBox( 0 , PChar( IntToStr( size div SizeOf( DWORD))) , '' , 0);
end .
uses
Windows , PsAPI;
procedure CvtInt;
asm
OR CL , CL
JNZ @ CvtLoop
@ C1 : OR EAX , EAX
JNS @ C2
NEG EAX
CALL @ C2
MOV AL , '-'
INC ECX
DEC ESI
MOV [ ESI ] , AL
RET
@ C2 : MOV ECX , 10
@ CvtLoop :
PUSH EDX
PUSH ESI
@ D1 : XOR EDX , EDX
DIV ECX
DEC ESI
ADD DL , '0'
CMP DL , '0' + 10
JB @ D2
ADD DL ,( 'A' - '0') - 10
@ D2 : MOV [ ESI ] , DL
OR EAX , EAX
JNE @ D1
POP ECX
POP EDX
SUB ECX , ESI
SUB EDX , ECX
JBE @ D5
ADD ECX , EDX
MOV AL , '0'
SUB ESI , EDX
JMP @ z
@ zloop : MOV [ ESI + EDX ] , AL
@ z : DEC EDX
JNZ @ zloop
MOV [ ESI ] , AL
@ D5 :
end;
function IntToStr( Value : Integer) : string;
// FmtStr(Result, '%d', [Value]);
asm
PUSH ESI
MOV ESI , ESP
SUB ESP , 16
XOR ECX , ECX // base: 0 for signed decimal
PUSH EDX // result ptr
XOR EDX , EDX // zero filled field width: 0 for no leading zeros
CALL CvtInt //--函数在下图
MOV EDX , ESI
POP EAX // result ptr
CALL System .@ LStrFromPCharLen
ADD ESP , 16
POP ESI
end;
var
pid : array [ 0 .. 65535 ] of DWORD;
size : DWORD;
begin
if EnumProcesses( @ pid , 65535 , size) then
MessageBox( 0 , PChar( IntToStr( size div SizeOf( DWORD))) , '' , 0);
end .