Skip to content

Commit

Permalink
Merge pull request #176 from K-Society/experimental
Browse files Browse the repository at this point in the history
Testing
  • Loading branch information
maniglia authored Dec 27, 2024
2 parents 1c38ff9 + 7da4a40 commit 37041aa
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/01/KSociety.SharpCubeProgrammer/CubeProgrammerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void LoadStLinkDriver()
out IntPtr handle))
{
var error = Marshal.GetLastWin32Error();
this._logger?.LogError("Loading with NativeLibrary {0} {1} library error: {3} !", target + @"\STLinkUSBDriver.dll", Environment.Is64BitProcess ? "x64" : "x86", error);
this._logger?.LogError("Loading with NativeLibrary {0} {1} library error: {2} !", target + @"\STLinkUSBDriver.dll", Environment.Is64BitProcess ? "x64" : "x86", error);
this._handleSTLinkDriver = null;
}
else
Expand Down Expand Up @@ -107,7 +107,7 @@ private void LoadStLinkDriver()
if (this._handleSTLinkDriver.IsInvalid)
{
int error = Marshal.GetLastWin32Error();
this._logger?.LogError("Loading {0} {1} library error: {3} !", target + @"\STLinkUSBDriver.dll", Environment.Is64BitProcess ? "x64" : "x86", error);
this._logger?.LogError("Loading {0} {1} library error: {2} !", target + @"\STLinkUSBDriver.dll", Environment.Is64BitProcess ? "x64" : "x86", error);
this._handleSTLinkDriver = null;
}
else
Expand Down Expand Up @@ -139,7 +139,7 @@ private void LoadProgrammer()
out IntPtr handle))
{
var error = Marshal.GetLastWin32Error();
this._logger?.LogError("Loading with NativeLibrary {0} {1} library error: {3} !", target, Environment.Is64BitProcess ? "x64" : "x86", error);
this._logger?.LogError("Loading with NativeLibrary {0} {1} library error: {2} !", target, Environment.Is64BitProcess ? "x64" : "x86", error);
this._handleProgrammer = null;
}
else
Expand Down Expand Up @@ -167,24 +167,27 @@ private void LoadProgrammer()

var result = Native.Utility.SetDllDirectoryW(target);

if (!result)
if (result)
{
this._handleProgrammer = Native.Utility.LoadLibraryEx(target + @"\Programmer.dll", IntPtr.Zero, dwFlags);

if (this._handleProgrammer.IsInvalid)
{
int error = Marshal.GetLastWin32Error();
this._logger?.LogError("Loading {0} {1} library error: {2} !", target + @"\Programmer.dll", Environment.Is64BitProcess ? "x64" : "x86", error);
this._handleProgrammer = null;
}
else
{
this._logger?.LogInformation("Loading {0} - {1} library.", "Programmer.dll", Environment.Is64BitProcess ? "x64" : "x86");
}
}
else
{
int error = Marshal.GetLastWin32Error();
this._logger?.LogError("SetDllDirectory {0} error: {1} !", target, error);
}
}

this._handleProgrammer = Native.Utility.LoadLibraryEx(target + @"\Programmer.dll", IntPtr.Zero, dwFlags);

if (this._handleProgrammer.IsInvalid)
{
int error = Marshal.GetLastWin32Error();
this._logger?.LogError("Loading {0} {1} library error: {3} !", target + @"\Programmer.dll", Environment.Is64BitProcess ? "x64" : "x86", error);
this._handleProgrammer = null;
}
else
{
this._logger?.LogInformation("Loading {0} - {1} library.", "Programmer.dll", Environment.Is64BitProcess ? "x64" : "x86");
}
}
#endif
}
}
Expand Down

0 comments on commit 37041aa

Please sign in to comment.