]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.ps.windows: use offset-of instead.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 15 Jul 2013 22:31:59 +0000 (15:31 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 15 Jul 2013 22:31:59 +0000 (15:31 -0700)
basis/tools/ps/windows/windows.factor

index 6076b9fb5640c916e8391d7d2bbe9eb4fa9f6d4e..e169befe245dfbef097797dc48afb9a1402e11f2 100644 (file)
@@ -33,7 +33,7 @@ IN: tools.ps.windows
         f
         NtQueryInformationProcess drop
     ] keep ;
-    
+
 :: read-process-memory ( HANDLE alien offset len -- byte-array )
     HANDLE
     offset alien <displaced-alien>
@@ -53,15 +53,12 @@ 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>>
     [
-        PEB "ProcessParameters" slot-offset-by-name
+        "ProcessParameters" PEB offset-of
         PVOID heap-size
         read-process-memory
         PVOID deref :> args-offset
@@ -70,7 +67,7 @@ IN: tools.ps.windows
         ] [
             handle
             args-offset
-            RTL_USER_PROCESS_PARAMETERS "CommandLine" slot-offset-by-name
+            "CommandLine" RTL_USER_PROCESS_PARAMETERS offset-of
             UNICODE_STRING heap-size
             read-process-memory
             [ handle ] dip
@@ -78,7 +75,7 @@ IN: tools.ps.windows
             utf16n decode
         ] if
     ] [ drop f ] if* ;
-    
+
 : process-list ( -- assoc )
     [
         TH32CS_SNAPALL do-snapshot