添加以下德爾福功能後,我收到有關數據類型錯位的錯誤:Project ... faulted with message: 'datatype misalignment at 0x77a7d7d8'. Process Stopped. Use Step or Run to continue.
德爾福的數據類型錯位?
我添加的功能如下。請注意,該函數實際上成功完成,但只有時間戳實際寫入文件。
procedure Log(msg : String);
var
tempFolderChars : array [0..MAX_PATH] of Char;
tempFolder : string;
logFile : TextFile;
dt : TDateTime;
begin
GetTempPath(SizeOf(tempFolderChars), tempFolderChars);
tempFolder := IncludeTrailingPathDelimiter(String(tempFolderChars));
dt := Now();
AssignFile(logFile, tempFolder + 'GenericHolding.txt');
if FileExists(tempFolder + 'GenericHolding.txt') then
Append(logFile)
else
ReWrite(logFile);
Write(logFile, FormatDateTime('yyyy-mm-dd hh:nn:ss ', now));
Write(logFile, msg);
Write(logFile, #13, #10);
CloseFile(logFile);
end;
編輯:增加更多組件的輸出。
ntdll.NtQueryInformationProcess:
77BAFAC8 B816000000 mov eax,$00000016
77BAFACD 33C9 xor ecx,ecx
77BAFACF 8D542404 lea edx,[esp+$04]
77BAFAD3 64FF15C0000000 call dword ptr fs:[$000000c0]
77BAFADA 83C404 add esp,$04
77BAFADD C21400 ret $0014
能否請您發佈的內容是在地址'0x77a7d7d8'?也許堆棧跟蹤? –
我無法使用您的代碼重現您的問題(複製/直接粘貼到D2007項目中)。你使用的是什麼Delphi版本和操作系統? –
IIRC,Delphi的版本非常重要,因爲簡單的類型轉換並不總是有效。在舊版Delphi中,您需要使用StrPas。另一個有用的信息是你傳遞的msg的內容。 – Graymatter