Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-03

version differences

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Pápai András

Hi!
I recently upgraded fpc on my computer (1.0.4 -> 1.0.10). Now some programs doen't work correctly. No problems with compilig, no run-time errors, but the program doesn't work like before. (Win32 platform).

I attached a source (poweroff.pas). Compiling with 1.0.4, it works as I want.
With 1.0.10 (and 1.0.6) some API functions return an error. LookupPrivilegeValue: 203, "ENVVAR_NOT_FOUND"
AdjustTokenPrivileges: 1300, "NOT_ALL_ASSIGNED"

I couldn't find the reason in the docs.
Can someone help me, please?

Thanks!
Andras

<<poweroff.pas>>

Ezen uzenet es annak barmely csatolt anyaga bizalmas, jogi vedelem alatt all, a nyilvanos kozlestol vedett. Az uzenetet kizarolag a cimzett, illetve az altala meghatalmazottak hasznalhatjak fel. Ha On nem az uzenet cimzettje, ugy kerjuk, hogy telefonon, vagy e-mail-ben ertesitse errol az uzenet kuldojet es torolje az uzenetet, valamint annak osszes csatolt mellekletet a rendszerebol. Ha On nem az uzenet cimzettje, abban az esetben tilos az uzenetet vagy annak barmely csatolt mellekletet lemasolnia, elmentenie, az uzenet tartalmat barkivel kozolnie vagy azzal visszaelnie.

This message and any attachment are confidential and are legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. Please note that any dissemination, distribution, copying or use of or reliance upon the information contained in and transmitted with this e-mail by or to anyone other than the recipient designated above by the sender is unauthorised and strictly prohibited.

Reply by email

Michael Van Canneyt
to Pápai András
Show quoted text 14 lines
Hi! I recently upgraded fpc on my computer (1.0.4 -> 1.0.10). Now some programs doen't work correctly. No problems with compilig, no run-time errors, but the program doesn't work like before. (Win32 platform). I attached a source (poweroff.pas). Compiling with 1.0.4, it works as I want. With 1.0.10 (and 1.0.6) some API functions return an error. LookupPrivilegeValue: 203, "ENVVAR_NOT_FOUND" AdjustTokenPrivileges: 1300, "NOT_ALL_ASSIGNED" I couldn't find the reason in the docs. Can someone help me, please?

I don't know what the reason is, but I suspect the large_integer (64 bits). In each case, using 1.9.X, your sources didn't changed them and now the program works correctly as far as I can see (at least, it reports no error).

Michael.
----------------------------------------------------------------------- {$mode objfpc}

program PowerOff;
{.$APPTYPE GUI}
uses windows;
var
  hToken: handle;
  Privileges: TOKEN_PRIVILEGES;
  Shutdown_LUID: int64;
Const
  ShutDownPriv : Pchar = 'SeShutdownPrivilege';
begin
  if not OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES,@hToken) then
    writeln('OPT: ',GetLastError:5);
  if not LookupPrivilegeValueA(Nil,ShutDownPriv,Shutdown_LUID) then
    writeln('LPV: ',GetLastError:5);
  with Privileges do
  begin
    PrivilegeCount := 1;
    Privileges[0].LUID := Shutdown_LUID;
    Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
  end;
  if not AdjustTokenPrivileges(hToken,false,@Privileges,0,Nil,Nil) then
    writeln('ATP: ',GetLastError:5);
  //ExitWindowsEx(EWX_POWEROFF,0);
end.

Reply by email

Pápai András
I don't know what the reason is, but I suspect the large_integer (64

bits).

Show quoted text 5 lines
In each case, using 1.9.X, your sources didn't compile at all. I changed them and now the program works correctly as far as I can see (at least, it reports no error). Michael.

The source you sent doesn't compile with 1.0.10:
test.pas(20,49) Error: Incompatible type for arg no. 3: Got INT64, expected PLUID
test.pas(25,27) Error: Incompatible types: got "INT64" expected "LARGE_INTEGER"
test.pas(33) Fatal: There were 2 errors compiling module, stopping

(1)
I added the typecasts, uncommented the ExitWindowsEx line, then could compile it.
But didn't work.

There is no error message: AdjustTokenPrivileges() returns TRUE, assuming no error, but GetLastError still returns error 1300.

(2)
I tried using variables with absolute address:

var
  luid_LUID: LUID absolute Shutdown_LUID;
  large_LUID: large_integer absolute Shutdown_LUID;

This compiles, too and runs with the same results. :-(

And the best: both compile and run with 1.0.4!

I'll analise the generated assembly source, to find something.

Andras

Ezen uzenet es annak barmely csatolt anyaga bizalmas, jogi vedelem alatt all, a nyilvanos kozlestol vedett. Az uzenetet kizarolag a cimzett, illetve az altala meghatalmazottak hasznalhatjak fel. Ha On nem az uzenet cimzettje, ugy kerjuk, hogy telefonon, vagy e-mail-ben ertesitse errol az uzenet kuldojet es torolje az uzenetet, valamint annak osszes csatolt mellekletet a rendszerebol. Ha On nem az uzenet cimzettje, abban az esetben tilos az uzenetet vagy annak barmely csatolt mellekletet lemasolnia, elmentenie, az uzenet tartalmat barkivel kozolnie vagy azzal visszaelnie.

This message and any attachment are confidential and are legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. Please note that any dissemination, distribution, copying or use of or reliance upon the information contained in and transmitted with this e-mail by or to anyone other than the recipient designated above by the sender is unauthorised and strictly prohibited.

Reply by email

Peter Vreman
to Pápai András
Show quoted text 16 lines
> I don't know what the reason is, but I suspect the large_integer (64 bits). > In each case, using 1.9.X, your sources didn't compile at all. > I changed them and now the program works correctly as far as I can > see (at least, it reports no error). > > Michael. The source you sent doesn't compile with 1.0.10: test.pas(20,49) Error: Incompatible type for arg no. 3: Got INT64, expected PLUID test.pas(25,27) Error: Incompatible types: got "INT64" expected "LARGE_INTEGER" test.pas(33) Fatal: There were 2 errors compiling module, stopping

<snip>

And the best: both compile and run with 1.0.4!

If the code compiles and works with 1.9.x than the bug is solved. It doesn't matter that 1.0.10 has a problem. We will not fix it in 1.0.x. The future and current development is 1.9.x only.

Peter

Reply by email