Skip to content

Commit dd2bf90

Browse files
committed
Support for Visual studio
The changes necessary to support visual studio fall into 2 basic groups. 1) reordering of header files, and 2) changes to support syntax differences between mingw and visual studio and 3). All changes are conditional upon the definition of the macro __VS_BUILD__ .
1 parent d34621a commit dd2bf90

File tree

10 files changed

+115
-6
lines changed

10 files changed

+115
-6
lines changed

contrib/win32/win32compat/lsa/Debug.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@
6666
#define DBG_ENTER(FUNC_NAME) DbgEntry(FUNC_NAME)
6767

6868
#define DBG_LEAVE(FUNC_NAME) DbgLeave(FUNC_NAME)
69-
69+
#ifndef __VS_BUILD__
7070
#define DBG_MSG(FMT, ARGS...) DbgMsg(FMT, ## ARGS)
7171

7272
#define DBG_MSG_NOLN(FMT, ARGS...) DbgMsgNoLn(FMT, ## ARGS)
73-
73+
#else
74+
#define DBG_MSG(FMT, ...) DbgMsg(FMT, __VA_ARGS__)
75+
76+
#define DBG_MSG_NOLN(FMT, ...) DbgMsgNoLn(FMT, __VA_ARGS__)
77+
#endif
7478

7579
#define DBG_DUMP_TO_FILE(fname, ptr, size) //DbgDumpToFile(fname, ptr, size)
7680

contrib/win32/win32compat/lsa/Key.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,28 @@
2929
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32+
#ifdef __VS_BUILD__
33+
#include <winsock2.h>
34+
#include <Windows.h>
35+
#include <LsaLookup.h>
36+
#include <Ntsecapi.h>
37+
#endif
38+
3239
#include <winsock2.h>
3340
#include "Key.h"
3441

42+
#ifdef __VS_BUILD__
43+
#ifdef __cplusplus
44+
extern "C" {
45+
#endif
46+
#endif // __VS_BUILD__
3547
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
48+
#ifdef __VS_BUILD__
49+
#ifdef __cplusplus
50+
}
51+
#endif
52+
#endif
53+
3654

3755
#ifdef DYNAMIC_OPENSSL
3856
extern SSLFuncList DynSSL;

contrib/win32/win32compat/lsa/KeyAuth.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@
3131

3232
#include "KeyAuth.h"
3333

34-
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
34+
#ifdef __VS_BUILD__
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
#endif // __VS_BUILD__
39+
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
40+
#ifdef __VS_BUILD__
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
#endif
3545

3646
#ifdef DYNAMIC_OPENSSL
3747
extern SSLFuncList DynSSL;

contrib/win32/win32compat/lsa/KeyAuth.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@
3434

3535
#undef STRING
3636

37+
#ifdef __VS_BUILD__
38+
#define UMDF_USING_NTSTATUS
39+
#include <winsock2.h>
40+
#include <Windows.h>
41+
#include <LsaLookup.h>
42+
#include <Ntsecapi.h>
43+
#endif
44+
45+
3746
#include <winsock2.h>
3847

3948
#include "Win64Fix.h"

contrib/win32/win32compat/lsa/LsaString.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,28 @@
2929
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32+
#ifdef __VS_BUILD__
33+
#define UMDF_USING_NTSTATUS
34+
#include <winsock2.h>
35+
#include <Windows.h>
36+
#include <LsaLookup.h>
37+
#include <Ntsecapi.h>
38+
#endif
39+
3240
#include <winsock2.h>
3341
#include "LsaString.h"
3442

35-
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
43+
#ifdef __VS_BUILD__
44+
#ifdef __cplusplus
45+
extern "C" {
46+
#endif
47+
#endif // __VS_BUILD__
48+
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
49+
#ifdef __VS_BUILD__
50+
#ifdef __cplusplus
51+
}
52+
#endif
53+
#endif
3654

3755
//
3856
// Allocate empty UNICODE_STRING in LSA address space.

contrib/win32/win32compat/lsa/LsaString.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
#undef STRING
3636

37+
38+
3739
#include "Win64Fix.h"
3840

3941
#include <stdio.h>
@@ -43,11 +45,15 @@
4345
#include <Ntsecapi.h>
4446
#include <NTSecPkg.h>
4547

48+
#ifndef __VS_BUILD__
4649
#ifdef _WIN64
4750
#include <ntstatus.h>
4851
#else
4952
#include <ddk/ntstatus.h>
5053
#endif
54+
#else
55+
#include <ntstatus.h>
56+
#endif
5157

5258
#include "Debug.h"
5359

contrib/win32/win32compat/lsa/PopBinary.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@
3131

3232
#include "PopBinary.h"
3333

34-
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
34+
#ifdef __VS_BUILD__
35+
#ifdef __cplusplus
36+
extern "C" {
37+
#endif
38+
#endif // __VS_BUILD__
39+
extern LSA_SECPKG_FUNCTION_TABLE LsaApi;
40+
#ifdef __VS_BUILD__
41+
#ifdef __cplusplus
42+
}
43+
#endif
44+
#endif
3545

3646
#ifdef DYNAMIC_OPENSSL
3747
extern SSLFuncList DynSSL;

contrib/win32/win32compat/lsa/PopBinary.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434

3535
#undef STRING
3636

37+
#ifdef __VS_BUILD__
38+
#define UMDF_USING_NTSTATUS
39+
#include <winsock2.h>
40+
#include <Windows.h>
41+
#include <LsaLookup.h>
42+
#include <Ntsecapi.h>
43+
#endif
44+
3745
#include <winsock2.h>
3846

3947
#include "Win64Fix.h"

contrib/win32/win32compat/lsa/Ssh-lsa.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131

3232
#define WINVER 0x501
3333

34+
#ifdef __VS_BUILD__
35+
#define UMDF_USING_NTSTATUS
36+
#include <winsock2.h>
37+
#include <Windows.h>
38+
#include <LsaLookup.h>
39+
#include <Ntsecapi.h>
40+
#endif
41+
42+
3443
#include <winsock2.h>
3544
#include "Ssh-lsa.h"
3645

@@ -432,9 +441,13 @@ Int AuthorizeUser(wchar_t homeDir[MAX_PATH], HANDLE token, SshLsaAuth *auth)
432441
if (wcschr(nextFile, ':') == NULL)
433442
{
434443
DBG_MSG("Expanding relative path to user homedir.\n");
435-
444+
#ifndef __VS_BUILD__
436445
snwprintf(keyFileName, sizeof(keyFileName),
437446
L"%ls\\%ls", homeDir, nextFile);
447+
#else
448+
_snwprintf(keyFileName, sizeof(keyFileName),
449+
L"%ls\\%ls", homeDir, nextFile);
450+
#endif
438451

439452
fileToCheck = keyFileName;
440453
}

contrib/win32/win32compat/lsa/Ssh-lsa.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@
4242

4343
#include <NTSecPkg.h>
4444

45+
#ifndef __VS_BUILD__
4546
#ifdef _WIN64
4647
#include <ntstatus.h>
4748
#else
4849
#include <ddk/ntstatus.h>
4950
#endif
51+
#else
52+
#include <ntstatus.h>
53+
#endif
5054

5155
#include <Userenv.h>
5256
#include <Shlwapi.h>
@@ -84,9 +88,17 @@ typedef struct _SshLsaAuth
8488
}
8589
SshLsaAuth;
8690

91+
#ifndef __VS_BUILD__
8792
typedef VOID WINAPI (*RtlInitUnicodeStringPtr)
8893
(PUNICODE_STRING, PCWSTR SourceString);
8994

95+
#else
96+
typedef VOID (WINAPI *RtlInitUnicodeStringPtr)
97+
(PUNICODE_STRING, PCWSTR SourceString);
98+
#endif
99+
100+
101+
#ifndef __VS_BUILD__
90102
#ifndef _WIN64
91103
typedef struct _LSA_TOKEN_INFORMATION_V1
92104
{
@@ -106,5 +118,6 @@ typedef struct _LSA_TOKEN_INFORMATION_V1
106118
}
107119
LSA_TOKEN_INFORMATION_V1, *PLSA_TOKEN_INFORMATION_V1;
108120
#endif
121+
#endif
109122

110123
#endif

0 commit comments

Comments
 (0)