From f5066241551896b7e89690b7bc22ebc6ce42afa2 Mon Sep 17 00:00:00 2001
From: qmuntal <qmuntaldiaz@microsoft.com>
Date: Tue, 5 Mar 2024 17:04:03 +0100
Subject: [PATCH] fix SILOOBJECT_BASIC_INFORMATION alignment

Signed-off-by: qmuntal <qmuntaldiaz@microsoft.com>
---
 internal/jobobject/jobobject.go | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/internal/jobobject/jobobject.go b/internal/jobobject/jobobject.go
index 10ae4d6700..980ea8c4ba 100644
--- a/internal/jobobject/jobobject.go
+++ b/internal/jobobject/jobobject.go
@@ -523,12 +523,16 @@ func (job *JobObject) ApplyFileBinding(root, target string, readOnly bool) error
 func isJobSilo(h windows.Handle) bool {
 	// None of the information from the structure that this info class expects will be used, this is just used as
 	// the call will fail if the job hasn't been upgraded to a silo so we can use this to tell when we open a job
-	// if it's a silo or not. Because none of the info matters simply define a dummy struct with the size that the call
-	// expects which is 16 bytes.
-	type isSiloObj struct {
-		_ [16]byte
-	}
-	var siloInfo isSiloObj
+	// if it's a silo or not. We still need to define the struct layout as expected by Win32, else the struct
+	// alignment might be different and the call will fail.
+	type SILOOBJECT_BASIC_INFORMATION struct {
+		SiloID            uint32
+		SiloParentID      uint32
+		NumberOfProcesses uint32
+		IsInServerSilo    bool
+		Reserved          [3]uint8
+	}
+	var siloInfo SILOOBJECT_BASIC_INFORMATION
 	err := winapi.QueryInformationJobObject(
 		h,
 		winapi.JobObjectSiloBasicInformation,