Skip to content

6 Win32 function stubs, 8 constants, 1 structure, and 1 helper function#535

Closed
mlfreeman2 wants to merge 9 commits intojava-native-access:masterfrom
mlfreeman2:master
Closed

6 Win32 function stubs, 8 constants, 1 structure, and 1 helper function#535
mlfreeman2 wants to merge 9 commits intojava-native-access:masterfrom
mlfreeman2:master

Conversation

@mlfreeman2
Copy link
Copy Markdown
Contributor

  • Advapi32
    • Added LOGON_WITH_PROFILE constant
    • Added LOGON_NETCREDENTIALS_ONLY constant
    • Added CreateProcessWithLogonW(String, String, String, int, String, String, int, Pointer, String, STARTUPINFO, PROCESS_INFORMATION)
      • No Unit Test - I would have to make it create a user to be 100% able to run a process as another user and that would be a security issue I figure.
  • Crypt32
    • Added CertAddEncodedCertificateToSystemStore(String, Pointer, DWORD)
      • No Unit Test - I doubt anyone would want the security risk of a unit test installing a root certificate.
  • GDI32
    • Added SRCCOPY constant
    • Added BitBlt(HDC, int, int, int, int, HDC, int, int, int)
      • No direct unit test - the test for GDI32Util.getScreenshot() seemed to cover it just fine.
    • Added GDI32Util.getScreenshot(HWND)
      • Added unit test as GDI32UtilTest.testGetScreenshot()
  • Shell32
    • Added SHERB_NOCONFIRMATION constant
    • Added SHERB_NOPROGRESSUI constant
    • Added SHERB_NOSOUND constant
    • Added SEE_MASK_NOCLOSEPROCESS constant
    • Added SHEmptyRecycleBin(HANDLE, String, int)
      • No unit test - no idea how to tell if the recycle bin is empty afterwards
    • Added ShellExecuteEx(SHELLEXECUTEINFO)
      • No unit test - there are a bunch of cases where the hProcess member in SHELLEXECUTEINFO isn't set - not sure how to control for that
  • ShellAPI
    • Added SHELLEXECUTEINFO structure
  • User32
    • Added GetDesktopWindow()
      • Added test as User32Test.testGetDesktopWindow()
  • WinGDI
    • Added HGDI_ERROR
    • Removed superfluous "public" and "public final" from WinGDI

Hopefully this is more manageable and more acceptable than my last way-too-large pull request

	* Added LOGON_WITH_PROFILE constant
	* Added LOGON_NETCREDENTIALS_ONLY constant
	* Added CreateProcessWithLogonW(String, String, String, int, String, String, int, Pointer, String, STARTUPINFO, PROCESS_INFORMATION)
		* No Unit Test - I would have to make it create a user to be 100% able to run a process as another user and that would be a security issue I figure.
* Crypt32
	* Added CertAddEncodedCertificateToSystemStore(String, Pointer, DWORD)
		* No Unit Test - I doubt anyone would want the security risk of a unit test installing a root certificate.
* GDI32
	* Added SRCCOPY constant
	* Added BitBlt(HDC, int, int, int, int, HDC, int, int, int)
		* No direct unit test - the test for GDI32Util.getScreenshot() seemed to cover it just fine.
	* Added GDI32Util.getScreenshot(HWND)
		* Added unit test as GDI32UtilTest.testGetScreenshot()
* Shell32
	* Added SHERB_NOCONFIRMATION constant
	* Added SHERB_NOPROGRESSUI constant
	* Added SHERB_NOSOUND constant
	* Added SEE_MASK_NOCLOSEPROCESS constant
	* Added SHEmptyRecycleBin(HANDLE, String, int)
		* No unit test - no idea how to tell if the recycle bin is empty afterwards
	* Added ShellExecuteEx(SHELLEXECUTEINFO)
		* No unit test - there are a bunch of cases where the hProcess member in SHELLEXECUTEINFO isn't set - not sure how to control for that
* ShellAPI
	* Added SHELLEXECUTEINFO structure
* User32
	* Added GetDesktopWindow()
		* Added test as User32Test.testGetDesktopWindow()
* WinGDI
	* Added HGDI_ERROR
	* Removed superfluous "public" and "public final" from WinGDI
@mlfreeman2
Copy link
Copy Markdown
Contributor Author

I did try to incorporate all the feedback that @lgoldstein and @dblock gave me on the last (now closed) pull request.

@mlfreeman2
Copy link
Copy Markdown
Contributor Author

Added negative unit tests for CreateProcessWithLogonW and CertAddEncodedCertificateToSystemStore

I figure those will be secure since they're meant to fail with specific windows error codes.

@mlfreeman2
Copy link
Copy Markdown
Contributor Author

Got creative and managed to figure out what I think might be reasonable negative tests for the remaining functions in this PR.
In theory every function added in this PR has some sort of test associated with it now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can usually safely use int instead of DWORD here (as well as for return values). I agree that DWORD and int are not entirely equivalent, but for most purposes the sign is not important - e.g., error codes or sizes (as in this case).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse the order of the arguments to assertEquals - the expected comes first (in this case W32Errors.ERROR_LOGON_FAILURE should be first and getLastError() second).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants