Skip to content

Commit

Permalink
Merge pull request #66 from GregLando113/dev
Browse files Browse the repository at this point in the history
make unicode encoding default, supply other encoding if necessary
  • Loading branch information
DubbleClick authored Jul 20, 2023
2 parents 3db675e + f882791 commit e03bf55
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion GW Launcher/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void RefreshUI()
{
var memory = new GWCAMemory(process);
GWMemory.FindAddressesIfNeeded(memory);
var email = memory.ReadWString(GWMemory.EmailAddPtr, 64);
var email = memory.ReadWString(GWMemory.EmailAddPtr, 64, Encoding.Default);
foreach (var account in Program.accounts)
{
if (email != account.email)
Expand Down
16 changes: 8 additions & 8 deletions GW Launcher/GW Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<Platforms>x86;AnyCPU</Platforms>
<PlatformTarget>x86</PlatformTarget>
<DebugType>portable</DebugType>
<AssemblyVersion>13.11</AssemblyVersion>
<FileVersion>13.11</FileVersion>
<AssemblyVersion>13.12</AssemblyVersion>
<FileVersion>13.12</FileVersion>
<Copyright>2015-2023 GregLando113</Copyright>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
</PropertyGroup>
Expand All @@ -40,13 +40,13 @@
</ItemGroup>

<ItemGroup>
<Content Include="Resources\gw-icon.ico"/>
<Content Include="Resources\gw-icon.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetZip" Version="1.16.0"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Octokit" Version="0.51.0"/>
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Octokit" Version="0.51.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -65,11 +65,11 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\PublishProfiles\"/>
<Folder Include="Properties\PublishProfiles\" />
</ItemGroup>

<ItemGroup>
<None Include=".editorconfig"/>
<None Include=".editorconfig" />
</ItemGroup>

</Project>
17 changes: 9 additions & 8 deletions GW Launcher/Memory/GWCAMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ out _
/// <param name="address">Address of base to read from.</param>
/// <param name="size">Amount of bytes to read from base.</param>
/// <returns>bytes read.</returns>
public byte[]? ReadBytes(IntPtr address, int size)
private byte[] ReadBytes(IntPtr address, int size)
{
var buffer = Marshal.AllocHGlobal(size);

Expand All @@ -177,16 +177,18 @@ out _
/// </summary>
/// <param name="address">Address of string base.</param>
/// <param name="maxsize">Max possible known size of string.</param>
/// <param name="encoding">Encoding of the string to be read.</param>
/// <returns>String found.</returns>
public string ReadWString(IntPtr address, int maxsize)
public string ReadWString(IntPtr address, int maxsize, Encoding? encoding = null)
{
encoding ??= Encoding.Unicode;
var rawbytes = ReadBytes(address, maxsize);
if (rawbytes == null)
if (rawbytes.Length == 0)
{
return "";
}

var ret = Encoding.Default.GetString(rawbytes);
var ret = encoding.GetString(rawbytes);
if (ret.Contains('\0'))
{
ret = ret[..ret.IndexOf('\0')];
Expand Down Expand Up @@ -286,9 +288,8 @@ public bool InitScanner(IntPtr startaddr, int size)
/// <returns>Address found if successful, IntPtr.Zero if not.</returns>
public IntPtr ScanForPtr(byte[] signature, int offset = 0, bool readptr = false)
{
bool match;
var first = signature[0];
var sig_length = signature.Length;
var sigLength = signature.Length;

// For start to end of scan range...
for (var scan = 0; scan < scan_size; ++scan)
Expand All @@ -300,10 +301,10 @@ public IntPtr ScanForPtr(byte[] signature, int offset = 0, bool readptr = false)
continue;
}

match = true;
var match = true;

// For sig size... check for matching signature.
for (var sig = 0; sig < sig_length; ++sig)
for (var sig = 0; sig < sigLength; ++sig)
{
if (memory_dump[scan + sig] != signature[sig] && signature[sig] != 0x00)
{
Expand Down
3 changes: 1 addition & 2 deletions GW Launcher/MulticlientPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ private static IntPtr GetProcessModuleBase(IntPtr process)
texClient = new uModTexClient();
}

var args =
$"-email \"{account.email}\" -password \"{account.password}\"";
var args = $"-email \"{account.email}\" -password \"{account.password}\"";

if (!string.IsNullOrEmpty(account.character))
{
Expand Down
4 changes: 2 additions & 2 deletions GW Launcher/Utilities/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ private static Tuple<IOrderedEnumerable<string>, IOrderedEnumerable<string>>
}

dllsToLoad.AddRange(mods
.Where(mod => mod.type == ModType.kModTypeDLL && mod.active && File.Exists(mod.fileName))
.Where(mod => mod is { type: ModType.kModTypeDLL, active: true } && File.Exists(mod.fileName))
.Select(mod => mod.fileName));
texsToLoad.AddRange(mods
.Where(mod => mod.type == ModType.kModTypeTexmod && mod.active && File.Exists(mod.fileName))
.Where(mod => mod is { type: ModType.kModTypeTexmod, active: true } && File.Exists(mod.fileName))
.Select(mod => mod.fileName));

if (texsToLoad.Count > 0)
Expand Down

0 comments on commit e03bf55

Please sign in to comment.