system.pp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2005 by Florian Klaempfl and Pavel Ozerski
  4. member of the Free Pascal development team.
  5. FPC Pascal system unit for the Win32 API.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit System;
  13. interface
  14. {$ifdef SYSTEMDEBUG}
  15. {$define SYSTEMEXCEPTIONDEBUG}
  16. {$endif SYSTEMDEBUG}
  17. {$ifdef VER3_0}
  18. { 3.1.1+ do not require this anymore }
  19. {$define FPC_HAS_INDIRECT_ENTRY_INFORMATION}
  20. {$endif VER3_0}
  21. {$ifdef cpui386}
  22. {$define Set_i386_Exception_handler}
  23. {$endif cpui386}
  24. {$define DISABLE_NO_THREAD_MANAGER}
  25. {$define HAS_WIDESTRINGMANAGER}
  26. {$define DISABLE_NO_DYNLIBS_MANAGER}
  27. {$define FPC_SYSTEM_HAS_SYSDLH}
  28. {$define FPC_HAS_SETCTRLBREAKHANDLER}
  29. {$ifdef FPC_USE_WIN32_SEH}
  30. {$define FPC_SYSTEM_HAS_RAISEEXCEPTION}
  31. {$define FPC_SYSTEM_HAS_RERAISE}
  32. {$define FPC_SYSTEM_HAS_DONEEXCEPTION}
  33. {$define FPC_SYSTEM_HAS_SAFECALLHANDLER}
  34. {$endif FPC_USE_WIN32_SEH}
  35. { include system-independent routine headers }
  36. {$I systemh.inc}
  37. { include common windows headers }
  38. {$I syswinh.inc}
  39. var
  40. MainInstance : longint;
  41. implementation
  42. var
  43. FPCSysInstance : PLongint;public name '_FPC_SysInstance';
  44. {$define FPC_SYSTEM_HAS_OSSETUPENTRYINFORMATION}
  45. procedure OsSetupEntryInformation(constref info: TEntryInformation); forward;
  46. {$ifdef FPC_USE_WIN32_SEH}
  47. function main_wrapper(arg: Pointer; proc: Pointer): ptrint; forward;
  48. procedure OutermostHandler; external name '__FPC_DEFAULT_HANDLER';
  49. {$endif FPC_USE_WIN32_SEH}
  50. {$define FPC_SYSTEM_HAS_STACKTOP}
  51. function StackTop: pointer; assembler;nostackframe;
  52. asm
  53. movl %fs:(4),%eax
  54. end;
  55. { include system independent routines }
  56. {$I system.inc}
  57. { include code common with win64 }
  58. {$I syswin.inc}
  59. procedure OsSetupEntryInformation(constref info: TEntryInformation);
  60. begin
  61. TlsKey := info.OS.TlsKeyAddr;
  62. FPCSysInstance := info.OS.SysInstance;
  63. WStrInitTablesTable := info.OS.WideInitTables;
  64. end;
  65. {*****************************************************************************
  66. System Dependent Exit code
  67. *****************************************************************************}
  68. {$ifndef FPC_USE_WIN32_SEH}
  69. procedure install_exception_handlers;forward;
  70. procedure remove_exception_handlers;forward;
  71. {$endif FPC_USE_WIN32_SEH}
  72. Procedure system_exit;
  73. begin
  74. if IsLibrary then
  75. begin
  76. { If exiting from DLL_PROCESS_ATTACH/DETACH, unwind to DllMain context. }
  77. if DllInitState in [DLL_PROCESS_ATTACH,DLL_PROCESS_DETACH] then
  78. LongJmp(DLLBuf,1)
  79. else
  80. { Abnormal termination, Halt has been called from DLL function,
  81. put down the entire process (DLL_PROCESS_DETACH will still
  82. occur). At this point RTL has been already finalized in InternalExit
  83. and shouldn't be finalized another time in DLL_PROCESS_DETACH.
  84. Indicate this by resetting MainThreadIdWin32. }
  85. MainThreadIDWin32:=0;
  86. end;
  87. if not IsConsole then
  88. begin
  89. Close(stderr);
  90. Close(stdout);
  91. Close(erroutput);
  92. Close(Input);
  93. Close(Output);
  94. { what about Input and Output ?? PM }
  95. { now handled, FPK }
  96. end;
  97. {$ifndef FPC_USE_WIN32_SEH}
  98. if not IsLibrary then
  99. remove_exception_handlers;
  100. {$endif FPC_USE_WIN32_SEH}
  101. { do cleanup required by the startup code }
  102. EntryInformation.OS.asm_exit();
  103. { call exitprocess, with cleanup as required }
  104. ExitProcess(exitcode);
  105. end;
  106. var
  107. { value of the stack segment
  108. to check if the call stack can be written on exceptions }
  109. _SS : Cardinal;
  110. procedure Exe_entry(constref info : TEntryInformation);[public,alias:'_FPC_EXE_Entry'];
  111. var
  112. xframe: TEXCEPTION_FRAME;
  113. begin
  114. SetupEntryInformation(info);
  115. IsLibrary:=false;
  116. { install the handlers for exe only ?
  117. or should we install them for DLL also ? (PM) }
  118. {$ifndef FPC_USE_WIN32_SEH}
  119. install_exception_handlers;
  120. {$endif FPC_USE_WIN32_SEH}
  121. { This strange construction is needed to solve the _SS problem
  122. with a smartlinked syswin32 (PFV) }
  123. asm
  124. { movl %esp,%fs:(0)
  125. but don't insert it as it doesn't
  126. point to anything yet
  127. this will be used in signals unit }
  128. leal xframe,%eax
  129. movl %fs:(0),%ecx
  130. movl %ecx,TException_Frame.next(%eax)
  131. movl %eax,System_exception_frame
  132. {$ifndef FPC_USE_WIN32_SEH}
  133. movl $0,TException_Frame.handler(%eax)
  134. {$else}
  135. movl $OutermostHandler,TException_Frame.handler(%eax)
  136. movl %eax,%fs:(0)
  137. {$endif FPC_USE_WIN32_SEH}
  138. pushl %ebp
  139. xorl %eax,%eax
  140. movw %ss,%ax
  141. movl %eax,_SS
  142. xorl %ebp,%ebp
  143. end;
  144. EntryInformation.PascalMain();
  145. asm
  146. popl %ebp
  147. end;
  148. { if we pass here there was no error ! }
  149. system_exit;
  150. end;
  151. function is_prefetch(p : pointer) : boolean;
  152. var
  153. a : array[0..15] of byte;
  154. doagain : boolean;
  155. instrlo,instrhi,opcode : byte;
  156. i : longint;
  157. begin
  158. result:=false;
  159. { read memory savely without causing another exeception }
  160. if not(ReadProcessMemory(GetCurrentProcess,p,@a,sizeof(a),nil)) then
  161. exit;
  162. i:=0;
  163. doagain:=true;
  164. while doagain and (i<15) do
  165. begin
  166. opcode:=a[i];
  167. instrlo:=opcode and $f;
  168. instrhi:=opcode and $f0;
  169. case instrhi of
  170. { prefix? }
  171. $20,$30:
  172. doagain:=(instrlo and 7)=6;
  173. $60:
  174. doagain:=(instrlo and $c)=4;
  175. $f0:
  176. doagain:=instrlo in [0,2,3];
  177. $0:
  178. begin
  179. result:=(instrlo=$f) and (a[i+1] in [$d,$18]);
  180. exit;
  181. end;
  182. else
  183. doagain:=false;
  184. end;
  185. inc(i);
  186. end;
  187. end;
  188. //
  189. // Hardware exception handling
  190. //
  191. {$ifdef Set_i386_Exception_handler}
  192. type
  193. PFloatingSaveArea = ^TFloatingSaveArea;
  194. TFloatingSaveArea = packed record
  195. ControlWord : Cardinal;
  196. StatusWord : Cardinal;
  197. TagWord : Cardinal;
  198. ErrorOffset : Cardinal;
  199. ErrorSelector : Cardinal;
  200. DataOffset : Cardinal;
  201. DataSelector : Cardinal;
  202. RegisterArea : array[0..79] of Byte;
  203. Cr0NpxState : Cardinal;
  204. end;
  205. PContext = ^TContext;
  206. TContext = packed record
  207. //
  208. // The flags values within this flag control the contents of
  209. // a CONTEXT record.
  210. //
  211. ContextFlags : Cardinal;
  212. //
  213. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  214. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  215. // included in CONTEXT_FULL.
  216. //
  217. Dr0, Dr1, Dr2,
  218. Dr3, Dr6, Dr7 : Cardinal;
  219. //
  220. // This section is specified/returned if the
  221. // ContextFlags word contains the flag CONTEXT_FLOATING_POINT.
  222. //
  223. FloatSave : TFloatingSaveArea;
  224. //
  225. // This section is specified/returned if the
  226. // ContextFlags word contains the flag CONTEXT_SEGMENTS.
  227. //
  228. SegGs, SegFs,
  229. SegEs, SegDs : Cardinal;
  230. //
  231. // This section is specified/returned if the
  232. // ContextFlags word contains the flag CONTEXT_INTEGER.
  233. //
  234. Edi, Esi, Ebx,
  235. Edx, Ecx, Eax : Cardinal;
  236. //
  237. // This section is specified/returned if the
  238. // ContextFlags word contains the flag CONTEXT_CONTROL.
  239. //
  240. Ebp : Cardinal;
  241. Eip : Cardinal;
  242. SegCs : Cardinal;
  243. EFlags, Esp, SegSs : Cardinal;
  244. //
  245. // This section is specified/returned if the ContextFlags word
  246. // contains the flag CONTEXT_EXTENDED_REGISTERS.
  247. // The format and contexts are processor specific
  248. //
  249. ExtendedRegisters : array[0..MAXIMUM_SUPPORTED_EXTENSION-1] of Byte;
  250. end;
  251. PExceptionPointers = ^TExceptionPointers;
  252. TExceptionPointers = packed record
  253. ExceptionRecord : PExceptionRecord;
  254. ContextRecord : PContext;
  255. end;
  256. { type of functions that should be used for exception handling }
  257. TTopLevelExceptionFilter = function (excep : PExceptionPointers) : Longint;stdcall;
  258. {$i seh32.inc}
  259. {$ifndef FPC_USE_WIN32_SEH}
  260. function SetUnhandledExceptionFilter(lpTopLevelExceptionFilter : TTopLevelExceptionFilter) : TTopLevelExceptionFilter;
  261. stdcall;external 'kernel32' name 'SetUnhandledExceptionFilter';
  262. const
  263. MaxExceptionLevel = 16;
  264. exceptLevel : Byte = 0;
  265. var
  266. exceptEip : array[0..MaxExceptionLevel-1] of Longint;
  267. exceptError : array[0..MaxExceptionLevel-1] of Byte;
  268. resetFPU : array[0..MaxExceptionLevel-1] of Boolean;
  269. {$ifdef SYSTEMEXCEPTIONDEBUG}
  270. procedure DebugHandleErrorAddrFrame(error : longint; addr, frame : pointer);
  271. begin
  272. if IsConsole then
  273. begin
  274. write(stderr,'HandleErrorAddrFrame(error=',error);
  275. write(stderr,',addr=',hexstr(ptruint(addr),8));
  276. writeln(stderr,',frame=',hexstr(ptruint(frame),8),')');
  277. end;
  278. HandleErrorAddrFrame(error,addr,frame);
  279. end;
  280. {$endif SYSTEMEXCEPTIONDEBUG}
  281. procedure JumpToHandleErrorFrame;
  282. var
  283. eip, ebp, error : Longint;
  284. begin
  285. // save ebp
  286. asm
  287. movl (%ebp),%eax
  288. movl %eax,ebp
  289. end;
  290. if (exceptLevel > 0) then
  291. dec(exceptLevel);
  292. eip:=exceptEip[exceptLevel];
  293. error:=exceptError[exceptLevel];
  294. {$ifdef SYSTEMEXCEPTIONDEBUG}
  295. if IsConsole then
  296. writeln(stderr,'In JumpToHandleErrorFrame error=',error);
  297. {$endif SYSTEMEXCEPTIONDEBUG}
  298. if resetFPU[exceptLevel] then
  299. SysResetFPU;
  300. { build a fake stack }
  301. asm
  302. movl ebp,%ecx
  303. movl eip,%edx
  304. movl error,%eax
  305. pushl eip
  306. movl ebp,%ebp // Change frame pointer
  307. {$ifdef SYSTEMEXCEPTIONDEBUG}
  308. jmpl DebugHandleErrorAddrFrame
  309. {$else not SYSTEMEXCEPTIONDEBUG}
  310. jmpl HandleErrorAddrFrame
  311. {$endif SYSTEMEXCEPTIONDEBUG}
  312. end;
  313. end;
  314. function syswin32_i386_exception_handler(excep : PExceptionPointers) : Longint;stdcall;
  315. var
  316. res,ssecode: longint;
  317. err: byte;
  318. must_reset_fpu: boolean;
  319. begin
  320. res := EXCEPTION_CONTINUE_SEARCH;
  321. if excep^.ContextRecord^.SegSs=_SS then begin
  322. err := 0;
  323. must_reset_fpu := true;
  324. {$ifdef SYSTEMEXCEPTIONDEBUG}
  325. if IsConsole then Writeln(stderr,'Exception ',
  326. hexstr(excep^.ExceptionRecord^.ExceptionCode, 8));
  327. {$endif SYSTEMEXCEPTIONDEBUG}
  328. case excep^.ExceptionRecord^.ExceptionCode of
  329. STATUS_INTEGER_DIVIDE_BY_ZERO :
  330. err := 200;
  331. STATUS_FLOAT_DIVIDE_BY_ZERO :
  332. err := 208;
  333. STATUS_ARRAY_BOUNDS_EXCEEDED :
  334. begin
  335. err := 201;
  336. must_reset_fpu := false;
  337. end;
  338. STATUS_STACK_OVERFLOW :
  339. begin
  340. err := 202;
  341. must_reset_fpu := false;
  342. end;
  343. STATUS_FLOAT_OVERFLOW :
  344. err := 205;
  345. STATUS_FLOAT_DENORMAL_OPERAND,
  346. STATUS_FLOAT_UNDERFLOW :
  347. err := 206;
  348. {excep^.ContextRecord^.FloatSave.StatusWord := excep^.ContextRecord^.FloatSave.StatusWord and $ffffff00;}
  349. STATUS_FLOAT_INEXACT_RESULT,
  350. STATUS_FLOAT_INVALID_OPERATION,
  351. STATUS_FLOAT_STACK_CHECK :
  352. err := 207;
  353. STATUS_INTEGER_OVERFLOW :
  354. begin
  355. err := 215;
  356. must_reset_fpu := false;
  357. end;
  358. STATUS_ILLEGAL_INSTRUCTION:
  359. { if we're testing sse support, simply set the flag and continue }
  360. if sse_check then
  361. begin
  362. os_supports_sse:=false;
  363. { skip the offending movaps %xmm7, %xmm6 instruction }
  364. inc(excep^.ContextRecord^.Eip,3);
  365. excep^.ExceptionRecord^.ExceptionCode := 0;
  366. res:=EXCEPTION_CONTINUE_EXECUTION;
  367. end
  368. else
  369. err := 216;
  370. STATUS_ACCESS_VIOLATION:
  371. { Athlon prefetch bug? }
  372. if is_prefetch(pointer(excep^.ContextRecord^.Eip)) then
  373. begin
  374. { if yes, then retry }
  375. excep^.ExceptionRecord^.ExceptionCode := 0;
  376. res:=EXCEPTION_CONTINUE_EXECUTION;
  377. end
  378. else
  379. err := 216;
  380. STATUS_CONTROL_C_EXIT:
  381. err := 217;
  382. STATUS_PRIVILEGED_INSTRUCTION:
  383. begin
  384. err := 218;
  385. must_reset_fpu := false;
  386. end;
  387. STATUS_FLOAT_MULTIPLE_FAULTS,
  388. STATUS_FLOAT_MULTIPLE_TRAPS:
  389. begin
  390. { dumping ExtendedRegisters and comparing with the actually value of mxcsr revealed 24 }
  391. TranslateMxcsr(excep^.ContextRecord^.ExtendedRegisters[24],ssecode);
  392. {$ifdef SYSTEMEXCEPTIONDEBUG}
  393. if IsConsole then
  394. Writeln(stderr,'MXSR: ',hexstr(excep^.ContextRecord^.ExtendedRegisters[24], 2),' SSECODE: ',ssecode);
  395. {$endif SYSTEMEXCEPTIONDEBUG}
  396. err:=-ssecode;
  397. end;
  398. else
  399. begin
  400. if ((excep^.ExceptionRecord^.ExceptionCode and SEVERITY_ERROR) = SEVERITY_ERROR) then
  401. err := 217
  402. else
  403. err := 255;
  404. end;
  405. end;
  406. if (err <> 0) and (exceptLevel < MaxExceptionLevel) then begin
  407. exceptEip[exceptLevel] := excep^.ContextRecord^.Eip;
  408. exceptError[exceptLevel] := err;
  409. resetFPU[exceptLevel] := must_reset_fpu;
  410. inc(exceptLevel);
  411. excep^.ContextRecord^.Eip := Longint(@JumpToHandleErrorFrame);
  412. excep^.ExceptionRecord^.ExceptionCode := 0;
  413. res := EXCEPTION_CONTINUE_EXECUTION;
  414. {$ifdef SYSTEMEXCEPTIONDEBUG}
  415. if IsConsole then begin
  416. writeln(stderr,'Exception Continue Exception set at ',
  417. hexstr(exceptEip[exceptLevel],8));
  418. writeln(stderr,'Eip changed to ',
  419. hexstr(longint(@JumpToHandleErrorFrame),8), ' error=', err);
  420. end;
  421. {$endif SYSTEMEXCEPTIONDEBUG}
  422. end;
  423. end;
  424. syswin32_i386_exception_handler := res;
  425. end;
  426. procedure install_exception_handlers;
  427. begin
  428. SetUnhandledExceptionFilter(@syswin32_i386_exception_handler);
  429. end;
  430. procedure remove_exception_handlers;
  431. begin
  432. SetUnhandledExceptionFilter(nil);
  433. end;
  434. {$endif not FPC_USE_WIN32_SEH}
  435. {$else not cpui386 (Processor specific !!)}
  436. procedure install_exception_handlers;
  437. begin
  438. end;
  439. procedure remove_exception_handlers;
  440. begin
  441. end;
  442. {$endif Set_i386_Exception_handler}
  443. {$ifdef FPC_SECTION_THREADVARS}
  444. function fpc_tls_add(addr: pointer): pointer; assembler; nostackframe;
  445. [public,alias: 'FPC_TLS_ADD']; compilerproc;
  446. asm
  447. sub $tls_data_start,%eax
  448. cmpb $0,IsLibrary
  449. mov _tls_index,%ecx
  450. jnz .L1
  451. mov %fs:(0x2c),%edx
  452. add (%edx,%ecx,4),%eax
  453. ret
  454. .L1:
  455. push %ebx
  456. mov %eax,%ebx
  457. call GetLastError
  458. push %eax { save LastError }
  459. push _tls_index
  460. call TlsGetValue
  461. test %eax,%eax
  462. jnz .L2
  463. { This can happen when a thread existed before DLL was loaded,
  464. or if DisableThreadLibraryCalls was called. }
  465. call SysAllocateThreadVars
  466. mov $0x1000000,%eax
  467. call InitThread
  468. push _tls_index
  469. call TlsGetValue
  470. .L2:
  471. add %eax,%ebx
  472. call SetLastError { restore (value is on stack) }
  473. mov %ebx,%eax
  474. pop %ebx
  475. end;
  476. {$endif FPC_SECTION_THREADVARS}
  477. function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
  478. type
  479. tdosheader = packed record
  480. e_magic : word;
  481. e_cblp : word;
  482. e_cp : word;
  483. e_crlc : word;
  484. e_cparhdr : word;
  485. e_minalloc : word;
  486. e_maxalloc : word;
  487. e_ss : word;
  488. e_sp : word;
  489. e_csum : word;
  490. e_ip : word;
  491. e_cs : word;
  492. e_lfarlc : word;
  493. e_ovno : word;
  494. e_res : array[0..3] of word;
  495. e_oemid : word;
  496. e_oeminfo : word;
  497. e_res2 : array[0..9] of word;
  498. e_lfanew : longint;
  499. end;
  500. tpeheader = packed record
  501. PEMagic : longint;
  502. Machine : word;
  503. NumberOfSections : word;
  504. TimeDateStamp : longint;
  505. PointerToSymbolTable : longint;
  506. NumberOfSymbols : longint;
  507. SizeOfOptionalHeader : word;
  508. Characteristics : word;
  509. Magic : word;
  510. MajorLinkerVersion : byte;
  511. MinorLinkerVersion : byte;
  512. SizeOfCode : longint;
  513. SizeOfInitializedData : longint;
  514. SizeOfUninitializedData : longint;
  515. AddressOfEntryPoint : longint;
  516. BaseOfCode : longint;
  517. BaseOfData : longint;
  518. ImageBase : longint;
  519. SectionAlignment : longint;
  520. FileAlignment : longint;
  521. MajorOperatingSystemVersion : word;
  522. MinorOperatingSystemVersion : word;
  523. MajorImageVersion : word;
  524. MinorImageVersion : word;
  525. MajorSubsystemVersion : word;
  526. MinorSubsystemVersion : word;
  527. Reserved1 : longint;
  528. SizeOfImage : longint;
  529. SizeOfHeaders : longint;
  530. CheckSum : longint;
  531. Subsystem : word;
  532. DllCharacteristics : word;
  533. SizeOfStackReserve : longint;
  534. SizeOfStackCommit : longint;
  535. SizeOfHeapReserve : longint;
  536. SizeOfHeapCommit : longint;
  537. LoaderFlags : longint;
  538. NumberOfRvaAndSizes : longint;
  539. DataDirectory : array[1..$80] of byte;
  540. end;
  541. begin
  542. result:=tpeheader((pointer(getmodulehandle(nil))+(tdosheader(pointer(getmodulehandle(nil))^).e_lfanew))^).SizeOfStackReserve;
  543. end;
  544. begin
  545. { get some helpful informations }
  546. GetStartupInfo(@startupinfo);
  547. { some misc Win32 stuff }
  548. if not IsLibrary then
  549. FPCSysInstance^:=getmodulehandle(nil);
  550. MainInstance:=FPCSysInstance^;
  551. { pass dummy value }
  552. StackLength := CheckInitialStkLen($1000000);
  553. StackBottom := StackTop - StackLength;
  554. cmdshow:=startupinfo.wshowwindow;
  555. { Setup heap and threading, these may be already initialized from TLS callback }
  556. if not Assigned(CurrentTM.BeginThread) then
  557. begin
  558. InitHeap;
  559. InitSystemThreads;
  560. end;
  561. SysInitExceptions;
  562. { setup fastmove stuff }
  563. fpc_cpucodeinit;
  564. initunicodestringmanager;
  565. InitWin32Widestrings;
  566. SysInitStdIO;
  567. { Arguments }
  568. setup_arguments;
  569. InitSystemDynLibs;
  570. { Reset IO Error }
  571. InOutRes:=0;
  572. ProcessID := GetCurrentProcessID;
  573. DispCallByIDProc:=@DoDispCallByIDError;
  574. end.