Re: Windows CE BinaryCompression



WORD aligned means it falls on a WORD divisible address (address % 2 == 0).
DWORD aligned means it falls on a DWORD divisible address (address %4 == 0)

What exactly are you trying to do here anyway? I seriously doubt that you
should be using this undocumented kernel API from an app, let alone a
managed app.


--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--




"Wagner Bertolini Junior" <wagnerbertolini@xxxxxxxxxxxxxxxxxx> wrote in
message news:uYcWqroNHHA.5016@xxxxxxxxxxxxxxxxxxxxxxx
Can anyone help me with this?

I found at winCe sources this function:

//------------------------------------------------------------------------------
// Compressors - bufin and bufout must be WORD aligned, lenout must be at
least as
// large as lenin, CECOMPRESS_FAILED is returned if it doesn't fit, else
compressed length
// CECOMPRESS_ALL_ZEROS returned if buffer entirely zero. If bufout is
NULL, the output
// length is computed, but the results are not stored. Lenin must be a
multiple of 2.
//------------------------------------------------------------------------------

DWORD
NKBinaryCompress(
LPBYTE bufin,
DWORD lenin,
LPBYTE bufout,
DWORD lenout
)
{
DWORD retval;

TRUSTED_API (L"NKBinaryCompress", CECOMPRESS_FAILED);

DEBUGMSG(ZONE_ENTRY, (L"NKBinaryCompress entry: %8.8lx %8.8lx %8.8lx
%8.8lx\r\n", bufin, lenin, bufout, lenout));

retval = CECompress(bufin, lenin, bufout, lenout, 1, 1024);

DEBUGMSG(ZONE_ENTRY, (L"NKBinaryCompress exit: %8.8lx\r\n", retval));

return retval;
}

But i CAN´T understand the comment, what is WORD aligned?

i'm trying to use it and i'm receving an Error.. i will post the sample
code:

//DWORD BinaryCompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD
lenout);
//DWORD BinaryDecompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD
lenout, DWORD skip);
[DllImport("coredll.dll", SetLastError=true)]
public static extern unsafe int BinaryCompress(byte* bufferIn, int lenIn,
byte* bufferOut, ref int lenOut);
[DllImport("coredll.dll", SetLastError = true)]
public static extern unsafe int BinaryDecompress(byte* bufferIn, int
lenIn, byte* bufferOut, ref int lenOut, int skip);
string fileOpen = "\\Temp\\test.bmp";
byte[] bFile;
bFile = OpenFile(fileOpen);
byte[] bufferNew = new byte[bFile.Length];
int iLen = 0;
int ret = 0;
fixed(byte* bLP = bFile)
fixed (byte* bLPNew = bufferNew)
{
ret = BinaryCompress(bLP, (int)bFile.Length, bLPNew, ref
iLen);
if (ret != 0)
{
ret = Marshal.GetLastWin32Error();
MessageBox.Show(new Win32Exception(ret).Message); //
this always return 87 / Win32Exception
}
}

if anyone wants to see the OpenFile
private static byte[] OpenFile(string fileOpen)
{
byte[] bFile;
FileStream fs = File.OpenRead(fileOpen);
bFile = new byte[fs.Length];
byte[] bAux = new byte[1024];
int bytToRead = (int)fs.Length;
int count = 0;
int idx = 0;
while (bytToRead > 0)
{
count = fs.Read(bAux, 0, bAux.Length);
idx = (int)fs.Length - bytToRead;
for (int i = 0; i < count; i++)
bFile[idx+i] = bAux[i];
bytToRead -= count;
}
fs.Close();
return bFile;
}

The file length is 307254 bytes.
Any idea??
Thanks a lot.



.



Relevant Pages

  • Windows CE BinaryCompression
    ... // Compressors - bufin and bufout must be WORD aligned, lenout must be at ... // large as lenin, CECOMPRESS_FAILED is returned if it doesn't fit, else ... public static extern unsafe int BinaryCompress(byte* bufferIn, int lenIn, ...
    (microsoft.public.windowsce.app.development)
  • Re: Windows CE BinaryCompression
    ... // Compressors - bufin and bufout must be WORD aligned, lenout must be ... // large as lenin, CECOMPRESS_FAILED is returned if it doesn't fit, ... DWORD lenin, ... public static extern unsafe int BinaryCompress(byte* bufferIn, ...
    (microsoft.public.windowsce.app.development)
  • Re: Windows CE BinaryCompression
    ... // Compressors - bufin and bufout must be WORD aligned, lenout must be at ... // large as lenin, CECOMPRESS_FAILED is returned if it doesn't fit, else ... DWORD lenin, ... public static extern unsafe int BinaryCompress(byte* bufferIn, int lenIn, ...
    (microsoft.public.windowsce.app.development)
  • [NT] Multiple Windows XP Kernel Vulnerability Allow User Mode Programs To Gain Kernel Privileges
    ... Kernel Privileges ... entry with a pointer to your code and execute an INT n instruction. ... DWORD NotUsed; // Never accessed by the kernel ... mov ecx,esp ...
    (Securiteam)
  • Re: Windows CE BinaryCompression
    ... Save Space Using Windows CE Built-in Compression API's ... You can use BinaryCompress and BinaryDecompress to perform buffer ... DWORD BinaryCompress(LPBYTE bufin, DWORD lenin, LPBYTE bufout, DWORD ... public static extern unsafe int BinaryCompress(byte* bufferIn, ...
    (microsoft.public.windowsce.app.development)