para fazer isto o binario tem de ser divisivel por 4! |
//codigo source:
forward OnRconCommand(const cmd[]);
public OnRconCommand(const cmd[]) return 0;
//hexadecimal:
static BIN[] = {0x00000057, 0x0808F1E0, 0x00080014, 0x00000050, 0x00000064, 0x00000064, 0x00004064, 0xFFFFFFFF, 0x00000038, 0x00000040, 0x00000040, 0x00000040, 0x00000040, 0x00000040, 0x00000008, 0x00000042, 0x6E4F001F, 0x6E6F6352, 0x6D6D6F43, 0x00646E61, 0x2E007880, 0x00305980};
//string resultado do hexadecimal:
[ ас P l l l@ яяяя8 @ @ @ @ @ B OnRconCommand Ђx .Ѓ Ѓ ЂY0Ѓ пс RCMD.pwn cmd OnRconCommand _ bool
//string esperado:
[ ас P l l l@ яяяя8 @ @ @ @ @ B OnRconCommand Ђx .Ѓ Ѓ ЂY0Ѓ пс RCMD.pwn cmd OnRconCommand _ bool
//codigo fonte: native CallRemoteFunction(const function[], const format[], {Float,_}:...); forward OnRconCommand(const cmd[]); public OnRconCommand(const cmd[]) return CallRemoteFunction("I_RCMD", "s", cmd); //resultado esperado: ’ ас l ґ Ш Ш@ яяяя8 @ H H H H J X OnRconCommand CallRemoteFunction Ђx .Ѓ Ѓ )'' 'Ђ{ ,0ЂIЂ_ЂRЂCЂMЂD Ђs ‰ пс RCMD.pwn H cmd H OnRconCommand _ bool Float //tentativa 1: sublime hexadecimal encode: ’ са l ґ Ш @Ш яя яя 8 @ H H H H J X nO cR no oC mm na d aC ll eR om et uF cn it no xЂ . Ѓ Ѓ ) ' ' ' {Ђ , 0 IЂ _Ђ RЂ CЂ MЂ DЂ Ђ s ‰ сп CR DM p. nw H c dm H O Rn oc Cn mo am dn _ b oo l lF ao t //tentativa 2: https://pastebin.com/vNmTh8va ’ а с l ґ Ш Ш @ я я я я 8 @ H H H H J X O n R c o n C o m m a n d C a l l R e m o t e F u n c t i o n Ђ x . Ѓ Ѓ ) ' ' ' Ђ { , 0 Ђ I Ђ _ Ђ R Ђ C Ђ M Ђ D Ђ s ‰ п с R C M D . p w n H c m d H O n R c o n C o m m a n d _ b o o l F l o a t я я я 8 @ H H H H J X O n R c o n C o m m a n d C a l l R e m o t e F u n c t i o n Ђ x . Ѓ Ѓ ) ' ' ' Ђ { , 0 Ђ I Ђ _ Ђ R Ђ C Ђ M Ђ D Ђ s ‰ п с R C M D . p w n H c m d H O n R c o n C o m m a n //tenho outras 3 tentativas diferentes, mas todas dгo resultado diferente do esperado!
new buf[1024], source[128];
new BRW:handle = BRW::Open("Binary/foo.amx", bin_read);
new len = BRW::GetTotalBytes(handle);
while(BRW::GetCurrentBytes(handle) != len)
{
format(source, 128, "0x%08x, ", BRW::ReadInt32(handle));
strcat(buf, source);
}
BRW::Close(handle);
print(buf);
new data[] = {0x00000090, 0x0808F1E0, 0x00080004, 0x0000006C, 0x000000B0, 0x000000D4, 0x000040D4, 0xFFFFFFFF, 0x00000038, 0x00000040, 0x00000048, 0x00000048, 0x00000048, 0x00000048, 0x00000008, 0x0000004A, 0x00000000, 0x00000058, 0x6E4F001F, 0x6E6F6352, 0x6D6D6F43, 0x00646E61, 0x6C6C6143, 0x6F6D6552, 0x75466574, 0x6974636E, 0x00006E6F, 0x2E007880, 0x0C290981, 0x00271C27, 0x7B800C27, 0x30102C00, 0x5F804980, 0x43805280, 0x44804D80, 0x00738000};
handle = BRW::Open("Binary/testfoo.amx", bin_write);
for(new i = 0; i < sizeof(data); i++)
{
BRW::WriteInt32(handle, data[i]);
}
BRW::Close(handle);
//esperado: ’ ас l ґ Ш Ш@ яяяя8 @ H H H H J X OnRconCommand CallRemoteFunction Ђx .Ѓ Ѓ )'' 'Ђ{ ,0ЂIЂ_ЂRЂCЂMЂD Ђs ‰ пс RCMD.pwn H cmd H OnRconCommand _ bool Float //resultado: ’ а с l ґ Ш Ш @ я я я я 8 @ H H H H J X O n R c o n C o m m a n d C a l l R e m o t e F u n c t i o n Ђ x . Ѓ Ѓ ) ' ' ' Ђ { , 0 Ђ I Ђ _ Ђ R Ђ C Ђ
0x00000092, 0x000000E0, 0x000000F1, 0x00000008, 0x00000008, 0x00000006, 0x00000008, 0x0000006C, 0x000000B4, 0x000000D8, 0x000000D8, 0x00000040, 0x000000FF,
0x000000FF, 0x000000FF, 0x000000FF, 0x00000038, 0x00000040, 0x00000048, 0x00000048, 0x00000048, 0x00000048, 0x00000008, 0x0000004A, 0x00000058, 0x0000001F,
0x0000004F, 0x0000006E, 0x00000052, 0x00000063, 0x0000006F, 0x0000006E, 0x00000043, 0x0000006F, 0x0000006D, 0x0000006D, 0x00000061, 0x0000006E, 0x00000064,
0x00000043, 0x00000061, 0x0000006C, 0x0000006C, 0x00000052, 0x00000065, 0x0000006D, 0x0000006F, 0x00000074, 0x00000065, 0x00000046, 0x00000075, 0x0000006E,
0x00000063, 0x00000074, 0x00000069, 0x0000006F, 0x0000006E, 0x00000080, 0x00000078, 0x0000002E, 0x00000081, 0x00000009, 0x00000081, 0x00000009, 0x00000029,
0x0000000C, 0x00000027, 0x0000001C, 0x00000027, 0x00000027, 0x0000000C, 0x00000080, 0x0000007B, 0x0000002C, 0x00000010, 0x00000030, 0x00000080, 0x00000049,
0x00000080, 0x0000005F, 0x00000080, 0x00000052, 0x00000080, 0x00000043, 0x00000080, 0x0
Note that this won't work if the size of the .amx file is not divisible by 4.
|
PHP код:
|
If you were reading and writing to the file byte by byte then this wouldn't be a problem. However, what you can do is write the number of bytes from the .amx file that are divisible by 4 and treat the remainder bytes in a different way.
For instance, if a file has a size of 131 bytes, you could write or read the first 128 bytes (divisible by 4) and you have a remainder of 3 bytes that you can read or write separately. Note that we're using little endian order. |