]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.ps.windows: Fix offsets for win64.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 15 Jul 2013 22:19:07 +0000 (15:19 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 15 Jul 2013 22:19:07 +0000 (15:19 -0700)
basis/tools/ps/windows/windows.factor

index eff6ce997f64a2fccc5372b8b91fb20cdf431e00..6076b9fb5640c916e8391d7d2bbe9eb4fa9f6d4e 100644 (file)
@@ -53,17 +53,26 @@ IN: tools.ps.windows
         [ dup query-information-process PebBaseAddress>> read-peb ] bi
     ] with-destructors ;
 
+: slot-offset-by-name ( struct-class name -- value/f )
+    [ struct-slots ] dip '[ name>> _ = ] find swap [ offset>> ] when ;
+
 :: read-args ( handle -- string/f )
     handle <win32-handle> &dispose drop
     handle query-information-process :> process-basic-information
     handle process-basic-information PebBaseAddress>>
     [
-        0x10 PVOID heap-size read-process-memory
+        PEB "ProcessParameters" slot-offset-by-name
+        PVOID heap-size
+        read-process-memory
         PVOID deref :> args-offset
         args-offset ALIEN: 0 = [
             f
         ] [
-            handle args-offset 0x40 UNICODE_STRING heap-size read-process-memory
+            handle
+            args-offset
+            RTL_USER_PROCESS_PARAMETERS "CommandLine" slot-offset-by-name
+            UNICODE_STRING heap-size
+            read-process-memory
             [ handle ] dip
             UNICODE_STRING deref [ Buffer>> 0 ] [ Length>> ] bi read-process-memory
             utf16n decode