Während meines alten 32-Bit-Code zu 64-Bit-Portierung, erhalte ichMapFileMemory (dwAllocSize: DWord); 'Haken DLL', 'map Datei kann nicht'
'Haken DLL', 'kann nicht Map-Datei'
Was soll ich tun falsch?
var
hObjHandle: THandle; //Variable for the file mapping object
lpHookRec: PHookRec; //Pointer to our hook record
procedure MapFileMemory(dwAllocSize: DWord);
begin //MapFileMemory
//Create a process wide memory mapped variable
hObjHandle := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, dwAllocSize, 'HookRecMemBlock');
if (hObjHandle = 0) then
begin
MessageBox(0, 'Hook DLL', 'Could not create file map object', mb_Ok);
exit
end;// (hObjHandle = 0)
//Get a pointer to our process wide memory mapped variable
lpHookRec := MapViewOfFile(hObjHandle, FILE_MAP_WRITE, 0, 0, dwAllocSize);
if (lpHookRec = nil) then
begin
CloseHandle(hObjHandle);
MessageBox(0, 'Hook DLL', 'Could not map file', mb_Ok);
exit
end //lpHookRec = Nil)
end; //MapFileMemory
procedure UnMapFileMemory;
begin //UnMapFileMemory
//Delete our process wide memory mapped variable
if (lpHookRec <> nil) then
begin
UnMapViewOfFile(lpHookRec);
lpHookRec := nil
end; // (lpHookRec <> Nil)
if (hObjHandle > 0) then
begin
CloseHandle(hObjHandle);
hObjHandle := 0
end //(hObjHandle > 0)
end; // UnMapFileMemory
procedure DllEntryPoint(dwReason: DWord);
begin { DllEntryPoint }
case dwReason of
Dll_Process_Attach:
begin
{if we are getting mapped into a process, then get}
{a pointer to our process wide memory mapped variable}
hObjHandle := 0;
lpHookRec := nil;
MapFileMemory(sizeof(lpHookRec^))
end;
Dll_Process_Detach:
begin
{if we are getting unmapped from a process then, remove}
{the pointer to our process wide memory mapped variable}
UnMapFileMemory
end;
end { case dwReason }
end; { DllEntryPoint }
Dies ist Code aus dem Internet. –
Lesen Sie die Dokumentation. Ich wette, dass bei 64 Bit der erste Arg in CreateFileMapping nicht $ ffffffff ist. Übergeben Sie INVALID_HANDLE_VALUE. Versuchen Sie, Ihren Code zu verstehen, anstatt ihn blind zu kopieren –
Warum möchten Sie Ihr Projekt auf 64 Bits ändern? Ein 32-Bit-Programm wird auch von x64-Prozessoren unterstützt. :-) –