Run windows app under WINE. Function GetModuleInformation return error code 5

74 Views Asked by At

I try to run my windows app on Linux using Wine, but it fail with error "Access denied". I have found the cause of my problem is function GetModuleInformation. It return the error code 5. I use

  1. Astra Linux Special Edition; version 1.7.4.11
  2. Wine version 8.0
  3. Simple Delphi code to show error
procedure TForm4.btnTest2Click(Sender: TObject);
var
  hProcess: Cardinal;
  hModule: Cardinal;
  ModInfo: MODULEINFO;
begin
  memLog.Lines.Clear;
  hProcess := GetCurrentProcess;
  if hProcess <> 0 then
    memLog.Lines.Add(Format('GetCurrentProcess successed: hProcess = %d',
      [hProcess]))
  else
    memLog.Lines.Add(Format('GetCurrentProcess failed: errorcode = %d',
      [GetLastError]));

  hModule := GetModuleHandle(nil);
  if hModule <> 0 then
    memLog.Lines.Add(Format('GetCurrentProcess successed: hModule = %d',
      [hModule]))
  else
    memLog.Lines.Add(Format('GetCurrentProcess failed: errorcode = %d',
      [GetLastError]));

  FillMemory(Addr(ModInfo), SizeOf(MODULEINFO), $AA);
  if GetModuleInformation(hProcess, hModule, Addr(ModInfo), SizeOf(MODULEINFO)) then
  begin
    memLog.Lines.Add(Format('GetModuleInformation successed: '
      + 'lpBaseOfDll = %p, SizeOfImage = %d, EntryPoint = %p',
      [ModInfo.lpBaseOfDll, ModInfo.SizeOfImage, ModInfo.EntryPoint]));
  end
  else
  begin
    memLog.Lines.Add(Format('GetModuleInformation failed: errorcode = %d',
      [GetLastError]));
  end;
end;

Do you have any idea to solve a problem?

I try to change rigths on my app executable (chmod 777 testapp.exe), but it has no effect

0

There are 0 best solutions below