Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static bool ErrorCheckPatch(byte[] fileBuffer)
- {
- /* Patches the following check:
- * GetLastError returns non-zero */
- byte[] oldClientSig = new byte[] { 0x85, 0xC0, 0x75, 0x2F, 0xBF };
- byte[] newClientSig = new byte[] { 0x85, 0xC0, 0x5F, 0x5E, 0x75, 0x2F };
- int offset;
- if (FindSignatureOffset(oldClientSig, fileBuffer, out offset)) //signature = target bytes, so no check necessary
- {
- //XOR AX, AX
- fileBuffer[offset] = 0x66;
- fileBuffer[offset + 1] = 0x33;
- fileBuffer[offset + 2] = 0xC0;
- fileBuffer[offset + 3] = 0x90;
- return true;
- }
- if (FindSignatureOffset(newClientSig, fileBuffer, out offset)) //signature = target bytes, so no check necessary
- {
- fileBuffer[offset + 4] = 0x90;
- fileBuffer[offset + 5] = 0x90;
- return true;
- }
- return false;
- }
- private static bool SingleCheckPatch(byte[] fileBuffer)
- {
- /* Patches the following check:
- * "Another copy of UO is already running!" */
- byte[] oldClientSig = new byte[] { 0xC7, 0x44, 0x24, 0x10, 0x11, 0x01, 0x00, 0x00 };
- byte[] newClientSig = new byte[] { 0x83, 0xC4, 0x04, 0x33, 0xDB, 0x53, 0x50 };
- int offset;
- if (FindSignatureOffset(oldClientSig, fileBuffer, out offset))
- {
- if (fileBuffer[offset + 0x17] == 0x74)
- {
- fileBuffer[offset + 0x17] = 0xEB;
- return true;
- }
- else
- {
- // Single check signature found, but actual byte differs from expected. Aborting.
- return false;
- }
- }
- if (FindSignatureOffset(newClientSig, fileBuffer, out offset))
- {
- if (fileBuffer[offset + 0x0F] == 0x74)
- {
- fileBuffer[offset + 0x0F] = 0xEB;
- return true;
- }
- else
- {
- // Single check signature found, but actual byte differs from expected. Aborting.
- return false;
- }
- }
- return false;
- }
- private static bool TripleCheckPatch(byte[] fileBuffer)
- {
- /* Patches following checks:
- * "Another instance of UO may already be running."
- * "Another instance of UO is already running."
- * "An instance of UO Patch is already running." */
- byte[] oldClientSig = new byte[] { 0xFF, 0xD6, 0x6A, 0x01, 0xFF, 0xD7, 0x68 };
- byte[] newClientSig = new byte[] { 0x3B, 0xC3, 0x89, 0x44, 0x24, 0x08 };
- int offset;
- if (FindSignatureOffset(oldClientSig, fileBuffer, out offset))
- {
- if (fileBuffer[offset - 0x2D] == 0x75 && fileBuffer[offset - 0x0E] == 0x75 && fileBuffer[offset + 0x18] == 0x74)
- {
- fileBuffer[offset - 0x2D] = 0xEB;
- fileBuffer[offset - 0x0E] = 0xEB;
- fileBuffer[offset + 0x18] = 0xEB;
- return true;
- }
- else
- {
- // Triple check signature found, but actual bytes differ from expected. Aborting.
- return false;
- }
- }
- if (FindSignatureOffset(newClientSig, fileBuffer, out offset))
- {
- if (fileBuffer[offset + 0x06] == 0x75 && fileBuffer[offset + 0x2D] == 0x75 && fileBuffer[offset + 0x5F] == 0x74)
- {
- fileBuffer[offset + 0x06] = 0xEB;
- fileBuffer[offset + 0x2D] = 0xEB;
- fileBuffer[offset + 0x5F] = 0xEB;
- return true;
- }
- else
- {
- // Triple check signature found, but actual bytes differ from expected. Aborting.
- return false;
- }
- }
- return false;
- }
- private void MultiClientPatch()
- {
- if (!TripleCheckPatch(bytes))
- {
- // Triple check signature not found. Aborting.
- return;
- }
- if (!SingleCheckPatch(bytes))
- {
- // Single check signature not found. Aborting.
- return;
- }
- if (!ErrorCheckPatch(bytes))
- {
- // Error check signature not found. Aborting.
- return;
- }
- this.LAB_StatusIS.Text = "Multi Client Patching...Done";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement