windows-pr 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,18 @@
1
+ = 0.7.3 - 23-Nov-2007
2
+ * Several thread related methods were moved out of the Windows::Process
3
+ module and into the Windows::Thread module.
4
+ * Added critical section methods to the Windows::Synchronize module.
5
+ * Added many more constants and methods to the Windows::Shell module.
6
+ * Created the Windows::Thread module.
7
+ * Fixed the PathCreateFromUrl return type in the Windows::Path module.
8
+ * Added the strncpy and wcsncpy functions to the Windows::MSVCRT::String
9
+ module.
10
+ * Added several token related methods and constants to the Windows::Security
11
+ module.
12
+ * The multi_to_wide and wide_to_multi methods were refactored slightly. Both
13
+ now only use MSVCRT string functions internally in case any Ruby String
14
+ methods are redefined.
15
+
1
16
  = 0.7.2 - 15-Oct-2007
2
17
  * Added the Windows::MSVCRT::Time module.
3
18
  * Added the Windows::MSVCRT::Directory module.
data/Rakefile CHANGED
@@ -36,7 +36,6 @@ end
36
36
 
37
37
  Rake::TestTask.new do |t|
38
38
  t.libs << 'lib'
39
- t.libs << 'lib/windows'
40
39
  t.warning = true
41
40
  t.test_files = FileList['test/tc*']
42
- end
41
+ end
@@ -69,6 +69,8 @@ module Windows
69
69
  FILE_DEVICE_FIPS = 0x0000003A
70
70
  FILE_DEVICE_INFINIBAND = 0x0000003B
71
71
 
72
+ FILE_ANY_ACCESS = 0
73
+
72
74
  METHOD_BUFFERED = 0
73
75
  METHOD_IN_DIRECT = 1
74
76
  METHOD_OUT_DIRECT = 2
data/lib/windows/error.rb CHANGED
@@ -32,6 +32,7 @@ module Windows
32
32
  SEM_NOGPFAULTERRORBOX = 0x0002
33
33
  SEM_NOOPENFILEERRORBOX = 0x8000
34
34
 
35
+ S_OK = 0
35
36
  NO_ERROR = 0
36
37
  ERROR_SUCCESS = 0
37
38
  ERROR_INVALID_FUNCTION = 1
@@ -71,6 +72,8 @@ module Windows
71
72
  ERROR_WRONG_DISK = 34
72
73
  ERROR_FCB_UNAVAILABLE = 35
73
74
  ERROR_SHARING_BUFFER_EXCEEDED = 36
75
+ ERROR_HANDLE_EOF = 38
76
+ ERROR_HANDLE_DISK_FULL = 39
74
77
 
75
78
  ERROR_NOT_SUPPORTED = 50
76
79
 
@@ -40,6 +40,7 @@ module Windows
40
40
  Getwc = API.new('getwc', 'L', 'L', 'msvcrt')
41
41
  Open = API.new('_open', 'PPI', 'I', 'msvcrt')
42
42
  Rmtmp = API.new('_rmtmp', 'V', 'I', 'msvcrt')
43
+ Setmode = API.new('_setmode', 'II', 'I', 'msvcrt')
43
44
  Tempnam = API.new('_tempnam', 'PP', 'P', 'msvcrt')
44
45
  Tmpfile = API.new('tmpfile', 'V', 'L', 'msvcrt')
45
46
  Tmpnam = API.new('tmpnam', 'P', 'P', 'msvcrt')
@@ -139,6 +140,10 @@ module Windows
139
140
  def open(file, flag, mode)
140
141
  Open.call(file, flag, mode)
141
142
  end
143
+
144
+ def setmode(fd, mode)
145
+ Setmode.call(fd, mode)
146
+ end
142
147
 
143
148
  def tmpfile()
144
149
  Tmpfile.call
@@ -8,20 +8,31 @@ module Windows
8
8
  API.auto_method = false
9
9
  API.auto_unicode = false
10
10
 
11
- Strcmp = API.new('strcmp', 'PP', 'I', 'msvcrt')
12
- Strcpy = API.new('strcpy', 'PL', 'L', 'msvcrt')
13
- Strlen = API.new('strlen', 'P', 'L', 'msvcrt')
14
- Strrev = API.new('_strrev', 'P', 'P', 'msvcrt')
11
+ Strcmp = API.new('strcmp', 'PP', 'I', 'msvcrt')
12
+ Strcpy = API.new('strcpy', 'PL', 'L', 'msvcrt')
13
+ Strcspn = API.new('strcspn', 'PP', 'L', 'msvcrt')
14
+ Strlen = API.new('strlen', 'P', 'L', 'msvcrt')
15
+ Strncpy = API.new('strncpy', 'PPL', 'P', 'msvcrt')
16
+ Strrchr = API.new('strrchr', 'PI', 'P', 'msvcrt')
17
+ Strrev = API.new('_strrev', 'P', 'P', 'msvcrt')
18
+ Strtok = API.new('strtok', 'PP', 'P', 'msvcrt')
15
19
 
16
- Mbscmp = API.new('_mbscmp', 'PP', 'I', 'msvcrt')
17
- Mbscpy = API.new('_mbscpy', 'PL', 'L', 'msvcrt')
18
- Mbslen = API.new('_mbslen', 'P', 'L', 'msvcrt')
19
- Mbsrev = API.new('_mbsrev', 'P', 'P', 'msvcrt')
20
-
21
- Wcscmp = API.new('wcscmp', 'PP', 'I', 'msvcrt')
22
- Wcscpy = API.new('wcscpy', 'PL', 'L', 'msvcrt')
23
- Wcslen = API.new('wcslen', 'P', 'L', 'msvcrt')
24
- Wcsrev = API.new('_wcsrev', 'P', 'P', 'msvcrt')
20
+ Mbscmp = API.new('_mbscmp', 'PP', 'I', 'msvcrt')
21
+ Mbscpy = API.new('_mbscpy', 'PL', 'L', 'msvcrt')
22
+ Mbslen = API.new('_mbslen', 'P', 'L', 'msvcrt')
23
+ Mbsrev = API.new('_mbsrev', 'P', 'P', 'msvcrt')
24
+
25
+ Wcscmp = API.new('wcscmp', 'PP', 'I', 'msvcrt')
26
+ Wcscpy = API.new('wcscpy', 'PL', 'L', 'msvcrt')
27
+ Wcslen = API.new('wcslen', 'P', 'L', 'msvcrt')
28
+ Wcsncpy = API.new('wcsncpy', 'PPL', 'P', 'msvcrt')
29
+ Wcsrev = API.new('_wcsrev', 'P', 'P', 'msvcrt')
30
+
31
+ begin
32
+ Strtok_s = API.new('strtok_s', 'PPI', 'P', 'msvcrt')
33
+ rescue RuntimeError
34
+ # Do nothing. Not supported on your system.
35
+ end
25
36
 
26
37
  def strcmp(str1, str2)
27
38
  if str1 == 0 || str2 == 0
@@ -40,11 +51,38 @@ module Windows
40
51
  Strlen.call(string)
41
52
  end
42
53
 
54
+ def strcspn(string, charset)
55
+ return nil if string == 0
56
+ Strcspn.call(string, charset)
57
+ end
58
+
59
+ def strncpy(dest, source, count)
60
+ return nil if source == 0
61
+ Strncpy.call(dest, source, count)
62
+ end
63
+
64
+ def strrchr(string, int)
65
+ return nil if string == 0
66
+ Strrchr.call(string, int)
67
+ end
68
+
43
69
  def strrev(str)
44
70
  return nil if str == 0
45
71
  Strrev.call(str)
46
72
  end
47
73
 
74
+ def strtok(token, delimeter)
75
+ return nil if token == 0 || delimeter == 0
76
+ Strtok.call(token, delimeter)
77
+ end
78
+
79
+ if defined? Strtok_s
80
+ def strtok_s(token, delimeter, context)
81
+ return nil if [token, delimter, context].include?(0)
82
+ Strtok_s.call(token, delimeter, context)
83
+ end
84
+ end
85
+
48
86
  def mbscmp(str1, str2)
49
87
  if str1 == 0 || str2 == 0
50
88
  return nil
@@ -84,6 +122,11 @@ module Windows
84
122
  Wcslen.call(string)
85
123
  end
86
124
 
125
+ def wcsncpy(dest, source, count)
126
+ return nil if source == 0
127
+ Wcsncpy.call(dest, source, count)
128
+ end
129
+
87
130
  def wcsrev(str)
88
131
  return nil if str == 0
89
132
  Wcsrev.call(str)
data/lib/windows/path.rb CHANGED
@@ -24,7 +24,7 @@ module Windows
24
24
  API.new('PathCommonPrefix', 'PPP', 'I', 'shlwapi')
25
25
  API.new('PathCompactPath', 'PPI', 'B', 'shlwapi')
26
26
  API.new('PathCompactPathEx', 'PPIL', 'B', 'shlwapi')
27
- API.new('PathCreateFromUrl', 'PPPL', 'B', 'shlwapi')
27
+ API.new('PathCreateFromUrl', 'PPPL', 'L', 'shlwapi')
28
28
  API.new('PathFileExists', 'P', 'B', 'shlwapi')
29
29
  API.new('PathFindExtension', 'P', 'P', 'shlwapi')
30
30
  API.new('PathFindFileName', 'P', 'P', 'shlwapi')
@@ -58,8 +58,6 @@ module Windows
58
58
  STARTF_USEHOTKEY = 0x00000200
59
59
 
60
60
  API.new('CreateProcess', 'LPLLLLLPPP', 'B')
61
- API.new('CreateRemoteThread', 'LPLLPLP', 'L')
62
- API.new('CreateThread', 'PLPPLP', 'L')
63
61
  API.new('ExitProcess', 'L', 'V')
64
62
  API.new('GetCommandLine', 'V', 'P')
65
63
  API.new('GetCurrentProcess', 'V', 'L')
@@ -72,8 +70,6 @@ module Windows
72
70
  API.new('GetStartupInfo', 'P', 'V')
73
71
  API.new('OpenProcess', 'LIL', 'L')
74
72
  API.new('SetEnvironmentVariable', 'PP', 'I')
75
- API.new('Sleep', 'L', 'V')
76
- API.new('SleepEx', 'LI', 'L')
77
73
  API.new('TerminateProcess', 'LL', 'B')
78
74
  API.new('WaitForInputIdle', 'LL', 'L', 'user32')
79
75
 
@@ -29,13 +29,40 @@ module Windows
29
29
  GENERIC_RIGHTS_MASK = 4026597376
30
30
  GENERIC_RIGHTS_CHK = 4026531840
31
31
  REST_RIGHTS_MASK = 2097151
32
+
33
+ TOKEN_READ = 131080
34
+ TOKEN_WRITE = 131296
35
+ TOKEN_EXECUTE = 131072
36
+ TOKEN_ASSIGN_PRIMARY = 0x0001
37
+ TOKEN_DUPLICATE = 0x0002
38
+ TOKEN_IMPERSONATE = 0x0004
39
+ TOKEN_QUERY = 0x0008
40
+ TOKEN_QUERY_SOURCE = 0x0010
41
+ TOKEN_ADJUST_PRIVILEGES = 0x0020
42
+ TOKEN_ADJUST_GROUPS = 0x0040
43
+ TOKEN_ADJUST_DEFAULT = 0x0080
44
+ TOKEN_ADJUST_SESSIONID = 0x0100
45
+ TOKEN_ALL_ACCESS_P = 983295 # Calculated from WinNt.h
46
+ TOKEN_ALL_ACCESS = TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID
47
+
48
+ SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001
49
+ SE_PRIVILEGE_ENABLED = 0x00000002
50
+ SE_PRIVILEGE_REMOVED = 0X00000004
51
+ SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000
32
52
 
53
+ API.new('AccessCheck', 'PLLPPLPP', 'B', 'advapi32')
33
54
  API.new('AddAce', 'PLLLL', 'B', 'advapi32')
55
+ API.new('AdjustTokenGroups', 'LLPLPP', 'B', 'advapi32')
56
+ API.new('AdjustTokenPrivileges', 'LLPLPP', 'B', 'advapi32')
57
+ API.new('CheckTokenMembership', 'LPP', 'B', 'advapi32')
34
58
  API.new('CopySid', 'LLP', 'B', 'advapi32')
35
59
  API.new('ConvertSidToStringSid', 'PL', 'B', 'advapi32')
36
60
  API.new('ConvertSecurityDescriptorToStringSecurityDescriptor', 'PLLPP', 'B', 'advapi32')
37
61
  API.new('ConvertStringSecurityDescriptorToSecurityDescriptor', 'PLPP', 'B', 'advapi32')
38
62
  API.new('ConvertStringSidToSid', 'PL', 'B', 'advapi32')
63
+ API.new('CreateRestrictedToken', 'LLLPLPLPP', 'B', 'advapi32')
64
+ API.new('DuplicateToken', 'LPP', 'B', 'advapi32')
65
+ API.new('DuplicateTokenEx', 'LLPLLP', 'B', 'advapi32')
39
66
  API.new('GetAce', 'LLP', 'B', 'advapi32')
40
67
  API.new('GetFileSecurity', 'PLPLP', 'B', 'advapi32')
41
68
  API.new('GetLengthSid', 'P', 'L', 'advapi32')
@@ -51,11 +78,16 @@ module Windows
51
78
  API.new('IsValidSecurityDescriptor', 'P', 'B', 'advapi32')
52
79
  API.new('LookupAccountName', 'PPPPPPP', 'B', 'advapi32')
53
80
  API.new('LookupAccountSid', 'PLPPPPP', 'B', 'advapi32')
81
+ API.new('LookupPrivilegeValue', 'PPP', 'B', 'advapi32')
82
+ API.new('OpenProcessToken', 'LLP', 'B', 'advapi32')
83
+ API.new('OpenThreadToken', 'LLLP', 'B', 'advapi32')
54
84
  API.new('SetFileSecurity', 'PPP', 'B', 'advapi32')
55
85
  API.new('SetSecurityDescriptorDacl', 'PIPI', 'B', 'advapi32')
56
86
  API.new('SetSecurityDescriptorGroup', 'PPI', 'B', 'advapi32')
57
87
  API.new('SetSecurityDescriptorOwner', 'PPI', 'B', 'advapi32')
58
88
  API.new('SetSecurityDescriptorRMControl', 'PP', 'L', 'advapi32')
59
89
  API.new('SetSecurityDescriptorSacl', 'PIPI', 'B', 'advapi32')
90
+ API.new('SetThreadToken', 'PL', 'B', 'advapi32')
91
+ API.new('SetTokenInformation', 'LLPL', 'B', 'advapi32')
60
92
  end
61
93
  end
@@ -21,8 +21,8 @@ module Windows
21
21
 
22
22
  # Service control action types
23
23
  SC_ACTION_NONE = 0
24
- SC_ACTION_REBOOT = 1
25
- SC_ACTION_RESTART = 2
24
+ SC_ACTION_RESTART = 1
25
+ SC_ACTION_REBOOT = 2
26
26
  SC_ACTION_RUN_COMMAND = 3
27
27
 
28
28
  # Service access rights
@@ -106,6 +106,9 @@ module Windows
106
106
  SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
107
107
  SERVICE_CONFIG_PRESHUTDOWN_INFO = 7
108
108
 
109
+ # Configuration
110
+ SERVICE_NO_CHANGE = 0xffffffff
111
+
109
112
  API.new('ChangeServiceConfig', 'LLLLPPPPPPP', 'B', 'advapi32')
110
113
  API.new('ChangeServiceConfig2', 'LLP', 'B', 'advapi32')
111
114
  API.new('CloseServiceHandle', 'L', 'B', 'advapi32')
data/lib/windows/shell.rb CHANGED
@@ -75,7 +75,82 @@ module Windows
75
75
  SHGFP_TYPE_CURRENT = 0
76
76
  SHGFP_TYPE_DEFAULT = 1
77
77
 
78
+ # Shell file operations
79
+ FO_MOVE = 0x0001
80
+ FO_COPY = 0x0002
81
+ FO_DELETE = 0x0003
82
+ FO_RENAME = 0x0004
83
+
84
+ FOF_MULTIDESTFILES = 0x0001
85
+ FOF_CONFIRMMOUSE = 0x0002
86
+ FOF_SILENT = 0x0004 # Don't create progress/report
87
+ FOF_RENAMEONCOLLISION = 0x0008
88
+ FOF_NOCONFIRMATION = 0x0010 # Don't prompt the user.
89
+ FOF_WANTMAPPINGHANDLE = 0x0020 # Fill in SHFILEOPSTRUCT.hNameMappings
90
+ FOF_ALLOWUNDO = 0x0040
91
+ FOF_FILESONLY = 0x0080 # On *.*, do only files
92
+ FOF_SIMPLEPROGRESS = 0x0100 # Means don't show names of files
93
+ FOF_NOCONFIRMMKDIR = 0x0200 # Don't confirm making any needed dirs
94
+ FOF_NOERRORUI = 0x0400 # Don't put up error UI
95
+ FOF_NOCOPYSECURITYATTRIBS = 0x0800 # Don't copy NT file Sec. Attributes
96
+ FOF_NORECURSION = 0x1000 # Don't recurse into directories.
97
+ FOF_NO_CONNECTED_ELEMENTS = 0x2000 # Don't operate on connected elements
98
+ FOF_WANTNUKEWARNING = 0x4000 # During delete op, warn if nuking
99
+ FOF_NORECURSEREPARSE = 0x8000 # Treat reparse points as objects
100
+
101
+ # Shell execute error codes
102
+ SE_ERR_FNF = 2 # file not found
103
+ SE_ERR_PNF = 3 # path not found
104
+ SE_ERR_ACCESSDENIED = 5 # access denied
105
+ SE_ERR_OOM = 8 # out of memory
106
+ SE_ERR_DLLNOTFOUND = 32
107
+ SE_ERR_SHARE = 26
108
+ SE_ERR_ASSOCINCOMPLETE = 27
109
+ SE_ERR_DDETIMEOUT = 28
110
+ SE_ERR_DDEFAIL = 29
111
+ SE_ERR_DDEBUSY = 30
112
+ SE_ERR_NOASSOC = 31
113
+
114
+ # Shell link constants
115
+ SHGNLI_PIDL = 0x000000001 # pszLinkTo is a pidl
116
+ SHGNLI_PREFIXNAME = 0x000000002 # Make name "Shortcut to xxx"
117
+ SHGNLI_NOUNIQUE = 0x000000004 # don't do the unique name generation
118
+ SHGNLI_NOLNK = 0x000000008 # don't add ".lnk" extension
119
+
120
+ # File information constants
121
+ SHGFI_ICON = 0x000000100 # get icon
122
+ SHGFI_DISPLAYNAME = 0x000000200 # get display name
123
+ SHGFI_TYPENAME = 0x000000400 # get type name
124
+ SHGFI_ATTRIBUTES = 0x000000800 # get attributes
125
+ SHGFI_ICONLOCATION = 0x000001000 # get icon location
126
+ SHGFI_EXETYPE = 0x000002000 # return exe type
127
+ SHGFI_SYSICONINDEX = 0x000004000 # get system icon index
128
+ SHGFI_LINKOVERLAY = 0x000008000 # put a link overlay on icon
129
+ SHGFI_SELECTED = 0x000010000 # show icon in selected state
130
+ SHGFI_ATTR_SPECIFIED = 0x000020000 # get only specified attributes
131
+ SHGFI_LARGEICON = 0x000000000 # get large icon
132
+ SHGFI_SMALLICON = 0x000000001 # get small icon
133
+ SHGFI_OPENICON = 0x000000002 # get open icon
134
+ SHGFI_SHELLICONSIZE = 0x000000004 # get shell size icon
135
+ SHGFI_PIDL = 0x000000008 # pszPath is a pidl
136
+ SHGFI_USEFILEATTRIBUTES = 0x000000010 # use passed dwFileAttribute
137
+ SHGFI_ADDOVERLAYS = 0x000000020 # apply the appropriate overlays
138
+ SHGFI_OVERLAYINDEX = 0x000000040 # Get the index of the overlay
139
+
140
+ API.new('DragQueryFile', 'LIPI', 'I', 'shell32')
141
+ API.new('ExtractIcon', 'LPI', 'L', 'shell32')
142
+ API.new('ExtractIconEx', 'PIPPI', 'I', 'shell32')
143
+ API.new('FindExecutable', 'PPP', 'L', 'shell32')
144
+ API.new('ShellAbout', 'LPPL', 'I', 'shell32')
145
+ API.new('SHBrowseForFolder', 'P', 'P', 'shell32')
146
+ API.new('SHChangeNotify', 'LILL', 'V', 'shell32')
147
+ API.new('ShellExecute', 'LPPPPI', 'L', 'shell32')
148
+ API.new('ShellExecuteEx', 'P', 'B', 'shell32')
149
+ API.new('SHFileOperation', 'P', 'I', 'shell32')
150
+ API.new('SHGetFileInfo', 'PLPII', 'L', 'shell32')
78
151
  API.new('SHGetFolderPath', 'LLLLP', 'L', 'shell32')
152
+ API.new('SHGetNewLinkInfo', 'PPPPI', 'B', 'shell32')
153
+ API.new('SHGetPathFromIDList', 'LL', 'B', 'shell32')
79
154
  API.new('SHGetSpecialFolderLocation', 'LIP', 'L', 'shell32')
80
155
  API.new('SHGetSpecialFolderPath', 'LPLL','L', 'shell32')
81
156
  end
@@ -52,7 +52,12 @@ module Windows
52
52
  API.new('CreateEvent', 'PIIP', 'L')
53
53
  API.new('CreateMutex', 'PIP', 'L')
54
54
  API.new('CreateSemaphore', 'PLLP', 'L')
55
+ API.new('DeleteCriticalSection', 'P', 'V')
56
+ API.new('EnterCriticalSection', 'P', 'V')
55
57
  API.new('GetOverlappedResult', 'LPPI', 'I')
58
+ API.new('InitializeCriticalSection', 'P', 'V')
59
+ API.new('InitializeCriticalSectionAndSpinCount', 'PL', 'B')
60
+ API.new('LeaveCriticalSection', 'P', 'V')
56
61
  API.new('MsgWaitForMultipleObjects', 'LPILL', 'L', 'user32')
57
62
  API.new('MsgWaitForMultipleObjectsEx', 'LPLLL', 'L', 'user32')
58
63
  API.new('OpenEvent', 'LIP', 'L')
@@ -61,15 +66,31 @@ module Windows
61
66
  API.new('ReleaseMutex', 'L', 'B')
62
67
  API.new('ReleaseSemaphore', 'LLP', 'B')
63
68
  API.new('ResetEvent', 'L', 'B')
69
+ API.new('SetCriticalSectionSpinCount', 'PL', 'V')
64
70
  API.new('SetEvent', 'L', 'B')
71
+ API.new('TryEnterCriticalSection', 'P', 'B')
65
72
  API.new('WaitForMultipleObjects', 'LPIL', 'L')
66
73
  API.new('WaitForMultipleObjectsEx', 'LPILI', 'L')
67
74
  API.new('WaitForSingleObject', 'LL', 'L')
68
75
  API.new('WaitForSingleObjectEx', 'LLI', 'L')
69
76
 
70
77
  # Macros
78
+
71
79
  def HasOverlappedIoCompleted(overlapped)
72
80
  overlapped[0,4].unpack('L')[0] != STATUS_PENDING
73
81
  end
82
+
83
+ # This simulates the RUBY_CRITICAL macro from rubysig.h, although I've
84
+ # added the begin/ensure wrapper to boot.
85
+ def RUBY_CRITICAL(&block)
86
+ critical_section = [0].pack('L')
87
+ begin
88
+ InitializeCriticalSection(critical_section)
89
+ EnterCriticalSection(critical_section)
90
+ block.call
91
+ ensure
92
+ LeaveCriticalSection(critical_section)
93
+ end
94
+ end
74
95
  end
75
96
  end
@@ -0,0 +1,64 @@
1
+ require 'windows/api'
2
+ include Windows
3
+
4
+ module Windows
5
+ module Thread
6
+ API.auto_namespace = 'Windows::Thread'
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
+ API.auto_unicode = true
10
+
11
+ SYNCHRONIZE = 0x00100000
12
+ THREAD_ALL_ACCESS = 0x1F03FF
13
+ THREAD_DIRECT_IMPERSONATION = 0x0200
14
+ THREAD_GET_CONTEXT = 0x0008
15
+ THREAD_IMPERSONATE = 0x0100
16
+ THREAD_QUERY_INFORMATION = 0x0040
17
+ THREAD_SET_CONTEXT = 0x0010
18
+ THREAD_SET_INFORMATION = 0x0020
19
+ THREAD_SET_THREAD_TOKEN = 0x0080
20
+ THREAD_SUSPEND_RESUME = 0x0002
21
+ THREAD_TERMINATE = 0x0001
22
+
23
+ THREAD_PRIORITY_ABOVE_NORMAL = 1
24
+ THREAD_PRIORITY_BELOW_NORMAL = -1
25
+ THREAD_PRIORITY_HIGHEST = 2
26
+ THREAD_PRIORITY_IDLE = -15
27
+ THREAD_PRIORITY_LOWEST = -2
28
+ THREAD_PRIORITY_NORMAL = 0
29
+ THREAD_PRIORITY_TIME_CRITICAL = 15
30
+
31
+ API.new('CreateRemoteThread', 'LPLLPLP', 'L')
32
+ API.new('CreateThread', 'PLPPLP', 'L')
33
+ API.new('ExitThread', 'L', 'V')
34
+ API.new('GetCurrentThread', 'V', 'L')
35
+ API.new('GetCurrentThreadId', 'V', 'L')
36
+ API.new('GetExitCodeThread', 'LP', 'B')
37
+ API.new('GetThreadPriority', 'L', 'I')
38
+ API.new('GetThreadPriorityBoost', 'LP', 'B')
39
+ API.new('GetThreadTimes', 'LPPPP', 'B')
40
+ API.new('OpenThread', 'LIL', 'L')
41
+ API.new('ResumeThread', 'L', 'L')
42
+ API.new('SetThreadAffinityMask', 'LP', 'P')
43
+ API.new('SetThreadIdealProcessor', 'LL', 'L')
44
+ API.new('SetThreadPriority', 'LI', 'B')
45
+ API.new('SetThreadPriorityBoost', 'LI', 'B')
46
+ API.new('Sleep', 'L', 'V')
47
+ API.new('SleepEx', 'LI', 'L')
48
+ API.new('SuspendThread', 'L', 'L')
49
+ API.new('SwitchToThread', 'V', 'B')
50
+ API.new('TerminateThread', 'LL', 'B')
51
+ API.new('TlsAlloc', 'V', 'L')
52
+ API.new('TlsFree', 'L', 'B')
53
+ API.new('TlsGetValue', 'L', 'L')
54
+ API.new('TlsSetValue', 'LL', 'B')
55
+
56
+ # Windows XP or later
57
+ begin
58
+ API.new('AttachThreadInput', 'LLI', 'B')
59
+ API.new('GetThreadIOPendingFlag', 'LP', 'B')
60
+ rescue Exception
61
+ # Do nothing. It's up to you to check for its existence.
62
+ end
63
+ end
64
+ end