300分求两句DELPHI语句翻译成VC(300分)

  • 主题发起人 主题发起人 余远源
  • 开始时间 开始时间

余远源

Unregistered / Unconfirmed
GUEST, unregistred user!
Buffer: PByte;
Buffer := AllocMem($80);
PDWORD(dword(Buffer))^ := 0;
PDWORD(dword(Buffer) + 4)^ := $73FB3E44;
PDWORD(dword(Buffer) + $10)^ := $77D1BA1E;
 
DWORD * Buffer;
Buffer = AllocMem(0x20);
*Buffer = 0;
*(Buffer + 4) = 0x73FB3E44;
*(Buffer + 0x10) = 0x77D1BA1E;
基本就这个思路
 
看我的网站 网站 http://bbs.8isp.cn/?u=233 上面有答案
 
kkyy 说的基本正确,但:
Buffer = AllocMem(0x20)
应该是:
Buffer = AllocMem(0x80);
 
对,好久没弄VC了,充忙间想多了画蛇添脚了,谢谢指正,呵呵
 
应该还是没有对...不知哪里错了...
 
VC中好像没有AllocMem吧.
我改为 Buffer = (DWORD *)malloc(0x80);
*Buffer = 0;
*(Buffer + 4) = 0x73FB3E44;
*(Buffer + 0x10) = 0x77D1BA1E;
但是程序得到的和DELPHI的结果还是不一样.
 
procedure ****

var
hDeviceHandle: THandle;
Buffer: PByte;
xr: dword;
begin
hDeviceHandle := CreateFile('//./PhysicalDrive0',
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE or 4,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if hDeviceHandle = INVALID_HANDLE_VALUE then Exit;

Buffer := AllocMem($80);
PDWORD(dword(Buffer) + 4)^ := $73FB3E44;
PDWORD(dword(Buffer) + $10)^ := $77D1BA1E;
if DeviceIoControl(hDeviceHandle, $76018, Buffer, $80, Buffer, $80, xr, nil) then
begin
showmessage('OK');
end;
CloseHandle(hDeviceHandle);
end;



void ****()
{
HANDLE hDeviceHandle;
DWORD xr;
DWORD * Buffer;
hDeviceHandle = CreateFile("////.//PhysicalDrive0",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | 4,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if(hDeviceHandle == INVALID_HANDLE_VALUE)
return


Buffer = (DWORD *)malloc(0x80);
*(Buffer + 4) = 0x73FB3E44;
*(Buffer + 0x10) = 0x77D1BA1E;
if(DeviceIoControl(hDeviceHandle, 0x76018, Buffer, 0x80, Buffer, 0x80, &xr, NULL))
{
MessageBox(0,"OK","bb",0);
} else MessageBox(0,"NO","bb",0)


CloseHandle(hDeviceHandle);
}
DELPHI的返回OK,VC的返回N0
 
PBYTE pBuf;

pBuf = malloc(0x80);
*(LPDWORD)pBuf = 0;
*(LPDWORD)(pBuf + 4) = 0x73FB3E44;
*(LPDWORD)(pBuf + 0x10) = 0x77D1BA1E;
 
zjan521的也是不行,最后自己搞定了...........
char *Buffer;
Buffer = (char *)malloc(0x80);
memcpy(Buffer,"/x00/x00/x00/x00",4);
memcpy(Buffer+4,"/x44/x3E/xFB/x73",4);
memcpy(Buffer+0x10,"/x1E/xBA/xD1/x77",4);
 
多人接受答案了。
 
后退
顶部