File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -286,11 +286,12 @@ static void getSystemArchitecture(FFPlatformSysinfo* info)
286286
287287static void getCwd (FFPlatform * platform )
288288{
289- #if _WIN64
290289 static_assert (
291- offsetof (RTL_USER_PROCESS_PARAMETERS , Reserved2 [5 ]) == 0x38 ,
292- "CurrentDirectory should be at offset 0x38 in RTL_USER_PROCESS_PARAMETERS. Structure layout mismatch detected." );
293- #endif
290+ offsetof (RTL_USER_PROCESS_PARAMETERS , Reserved2 [5 ]) == sizeof (ULONG ) * 5 + sizeof (HANDLE ) * 4
291+ #if __amd64__ || __aarch64__
292+ + sizeof (ULONG ) // Padding
293+ #endif
294+ , "Structure layout mismatch detected." );
294295 PCURDIR cwd = (PCURDIR ) & NtCurrentTeb ()-> ProcessEnvironmentBlock -> ProcessParameters -> Reserved2 [5 ];
295296 ffStrbufSetNWS (& platform -> cwd , cwd -> DosPath .Length / sizeof (WCHAR ), cwd -> DosPath .Buffer );
296297 ffStrbufReplaceAllC (& platform -> cwd , '\\' , '/' );
@@ -299,7 +300,8 @@ static void getCwd(FFPlatform* platform)
299300
300301void ffPlatformInitImpl (FFPlatform * platform )
301302{
302- platform -> pid = (uint32_t ) GetCurrentProcessId ();
303+ static_assert (offsetof (TEB , Reserved1 [8 ]) == sizeof (NT_TIB ) + sizeof (PVOID ) /*EnvironmentPointer*/ , "Structure layout mismatch detected." );
304+ platform -> pid = (uint32_t ) (uintptr_t ) ((CLIENT_ID * ) & NtCurrentTeb ()-> Reserved1 [8 ])-> UniqueProcess ;
303305 getExePath (platform );
304306 getCwd (platform );
305307 getHomeDir (platform );
You can’t perform that action at this time.
0 commit comments