Skip to content

Commit

Permalink
Fix Fixed Length CString bug
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed Dec 26, 2021
1 parent caed27a commit 21cecd4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions StringReloads/Engine/String/CString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ private CString(byte* Ptr) : base(Ptr) { }

public static implicit operator string(CString Str)
{
var Len = Str.Count();
return new string(Str.Address, 0, Len, Str.ReadEncoding);
var Len = Str.FixedLength ?? Str.Count();
return new string(Str.Address, 0, (int)Len, Str.ReadEncoding);
}

public static implicit operator CString(string Content)
Expand Down
2 changes: 1 addition & 1 deletion StringReloads/Engine/String/StringBufferA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace StringReloads.Engine.String
{
public unsafe abstract class StringBufferA : IEnumerable<byte>
{
public uint? FixedLength = null;
public long? FixedLength = null;
public sbyte* Address => (sbyte*)Ptr;
public IEnumerator<byte> GetEnumerator()
{
Expand Down
2 changes: 1 addition & 1 deletion StringReloads/Engine/String/StringBufferW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace StringReloads.Engine.String
{
public unsafe abstract class StringBufferW : IEnumerable<byte>
{
public uint? FixedLength = null;
public long? FixedLength = null;
public sbyte* Address => (sbyte*)Ptr;
public IEnumerator<byte> GetEnumerator()
{
Expand Down
4 changes: 2 additions & 2 deletions StringReloads/Engine/String/WCString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ private WCString(byte* Ptr) : base(Ptr) { }

public static implicit operator string(WCString Str)
{
var Len = Str.Count();
return new string(Str.Address, 0, Len, Encoding.Unicode);
var Len = Str.FixedLength ?? Str.Count();
return new string(Str.Address, 0, (int)Len, Encoding.Unicode);
}

public static implicit operator WCString(string Content)
Expand Down
2 changes: 1 addition & 1 deletion StringReloads/Hook/Win32/TextOutA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override void Initialize()
bool hTextOut(void* dc, int xStart, int yStart, byte* pStr, int strLen)
{
CString OriStr = pStr;
OriStr.FixedLength = (uint)strLen;
OriStr.FixedLength = strLen;

WCString InStr = EntryPoint.ProcessW((WCString)(string)OriStr);

Expand Down

0 comments on commit 21cecd4

Please sign in to comment.